Version Description
Download this release
Release Info
Developer | nsinelnikov |
Plugin | Ultimate Member – User Profile & Membership Plugin |
Version | 2.4.2 |
Comparing to | |
See all releases |
Code changes from version 2.4.1 to 2.4.2
- assets/css/um-styles.css +77 -84
- includes/admin/class-admin.php +1980 -1980
- includes/core/class-fields.php +4912 -4902
- includes/core/class-member-directory-meta.php +907 -898
- includes/core/class-member-directory.php +2731 -2722
- includes/core/class-query.php +460 -460
- includes/core/um-actions-register.php +753 -753
- readme.txt +10 -1
- ultimate-member.php +1 -1
assets/css/um-styles.css
CHANGED
@@ -881,10 +881,12 @@ small.um-max-filesize span{
|
|
881 |
- Customize Select2 CSS
|
882 |
*/
|
883 |
|
884 |
-
.select2-container.select2-container--open
|
|
|
885 |
z-index: 9999999;
|
886 |
}
|
887 |
-
.select2.select2-container .select2-selection
|
|
|
888 |
display: block !important;
|
889 |
height: 40px;
|
890 |
padding: 0 0 0 12px !important;
|
@@ -894,8 +896,6 @@ small.um-max-filesize span{
|
|
894 |
line-height: 35px !important;
|
895 |
color: #666 !important;
|
896 |
font-size: 15px !important;
|
897 |
-
text-align: left !important;
|
898 |
-
text-decoration: none !important;
|
899 |
-moz-border-radius: 2px !important;
|
900 |
-webkit-border-radius: 2px !important;
|
901 |
border-radius: 2px !important;
|
@@ -905,39 +905,37 @@ small.um-max-filesize span{
|
|
905 |
-moz-user-select: none;
|
906 |
-ms-user-select: none;
|
907 |
user-select: none;
|
908 |
-
background:
|
909 |
-
background-color: #fff !important;
|
910 |
border: 1px solid #ddd !important;
|
911 |
}
|
912 |
-
.rtl .select2.select2-container .select2-selection
|
|
|
913 |
padding: 0 12px 0 0 !important;
|
914 |
}
|
915 |
|
916 |
-
.select2.select2-container .select2-selection .select2-selection__arrow
|
|
|
917 |
display: inline-block !important;
|
918 |
width: 34px !important;
|
919 |
height: 100% !important;
|
920 |
-
position: absolute
|
921 |
-
right: 0
|
922 |
-
top: 0
|
923 |
-
-
|
924 |
-
-webkit-border-radius: 0 2px 2px 0 !important;
|
925 |
-
border-radius: 0 2px 2px 0 !important;
|
926 |
-
background-clip: padding-box !important;
|
927 |
-
text-align: center !important;
|
928 |
background: transparent !important;
|
929 |
-
border
|
930 |
}
|
931 |
-
.rtl .select2.select2-container .select2-selection .select2-selection__arrow
|
932 |
-
|
933 |
-
|
|
|
934 |
}
|
935 |
|
936 |
-
.select2.select2-container .select2-selection .select2-selection__arrow:before
|
|
|
937 |
content: "\f3d0" !important;
|
938 |
font-size: 28px !important;
|
939 |
font-family: "Ionicons" !important;
|
940 |
-
font-weight: normal;
|
941 |
display: block;
|
942 |
height: 100%;
|
943 |
line-height: 40px;
|
@@ -946,72 +944,82 @@ small.um-max-filesize span{
|
|
946 |
color: #aaaaaa;
|
947 |
}
|
948 |
|
949 |
-
.select2.select2-container .select2-selection .select2-selection__arrow b[role="presentation"]
|
|
|
950 |
display: none;
|
951 |
}
|
952 |
|
953 |
-
.select2-container.select2-container--open .select2-dropdown
|
|
|
954 |
border: 1px solid #ddd !important;
|
955 |
border-radius: 0;
|
956 |
}
|
957 |
|
958 |
-
.select2-container.select2-container--open .select2-dropdown .select2-results li
|
|
|
959 |
list-style: none;
|
960 |
display: list-item;
|
961 |
-
background
|
962 |
font-size: 15px;
|
963 |
margin: 5px !important;
|
964 |
color: #666 !important;
|
965 |
padding: 3px 7px 4px !important;
|
966 |
cursor: pointer;
|
967 |
-
min-height: 1em
|
968 |
}
|
969 |
|
970 |
-
.select2.select2-container .select2-selection.select2-selection--multiple
|
|
|
971 |
height: auto !important;
|
972 |
line-height: 0.8 !important;
|
973 |
min-height: 40px;
|
974 |
padding-bottom: 4px !important;
|
975 |
}
|
976 |
|
977 |
-
.select2-container--default .select2-selection--single .select2-selection__rendered
|
|
|
978 |
line-height: 37px;
|
979 |
-
padding-left:
|
980 |
-
padding-right: 24px
|
981 |
}
|
982 |
-
.rtl .select2-container--default .select2-selection--single .select2-selection__rendered
|
983 |
-
|
984 |
-
padding-
|
|
|
985 |
}
|
986 |
|
987 |
-
.select2-container--default .select2-selection--multiple .select2-selection__rendered
|
|
|
988 |
line-height: 37px;
|
989 |
box-sizing: border-box;
|
990 |
list-style: none;
|
991 |
margin: 0;
|
992 |
-
padding-left:
|
993 |
padding-right: 30px;
|
994 |
width: 100%;
|
995 |
font-size: 13px;
|
996 |
}
|
997 |
-
.rtl .select2-container--default .select2-selection--multiple .select2-selection__rendered
|
998 |
-
|
999 |
-
padding-
|
|
|
1000 |
}
|
1001 |
|
1002 |
-
.select2-results li.select2-results__option.select2-results__option--highlighted
|
1003 |
-
|
1004 |
-
background: #f4f4f4
|
1005 |
-
color: #666
|
1006 |
}
|
1007 |
-
.select2-
|
|
|
1008 |
background-color: #ddd;
|
1009 |
}
|
1010 |
|
1011 |
-
|
1012 |
-
.select2-container--default .select2-selection--
|
1013 |
-
.select2-container--default .select2-selection--
|
1014 |
-
|
|
|
1015 |
font-size: 28px;
|
1016 |
font-weight: normal;
|
1017 |
line-height: 34px;
|
@@ -1020,42 +1028,50 @@ small.um-max-filesize span{
|
|
1020 |
text-align: center;
|
1021 |
width: 1em;
|
1022 |
}
|
1023 |
-
.rtl .select2-container--default .select2-selection--single .select2-selection__clear,
|
1024 |
-
.rtl .select2-container--default .select2-selection--multiple .select2-selection__clear
|
|
|
|
|
1025 |
left: 0;
|
1026 |
right: initial;
|
1027 |
}
|
1028 |
|
1029 |
-
.select2-container--default .select2-selection--multiple .select2-selection__clear
|
|
|
1030 |
position: absolute;
|
1031 |
}
|
1032 |
|
1033 |
-
.select2-container--default .select2-selection--multiple .select2-selection__choice
|
|
|
1034 |
margin: 5px 5px 0 0;
|
|
|
1035 |
padding: 3px 3px 3px 5px;
|
1036 |
}
|
1037 |
-
.rtl .select2-container--default .select2-selection--multiple .select2-selection__choice
|
|
|
1038 |
margin: 5px 0 0 5px;
|
1039 |
-
max-height: 28px;
|
1040 |
padding: 3px 5px 3px 3px;
|
1041 |
}
|
1042 |
|
1043 |
-
.um .
|
|
|
1044 |
margin: 5px 5px 0 0;
|
1045 |
padding: 0px;
|
1046 |
}
|
1047 |
-
.rtl .um .
|
|
|
1048 |
margin: 5px 0 0 5px;
|
1049 |
}
|
1050 |
|
1051 |
-
.um .
|
|
|
1052 |
border: none !important;
|
1053 |
padding: 0 !important;
|
1054 |
-
border-radius: 0 !important;
|
1055 |
max-height: 28px;
|
1056 |
}
|
1057 |
|
1058 |
-
.um
|
|
|
1059 |
overflow-x: hidden;
|
1060 |
text-overflow: ellipsis;
|
1061 |
max-width: 100%;
|
@@ -1066,31 +1082,8 @@ small.um-max-filesize span{
|
|
1066 |
/*
|
1067 |
- Multi-select
|
1068 |
*/
|
1069 |
-
|
1070 |
-
|
1071 |
-
/*float: none;*/
|
1072 |
-
/*margin-right: 12px;*/
|
1073 |
-
/*padding-top: 0.5rem;*/
|
1074 |
-
/*position: relative;*/
|
1075 |
-
/*}*/
|
1076 |
-
/*.um-field .select2-selection--multiple .select2-search:first-of-type{*/
|
1077 |
-
/*padding-top: 12px;*/
|
1078 |
-
/*}*/
|
1079 |
-
/*.um-field .select2-selection--multiple .select2-search::before {*/
|
1080 |
-
/*content: "\f21f";*/
|
1081 |
-
/*font-family: "Ionicons";*/
|
1082 |
-
/*font-size: 1.4rem;*/
|
1083 |
-
/*line-height: 2rem;*/
|
1084 |
-
/*right: 0.3rem;*/
|
1085 |
-
/*position: absolute;*/
|
1086 |
-
/*}*/
|
1087 |
-
/*.um-field .select2-selection--multiple .select2-search input.select2-search__field{*/
|
1088 |
-
/*background-color: rgba(128,128,128,0.1) !important;*/
|
1089 |
-
/*height: 2rem !important;*/
|
1090 |
-
/*width: 100% !important;*/
|
1091 |
-
/*}*/
|
1092 |
-
|
1093 |
-
/* @todo maybe deprecated and used only for select and multiselect */
|
1094 |
.um-field-select .um-field-area .um-field-icon,
|
1095 |
.um-field-multiselect .um-field-area .um-field-icon {
|
1096 |
z-index: 99999999;
|
881 |
- Customize Select2 CSS
|
882 |
*/
|
883 |
|
884 |
+
.um-search-filter .select2-container.select2-container--open,
|
885 |
+
.um-field .select2-container.select2-container--open {
|
886 |
z-index: 9999999;
|
887 |
}
|
888 |
+
.um-search-filter .select2.select2-container .select2-selection,
|
889 |
+
.um-field .select2.select2-container .select2-selection {
|
890 |
display: block !important;
|
891 |
height: 40px;
|
892 |
padding: 0 0 0 12px !important;
|
896 |
line-height: 35px !important;
|
897 |
color: #666 !important;
|
898 |
font-size: 15px !important;
|
|
|
|
|
899 |
-moz-border-radius: 2px !important;
|
900 |
-webkit-border-radius: 2px !important;
|
901 |
border-radius: 2px !important;
|
905 |
-moz-user-select: none;
|
906 |
-ms-user-select: none;
|
907 |
user-select: none;
|
908 |
+
background: #fff !important;
|
|
|
909 |
border: 1px solid #ddd !important;
|
910 |
}
|
911 |
+
.rtl .um-search-filter .select2.select2-container .select2-selection,
|
912 |
+
.rtl .um-field .select2.select2-container .select2-selection {
|
913 |
padding: 0 12px 0 0 !important;
|
914 |
}
|
915 |
|
916 |
+
.um-search-filter .select2.select2-container .select2-selection .select2-selection__arrow,
|
917 |
+
.um-field .select2.select2-container .select2-selection .select2-selection__arrow {
|
918 |
display: inline-block !important;
|
919 |
width: 34px !important;
|
920 |
height: 100% !important;
|
921 |
+
position: absolute;
|
922 |
+
right: 0;
|
923 |
+
top: 0;
|
924 |
+
text-align: center;
|
|
|
|
|
|
|
|
|
925 |
background: transparent !important;
|
926 |
+
border: none !important;
|
927 |
}
|
928 |
+
.rtl .um-search-filter .select2.select2-container .select2-selection .select2-selection__arrow,
|
929 |
+
.rtl .um-field .select2.select2-container .select2-selection .select2-selection__arrow {
|
930 |
+
right: initial;
|
931 |
+
left: 0;
|
932 |
}
|
933 |
|
934 |
+
.um-search-filter .select2.select2-container .select2-selection .select2-selection__arrow:before,
|
935 |
+
.um-field .select2.select2-container .select2-selection .select2-selection__arrow:before {
|
936 |
content: "\f3d0" !important;
|
937 |
font-size: 28px !important;
|
938 |
font-family: "Ionicons" !important;
|
|
|
939 |
display: block;
|
940 |
height: 100%;
|
941 |
line-height: 40px;
|
944 |
color: #aaaaaa;
|
945 |
}
|
946 |
|
947 |
+
.um-search-filter .select2.select2-container .select2-selection .select2-selection__arrow b[role="presentation"],
|
948 |
+
.um-field .select2.select2-container .select2-selection .select2-selection__arrow b[role="presentation"] {
|
949 |
display: none;
|
950 |
}
|
951 |
|
952 |
+
.um-search-filter .select2-container.select2-container--open .select2-dropdown,
|
953 |
+
.um-field .select2-container.select2-container--open .select2-dropdown {
|
954 |
border: 1px solid #ddd !important;
|
955 |
border-radius: 0;
|
956 |
}
|
957 |
|
958 |
+
.um-search-filter .select2-container.select2-container--open .select2-dropdown .select2-results li,
|
959 |
+
.um-field .select2-container.select2-container--open .select2-dropdown .select2-results li {
|
960 |
list-style: none;
|
961 |
display: list-item;
|
962 |
+
background: none;
|
963 |
font-size: 15px;
|
964 |
margin: 5px !important;
|
965 |
color: #666 !important;
|
966 |
padding: 3px 7px 4px !important;
|
967 |
cursor: pointer;
|
968 |
+
min-height: 1em;
|
969 |
}
|
970 |
|
971 |
+
.um-search-filter .select2.select2-container .select2-selection.select2-selection--multiple,
|
972 |
+
.um-field .select2.select2-container .select2-selection.select2-selection--multiple {
|
973 |
height: auto !important;
|
974 |
line-height: 0.8 !important;
|
975 |
min-height: 40px;
|
976 |
padding-bottom: 4px !important;
|
977 |
}
|
978 |
|
979 |
+
.um-search-filter .select2-container--default .select2-selection--single .select2-selection__rendered,
|
980 |
+
.um-field .select2-container--default .select2-selection--single .select2-selection__rendered {
|
981 |
line-height: 37px;
|
982 |
+
padding-left: 0px;
|
983 |
+
padding-right: 24px;
|
984 |
}
|
985 |
+
.rtl .um-search-filter .select2-container--default .select2-selection--single .select2-selection__rendered,
|
986 |
+
.rtl .um-field .select2-container--default .select2-selection--single .select2-selection__rendered {
|
987 |
+
padding-left: 24px;
|
988 |
+
padding-right: 0px;
|
989 |
}
|
990 |
|
991 |
+
.um-search-filter .select2-container--default .select2-selection--multiple .select2-selection__rendered,
|
992 |
+
.um-field .select2-container--default .select2-selection--multiple .select2-selection__rendered {
|
993 |
line-height: 37px;
|
994 |
box-sizing: border-box;
|
995 |
list-style: none;
|
996 |
margin: 0;
|
997 |
+
padding-left: 0px;
|
998 |
padding-right: 30px;
|
999 |
width: 100%;
|
1000 |
font-size: 13px;
|
1001 |
}
|
1002 |
+
.rtl .um-search-filter .select2-container--default .select2-selection--multiple .select2-selection__rendered,
|
1003 |
+
.rtl .um-field .select2-container--default .select2-selection--multiple .select2-selection__rendered {
|
1004 |
+
padding-left: 30px;
|
1005 |
+
padding-right: 0px;
|
1006 |
}
|
1007 |
|
1008 |
+
.um-search-filter .select2-dropdown .select2-results li.select2-results__option.select2-results__option--highlighted,
|
1009 |
+
.um-field .select2-dropdown .select2-results li.select2-results__option.select2-results__option--highlighted {
|
1010 |
+
background: #f4f4f4;
|
1011 |
+
color: #666;
|
1012 |
}
|
1013 |
+
.um-search-filter .select2-dropdown .select2-results li.select2-results__option[aria-selected="true"],
|
1014 |
+
.um-field .select2-dropdown .select2-results li.select2-results__option[aria-selected="true"] {
|
1015 |
background-color: #ddd;
|
1016 |
}
|
1017 |
|
1018 |
+
.um-search-filter .select2-container--default .select2-selection--single .select2-selection__clear,
|
1019 |
+
.um-search-filter .select2-container--default .select2-selection--multiple .select2-selection__clear,
|
1020 |
+
.um-field .select2-container--default .select2-selection--single .select2-selection__clear,
|
1021 |
+
.um-field .select2-container--default .select2-selection--multiple .select2-selection__clear {
|
1022 |
+
color: #aaaaaa;
|
1023 |
font-size: 28px;
|
1024 |
font-weight: normal;
|
1025 |
line-height: 34px;
|
1028 |
text-align: center;
|
1029 |
width: 1em;
|
1030 |
}
|
1031 |
+
.rtl .um-search-filter .select2-container--default .select2-selection--single .select2-selection__clear,
|
1032 |
+
.rtl .um-search-filter .select2-container--default .select2-selection--multiple .select2-selection__clear,
|
1033 |
+
.rtl .um-field .select2-container--default .select2-selection--single .select2-selection__clear,
|
1034 |
+
.rtl .um-field .select2-container--default .select2-selection--multiple .select2-selection__clear {
|
1035 |
left: 0;
|
1036 |
right: initial;
|
1037 |
}
|
1038 |
|
1039 |
+
.um-search-filter .select2-container--default .select2-selection--multiple .select2-selection__clear,
|
1040 |
+
.um-field .select2-container--default .select2-selection--multiple .select2-selection__clear {
|
1041 |
position: absolute;
|
1042 |
}
|
1043 |
|
1044 |
+
.um-search-filter .select2-container--default .select2-selection--multiple .select2-selection__choice,
|
1045 |
+
.um-field .select2-container--default .select2-selection--multiple .select2-selection__choice {
|
1046 |
margin: 5px 5px 0 0;
|
1047 |
+
max-height: 28px;
|
1048 |
padding: 3px 3px 3px 5px;
|
1049 |
}
|
1050 |
+
.rtl .um-search-filter .select2-container--default .select2-selection--multiple .select2-selection__choice,
|
1051 |
+
.rtl .um-field .select2-container--default .select2-selection--multiple .select2-selection__choice {
|
1052 |
margin: 5px 0 0 5px;
|
|
|
1053 |
padding: 3px 5px 3px 3px;
|
1054 |
}
|
1055 |
|
1056 |
+
.um-search-filter .select2-container--default .select2-selection--multiple .select2-search.select2-search--inline,
|
1057 |
+
.um-field .select2-container--default .select2-selection--multiple .select2-search.select2-search--inline {
|
1058 |
margin: 5px 5px 0 0;
|
1059 |
padding: 0px;
|
1060 |
}
|
1061 |
+
.rtl .um-search-filter .select2-container--default .select2-selection--multiple .select2-search.select2-search--inline,
|
1062 |
+
.rtl .um-field .select2-container--default .select2-selection--multiple .select2-search.select2-search--inline {
|
1063 |
margin: 5px 0 0 5px;
|
1064 |
}
|
1065 |
|
1066 |
+
.um-search-filter .select2-container--default .select2-selection--multiple .select2-search.select2-search--inline > input,
|
1067 |
+
.um-field .select2-container--default .select2-selection--multiple .select2-search.select2-search--inline > input {
|
1068 |
border: none !important;
|
1069 |
padding: 0 !important;
|
|
|
1070 |
max-height: 28px;
|
1071 |
}
|
1072 |
|
1073 |
+
.um-search-filter .select2-container--default .select2-selection--multiple .select2-selection__rendered li,
|
1074 |
+
.um-field .select2-container--default .select2-selection--multiple .select2-selection__rendered li {
|
1075 |
overflow-x: hidden;
|
1076 |
text-overflow: ellipsis;
|
1077 |
max-width: 100%;
|
1082 |
/*
|
1083 |
- Multi-select
|
1084 |
*/
|
1085 |
+
|
1086 |
+
/* @todo maybe deprecated and used only for select and multiselect */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1087 |
.um-field-select .um-field-area .um-field-icon,
|
1088 |
.um-field-multiselect .um-field-area .um-field-icon {
|
1089 |
z-index: 99999999;
|
includes/admin/class-admin.php
CHANGED
@@ -1,1980 +1,1980 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\admin;
|
3 |
-
|
4 |
-
// Exit if accessed directly.
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
6 |
-
exit;
|
7 |
-
}
|
8 |
-
|
9 |
-
if ( ! class_exists( 'um\admin\Admin' ) ) {
|
10 |
-
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Class Admin
|
14 |
-
* @package um\admin
|
15 |
-
*/
|
16 |
-
class Admin extends Admin_Functions {
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* @var string
|
21 |
-
*/
|
22 |
-
public $templates_path;
|
23 |
-
|
24 |
-
|
25 |
-
/**
|
26 |
-
* @var array
|
27 |
-
*/
|
28 |
-
public $role_meta;
|
29 |
-
|
30 |
-
|
31 |
-
/**
|
32 |
-
* @var array
|
33 |
-
*/
|
34 |
-
public $restriction_term_meta;
|
35 |
-
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @var array
|
39 |
-
*/
|
40 |
-
public $member_directory_meta;
|
41 |
-
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @var array
|
45 |
-
*/
|
46 |
-
public $form_meta;
|
47 |
-
|
48 |
-
|
49 |
-
/**
|
50 |
-
* @var array
|
51 |
-
*/
|
52 |
-
public $builder_input;
|
53 |
-
|
54 |
-
|
55 |
-
/**
|
56 |
-
* @var array
|
57 |
-
*/
|
58 |
-
public $restriction_post_meta;
|
59 |
-
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Admin constructor.
|
63 |
-
*/
|
64 |
-
public function __construct() {
|
65 |
-
parent::__construct();
|
66 |
-
|
67 |
-
$this->templates_path = um_path . 'includes/admin/templates/';
|
68 |
-
|
69 |
-
add_action( 'admin_init', array( &$this, 'admin_init' ), 0 );
|
70 |
-
|
71 |
-
$prefix = is_network_admin() ? 'network_admin_' : '';
|
72 |
-
add_filter( "{$prefix}plugin_action_links_" . um_plugin, array( &$this, 'plugin_links' ) );
|
73 |
-
|
74 |
-
add_action( 'um_admin_do_action__user_cache', array( &$this, 'user_cache' ) );
|
75 |
-
add_action( 'um_admin_do_action__purge_temp', array( &$this, 'purge_temp' ) );
|
76 |
-
add_action( 'um_admin_do_action__manual_upgrades_request', array( &$this, 'manual_upgrades_request' ) );
|
77 |
-
add_action( 'um_admin_do_action__duplicate_form', array( &$this, 'duplicate_form' ) );
|
78 |
-
add_action( 'um_admin_do_action__um_hide_locale_notice', array( &$this, 'um_hide_notice' ) );
|
79 |
-
add_action( 'um_admin_do_action__um_can_register_notice', array( &$this, 'um_hide_notice' ) );
|
80 |
-
add_action( 'um_admin_do_action__um_hide_exif_notice', array( &$this, 'um_hide_notice' ) );
|
81 |
-
add_action( 'um_admin_do_action__user_action', array( &$this, 'user_action' ) );
|
82 |
-
|
83 |
-
add_action( 'um_admin_do_action__install_core_pages', array( &$this, 'install_core_pages' ) );
|
84 |
-
|
85 |
-
add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ), 999 );
|
86 |
-
|
87 |
-
add_action( 'parent_file', array( &$this, 'parent_file' ), 9 );
|
88 |
-
add_filter( 'gettext', array( &$this, 'gettext' ), 10, 4 );
|
89 |
-
add_filter( 'post_updated_messages', array( &$this, 'post_updated_messages' ) );
|
90 |
-
}
|
91 |
-
|
92 |
-
|
93 |
-
function init_variables() {
|
94 |
-
$this->role_meta = apply_filters(
|
95 |
-
'um_role_meta_map',
|
96 |
-
array(
|
97 |
-
'_um_priority' => array(
|
98 |
-
'sanitize' => 'int',
|
99 |
-
),
|
100 |
-
'_um_can_access_wpadmin' => array(
|
101 |
-
'sanitize' => 'bool',
|
102 |
-
),
|
103 |
-
'_um_can_not_see_adminbar' => array(
|
104 |
-
'sanitize' => 'bool',
|
105 |
-
),
|
106 |
-
'_um_can_edit_everyone' => array(
|
107 |
-
'sanitize' => 'bool',
|
108 |
-
),
|
109 |
-
'_um_can_edit_roles' => array(
|
110 |
-
'sanitize' => array( $this, 'sanitize_existed_role' ),
|
111 |
-
),
|
112 |
-
'_um_can_delete_everyone' => array(
|
113 |
-
'sanitize' => 'bool',
|
114 |
-
),
|
115 |
-
'_um_can_delete_roles' => array(
|
116 |
-
'sanitize' => array( $this, 'sanitize_existed_role' ),
|
117 |
-
),
|
118 |
-
'_um_can_edit_profile' => array(
|
119 |
-
'sanitize' => 'bool',
|
120 |
-
),
|
121 |
-
'_um_can_delete_profile' => array(
|
122 |
-
'sanitize' => 'bool',
|
123 |
-
),
|
124 |
-
'_um_can_view_all' => array(
|
125 |
-
'sanitize' => 'bool',
|
126 |
-
),
|
127 |
-
'_um_can_view_roles' => array(
|
128 |
-
'sanitize' => array( $this, 'sanitize_existed_role' ),
|
129 |
-
),
|
130 |
-
'_um_can_make_private_profile' => array(
|
131 |
-
'sanitize' => 'bool',
|
132 |
-
),
|
133 |
-
'_um_can_access_private_profile' => array(
|
134 |
-
'sanitize' => 'bool',
|
135 |
-
),
|
136 |
-
'_um_profile_noindex' => array(
|
137 |
-
'sanitize' => array( $this, 'sanitize_profile_noindex' ),
|
138 |
-
),
|
139 |
-
'_um_default_homepage' => array(
|
140 |
-
'sanitize' => 'bool',
|
141 |
-
),
|
142 |
-
'_um_redirect_homepage' => array(
|
143 |
-
'sanitize' => 'url',
|
144 |
-
),
|
145 |
-
'_um_status' => array(
|
146 |
-
'sanitize' => 'sanitize_array_key',
|
147 |
-
'default' => 'approved',
|
148 |
-
'array' => array( 'approved', 'checkmail', 'pending' ),
|
149 |
-
),
|
150 |
-
'_um_auto_approve_act' => array(
|
151 |
-
'sanitize' => 'sanitize_array_key',
|
152 |
-
'default' => 'redirect_profile',
|
153 |
-
'array' => array( 'redirect_profile', 'redirect_url' ),
|
154 |
-
),
|
155 |
-
'_um_auto_approve_url' => array(
|
156 |
-
'sanitize' => 'url',
|
157 |
-
),
|
158 |
-
'_um_login_email_activate' => array(
|
159 |
-
'sanitize' => 'bool',
|
160 |
-
),
|
161 |
-
'_um_checkmail_action' => array(
|
162 |
-
'sanitize' => 'sanitize_array_key',
|
163 |
-
'default' => 'show_message',
|
164 |
-
'array' => array( 'show_message', 'redirect_url' ),
|
165 |
-
),
|
166 |
-
'_um_checkmail_message' => array(
|
167 |
-
'sanitize' => 'textarea',
|
168 |
-
),
|
169 |
-
'_um_checkmail_url' => array(
|
170 |
-
'sanitize' => 'url',
|
171 |
-
),
|
172 |
-
'_um_url_email_activate' => array(
|
173 |
-
'sanitize' => 'url',
|
174 |
-
),
|
175 |
-
'_um_pending_action' => array(
|
176 |
-
'sanitize' => 'sanitize_array_key',
|
177 |
-
'default' => 'show_message',
|
178 |
-
'array' => array( 'show_message', 'redirect_url' ),
|
179 |
-
),
|
180 |
-
'_um_pending_message' => array(
|
181 |
-
'sanitize' => 'textarea',
|
182 |
-
),
|
183 |
-
'_um_pending_url' => array(
|
184 |
-
'sanitize' => 'url',
|
185 |
-
),
|
186 |
-
'_um_after_login' => array(
|
187 |
-
'sanitize' => 'sanitize_array_key',
|
188 |
-
'default' => 'redirect_profile',
|
189 |
-
'array' => array( 'redirect_profile', 'redirect_url', 'refresh', 'redirect_admin' ),
|
190 |
-
),
|
191 |
-
'_um_login_redirect_url' => array(
|
192 |
-
'sanitize' => 'url',
|
193 |
-
),
|
194 |
-
'_um_after_logout' => array(
|
195 |
-
'sanitize' => 'sanitize_array_key',
|
196 |
-
'default' => 'redirect_home',
|
197 |
-
'array' => array( 'redirect_home', 'redirect_url' ),
|
198 |
-
),
|
199 |
-
'_um_logout_redirect_url' => array(
|
200 |
-
'sanitize' => 'url',
|
201 |
-
),
|
202 |
-
'_um_after_delete' => array(
|
203 |
-
'sanitize' => 'sanitize_array_key',
|
204 |
-
'default' => 'redirect_home',
|
205 |
-
'array' => array( 'redirect_home', 'redirect_url' ),
|
206 |
-
),
|
207 |
-
'_um_delete_redirect_url' => array(
|
208 |
-
'sanitize' => 'url',
|
209 |
-
),
|
210 |
-
'wp_capabilities' => array(
|
211 |
-
'sanitize' => array( $this, 'sanitize_wp_capabilities' ),
|
212 |
-
),
|
213 |
-
)
|
214 |
-
);
|
215 |
-
|
216 |
-
$this->restriction_post_meta = apply_filters(
|
217 |
-
'um_restriction_post_meta_map',
|
218 |
-
array(
|
219 |
-
'_um_custom_access_settings' => array(
|
220 |
-
'sanitize' => 'bool',
|
221 |
-
),
|
222 |
-
'_um_accessible' => array(
|
223 |
-
'sanitize' => 'int',
|
224 |
-
),
|
225 |
-
'_um_access_roles' => array(
|
226 |
-
'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
|
227 |
-
),
|
228 |
-
'_um_noaccess_action' => array(
|
229 |
-
'sanitize' => 'int',
|
230 |
-
),
|
231 |
-
'_um_restrict_by_custom_message' => array(
|
232 |
-
'sanitize' => 'int',
|
233 |
-
),
|
234 |
-
'_um_restrict_custom_message' => array(
|
235 |
-
'sanitize' => 'wp_kses',
|
236 |
-
),
|
237 |
-
'_um_access_redirect' => array(
|
238 |
-
'sanitize' => 'int',
|
239 |
-
),
|
240 |
-
'_um_access_redirect_url' => array(
|
241 |
-
'sanitize' => 'url',
|
242 |
-
),
|
243 |
-
'_um_access_hide_from_queries' => array(
|
244 |
-
'sanitize' => 'bool',
|
245 |
-
),
|
246 |
-
)
|
247 |
-
);
|
248 |
-
|
249 |
-
$this->restriction_term_meta = apply_filters(
|
250 |
-
'um_restriction_term_meta_map',
|
251 |
-
array(
|
252 |
-
'_um_custom_access_settings' => array(
|
253 |
-
'sanitize' => 'bool',
|
254 |
-
),
|
255 |
-
'_um_accessible' => array(
|
256 |
-
'sanitize' => 'int',
|
257 |
-
),
|
258 |
-
'_um_access_roles' => array(
|
259 |
-
'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
|
260 |
-
),
|
261 |
-
'_um_noaccess_action' => array(
|
262 |
-
'sanitize' => 'int',
|
263 |
-
),
|
264 |
-
'_um_restrict_by_custom_message' => array(
|
265 |
-
'sanitize' => 'int',
|
266 |
-
),
|
267 |
-
'_um_restrict_custom_message' => array(
|
268 |
-
'sanitize' => 'wp_kses',
|
269 |
-
),
|
270 |
-
'_um_access_redirect' => array(
|
271 |
-
'sanitize' => 'int',
|
272 |
-
),
|
273 |
-
'_um_access_redirect_url' => array(
|
274 |
-
'sanitize' => 'url',
|
275 |
-
),
|
276 |
-
'_um_access_hide_from_queries' => array(
|
277 |
-
'sanitize' => 'bool',
|
278 |
-
),
|
279 |
-
)
|
280 |
-
);
|
281 |
-
|
282 |
-
$this->member_directory_meta = apply_filters(
|
283 |
-
'um_member_directory_meta_map',
|
284 |
-
array(
|
285 |
-
'_um_directory_template' => array(
|
286 |
-
'sanitize' => 'text',
|
287 |
-
),
|
288 |
-
'_um_mode' => array(
|
289 |
-
'sanitize' => 'key',
|
290 |
-
),
|
291 |
-
'_um_view_types' => array(
|
292 |
-
'sanitize' => array( $this, 'sanitize_md_view_types' ),
|
293 |
-
),
|
294 |
-
'_um_default_view' => array(
|
295 |
-
'sanitize' => 'key',
|
296 |
-
),
|
297 |
-
'_um_roles' => array(
|
298 |
-
'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
|
299 |
-
),
|
300 |
-
'_um_has_profile_photo' => array(
|
301 |
-
'sanitize' => 'bool',
|
302 |
-
),
|
303 |
-
'_um_show_these_users' => array(
|
304 |
-
'sanitize' => 'textarea',
|
305 |
-
),
|
306 |
-
'_um_exclude_these_users' => array(
|
307 |
-
'sanitize' => 'textarea',
|
308 |
-
),
|
309 |
-
'_um_must_search' => array(
|
310 |
-
'sanitize' => 'bool',
|
311 |
-
),
|
312 |
-
'_um_max_users' => array(
|
313 |
-
'sanitize' => 'absint',
|
314 |
-
),
|
315 |
-
'_um_profiles_per_page' => array(
|
316 |
-
'sanitize' => 'absint',
|
317 |
-
),
|
318 |
-
'_um_profiles_per_page_mobile' => array(
|
319 |
-
'sanitize' => 'absint',
|
320 |
-
),
|
321 |
-
'_um_directory_header' => array(
|
322 |
-
'sanitize' => 'text',
|
323 |
-
),
|
324 |
-
'_um_directory_header_single' => array(
|
325 |
-
'sanitize' => 'text',
|
326 |
-
),
|
327 |
-
'_um_directory_no_users' => array(
|
328 |
-
'sanitize' => 'text',
|
329 |
-
),
|
330 |
-
'_um_profile_photo' => array(
|
331 |
-
'sanitize' => 'bool',
|
332 |
-
),
|
333 |
-
'_um_cover_photos' => array(
|
334 |
-
'sanitize' => 'bool',
|
335 |
-
),
|
336 |
-
'_um_show_name' => array(
|
337 |
-
'sanitize' => 'bool',
|
338 |
-
),
|
339 |
-
'_um_show_tagline' => array(
|
340 |
-
'sanitize' => 'bool',
|
341 |
-
),
|
342 |
-
'_um_tagline_fields' => array(
|
343 |
-
'sanitize' => array( $this, 'sanitize_user_field' ),
|
344 |
-
),
|
345 |
-
'_um_show_userinfo' => array(
|
346 |
-
'sanitize' => 'bool',
|
347 |
-
),
|
348 |
-
'_um_reveal_fields' => array(
|
349 |
-
'sanitize' => array( $this, 'sanitize_user_field' ),
|
350 |
-
),
|
351 |
-
'_um_show_social' => array(
|
352 |
-
'sanitize' => 'bool',
|
353 |
-
),
|
354 |
-
'_um_userinfo_animate' => array(
|
355 |
-
'sanitize' => 'bool',
|
356 |
-
),
|
357 |
-
'_um_search' => array(
|
358 |
-
'sanitize' => 'bool',
|
359 |
-
),
|
360 |
-
'_um_roles_can_search' => array(
|
361 |
-
'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
|
362 |
-
),
|
363 |
-
'_um_filters' => array(
|
364 |
-
'sanitize' => 'bool',
|
365 |
-
),
|
366 |
-
'_um_roles_can_filter' => array(
|
367 |
-
'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
|
368 |
-
),
|
369 |
-
'_um_search_fields' => array(
|
370 |
-
'sanitize' => array( $this, 'sanitize_filter_fields' ),
|
371 |
-
),
|
372 |
-
'_um_filters_expanded' => array(
|
373 |
-
'sanitize' => 'bool',
|
374 |
-
),
|
375 |
-
'_um_filters_is_collapsible' => array(
|
376 |
-
'sanitize' => 'bool',
|
377 |
-
),
|
378 |
-
'_um_search_filters' => array(
|
379 |
-
'sanitize' => array( $this, 'sanitize_filter_fields' ),
|
380 |
-
),
|
381 |
-
'_um_sortby' => array(
|
382 |
-
'sanitize' => 'text',
|
383 |
-
),
|
384 |
-
'_um_sortby_custom' => array(
|
385 |
-
'sanitize' => 'text',
|
386 |
-
),
|
387 |
-
'_um_sortby_custom_label' => array(
|
388 |
-
'sanitize' => 'text',
|
389 |
-
),
|
390 |
-
'_um_enable_sorting' => array(
|
391 |
-
'sanitize' => 'bool',
|
392 |
-
),
|
393 |
-
'_um_sorting_fields' => array(
|
394 |
-
'sanitize' => array( $this, 'sanitize_md_sorting_fields' ),
|
395 |
-
),
|
396 |
-
)
|
397 |
-
);
|
398 |
-
|
399 |
-
$this->form_meta = apply_filters(
|
400 |
-
'um_form_meta_map',
|
401 |
-
array(
|
402 |
-
'_um_mode' => array(
|
403 |
-
'sanitize' => 'key',
|
404 |
-
),
|
405 |
-
'_um_register_use_gdpr' => array(
|
406 |
-
'sanitize' => 'bool',
|
407 |
-
),
|
408 |
-
'_um_register_use_gdpr_content_id' => array(
|
409 |
-
'sanitize' => 'absint',
|
410 |
-
),
|
411 |
-
'_um_register_use_gdpr_toggle_show' => array(
|
412 |
-
'sanitize' => 'text',
|
413 |
-
),
|
414 |
-
'_um_register_use_gdpr_toggle_hide' => array(
|
415 |
-
'sanitize' => 'text',
|
416 |
-
),
|
417 |
-
'_um_register_use_gdpr_agreement' => array(
|
418 |
-
'sanitize' => 'text',
|
419 |
-
),
|
420 |
-
'_um_register_use_gdpr_error_text' => array(
|
421 |
-
'sanitize' => 'text',
|
422 |
-
),
|
423 |
-
'_um_register_use_custom_settings' => array(
|
424 |
-
'sanitize' => 'bool',
|
425 |
-
),
|
426 |
-
'_um_register_role' => array(
|
427 |
-
'sanitize' => 'key',
|
428 |
-
),
|
429 |
-
'_um_register_template' => array(
|
430 |
-
'sanitize' => 'text',
|
431 |
-
),
|
432 |
-
'_um_register_max_width' => array(
|
433 |
-
'sanitize' => 'text',
|
434 |
-
),
|
435 |
-
'_um_register_icons' => array(
|
436 |
-
'sanitize' => 'key',
|
437 |
-
),
|
438 |
-
'_um_register_primary_btn_word' => array(
|
439 |
-
'sanitize' => 'text',
|
440 |
-
),
|
441 |
-
'_um_register_secondary_btn' => array(
|
442 |
-
'sanitize' => 'bool',
|
443 |
-
),
|
444 |
-
'_um_register_secondary_btn_word' => array(
|
445 |
-
'sanitize' => 'text',
|
446 |
-
),
|
447 |
-
'_um_login_after_login' => array(
|
448 |
-
'sanitize' => 'key',
|
449 |
-
),
|
450 |
-
'_um_login_redirect_url' => array(
|
451 |
-
'sanitize' => 'url',
|
452 |
-
),
|
453 |
-
'_um_login_use_custom_settings' => array(
|
454 |
-
'sanitize' => 'bool',
|
455 |
-
),
|
456 |
-
'_um_login_template' => array(
|
457 |
-
'sanitize' => 'text',
|
458 |
-
),
|
459 |
-
'_um_login_max_width' => array(
|
460 |
-
'sanitize' => 'text',
|
461 |
-
),
|
462 |
-
'_um_login_icons' => array(
|
463 |
-
'sanitize' => 'key',
|
464 |
-
),
|
465 |
-
'_um_login_primary_btn_word' => array(
|
466 |
-
'sanitize' => 'text',
|
467 |
-
),
|
468 |
-
'_um_login_secondary_btn' => array(
|
469 |
-
'sanitize' => 'bool',
|
470 |
-
),
|
471 |
-
'_um_login_secondary_btn_word' => array(
|
472 |
-
'sanitize' => 'text',
|
473 |
-
),
|
474 |
-
'_um_login_forgot_pass_link' => array(
|
475 |
-
'sanitize' => 'bool',
|
476 |
-
),
|
477 |
-
'_um_login_show_rememberme' => array(
|
478 |
-
'sanitize' => 'bool',
|
479 |
-
),
|
480 |
-
'_um_profile_metafields' => array(
|
481 |
-
'sanitize' => array( $this, 'sanitize_user_field' ),
|
482 |
-
),
|
483 |
-
'_um_profile_use_custom_settings' => array(
|
484 |
-
'sanitize' => 'bool',
|
485 |
-
),
|
486 |
-
'_um_profile_role' => array(
|
487 |
-
'sanitize' => array( $this, 'sanitize_existed_role' ),
|
488 |
-
),
|
489 |
-
'_um_profile_template' => array(
|
490 |
-
'sanitize' => 'text',
|
491 |
-
),
|
492 |
-
'_um_profile_max_width' => array(
|
493 |
-
'sanitize' => 'text',
|
494 |
-
),
|
495 |
-
'_um_profile_area_max_width' => array(
|
496 |
-
'sanitize' => 'text',
|
497 |
-
),
|
498 |
-
'_um_profile_icons' => array(
|
499 |
-
'sanitize' => 'key',
|
500 |
-
),
|
501 |
-
'_um_profile_primary_btn_word' => array(
|
502 |
-
'sanitize' => 'text',
|
503 |
-
),
|
504 |
-
'_um_profile_secondary_btn' => array(
|
505 |
-
'sanitize' => 'bool',
|
506 |
-
),
|
507 |
-
'_um_profile_secondary_btn_word' => array(
|
508 |
-
'sanitize' => 'text',
|
509 |
-
),
|
510 |
-
'_um_profile_cover_enabled' => array(
|
511 |
-
'sanitize' => 'bool',
|
512 |
-
),
|
513 |
-
'_um_profile_coversize' => array(
|
514 |
-
'sanitize' => 'absint',
|
515 |
-
),
|
516 |
-
'_um_profile_cover_ratio' => array(
|
517 |
-
'sanitize' => 'text',
|
518 |
-
),
|
519 |
-
'_um_profile_disable_photo_upload' => array(
|
520 |
-
'sanitize' => 'bool',
|
521 |
-
),
|
522 |
-
'_um_profile_photosize' => array(
|
523 |
-
'sanitize' => array( $this, 'sanitize_photosize' ),
|
524 |
-
),
|
525 |
-
'_um_profile_photo_required' => array(
|
526 |
-
'sanitize' => 'bool',
|
527 |
-
),
|
528 |
-
'_um_profile_show_name' => array(
|
529 |
-
'sanitize' => 'bool',
|
530 |
-
),
|
531 |
-
'_um_profile_show_social_links' => array(
|
532 |
-
'sanitize' => 'bool',
|
533 |
-
),
|
534 |
-
'_um_profile_show_bio' => array(
|
535 |
-
'sanitize' => 'bool',
|
536 |
-
),
|
537 |
-
|
538 |
-
)
|
539 |
-
);
|
540 |
-
|
541 |
-
$this->builder_input = apply_filters(
|
542 |
-
'um_builder_input_map',
|
543 |
-
array(
|
544 |
-
'_in_row' => array(
|
545 |
-
'sanitize' => 'key',
|
546 |
-
),
|
547 |
-
'_in_sub_row' => array(
|
548 |
-
'sanitize' => 'absint',
|
549 |
-
),
|
550 |
-
'_in_column' => array(
|
551 |
-
'sanitize' => 'absint',
|
552 |
-
),
|
553 |
-
'_in_group' => array(
|
554 |
-
'sanitize' => 'absint',
|
555 |
-
),
|
556 |
-
'_visibility' => array(
|
557 |
-
'sanitize' => 'key',
|
558 |
-
),
|
559 |
-
'_conditional_action' => array(
|
560 |
-
'sanitize' => 'key',
|
561 |
-
),
|
562 |
-
'_conditional_action1' => array(
|
563 |
-
'sanitize' => 'key',
|
564 |
-
),
|
565 |
-
'_conditional_action2' => array(
|
566 |
-
'sanitize' => 'key',
|
567 |
-
),
|
568 |
-
'_conditional_action3' => array(
|
569 |
-
'sanitize' => 'key',
|
570 |
-
),
|
571 |
-
'_conditional_action4' => array(
|
572 |
-
'sanitize' => 'key',
|
573 |
-
),
|
574 |
-
'_conditional_field' => array(
|
575 |
-
'sanitize' => 'text',
|
576 |
-
),
|
577 |
-
'_conditional_field1' => array(
|
578 |
-
'sanitize' => 'text',
|
579 |
-
),
|
580 |
-
'_conditional_field2' => array(
|
581 |
-
'sanitize' => 'text',
|
582 |
-
),
|
583 |
-
'_conditional_field3' => array(
|
584 |
-
'sanitize' => 'text',
|
585 |
-
),
|
586 |
-
'_conditional_field4' => array(
|
587 |
-
'sanitize' => 'text',
|
588 |
-
),
|
589 |
-
'_conditional_operator' => array(
|
590 |
-
'sanitize' => 'text',
|
591 |
-
),
|
592 |
-
'_conditional_operator1' => array(
|
593 |
-
'sanitize' => 'text',
|
594 |
-
),
|
595 |
-
'_conditional_operator2' => array(
|
596 |
-
'sanitize' => 'text',
|
597 |
-
),
|
598 |
-
'_conditional_operator3' => array(
|
599 |
-
'sanitize' => 'text',
|
600 |
-
),
|
601 |
-
'_conditional_operator4' => array(
|
602 |
-
'sanitize' => 'text',
|
603 |
-
),
|
604 |
-
'_conditional_value' => array(
|
605 |
-
'sanitize' => 'text',
|
606 |
-
),
|
607 |
-
'_conditional_value1' => array(
|
608 |
-
'sanitize' => 'text',
|
609 |
-
),
|
610 |
-
'_conditional_value2' => array(
|
611 |
-
'sanitize' => 'text',
|
612 |
-
),
|
613 |
-
'_conditional_value3' => array(
|
614 |
-
'sanitize' => 'text',
|
615 |
-
),
|
616 |
-
'_conditional_value4' => array(
|
617 |
-
'sanitize' => 'text',
|
618 |
-
),
|
619 |
-
'_validate' => array(
|
620 |
-
'sanitize' => 'key',
|
621 |
-
),
|
622 |
-
'_custom_validate' => array(
|
623 |
-
'sanitize' => 'text',
|
624 |
-
),
|
625 |
-
'_icon' => array(
|
626 |
-
'sanitize' => 'key',
|
627 |
-
),
|
628 |
-
'_css_class' => array(
|
629 |
-
'sanitize' => 'text',
|
630 |
-
),
|
631 |
-
'_width' => array(
|
632 |
-
'sanitize' => 'absint',
|
633 |
-
),
|
634 |
-
'_divider_text' => array(
|
635 |
-
'sanitize' => 'text',
|
636 |
-
),
|
637 |
-
'_padding' => array(
|
638 |
-
'sanitize' => 'text',
|
639 |
-
),
|
640 |
-
'_margin' => array(
|
641 |
-
'sanitize' => 'text',
|
642 |
-
),
|
643 |
-
'_border' => array(
|
644 |
-
'sanitize' => 'text',
|
645 |
-
),
|
646 |
-
'_borderstyle' => array(
|
647 |
-
'sanitize' => 'key',
|
648 |
-
),
|
649 |
-
'_borderradius' => array(
|
650 |
-
'sanitize' => 'text',
|
651 |
-
),
|
652 |
-
'_bordercolor' => array(
|
653 |
-
'sanitize' => 'text',
|
654 |
-
),
|
655 |
-
'_heading' => array(
|
656 |
-
'sanitize' => 'bool',
|
657 |
-
),
|
658 |
-
'_heading_text' => array(
|
659 |
-
'sanitize' => 'text',
|
660 |
-
),
|
661 |
-
'_background' => array(
|
662 |
-
'sanitize' => 'text',
|
663 |
-
),
|
664 |
-
'_heading_background_color' => array(
|
665 |
-
'sanitize' => 'text',
|
666 |
-
),
|
667 |
-
'_heading_text_color' => array(
|
668 |
-
'sanitize' => 'text',
|
669 |
-
),
|
670 |
-
'_text_color' => array(
|
671 |
-
'sanitize' => 'text',
|
672 |
-
),
|
673 |
-
'_icon_color' => array(
|
674 |
-
'sanitize' => 'text',
|
675 |
-
),
|
676 |
-
'_color' => array(
|
677 |
-
'sanitize' => 'text',
|
678 |
-
),
|
679 |
-
'_url_text' => array(
|
680 |
-
'sanitize' => 'text',
|
681 |
-
),
|
682 |
-
'_url_target' => array(
|
683 |
-
'sanitize' => 'key',
|
684 |
-
),
|
685 |
-
'_url_rel' => array(
|
686 |
-
'sanitize' => 'key',
|
687 |
-
),
|
688 |
-
'_force_good_pass' => array(
|
689 |
-
'sanitize' => 'bool',
|
690 |
-
),
|
691 |
-
'_force_confirm_pass' => array(
|
692 |
-
'sanitize' => 'bool',
|
693 |
-
),
|
694 |
-
'_style' => array(
|
695 |
-
'sanitize' => 'key',
|
696 |
-
),
|
697 |
-
'_intervals' => array(
|
698 |
-
'sanitize' => 'absint',
|
699 |
-
),
|
700 |
-
'_format' => array(
|
701 |
-
'sanitize' => 'text',
|
702 |
-
),
|
703 |
-
'_format_custom' => array(
|
704 |
-
'sanitize' => 'text',
|
705 |
-
),
|
706 |
-
'_pretty_format' => array(
|
707 |
-
'sanitize' => 'bool',
|
708 |
-
),
|
709 |
-
'_disabled_weekdays' => array(
|
710 |
-
'sanitize' => 'absint',
|
711 |
-
),
|
712 |
-
'_years' => array(
|
713 |
-
'sanitize' => 'absint',
|
714 |
-
),
|
715 |
-
'_years_x' => array(
|
716 |
-
'sanitize' => 'key',
|
717 |
-
),
|
718 |
-
'_range_start' => array(
|
719 |
-
'sanitize' => 'text',
|
720 |
-
),
|
721 |
-
'_range_end' => array(
|
722 |
-
'sanitize' => 'text',
|
723 |
-
),
|
724 |
-
'_range' => array(
|
725 |
-
'sanitize' => 'key',
|
726 |
-
),
|
727 |
-
'_content' => array(
|
728 |
-
'sanitize' => 'textarea',
|
729 |
-
),
|
730 |
-
'_crop' => array(
|
731 |
-
'sanitize' => 'int',
|
732 |
-
),
|
733 |
-
'_allowed_types' => array(
|
734 |
-
'sanitize' => 'key',
|
735 |
-
),
|
736 |
-
'_upload_text' => array(
|
737 |
-
'sanitize' => 'text',
|
738 |
-
),
|
739 |
-
'_upload_help_text' => array(
|
740 |
-
'sanitize' => 'text',
|
741 |
-
),
|
742 |
-
'_button_text' => array(
|
743 |
-
'sanitize' => 'text',
|
744 |
-
),
|
745 |
-
'_max_size' => array(
|
746 |
-
'sanitize' => 'absint',
|
747 |
-
),
|
748 |
-
'_height' => array(
|
749 |
-
'sanitize' => 'text',
|
750 |
-
),
|
751 |
-
'_spacing' => array(
|
752 |
-
'sanitize' => 'text',
|
753 |
-
),
|
754 |
-
'_is_multi' => array(
|
755 |
-
'sanitize' => 'bool',
|
756 |
-
),
|
757 |
-
'_max_selections' => array(
|
758 |
-
'sanitize' => 'absint',
|
759 |
-
),
|
760 |
-
'_min_selections' => array(
|
761 |
-
'sanitize' => 'absint',
|
762 |
-
),
|
763 |
-
'_max_entries' => array(
|
764 |
-
'sanitize' => 'absint',
|
765 |
-
),
|
766 |
-
'_max_words' => array(
|
767 |
-
'sanitize' => 'absint',
|
768 |
-
),
|
769 |
-
'_min' => array(
|
770 |
-
'sanitize' => 'empty_int',
|
771 |
-
),
|
772 |
-
'_max' => array(
|
773 |
-
'sanitize' => 'empty_int',
|
774 |
-
),
|
775 |
-
'_min_chars' => array(
|
776 |
-
'sanitize' => 'absint',
|
777 |
-
),
|
778 |
-
'_max_chars' => array(
|
779 |
-
'sanitize' => 'absint',
|
780 |
-
),
|
781 |
-
'_html' => array(
|
782 |
-
'sanitize' => 'bool',
|
783 |
-
),
|
784 |
-
'_options' => array(
|
785 |
-
'sanitize' => 'textarea',
|
786 |
-
),
|
787 |
-
'_title' => array(
|
788 |
-
'sanitize' => 'text',
|
789 |
-
),
|
790 |
-
'_id' => array(
|
791 |
-
'sanitize' => 'text',
|
792 |
-
),
|
793 |
-
'_metakey' => array(
|
794 |
-
'sanitize' => 'text',
|
795 |
-
),
|
796 |
-
'_help' => array(
|
797 |
-
'sanitize' => 'text',
|
798 |
-
),
|
799 |
-
'_default' => array(
|
800 |
-
'sanitize' => 'text',
|
801 |
-
),
|
802 |
-
'_label' => array(
|
803 |
-
'sanitize' => 'text',
|
804 |
-
),
|
805 |
-
'_label_confirm_pass' => array(
|
806 |
-
'sanitize' => 'text',
|
807 |
-
),
|
808 |
-
'_placeholder' => array(
|
809 |
-
'sanitize' => 'text',
|
810 |
-
),
|
811 |
-
'_public' => array(
|
812 |
-
'sanitize' => 'text',
|
813 |
-
),
|
814 |
-
'_roles' => array(
|
815 |
-
'sanitize' => array( $this, 'sanitize_existed_role' ),
|
816 |
-
),
|
817 |
-
'_required' => array(
|
818 |
-
'sanitize' => 'bool',
|
819 |
-
),
|
820 |
-
'_editable' => array(
|
821 |
-
'sanitize' => 'bool',
|
822 |
-
),
|
823 |
-
'_number' => array(
|
824 |
-
'sanitize' => 'absint',
|
825 |
-
),
|
826 |
-
'_custom_dropdown_options_source' => array(
|
827 |
-
'sanitize' => 'text',
|
828 |
-
),
|
829 |
-
'_parent_dropdown_relationship' => array(
|
830 |
-
'sanitize' => 'text',
|
831 |
-
),
|
832 |
-
)
|
833 |
-
);
|
834 |
-
}
|
835 |
-
|
836 |
-
|
837 |
-
/**
|
838 |
-
* @param array|string $value
|
839 |
-
*
|
840 |
-
* @return array|string
|
841 |
-
*/
|
842 |
-
public function sanitize_md_sorting_fields( $value ) {
|
843 |
-
$filter_fields = array_merge( UM()->member_directory()->sort_fields, array( 'other' => __( 'Other (Custom Field)', 'ultimate-member' ) ) );
|
844 |
-
$filter_fields = array_keys( $filter_fields );
|
845 |
-
|
846 |
-
if ( '' !== $value ) {
|
847 |
-
$value = array_filter(
|
848 |
-
$value,
|
849 |
-
function( $v, $k ) use ( $filter_fields ) {
|
850 |
-
if ( 'other_data' === $k ) {
|
851 |
-
return true;
|
852 |
-
} else {
|
853 |
-
return in_array( sanitize_text_field( $v ), $filter_fields, true );
|
854 |
-
}
|
855 |
-
},
|
856 |
-
ARRAY_FILTER_USE_BOTH
|
857 |
-
);
|
858 |
-
|
859 |
-
$value = array_map(
|
860 |
-
function( $item ) {
|
861 |
-
if ( is_array( $item ) ) {
|
862 |
-
if ( isset( $item['meta_key'] ) ) {
|
863 |
-
$item['meta_key'] = sanitize_text_field( $item['meta_key'] );
|
864 |
-
}
|
865 |
-
if ( isset( $item['label'] ) ) {
|
866 |
-
$item['label'] = sanitize_text_field( $item['label'] );
|
867 |
-
}
|
868 |
-
|
869 |
-
return $item;
|
870 |
-
} else {
|
871 |
-
return sanitize_text_field( $item );
|
872 |
-
}
|
873 |
-
},
|
874 |
-
$value
|
875 |
-
);
|
876 |
-
}
|
877 |
-
|
878 |
-
return $value;
|
879 |
-
}
|
880 |
-
|
881 |
-
|
882 |
-
/**
|
883 |
-
* @param array|string $value
|
884 |
-
*
|
885 |
-
* @return array|string
|
886 |
-
*/
|
887 |
-
public function sanitize_filter_fields( $value ) {
|
888 |
-
$filter_fields = array_keys( UM()->member_directory()->filter_fields );
|
889 |
-
|
890 |
-
if ( '' !== $value ) {
|
891 |
-
$value = array_filter(
|
892 |
-
$value,
|
893 |
-
function( $v, $k ) use ( $filter_fields ) {
|
894 |
-
return in_array( sanitize_text_field( $v ), $filter_fields, true );
|
895 |
-
},
|
896 |
-
ARRAY_FILTER_USE_BOTH
|
897 |
-
);
|
898 |
-
|
899 |
-
$value = array_map( 'sanitize_text_field', $value );
|
900 |
-
}
|
901 |
-
|
902 |
-
return $value;
|
903 |
-
}
|
904 |
-
|
905 |
-
|
906 |
-
/**
|
907 |
-
* @param array|string $value
|
908 |
-
*
|
909 |
-
* @return array|string
|
910 |
-
*/
|
911 |
-
public function sanitize_user_field( $value ) {
|
912 |
-
$user_fields = array_keys( UM()->builtin()->all_user_fields() );
|
913 |
-
|
914 |
-
if ( '' !== $value ) {
|
915 |
-
$value = array_filter(
|
916 |
-
$value,
|
917 |
-
function( $v, $k ) use ( $user_fields ) {
|
918 |
-
return in_array( sanitize_text_field( $v ), $user_fields, true );
|
919 |
-
},
|
920 |
-
ARRAY_FILTER_USE_BOTH
|
921 |
-
);
|
922 |
-
|
923 |
-
$value = array_map( 'sanitize_text_field', $value );
|
924 |
-
}
|
925 |
-
|
926 |
-
return $value;
|
927 |
-
}
|
928 |
-
|
929 |
-
|
930 |
-
/**
|
931 |
-
* @param array|string $value
|
932 |
-
*
|
933 |
-
* @return array|string
|
934 |
-
*/
|
935 |
-
public function sanitize_md_view_types( $value ) {
|
936 |
-
$view_types = array_map(
|
937 |
-
function ( $item ) {
|
938 |
-
return $item['title'];
|
939 |
-
},
|
940 |
-
UM()->member_directory()->view_types
|
941 |
-
);
|
942 |
-
$view_types = array_keys( $view_types );
|
943 |
-
|
944 |
-
if ( '' !== $value ) {
|
945 |
-
$value = array_filter(
|
946 |
-
$value,
|
947 |
-
function( $v, $k ) use ( $view_types ) {
|
948 |
-
return in_array( sanitize_key( $k ), $view_types, true ) && 1 === (int) $v;
|
949 |
-
},
|
950 |
-
ARRAY_FILTER_USE_BOTH
|
951 |
-
);
|
952 |
-
|
953 |
-
$value = array_map( 'sanitize_key', $value );
|
954 |
-
}
|
955 |
-
|
956 |
-
return $value;
|
957 |
-
}
|
958 |
-
|
959 |
-
|
960 |
-
/**
|
961 |
-
* @param array|string $value
|
962 |
-
*
|
963 |
-
* @return array|string
|
964 |
-
*/
|
965 |
-
public function sanitize_photosize( $value ) {
|
966 |
-
$sizes = UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' );
|
967 |
-
$sizes = array_keys( $sizes );
|
968 |
-
|
969 |
-
if ( '' !== $value ) {
|
970 |
-
$value = in_array( absint( $value ), $sizes, true ) ? absint( $value ) : '';
|
971 |
-
}
|
972 |
-
|
973 |
-
return $value;
|
974 |
-
}
|
975 |
-
|
976 |
-
|
977 |
-
/**
|
978 |
-
* @param array|string $value
|
979 |
-
*
|
980 |
-
* @return array|string
|
981 |
-
*/
|
982 |
-
public function sanitize_cover_photosize( $value ) {
|
983 |
-
$sizes = UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' );
|
984 |
-
$sizes = array_keys( $sizes );
|
985 |
-
|
986 |
-
if ( '' !== $value ) {
|
987 |
-
$value = in_array( absint( $value ), $sizes, true ) ? absint( $value ) : '';
|
988 |
-
}
|
989 |
-
|
990 |
-
return $value;
|
991 |
-
}
|
992 |
-
|
993 |
-
|
994 |
-
/**
|
995 |
-
* @param array|string $value
|
996 |
-
*
|
997 |
-
* @return array|string
|
998 |
-
*/
|
999 |
-
public function sanitize_restriction_existed_role( $value ) {
|
1000 |
-
$all_roles = array_keys( UM()->roles()->get_roles() );
|
1001 |
-
|
1002 |
-
if ( '' !== $value ) {
|
1003 |
-
$value = array_filter(
|
1004 |
-
$value,
|
1005 |
-
function( $v, $k ) use ( $all_roles ) {
|
1006 |
-
return in_array( sanitize_key( $k ), $all_roles, true ) && 1 === (int) $v;
|
1007 |
-
},
|
1008 |
-
ARRAY_FILTER_USE_BOTH
|
1009 |
-
);
|
1010 |
-
|
1011 |
-
$value = array_map( 'sanitize_key', $value );
|
1012 |
-
}
|
1013 |
-
|
1014 |
-
return $value;
|
1015 |
-
}
|
1016 |
-
|
1017 |
-
|
1018 |
-
/**
|
1019 |
-
* @param array|string $value
|
1020 |
-
*
|
1021 |
-
* @return array|string
|
1022 |
-
*/
|
1023 |
-
public function sanitize_existed_role( $value ) {
|
1024 |
-
$all_roles = array_keys( UM()->roles()->get_roles() );
|
1025 |
-
|
1026 |
-
if ( '' !== $value ) {
|
1027 |
-
$value = array_filter(
|
1028 |
-
$value,
|
1029 |
-
function( $v, $k ) use ( $all_roles ) {
|
1030 |
-
return in_array( sanitize_key( $v ), $all_roles, true );
|
1031 |
-
},
|
1032 |
-
ARRAY_FILTER_USE_BOTH
|
1033 |
-
);
|
1034 |
-
|
1035 |
-
$value = array_map( 'sanitize_key', $value );
|
1036 |
-
}
|
1037 |
-
|
1038 |
-
return $value;
|
1039 |
-
}
|
1040 |
-
|
1041 |
-
|
1042 |
-
/**
|
1043 |
-
* @param array|string $value
|
1044 |
-
*
|
1045 |
-
* @return array|string
|
1046 |
-
*/
|
1047 |
-
public function sanitize_tabs_privacy( $value ) {
|
1048 |
-
$all_privacy = array_keys( UM()->profile()->tabs_privacy() );
|
1049 |
-
|
1050 |
-
if ( '' !== $value ) {
|
1051 |
-
$value = in_array( absint( $value ), $all_privacy, true ) ? absint( $value ) : '';
|
1052 |
-
}
|
1053 |
-
|
1054 |
-
return $value;
|
1055 |
-
}
|
1056 |
-
|
1057 |
-
|
1058 |
-
/**
|
1059 |
-
* @param $value
|
1060 |
-
*
|
1061 |
-
* @return bool|string
|
1062 |
-
*/
|
1063 |
-
public function sanitize_profile_noindex( $value ) {
|
1064 |
-
$value = '' !== $value ? (bool) $value : $value;
|
1065 |
-
return $value;
|
1066 |
-
}
|
1067 |
-
|
1068 |
-
|
1069 |
-
/**
|
1070 |
-
* @param $value
|
1071 |
-
*
|
1072 |
-
* @return array
|
1073 |
-
*/
|
1074 |
-
public function sanitize_wp_capabilities( $value ) {
|
1075 |
-
$value = array_map( 'boolval', array_filter( $value ) );
|
1076 |
-
return $value;
|
1077 |
-
}
|
1078 |
-
|
1079 |
-
|
1080 |
-
/**
|
1081 |
-
* Sanitize role meta fields when wp-admin form has been submitted
|
1082 |
-
*
|
1083 |
-
* @param array $data
|
1084 |
-
*
|
1085 |
-
* @return array
|
1086 |
-
*/
|
1087 |
-
public function sanitize_role_meta( $data ) {
|
1088 |
-
$sanitized = array();
|
1089 |
-
foreach ( $data as $k => $v ) {
|
1090 |
-
if ( ! array_key_exists( $k, $this->role_meta ) ) {
|
1091 |
-
// @todo remove since 2.2.x and leave only continue
|
1092 |
-
$sanitized[ $k ] = $v;
|
1093 |
-
continue;
|
1094 |
-
}
|
1095 |
-
|
1096 |
-
if ( ! array_key_exists( 'sanitize', $this->role_meta[ $k ] ) ) {
|
1097 |
-
// @todo remove since 2.2.x and leave only continue
|
1098 |
-
$sanitized[ $k ] = $v;
|
1099 |
-
continue;
|
1100 |
-
}
|
1101 |
-
|
1102 |
-
if ( is_callable( $this->role_meta[ $k ]['sanitize'], true, $callable_name ) ) {
|
1103 |
-
add_filter( 'um_role_meta_sanitize_' . $k, $this->role_meta[ $k ]['sanitize'], 10, 1 );
|
1104 |
-
}
|
1105 |
-
|
1106 |
-
switch ( $this->role_meta[ $k ]['sanitize'] ) {
|
1107 |
-
default:
|
1108 |
-
$sanitized[ $k ] = apply_filters( 'um_role_meta_sanitize_' . $k, $data[ $k ] );
|
1109 |
-
break;
|
1110 |
-
case 'int':
|
1111 |
-
$sanitized[ $k ] = (int) $v;
|
1112 |
-
break;
|
1113 |
-
case 'bool':
|
1114 |
-
$sanitized[ $k ] = (bool) $v;
|
1115 |
-
break;
|
1116 |
-
case 'url':
|
1117 |
-
$sanitized[ $k ] = esc_url_raw( $v );
|
1118 |
-
break;
|
1119 |
-
case 'textarea':
|
1120 |
-
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1121 |
-
break;
|
1122 |
-
case 'sanitize_array_key':
|
1123 |
-
if ( ! array_key_exists( 'default', $this->role_meta[ $k ] ) || ! array_key_exists( 'array', $this->role_meta[ $k ] ) ) {
|
1124 |
-
continue 2;
|
1125 |
-
}
|
1126 |
-
|
1127 |
-
$sanitized[ $k ] = ! in_array( sanitize_key( $v ), $this->role_meta[ $k ]['array'], true ) ? $this->role_meta[ $k ]['default'] : sanitize_key( $v );
|
1128 |
-
break;
|
1129 |
-
}
|
1130 |
-
}
|
1131 |
-
|
1132 |
-
$data = $sanitized;
|
1133 |
-
|
1134 |
-
$data = apply_filters( 'um_save_role_meta_sanitize', $data );
|
1135 |
-
|
1136 |
-
return $data;
|
1137 |
-
}
|
1138 |
-
|
1139 |
-
|
1140 |
-
/**
|
1141 |
-
* Sanitize post restriction meta fields when wp-admin form has been submitted
|
1142 |
-
*
|
1143 |
-
* @param array $data
|
1144 |
-
*
|
1145 |
-
* @return array
|
1146 |
-
*/
|
1147 |
-
public function sanitize_post_restriction_meta( $data ) {
|
1148 |
-
$sanitized = array();
|
1149 |
-
foreach ( $data as $k => $v ) {
|
1150 |
-
if ( ! array_key_exists( $k, $this->restriction_post_meta ) ) {
|
1151 |
-
// @todo remove since 2.2.x and leave only continue
|
1152 |
-
$sanitized[ $k ] = $v;
|
1153 |
-
continue;
|
1154 |
-
}
|
1155 |
-
|
1156 |
-
if ( ! array_key_exists( 'sanitize', $this->restriction_post_meta[ $k ] ) ) {
|
1157 |
-
// @todo remove since 2.2.x and leave only continue
|
1158 |
-
$sanitized[ $k ] = $v;
|
1159 |
-
continue;
|
1160 |
-
}
|
1161 |
-
|
1162 |
-
if ( is_callable( $this->restriction_post_meta[ $k ]['sanitize'], true, $callable_name ) ) {
|
1163 |
-
add_filter( 'um_restriction_post_meta_sanitize_' . $k, $this->restriction_post_meta[ $k ]['sanitize'], 10, 1 );
|
1164 |
-
}
|
1165 |
-
|
1166 |
-
switch ( $this->restriction_post_meta[ $k ]['sanitize'] ) {
|
1167 |
-
default:
|
1168 |
-
$sanitized[ $k ] = apply_filters( 'um_restriction_post_meta_sanitize_' . $k, $data[ $k ] );
|
1169 |
-
break;
|
1170 |
-
case 'int':
|
1171 |
-
$sanitized[ $k ] = (int) $v;
|
1172 |
-
break;
|
1173 |
-
case 'bool':
|
1174 |
-
$sanitized[ $k ] = (bool) $v;
|
1175 |
-
break;
|
1176 |
-
case 'url':
|
1177 |
-
$sanitized[ $k ] = esc_url_raw( $v );
|
1178 |
-
break;
|
1179 |
-
case 'textarea':
|
1180 |
-
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1181 |
-
break;
|
1182 |
-
case 'wp_kses':
|
1183 |
-
$sanitized[ $k ] = wp_kses_post( $v );
|
1184 |
-
break;
|
1185 |
-
}
|
1186 |
-
}
|
1187 |
-
|
1188 |
-
$data = $sanitized;
|
1189 |
-
|
1190 |
-
$data = apply_filters( 'um_save_restriction_post_meta_sanitize', $data );
|
1191 |
-
|
1192 |
-
return $data;
|
1193 |
-
}
|
1194 |
-
|
1195 |
-
|
1196 |
-
/**
|
1197 |
-
* Sanitize term restriction meta fields when wp-admin form has been submitted
|
1198 |
-
*
|
1199 |
-
* @param array $data
|
1200 |
-
*
|
1201 |
-
* @return array
|
1202 |
-
*/
|
1203 |
-
public function sanitize_term_restriction_meta( $data ) {
|
1204 |
-
$sanitized = array();
|
1205 |
-
foreach ( $data as $k => $v ) {
|
1206 |
-
if ( ! array_key_exists( $k, $this->restriction_term_meta ) ) {
|
1207 |
-
// @todo remove since 2.2.x and leave only continue
|
1208 |
-
$sanitized[ $k ] = $v;
|
1209 |
-
continue;
|
1210 |
-
}
|
1211 |
-
|
1212 |
-
if ( ! array_key_exists( 'sanitize', $this->restriction_term_meta[ $k ] ) ) {
|
1213 |
-
// @todo remove since 2.2.x and leave only continue
|
1214 |
-
$sanitized[ $k ] = $v;
|
1215 |
-
continue;
|
1216 |
-
}
|
1217 |
-
|
1218 |
-
if ( is_callable( $this->restriction_term_meta[ $k ]['sanitize'], true, $callable_name ) ) {
|
1219 |
-
add_filter( 'um_restriction_term_meta_sanitize_' . $k, $this->restriction_term_meta[ $k ]['sanitize'], 10, 1 );
|
1220 |
-
}
|
1221 |
-
|
1222 |
-
switch ( $this->restriction_term_meta[ $k ]['sanitize'] ) {
|
1223 |
-
default:
|
1224 |
-
$sanitized[ $k ] = apply_filters( 'um_restriction_term_meta_sanitize_' . $k, $data[ $k ] );
|
1225 |
-
break;
|
1226 |
-
case 'int':
|
1227 |
-
$sanitized[ $k ] = (int) $v;
|
1228 |
-
break;
|
1229 |
-
case 'bool':
|
1230 |
-
$sanitized[ $k ] = (bool) $v;
|
1231 |
-
break;
|
1232 |
-
case 'url':
|
1233 |
-
$sanitized[ $k ] = esc_url_raw( $v );
|
1234 |
-
break;
|
1235 |
-
case 'textarea':
|
1236 |
-
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1237 |
-
break;
|
1238 |
-
case 'wp_kses':
|
1239 |
-
$sanitized[ $k ] = wp_kses_post( $v );
|
1240 |
-
break;
|
1241 |
-
}
|
1242 |
-
}
|
1243 |
-
|
1244 |
-
$data = $sanitized;
|
1245 |
-
|
1246 |
-
$data = apply_filters( 'um_save_restriction_term_meta_sanitize', $data );
|
1247 |
-
|
1248 |
-
return $data;
|
1249 |
-
}
|
1250 |
-
|
1251 |
-
|
1252 |
-
/**
|
1253 |
-
* Sanitize member directory meta when wp-admin form has been submitted
|
1254 |
-
*
|
1255 |
-
* @todo checking all sanitize types
|
1256 |
-
*
|
1257 |
-
* @param array $data
|
1258 |
-
*
|
1259 |
-
* @return array
|
1260 |
-
*/
|
1261 |
-
public function sanitize_member_directory_meta( $data ) {
|
1262 |
-
$sanitized = array();
|
1263 |
-
foreach ( $data as $k => $v ) {
|
1264 |
-
if ( ! array_key_exists( $k, $this->member_directory_meta ) ) {
|
1265 |
-
// @todo remove since 2.2.x and leave only continue
|
1266 |
-
$sanitized[ $k ] = $v;
|
1267 |
-
continue;
|
1268 |
-
}
|
1269 |
-
|
1270 |
-
if ( ! array_key_exists( 'sanitize', $this->member_directory_meta[ $k ] ) ) {
|
1271 |
-
// @todo remove since 2.2.x and leave only continue
|
1272 |
-
$sanitized[ $k ] = $v;
|
1273 |
-
continue;
|
1274 |
-
}
|
1275 |
-
|
1276 |
-
if ( is_callable( $this->member_directory_meta[ $k ]['sanitize'], true, $callable_name ) ) {
|
1277 |
-
add_filter( 'um_member_directory_meta_sanitize_' . $k, $this->member_directory_meta[ $k ]['sanitize'], 10, 1 );
|
1278 |
-
}
|
1279 |
-
|
1280 |
-
switch ( $this->member_directory_meta[ $k ]['sanitize'] ) {
|
1281 |
-
default:
|
1282 |
-
$sanitized[ $k ] = apply_filters( 'um_member_directory_meta_sanitize_' . $k, $data[ $k ] );
|
1283 |
-
break;
|
1284 |
-
case 'int':
|
1285 |
-
$sanitized[ $k ] = (int) $v;
|
1286 |
-
break;
|
1287 |
-
case 'bool':
|
1288 |
-
$sanitized[ $k ] = (bool) $v;
|
1289 |
-
break;
|
1290 |
-
case 'url':
|
1291 |
-
if ( is_array( $v ) ) {
|
1292 |
-
$sanitized[ $k ] = array_map( 'esc_url_raw', $v );
|
1293 |
-
} else {
|
1294 |
-
$sanitized[ $k ] = esc_url_raw( $v );
|
1295 |
-
}
|
1296 |
-
break;
|
1297 |
-
case 'text':
|
1298 |
-
$sanitized[ $k ] = sanitize_text_field( $v );
|
1299 |
-
break;
|
1300 |
-
case 'textarea':
|
1301 |
-
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1302 |
-
break;
|
1303 |
-
case 'key':
|
1304 |
-
if ( is_array( $v ) ) {
|
1305 |
-
$sanitized[ $k ] = array_map( 'sanitize_key', $v );
|
1306 |
-
} else {
|
1307 |
-
$sanitized[ $k ] = sanitize_key( $v );
|
1308 |
-
}
|
1309 |
-
break;
|
1310 |
-
case 'absint':
|
1311 |
-
if ( is_array( $v ) ) {
|
1312 |
-
$sanitized[ $k ] = array_map( 'absint', $v );
|
1313 |
-
} else {
|
1314 |
-
$sanitized[ $k ] = absint( $v );
|
1315 |
-
}
|
1316 |
-
break;
|
1317 |
-
}
|
1318 |
-
}
|
1319 |
-
|
1320 |
-
$data = $sanitized;
|
1321 |
-
|
1322 |
-
$data = apply_filters( 'um_save_member_directory_meta_sanitize', $data );
|
1323 |
-
|
1324 |
-
return $data;
|
1325 |
-
}
|
1326 |
-
|
1327 |
-
|
1328 |
-
/**
|
1329 |
-
* Sanitize builder field meta when wp-admin form has been submitted
|
1330 |
-
*
|
1331 |
-
* @todo checking all sanitize types
|
1332 |
-
*
|
1333 |
-
* @param array $data
|
1334 |
-
*
|
1335 |
-
* @return array
|
1336 |
-
*/
|
1337 |
-
public function sanitize_builder_field_meta( $data ) {
|
1338 |
-
$sanitized = array();
|
1339 |
-
foreach ( $data as $k => $v ) {
|
1340 |
-
if ( ! array_key_exists( $k, $this->builder_input ) ) {
|
1341 |
-
// @todo remove since 2.2.x and leave only continue
|
1342 |
-
$sanitized[ $k ] = $v;
|
1343 |
-
continue;
|
1344 |
-
}
|
1345 |
-
|
1346 |
-
if ( ! array_key_exists( 'sanitize', $this->builder_input[ $k ] ) ) {
|
1347 |
-
// @todo remove since 2.2.x and leave only continue
|
1348 |
-
$sanitized[ $k ] = $v;
|
1349 |
-
continue;
|
1350 |
-
}
|
1351 |
-
|
1352 |
-
if ( is_callable( $this->builder_input[ $k ]['sanitize'], true, $callable_name ) ) {
|
1353 |
-
add_filter( 'um_builder_input_sanitize_' . $k, $this->builder_input[ $k ]['sanitize'], 10, 1 );
|
1354 |
-
}
|
1355 |
-
|
1356 |
-
switch ( $this->builder_input[ $k ]['sanitize'] ) {
|
1357 |
-
default:
|
1358 |
-
$sanitized[ $k ] = apply_filters( 'um_builder_input_sanitize_' . $k, $data[ $k ] );
|
1359 |
-
break;
|
1360 |
-
case 'int':
|
1361 |
-
$sanitized[ $k ] = (int) $v;
|
1362 |
-
break;
|
1363 |
-
case 'empty_int':
|
1364 |
-
$sanitized[ $k ] = ( '' !== $v ) ? (int) $v : '';
|
1365 |
-
break;
|
1366 |
-
case 'bool':
|
1367 |
-
$sanitized[ $k ] = (bool) $v;
|
1368 |
-
break;
|
1369 |
-
case 'url':
|
1370 |
-
if ( is_array( $v ) ) {
|
1371 |
-
$sanitized[ $k ] = array_map( 'esc_url_raw', $v );
|
1372 |
-
} else {
|
1373 |
-
$sanitized[ $k ] = esc_url_raw( $v );
|
1374 |
-
}
|
1375 |
-
break;
|
1376 |
-
case 'text':
|
1377 |
-
$sanitized[ $k ] = sanitize_text_field( $v );
|
1378 |
-
break;
|
1379 |
-
case 'textarea':
|
1380 |
-
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1381 |
-
break;
|
1382 |
-
case 'wp_kses':
|
1383 |
-
$sanitized[ $k ] = wp_kses_post( $v );
|
1384 |
-
break;
|
1385 |
-
case 'key':
|
1386 |
-
if ( is_array( $v ) ) {
|
1387 |
-
$sanitized[ $k ] = array_map( 'sanitize_key', $v );
|
1388 |
-
} else {
|
1389 |
-
$sanitized[ $k ] = sanitize_key( $v );
|
1390 |
-
}
|
1391 |
-
break;
|
1392 |
-
case 'absint':
|
1393 |
-
if ( is_array( $v ) ) {
|
1394 |
-
$sanitized[ $k ] = array_map( 'absint', $v );
|
1395 |
-
} else {
|
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 |
-
|
1409 |
-
$data = $sanitized;
|
1410 |
-
|
1411 |
-
$data = apply_filters( 'um_save_builder_input_sanitize', $data );
|
1412 |
-
|
1413 |
-
return $data;
|
1414 |
-
}
|
1415 |
-
|
1416 |
-
|
1417 |
-
/**
|
1418 |
-
* Sanitize form meta when wp-admin form has been submitted
|
1419 |
-
*
|
1420 |
-
* @todo checking all sanitize types
|
1421 |
-
*
|
1422 |
-
* @param array $data
|
1423 |
-
*
|
1424 |
-
* @return array
|
1425 |
-
*/
|
1426 |
-
public function sanitize_form_meta( $data ) {
|
1427 |
-
$sanitized = array();
|
1428 |
-
foreach ( $data as $k => $v ) {
|
1429 |
-
if ( ! array_key_exists( $k, $this->form_meta ) ) {
|
1430 |
-
// @todo remove since 2.2.x and leave only continue
|
1431 |
-
$sanitized[ $k ] = $v;
|
1432 |
-
continue;
|
1433 |
-
}
|
1434 |
-
|
1435 |
-
if ( ! array_key_exists( 'sanitize', $this->form_meta[ $k ] ) ) {
|
1436 |
-
// @todo remove since 2.2.x and leave only continue
|
1437 |
-
$sanitized[ $k ] = $v;
|
1438 |
-
continue;
|
1439 |
-
}
|
1440 |
-
|
1441 |
-
if ( is_callable( $this->form_meta[ $k ]['sanitize'], true, $callable_name ) ) {
|
1442 |
-
add_filter( 'um_form_meta_sanitize_' . $k, $this->form_meta[ $k ]['sanitize'], 10, 1 );
|
1443 |
-
}
|
1444 |
-
|
1445 |
-
switch ( $this->form_meta[ $k ]['sanitize'] ) {
|
1446 |
-
default:
|
1447 |
-
$sanitized[ $k ] = apply_filters( 'um_form_meta_sanitize_' . $k, $data[ $k ] );
|
1448 |
-
break;
|
1449 |
-
case 'int':
|
1450 |
-
$sanitized[ $k ] = (int) $v;
|
1451 |
-
break;
|
1452 |
-
case 'bool':
|
1453 |
-
$sanitized[ $k ] = (bool) $v;
|
1454 |
-
break;
|
1455 |
-
case 'url':
|
1456 |
-
if ( is_array( $v ) ) {
|
1457 |
-
$sanitized[ $k ] = array_map( 'esc_url_raw', $v );
|
1458 |
-
} else {
|
1459 |
-
$sanitized[ $k ] = esc_url_raw( $v );
|
1460 |
-
}
|
1461 |
-
break;
|
1462 |
-
case 'text':
|
1463 |
-
$sanitized[ $k ] = sanitize_text_field( $v );
|
1464 |
-
break;
|
1465 |
-
case 'textarea':
|
1466 |
-
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1467 |
-
break;
|
1468 |
-
case 'key':
|
1469 |
-
if ( is_array( $v ) ) {
|
1470 |
-
$sanitized[ $k ] = array_map( 'sanitize_key', $v );
|
1471 |
-
} else {
|
1472 |
-
$sanitized[ $k ] = sanitize_key( $v );
|
1473 |
-
}
|
1474 |
-
break;
|
1475 |
-
case 'absint':
|
1476 |
-
if ( is_array( $v ) ) {
|
1477 |
-
$sanitized[ $k ] = array_map( 'absint', $v );
|
1478 |
-
} else {
|
1479 |
-
$sanitized[ $k ] = absint( $v );
|
1480 |
-
}
|
1481 |
-
break;
|
1482 |
-
}
|
1483 |
-
}
|
1484 |
-
|
1485 |
-
$data = $sanitized;
|
1486 |
-
|
1487 |
-
$data = apply_filters( 'um_save_form_meta_sanitize', $data );
|
1488 |
-
|
1489 |
-
return $data;
|
1490 |
-
}
|
1491 |
-
|
1492 |
-
|
1493 |
-
/**
|
1494 |
-
* Sanitize options when wp-admin form has been submitted
|
1495 |
-
*
|
1496 |
-
* @todo checking all sanitize types
|
1497 |
-
*
|
1498 |
-
* @param array $data
|
1499 |
-
*
|
1500 |
-
* @return array
|
1501 |
-
*/
|
1502 |
-
public function sanitize_options( $data ) {
|
1503 |
-
$sanitized = array();
|
1504 |
-
foreach ( $data as $k => $v ) {
|
1505 |
-
if ( ! array_key_exists( $k, UM()->admin_settings()->settings_map ) ) {
|
1506 |
-
// @todo remove since 2.2.x and leave only continue
|
1507 |
-
$sanitized[ $k ] = $v;
|
1508 |
-
continue;
|
1509 |
-
}
|
1510 |
-
|
1511 |
-
if ( ! array_key_exists( 'sanitize', UM()->admin_settings()->settings_map[ $k ] ) ) {
|
1512 |
-
// @todo remove since 2.2.x and leave only continue
|
1513 |
-
$sanitized[ $k ] = $v;
|
1514 |
-
continue;
|
1515 |
-
}
|
1516 |
-
|
1517 |
-
if ( is_callable( UM()->admin_settings()->settings_map[ $k ]['sanitize'], true, $callable_name ) ) {
|
1518 |
-
add_filter( 'um_settings_sanitize_' . $k, UM()->admin_settings()->settings_map[ $k ]['sanitize'], 10, 1 );
|
1519 |
-
}
|
1520 |
-
|
1521 |
-
switch ( UM()->admin_settings()->settings_map[ $k ]['sanitize'] ) {
|
1522 |
-
default:
|
1523 |
-
$sanitized[ $k ] = apply_filters( 'um_settings_sanitize_' . $k, $v );
|
1524 |
-
break;
|
1525 |
-
case 'int':
|
1526 |
-
$sanitized[ $k ] = (int) $v;
|
1527 |
-
break;
|
1528 |
-
case 'absint':
|
1529 |
-
if ( is_array( $v ) ) {
|
1530 |
-
$sanitized[ $k ] = array_map( 'absint', $v );
|
1531 |
-
} else {
|
1532 |
-
$sanitized[ $k ] = absint( $v );
|
1533 |
-
}
|
1534 |
-
break;
|
1535 |
-
case 'key':
|
1536 |
-
if ( is_array( $v ) ) {
|
1537 |
-
$sanitized[ $k ] = array_map( 'sanitize_key', $v );
|
1538 |
-
} else {
|
1539 |
-
$sanitized[ $k ] = sanitize_key( $v );
|
1540 |
-
}
|
1541 |
-
break;
|
1542 |
-
case 'bool':
|
1543 |
-
$sanitized[ $k ] = (bool) $v;
|
1544 |
-
break;
|
1545 |
-
case 'url':
|
1546 |
-
if ( is_array( $v ) ) {
|
1547 |
-
$sanitized[ $k ] = array_map( 'esc_url_raw', $v );
|
1548 |
-
} else {
|
1549 |
-
$sanitized[ $k ] = esc_url_raw( $v );
|
1550 |
-
}
|
1551 |
-
break;
|
1552 |
-
case 'wp_kses':
|
1553 |
-
$sanitized[ $k ] = wp_kses_post( $v );
|
1554 |
-
break;
|
1555 |
-
case 'textarea':
|
1556 |
-
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1557 |
-
break;
|
1558 |
-
case 'text':
|
1559 |
-
$sanitized[ $k ] = sanitize_text_field( $v );
|
1560 |
-
break;
|
1561 |
-
}
|
1562 |
-
}
|
1563 |
-
|
1564 |
-
$data = $sanitized;
|
1565 |
-
|
1566 |
-
$data = apply_filters( 'um_save_settings_sanitize', $data );
|
1567 |
-
|
1568 |
-
return $data;
|
1569 |
-
}
|
1570 |
-
|
1571 |
-
|
1572 |
-
/**
|
1573 |
-
* Adds class to our admin pages
|
1574 |
-
*
|
1575 |
-
* @param $classes
|
1576 |
-
*
|
1577 |
-
* @return string
|
1578 |
-
*/
|
1579 |
-
public function admin_body_class( $classes ) {
|
1580 |
-
if ( $this->is_um_screen() ) {
|
1581 |
-
return "$classes um-admin";
|
1582 |
-
}
|
1583 |
-
return $classes;
|
1584 |
-
}
|
1585 |
-
|
1586 |
-
|
1587 |
-
/**
|
1588 |
-
*
|
1589 |
-
*/
|
1590 |
-
public function manual_upgrades_request() {
|
1591 |
-
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
|
1592 |
-
die();
|
1593 |
-
}
|
1594 |
-
|
1595 |
-
$last_request = get_option( 'um_last_manual_upgrades_request', false );
|
1596 |
-
|
1597 |
-
if ( empty( $last_request ) || time() > $last_request + DAY_IN_SECONDS ) {
|
1598 |
-
|
1599 |
-
if ( is_multisite() ) {
|
1600 |
-
$blogs_ids = get_sites();
|
1601 |
-
foreach( $blogs_ids as $b ) {
|
1602 |
-
switch_to_blog( $b->blog_id );
|
1603 |
-
wp_clean_update_cache();
|
1604 |
-
|
1605 |
-
UM()->plugin_updater()->um_checklicenses();
|
1606 |
-
|
1607 |
-
update_option( 'um_last_manual_upgrades_request', time() );
|
1608 |
-
restore_current_blog();
|
1609 |
-
}
|
1610 |
-
} else {
|
1611 |
-
wp_clean_update_cache();
|
1612 |
-
|
1613 |
-
UM()->plugin_updater()->um_checklicenses();
|
1614 |
-
|
1615 |
-
update_option( 'um_last_manual_upgrades_request', time() );
|
1616 |
-
}
|
1617 |
-
|
1618 |
-
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'got_updates' ), admin_url( 'admin.php' ) );
|
1619 |
-
} else {
|
1620 |
-
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'often_updates' ), admin_url( 'admin.php' ) );
|
1621 |
-
}
|
1622 |
-
exit( wp_redirect( $url ) );
|
1623 |
-
}
|
1624 |
-
|
1625 |
-
|
1626 |
-
/**
|
1627 |
-
* Core pages installation
|
1628 |
-
*/
|
1629 |
-
function install_core_pages() {
|
1630 |
-
if ( ! is_admin() ) {
|
1631 |
-
die();
|
1632 |
-
}
|
1633 |
-
|
1634 |
-
UM()->setup()->install_default_pages();
|
1635 |
-
|
1636 |
-
//check empty pages in settings
|
1637 |
-
$empty_pages = array();
|
1638 |
-
|
1639 |
-
$pages = UM()->config()->permalinks;
|
1640 |
-
if ( $pages && is_array( $pages ) ) {
|
1641 |
-
foreach ( $pages as $slug => $page_id ) {
|
1642 |
-
$page = get_post( $page_id );
|
1643 |
-
|
1644 |
-
if ( ! isset( $page->ID ) && in_array( $slug, array_keys( UM()->config()->core_pages ) ) ) {
|
1645 |
-
$empty_pages[] = $slug;
|
1646 |
-
}
|
1647 |
-
}
|
1648 |
-
}
|
1649 |
-
|
1650 |
-
//if there aren't empty pages - then hide pages notice
|
1651 |
-
if ( empty( $empty_pages ) ) {
|
1652 |
-
$hidden_notices = get_option( 'um_hidden_admin_notices', array() );
|
1653 |
-
$hidden_notices[] = 'wrong_pages';
|
1654 |
-
|
1655 |
-
update_option( 'um_hidden_admin_notices', $hidden_notices );
|
1656 |
-
}
|
1657 |
-
|
1658 |
-
$url = add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) );
|
1659 |
-
exit( wp_redirect( $url ) );
|
1660 |
-
}
|
1661 |
-
|
1662 |
-
|
1663 |
-
/**
|
1664 |
-
* Clear all users cache
|
1665 |
-
*
|
1666 |
-
* @param $action
|
1667 |
-
*/
|
1668 |
-
function user_cache( $action ) {
|
1669 |
-
global $wpdb;
|
1670 |
-
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
|
1671 |
-
die();
|
1672 |
-
}
|
1673 |
-
|
1674 |
-
$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" );
|
1675 |
-
|
1676 |
-
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'cleared_cache' ), admin_url( 'admin.php' ) );
|
1677 |
-
exit( wp_redirect( $url ) );
|
1678 |
-
}
|
1679 |
-
|
1680 |
-
|
1681 |
-
/**
|
1682 |
-
* Purge temp uploads dir
|
1683 |
-
* @param $action
|
1684 |
-
*/
|
1685 |
-
function purge_temp( $action ) {
|
1686 |
-
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
|
1687 |
-
die();
|
1688 |
-
}
|
1689 |
-
|
1690 |
-
UM()->files()->remove_dir( UM()->files()->upload_temp );
|
1691 |
-
|
1692 |
-
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'purged_temp' ), admin_url( 'admin.php' ) );
|
1693 |
-
exit( wp_redirect( $url ) );
|
1694 |
-
}
|
1695 |
-
|
1696 |
-
|
1697 |
-
/**
|
1698 |
-
* Duplicate form
|
1699 |
-
*
|
1700 |
-
* @param $action
|
1701 |
-
*/
|
1702 |
-
function duplicate_form( $action ) {
|
1703 |
-
if ( ! is_admin() || ! current_user_can('manage_options') ) {
|
1704 |
-
die();
|
1705 |
-
}
|
1706 |
-
if ( ! isset( $_REQUEST['post_id'] ) || ! is_numeric( $_REQUEST['post_id'] ) ) {
|
1707 |
-
die();
|
1708 |
-
}
|
1709 |
-
|
1710 |
-
$post_id = absint( $_REQUEST['post_id'] );
|
1711 |
-
|
1712 |
-
$n = array(
|
1713 |
-
'post_type' => 'um_form',
|
1714 |
-
'post_title' => sprintf( __( 'Duplicate of %s', 'ultimate-member' ), get_the_title( $post_id ) ),
|
1715 |
-
'post_status' => 'publish',
|
1716 |
-
'post_author' => get_current_user_id(),
|
1717 |
-
);
|
1718 |
-
|
1719 |
-
$n_id = wp_insert_post( $n );
|
1720 |
-
|
1721 |
-
$n_fields = get_post_custom( $post_id );
|
1722 |
-
foreach ( $n_fields as $key => $value ) {
|
1723 |
-
|
1724 |
-
if ( $key == '_um_custom_fields' ) {
|
1725 |
-
$the_value = unserialize( $value[0] );
|
1726 |
-
} else {
|
1727 |
-
$the_value = $value[0];
|
1728 |
-
}
|
1729 |
-
|
1730 |
-
update_post_meta( $n_id, $key, $the_value );
|
1731 |
-
|
1732 |
-
}
|
1733 |
-
|
1734 |
-
delete_post_meta( $n_id, '_um_core' );
|
1735 |
-
|
1736 |
-
$url = admin_url( 'edit.php?post_type=um_form' );
|
1737 |
-
$url = add_query_arg( 'update', 'form_duplicated', $url );
|
1738 |
-
|
1739 |
-
exit( wp_redirect( $url ) );
|
1740 |
-
|
1741 |
-
}
|
1742 |
-
|
1743 |
-
|
1744 |
-
/**
|
1745 |
-
* Action to hide notices in admin
|
1746 |
-
*
|
1747 |
-
* @param $action
|
1748 |
-
*/
|
1749 |
-
function um_hide_notice( $action ) {
|
1750 |
-
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
|
1751 |
-
die();
|
1752 |
-
}
|
1753 |
-
|
1754 |
-
update_option( $action, 1 );
|
1755 |
-
exit( wp_redirect( remove_query_arg( 'um_adm_action' ) ) );
|
1756 |
-
}
|
1757 |
-
|
1758 |
-
|
1759 |
-
/**
|
1760 |
-
* Various user actions
|
1761 |
-
*
|
1762 |
-
* @param $action
|
1763 |
-
*/
|
1764 |
-
function user_action( $action ) {
|
1765 |
-
if ( ! is_admin() || ! current_user_can( 'edit_users' ) ) {
|
1766 |
-
die();
|
1767 |
-
}
|
1768 |
-
if ( ! isset( $_REQUEST['sub'] ) ) {
|
1769 |
-
die();
|
1770 |
-
}
|
1771 |
-
if ( ! isset( $_REQUEST['user_id'] ) ) {
|
1772 |
-
die();
|
1773 |
-
}
|
1774 |
-
|
1775 |
-
um_fetch_user( absint( $_REQUEST['user_id'] ) );
|
1776 |
-
|
1777 |
-
$subaction = sanitize_key( $_REQUEST['sub'] );
|
1778 |
-
|
1779 |
-
/**
|
1780 |
-
* UM hook
|
1781 |
-
*
|
1782 |
-
* @type action
|
1783 |
-
* @title um_admin_user_action_hook
|
1784 |
-
* @description Action on bulk user subaction
|
1785 |
-
* @input_vars
|
1786 |
-
* [{"var":"$subaction","type":"string","desc":"Bulk Subaction"}]
|
1787 |
-
* @change_log
|
1788 |
-
* ["Since: 2.0"]
|
1789 |
-
* @usage add_action( 'um_admin_user_action_hook', 'function_name', 10, 1 );
|
1790 |
-
* @example
|
1791 |
-
* <?php
|
1792 |
-
* add_action( 'um_admin_user_action_hook', 'my_admin_user_action', 10, 1 );
|
1793 |
-
* function my_admin_user_action( $subaction ) {
|
1794 |
-
* // your code here
|
1795 |
-
* }
|
1796 |
-
* ?>
|
1797 |
-
*/
|
1798 |
-
do_action( 'um_admin_user_action_hook', $subaction );
|
1799 |
-
/**
|
1800 |
-
* UM hook
|
1801 |
-
*
|
1802 |
-
* @type action
|
1803 |
-
* @title um_admin_user_action_{$subaction}_hook
|
1804 |
-
* @description Action on bulk user subaction
|
1805 |
-
* @change_log
|
1806 |
-
* ["Since: 2.0"]
|
1807 |
-
* @usage add_action( 'um_admin_user_action_{$subaction}_hook', 'function_name', 10 );
|
1808 |
-
* @example
|
1809 |
-
* <?php
|
1810 |
-
* add_action( 'um_admin_user_action_{$subaction}_hook', 'my_admin_user_action', 10 );
|
1811 |
-
* function my_admin_user_action() {
|
1812 |
-
* // your code here
|
1813 |
-
* }
|
1814 |
-
* ?>
|
1815 |
-
*/
|
1816 |
-
do_action( "um_admin_user_action_{$subaction}_hook" );
|
1817 |
-
|
1818 |
-
um_reset_user();
|
1819 |
-
|
1820 |
-
wp_redirect( add_query_arg( 'update', 'user_updated', admin_url( '?page=ultimatemember' ) ) );
|
1821 |
-
exit;
|
1822 |
-
|
1823 |
-
}
|
1824 |
-
|
1825 |
-
|
1826 |
-
/**
|
1827 |
-
* Add any custom links to plugin page
|
1828 |
-
*
|
1829 |
-
* @param array $links
|
1830 |
-
*
|
1831 |
-
* @return array
|
1832 |
-
*/
|
1833 |
-
function plugin_links( $links ) {
|
1834 |
-
$more_links[] = '<a href="http://docs.ultimatemember.com/">' . __( 'Docs', 'ultimate-member' ) . '</a>';
|
1835 |
-
$more_links[] = '<a href="'.admin_url().'admin.php?page=um_options">' . __( 'Settings', 'ultimate-member' ) . '</a>';
|
1836 |
-
|
1837 |
-
$links = $more_links + $links;
|
1838 |
-
return $links;
|
1839 |
-
}
|
1840 |
-
|
1841 |
-
|
1842 |
-
/**
|
1843 |
-
* Init admin action/filters + request handlers
|
1844 |
-
*/
|
1845 |
-
function admin_init() {
|
1846 |
-
$this->init_variables();
|
1847 |
-
|
1848 |
-
if ( is_admin() && current_user_can( 'manage_options' ) && ! empty( $_REQUEST['um_adm_action'] ) ) {
|
1849 |
-
$action = sanitize_key( $_REQUEST['um_adm_action'] );
|
1850 |
-
|
1851 |
-
/**
|
1852 |
-
* UM hook
|
1853 |
-
*
|
1854 |
-
* @type action
|
1855 |
-
* @title um_admin_do_action__
|
1856 |
-
* @description Make some action on custom admin action
|
1857 |
-
* @input_vars
|
1858 |
-
* [{"var":"$action","type":"string","desc":"Admin Action"}]
|
1859 |
-
* @change_log
|
1860 |
-
* ["Since: 2.0"]
|
1861 |
-
* @usage add_action( 'um_admin_do_action__', 'function_name', 10, 1 );
|
1862 |
-
* @example
|
1863 |
-
* <?php
|
1864 |
-
* add_action( 'um_admin_do_action__', 'my_admin_do_action', 10, 1 );
|
1865 |
-
* function my_admin_do_action( $action ) {
|
1866 |
-
* // your code here
|
1867 |
-
* }
|
1868 |
-
* ?>
|
1869 |
-
*/
|
1870 |
-
do_action( 'um_admin_do_action__', $action );
|
1871 |
-
/**
|
1872 |
-
* UM hook
|
1873 |
-
*
|
1874 |
-
* @type action
|
1875 |
-
* @title um_admin_do_action__{$action}
|
1876 |
-
* @description Make some action on custom admin $action
|
1877 |
-
* @input_vars
|
1878 |
-
* [{"var":"$action","type":"string","desc":"Admin Action"}]
|
1879 |
-
* @change_log
|
1880 |
-
* ["Since: 2.0"]
|
1881 |
-
* @usage add_action( 'um_admin_do_action__{$action}', 'function_name', 10, 1 );
|
1882 |
-
* @example
|
1883 |
-
* <?php
|
1884 |
-
* add_action( 'um_admin_do_action__{$action}', 'my_admin_do_action', 10, 1 );
|
1885 |
-
* function my_admin_do_action( $action ) {
|
1886 |
-
* // your code here
|
1887 |
-
* }
|
1888 |
-
* ?>
|
1889 |
-
*/
|
1890 |
-
do_action( "um_admin_do_action__{$action}", $action );
|
1891 |
-
}
|
1892 |
-
}
|
1893 |
-
|
1894 |
-
|
1895 |
-
/**
|
1896 |
-
* Updated post messages
|
1897 |
-
*
|
1898 |
-
* @param array $messages
|
1899 |
-
*
|
1900 |
-
* @return array
|
1901 |
-
*/
|
1902 |
-
function post_updated_messages( $messages ) {
|
1903 |
-
global $post_ID;
|
1904 |
-
|
1905 |
-
$post_type = get_post_type( $post_ID );
|
1906 |
-
|
1907 |
-
if ( $post_type == 'um_form' ) {
|
1908 |
-
$messages['um_form'] = array(
|
1909 |
-
0 => '',
|
1910 |
-
1 => __( 'Form updated.', 'ultimate-member' ),
|
1911 |
-
2 => __( 'Custom field updated.', 'ultimate-member' ),
|
1912 |
-
3 => __( 'Custom field deleted.', 'ultimate-member' ),
|
1913 |
-
4 => __( 'Form updated.', 'ultimate-member' ),
|
1914 |
-
5 => isset( $_GET['revision'] ) ? __( 'Form restored to revision.', 'ultimate-member' ) : false,
|
1915 |
-
6 => __( 'Form created.', 'ultimate-member' ),
|
1916 |
-
7 => __( 'Form saved.', 'ultimate-member' ),
|
1917 |
-
8 => __( 'Form submitted.', 'ultimate-member' ),
|
1918 |
-
9 => __( 'Form scheduled.', 'ultimate-member' ),
|
1919 |
-
10 => __( 'Form draft updated.', 'ultimate-member' ),
|
1920 |
-
);
|
1921 |
-
}
|
1922 |
-
|
1923 |
-
return $messages;
|
1924 |
-
}
|
1925 |
-
|
1926 |
-
|
1927 |
-
/**
|
1928 |
-
* Gettext filters
|
1929 |
-
*
|
1930 |
-
* @param $translation
|
1931 |
-
* @param $text
|
1932 |
-
* @param $domain
|
1933 |
-
*
|
1934 |
-
* @return string
|
1935 |
-
*/
|
1936 |
-
function gettext( $translation, $text, $domain ) {
|
1937 |
-
global $post;
|
1938 |
-
if ( isset( $post->post_type ) && $this->is_plugin_post_type() ) {
|
1939 |
-
$translations = get_translations_for_domain( $domain );
|
1940 |
-
if ( $text == 'Publish' ) {
|
1941 |
-
return $translations->translate( 'Create' );
|
1942 |
-
} elseif ( $text == 'Move to Trash' ) {
|
1943 |
-
return $translations->translate( 'Delete' );
|
1944 |
-
}
|
1945 |
-
}
|
1946 |
-
|
1947 |
-
return $translation;
|
1948 |
-
}
|
1949 |
-
|
1950 |
-
|
1951 |
-
/**
|
1952 |
-
* Fix parent file for correct highlighting
|
1953 |
-
*
|
1954 |
-
* @param $parent_file
|
1955 |
-
*
|
1956 |
-
* @return string
|
1957 |
-
*/
|
1958 |
-
function parent_file( $parent_file ) {
|
1959 |
-
global $current_screen;
|
1960 |
-
$screen_id = $current_screen->id;
|
1961 |
-
if ( strstr( $screen_id, 'um_' ) ) {
|
1962 |
-
$parent_file = 'ultimatemember';
|
1963 |
-
}
|
1964 |
-
return $parent_file;
|
1965 |
-
}
|
1966 |
-
|
1967 |
-
|
1968 |
-
/**
|
1969 |
-
* @since 2.0
|
1970 |
-
*
|
1971 |
-
* @return core\Admin_Notices()
|
1972 |
-
*/
|
1973 |
-
function notices() {
|
1974 |
-
if ( empty( UM()->classes['admin_notices'] ) ) {
|
1975 |
-
UM()->classes['admin_notices'] = new core\Admin_Notices();
|
1976 |
-
}
|
1977 |
-
return UM()->classes['admin_notices'];
|
1978 |
-
}
|
1979 |
-
}
|
1980 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\admin;
|
3 |
+
|
4 |
+
// Exit if accessed directly.
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
6 |
+
exit;
|
7 |
+
}
|
8 |
+
|
9 |
+
if ( ! class_exists( 'um\admin\Admin' ) ) {
|
10 |
+
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class Admin
|
14 |
+
* @package um\admin
|
15 |
+
*/
|
16 |
+
class Admin extends Admin_Functions {
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @var string
|
21 |
+
*/
|
22 |
+
public $templates_path;
|
23 |
+
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @var array
|
27 |
+
*/
|
28 |
+
public $role_meta;
|
29 |
+
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @var array
|
33 |
+
*/
|
34 |
+
public $restriction_term_meta;
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @var array
|
39 |
+
*/
|
40 |
+
public $member_directory_meta;
|
41 |
+
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @var array
|
45 |
+
*/
|
46 |
+
public $form_meta;
|
47 |
+
|
48 |
+
|
49 |
+
/**
|
50 |
+
* @var array
|
51 |
+
*/
|
52 |
+
public $builder_input;
|
53 |
+
|
54 |
+
|
55 |
+
/**
|
56 |
+
* @var array
|
57 |
+
*/
|
58 |
+
public $restriction_post_meta;
|
59 |
+
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Admin constructor.
|
63 |
+
*/
|
64 |
+
public function __construct() {
|
65 |
+
parent::__construct();
|
66 |
+
|
67 |
+
$this->templates_path = um_path . 'includes/admin/templates/';
|
68 |
+
|
69 |
+
add_action( 'admin_init', array( &$this, 'admin_init' ), 0 );
|
70 |
+
|
71 |
+
$prefix = is_network_admin() ? 'network_admin_' : '';
|
72 |
+
add_filter( "{$prefix}plugin_action_links_" . um_plugin, array( &$this, 'plugin_links' ) );
|
73 |
+
|
74 |
+
add_action( 'um_admin_do_action__user_cache', array( &$this, 'user_cache' ) );
|
75 |
+
add_action( 'um_admin_do_action__purge_temp', array( &$this, 'purge_temp' ) );
|
76 |
+
add_action( 'um_admin_do_action__manual_upgrades_request', array( &$this, 'manual_upgrades_request' ) );
|
77 |
+
add_action( 'um_admin_do_action__duplicate_form', array( &$this, 'duplicate_form' ) );
|
78 |
+
add_action( 'um_admin_do_action__um_hide_locale_notice', array( &$this, 'um_hide_notice' ) );
|
79 |
+
add_action( 'um_admin_do_action__um_can_register_notice', array( &$this, 'um_hide_notice' ) );
|
80 |
+
add_action( 'um_admin_do_action__um_hide_exif_notice', array( &$this, 'um_hide_notice' ) );
|
81 |
+
add_action( 'um_admin_do_action__user_action', array( &$this, 'user_action' ) );
|
82 |
+
|
83 |
+
add_action( 'um_admin_do_action__install_core_pages', array( &$this, 'install_core_pages' ) );
|
84 |
+
|
85 |
+
add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ), 999 );
|
86 |
+
|
87 |
+
add_action( 'parent_file', array( &$this, 'parent_file' ), 9 );
|
88 |
+
add_filter( 'gettext', array( &$this, 'gettext' ), 10, 4 );
|
89 |
+
add_filter( 'post_updated_messages', array( &$this, 'post_updated_messages' ) );
|
90 |
+
}
|
91 |
+
|
92 |
+
|
93 |
+
function init_variables() {
|
94 |
+
$this->role_meta = apply_filters(
|
95 |
+
'um_role_meta_map',
|
96 |
+
array(
|
97 |
+
'_um_priority' => array(
|
98 |
+
'sanitize' => 'int',
|
99 |
+
),
|
100 |
+
'_um_can_access_wpadmin' => array(
|
101 |
+
'sanitize' => 'bool',
|
102 |
+
),
|
103 |
+
'_um_can_not_see_adminbar' => array(
|
104 |
+
'sanitize' => 'bool',
|
105 |
+
),
|
106 |
+
'_um_can_edit_everyone' => array(
|
107 |
+
'sanitize' => 'bool',
|
108 |
+
),
|
109 |
+
'_um_can_edit_roles' => array(
|
110 |
+
'sanitize' => array( $this, 'sanitize_existed_role' ),
|
111 |
+
),
|
112 |
+
'_um_can_delete_everyone' => array(
|
113 |
+
'sanitize' => 'bool',
|
114 |
+
),
|
115 |
+
'_um_can_delete_roles' => array(
|
116 |
+
'sanitize' => array( $this, 'sanitize_existed_role' ),
|
117 |
+
),
|
118 |
+
'_um_can_edit_profile' => array(
|
119 |
+
'sanitize' => 'bool',
|
120 |
+
),
|
121 |
+
'_um_can_delete_profile' => array(
|
122 |
+
'sanitize' => 'bool',
|
123 |
+
),
|
124 |
+
'_um_can_view_all' => array(
|
125 |
+
'sanitize' => 'bool',
|
126 |
+
),
|
127 |
+
'_um_can_view_roles' => array(
|
128 |
+
'sanitize' => array( $this, 'sanitize_existed_role' ),
|
129 |
+
),
|
130 |
+
'_um_can_make_private_profile' => array(
|
131 |
+
'sanitize' => 'bool',
|
132 |
+
),
|
133 |
+
'_um_can_access_private_profile' => array(
|
134 |
+
'sanitize' => 'bool',
|
135 |
+
),
|
136 |
+
'_um_profile_noindex' => array(
|
137 |
+
'sanitize' => array( $this, 'sanitize_profile_noindex' ),
|
138 |
+
),
|
139 |
+
'_um_default_homepage' => array(
|
140 |
+
'sanitize' => 'bool',
|
141 |
+
),
|
142 |
+
'_um_redirect_homepage' => array(
|
143 |
+
'sanitize' => 'url',
|
144 |
+
),
|
145 |
+
'_um_status' => array(
|
146 |
+
'sanitize' => 'sanitize_array_key',
|
147 |
+
'default' => 'approved',
|
148 |
+
'array' => array( 'approved', 'checkmail', 'pending' ),
|
149 |
+
),
|
150 |
+
'_um_auto_approve_act' => array(
|
151 |
+
'sanitize' => 'sanitize_array_key',
|
152 |
+
'default' => 'redirect_profile',
|
153 |
+
'array' => array( 'redirect_profile', 'redirect_url' ),
|
154 |
+
),
|
155 |
+
'_um_auto_approve_url' => array(
|
156 |
+
'sanitize' => 'url',
|
157 |
+
),
|
158 |
+
'_um_login_email_activate' => array(
|
159 |
+
'sanitize' => 'bool',
|
160 |
+
),
|
161 |
+
'_um_checkmail_action' => array(
|
162 |
+
'sanitize' => 'sanitize_array_key',
|
163 |
+
'default' => 'show_message',
|
164 |
+
'array' => array( 'show_message', 'redirect_url' ),
|
165 |
+
),
|
166 |
+
'_um_checkmail_message' => array(
|
167 |
+
'sanitize' => 'textarea',
|
168 |
+
),
|
169 |
+
'_um_checkmail_url' => array(
|
170 |
+
'sanitize' => 'url',
|
171 |
+
),
|
172 |
+
'_um_url_email_activate' => array(
|
173 |
+
'sanitize' => 'url',
|
174 |
+
),
|
175 |
+
'_um_pending_action' => array(
|
176 |
+
'sanitize' => 'sanitize_array_key',
|
177 |
+
'default' => 'show_message',
|
178 |
+
'array' => array( 'show_message', 'redirect_url' ),
|
179 |
+
),
|
180 |
+
'_um_pending_message' => array(
|
181 |
+
'sanitize' => 'textarea',
|
182 |
+
),
|
183 |
+
'_um_pending_url' => array(
|
184 |
+
'sanitize' => 'url',
|
185 |
+
),
|
186 |
+
'_um_after_login' => array(
|
187 |
+
'sanitize' => 'sanitize_array_key',
|
188 |
+
'default' => 'redirect_profile',
|
189 |
+
'array' => array( 'redirect_profile', 'redirect_url', 'refresh', 'redirect_admin' ),
|
190 |
+
),
|
191 |
+
'_um_login_redirect_url' => array(
|
192 |
+
'sanitize' => 'url',
|
193 |
+
),
|
194 |
+
'_um_after_logout' => array(
|
195 |
+
'sanitize' => 'sanitize_array_key',
|
196 |
+
'default' => 'redirect_home',
|
197 |
+
'array' => array( 'redirect_home', 'redirect_url' ),
|
198 |
+
),
|
199 |
+
'_um_logout_redirect_url' => array(
|
200 |
+
'sanitize' => 'url',
|
201 |
+
),
|
202 |
+
'_um_after_delete' => array(
|
203 |
+
'sanitize' => 'sanitize_array_key',
|
204 |
+
'default' => 'redirect_home',
|
205 |
+
'array' => array( 'redirect_home', 'redirect_url' ),
|
206 |
+
),
|
207 |
+
'_um_delete_redirect_url' => array(
|
208 |
+
'sanitize' => 'url',
|
209 |
+
),
|
210 |
+
'wp_capabilities' => array(
|
211 |
+
'sanitize' => array( $this, 'sanitize_wp_capabilities' ),
|
212 |
+
),
|
213 |
+
)
|
214 |
+
);
|
215 |
+
|
216 |
+
$this->restriction_post_meta = apply_filters(
|
217 |
+
'um_restriction_post_meta_map',
|
218 |
+
array(
|
219 |
+
'_um_custom_access_settings' => array(
|
220 |
+
'sanitize' => 'bool',
|
221 |
+
),
|
222 |
+
'_um_accessible' => array(
|
223 |
+
'sanitize' => 'int',
|
224 |
+
),
|
225 |
+
'_um_access_roles' => array(
|
226 |
+
'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
|
227 |
+
),
|
228 |
+
'_um_noaccess_action' => array(
|
229 |
+
'sanitize' => 'int',
|
230 |
+
),
|
231 |
+
'_um_restrict_by_custom_message' => array(
|
232 |
+
'sanitize' => 'int',
|
233 |
+
),
|
234 |
+
'_um_restrict_custom_message' => array(
|
235 |
+
'sanitize' => 'wp_kses',
|
236 |
+
),
|
237 |
+
'_um_access_redirect' => array(
|
238 |
+
'sanitize' => 'int',
|
239 |
+
),
|
240 |
+
'_um_access_redirect_url' => array(
|
241 |
+
'sanitize' => 'url',
|
242 |
+
),
|
243 |
+
'_um_access_hide_from_queries' => array(
|
244 |
+
'sanitize' => 'bool',
|
245 |
+
),
|
246 |
+
)
|
247 |
+
);
|
248 |
+
|
249 |
+
$this->restriction_term_meta = apply_filters(
|
250 |
+
'um_restriction_term_meta_map',
|
251 |
+
array(
|
252 |
+
'_um_custom_access_settings' => array(
|
253 |
+
'sanitize' => 'bool',
|
254 |
+
),
|
255 |
+
'_um_accessible' => array(
|
256 |
+
'sanitize' => 'int',
|
257 |
+
),
|
258 |
+
'_um_access_roles' => array(
|
259 |
+
'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
|
260 |
+
),
|
261 |
+
'_um_noaccess_action' => array(
|
262 |
+
'sanitize' => 'int',
|
263 |
+
),
|
264 |
+
'_um_restrict_by_custom_message' => array(
|
265 |
+
'sanitize' => 'int',
|
266 |
+
),
|
267 |
+
'_um_restrict_custom_message' => array(
|
268 |
+
'sanitize' => 'wp_kses',
|
269 |
+
),
|
270 |
+
'_um_access_redirect' => array(
|
271 |
+
'sanitize' => 'int',
|
272 |
+
),
|
273 |
+
'_um_access_redirect_url' => array(
|
274 |
+
'sanitize' => 'url',
|
275 |
+
),
|
276 |
+
'_um_access_hide_from_queries' => array(
|
277 |
+
'sanitize' => 'bool',
|
278 |
+
),
|
279 |
+
)
|
280 |
+
);
|
281 |
+
|
282 |
+
$this->member_directory_meta = apply_filters(
|
283 |
+
'um_member_directory_meta_map',
|
284 |
+
array(
|
285 |
+
'_um_directory_template' => array(
|
286 |
+
'sanitize' => 'text',
|
287 |
+
),
|
288 |
+
'_um_mode' => array(
|
289 |
+
'sanitize' => 'key',
|
290 |
+
),
|
291 |
+
'_um_view_types' => array(
|
292 |
+
'sanitize' => array( $this, 'sanitize_md_view_types' ),
|
293 |
+
),
|
294 |
+
'_um_default_view' => array(
|
295 |
+
'sanitize' => 'key',
|
296 |
+
),
|
297 |
+
'_um_roles' => array(
|
298 |
+
'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
|
299 |
+
),
|
300 |
+
'_um_has_profile_photo' => array(
|
301 |
+
'sanitize' => 'bool',
|
302 |
+
),
|
303 |
+
'_um_show_these_users' => array(
|
304 |
+
'sanitize' => 'textarea',
|
305 |
+
),
|
306 |
+
'_um_exclude_these_users' => array(
|
307 |
+
'sanitize' => 'textarea',
|
308 |
+
),
|
309 |
+
'_um_must_search' => array(
|
310 |
+
'sanitize' => 'bool',
|
311 |
+
),
|
312 |
+
'_um_max_users' => array(
|
313 |
+
'sanitize' => 'absint',
|
314 |
+
),
|
315 |
+
'_um_profiles_per_page' => array(
|
316 |
+
'sanitize' => 'absint',
|
317 |
+
),
|
318 |
+
'_um_profiles_per_page_mobile' => array(
|
319 |
+
'sanitize' => 'absint',
|
320 |
+
),
|
321 |
+
'_um_directory_header' => array(
|
322 |
+
'sanitize' => 'text',
|
323 |
+
),
|
324 |
+
'_um_directory_header_single' => array(
|
325 |
+
'sanitize' => 'text',
|
326 |
+
),
|
327 |
+
'_um_directory_no_users' => array(
|
328 |
+
'sanitize' => 'text',
|
329 |
+
),
|
330 |
+
'_um_profile_photo' => array(
|
331 |
+
'sanitize' => 'bool',
|
332 |
+
),
|
333 |
+
'_um_cover_photos' => array(
|
334 |
+
'sanitize' => 'bool',
|
335 |
+
),
|
336 |
+
'_um_show_name' => array(
|
337 |
+
'sanitize' => 'bool',
|
338 |
+
),
|
339 |
+
'_um_show_tagline' => array(
|
340 |
+
'sanitize' => 'bool',
|
341 |
+
),
|
342 |
+
'_um_tagline_fields' => array(
|
343 |
+
'sanitize' => array( $this, 'sanitize_user_field' ),
|
344 |
+
),
|
345 |
+
'_um_show_userinfo' => array(
|
346 |
+
'sanitize' => 'bool',
|
347 |
+
),
|
348 |
+
'_um_reveal_fields' => array(
|
349 |
+
'sanitize' => array( $this, 'sanitize_user_field' ),
|
350 |
+
),
|
351 |
+
'_um_show_social' => array(
|
352 |
+
'sanitize' => 'bool',
|
353 |
+
),
|
354 |
+
'_um_userinfo_animate' => array(
|
355 |
+
'sanitize' => 'bool',
|
356 |
+
),
|
357 |
+
'_um_search' => array(
|
358 |
+
'sanitize' => 'bool',
|
359 |
+
),
|
360 |
+
'_um_roles_can_search' => array(
|
361 |
+
'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
|
362 |
+
),
|
363 |
+
'_um_filters' => array(
|
364 |
+
'sanitize' => 'bool',
|
365 |
+
),
|
366 |
+
'_um_roles_can_filter' => array(
|
367 |
+
'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
|
368 |
+
),
|
369 |
+
'_um_search_fields' => array(
|
370 |
+
'sanitize' => array( $this, 'sanitize_filter_fields' ),
|
371 |
+
),
|
372 |
+
'_um_filters_expanded' => array(
|
373 |
+
'sanitize' => 'bool',
|
374 |
+
),
|
375 |
+
'_um_filters_is_collapsible' => array(
|
376 |
+
'sanitize' => 'bool',
|
377 |
+
),
|
378 |
+
'_um_search_filters' => array(
|
379 |
+
'sanitize' => array( $this, 'sanitize_filter_fields' ),
|
380 |
+
),
|
381 |
+
'_um_sortby' => array(
|
382 |
+
'sanitize' => 'text',
|
383 |
+
),
|
384 |
+
'_um_sortby_custom' => array(
|
385 |
+
'sanitize' => 'text',
|
386 |
+
),
|
387 |
+
'_um_sortby_custom_label' => array(
|
388 |
+
'sanitize' => 'text',
|
389 |
+
),
|
390 |
+
'_um_enable_sorting' => array(
|
391 |
+
'sanitize' => 'bool',
|
392 |
+
),
|
393 |
+
'_um_sorting_fields' => array(
|
394 |
+
'sanitize' => array( $this, 'sanitize_md_sorting_fields' ),
|
395 |
+
),
|
396 |
+
)
|
397 |
+
);
|
398 |
+
|
399 |
+
$this->form_meta = apply_filters(
|
400 |
+
'um_form_meta_map',
|
401 |
+
array(
|
402 |
+
'_um_mode' => array(
|
403 |
+
'sanitize' => 'key',
|
404 |
+
),
|
405 |
+
'_um_register_use_gdpr' => array(
|
406 |
+
'sanitize' => 'bool',
|
407 |
+
),
|
408 |
+
'_um_register_use_gdpr_content_id' => array(
|
409 |
+
'sanitize' => 'absint',
|
410 |
+
),
|
411 |
+
'_um_register_use_gdpr_toggle_show' => array(
|
412 |
+
'sanitize' => 'text',
|
413 |
+
),
|
414 |
+
'_um_register_use_gdpr_toggle_hide' => array(
|
415 |
+
'sanitize' => 'text',
|
416 |
+
),
|
417 |
+
'_um_register_use_gdpr_agreement' => array(
|
418 |
+
'sanitize' => 'text',
|
419 |
+
),
|
420 |
+
'_um_register_use_gdpr_error_text' => array(
|
421 |
+
'sanitize' => 'text',
|
422 |
+
),
|
423 |
+
'_um_register_use_custom_settings' => array(
|
424 |
+
'sanitize' => 'bool',
|
425 |
+
),
|
426 |
+
'_um_register_role' => array(
|
427 |
+
'sanitize' => 'key',
|
428 |
+
),
|
429 |
+
'_um_register_template' => array(
|
430 |
+
'sanitize' => 'text',
|
431 |
+
),
|
432 |
+
'_um_register_max_width' => array(
|
433 |
+
'sanitize' => 'text',
|
434 |
+
),
|
435 |
+
'_um_register_icons' => array(
|
436 |
+
'sanitize' => 'key',
|
437 |
+
),
|
438 |
+
'_um_register_primary_btn_word' => array(
|
439 |
+
'sanitize' => 'text',
|
440 |
+
),
|
441 |
+
'_um_register_secondary_btn' => array(
|
442 |
+
'sanitize' => 'bool',
|
443 |
+
),
|
444 |
+
'_um_register_secondary_btn_word' => array(
|
445 |
+
'sanitize' => 'text',
|
446 |
+
),
|
447 |
+
'_um_login_after_login' => array(
|
448 |
+
'sanitize' => 'key',
|
449 |
+
),
|
450 |
+
'_um_login_redirect_url' => array(
|
451 |
+
'sanitize' => 'url',
|
452 |
+
),
|
453 |
+
'_um_login_use_custom_settings' => array(
|
454 |
+
'sanitize' => 'bool',
|
455 |
+
),
|
456 |
+
'_um_login_template' => array(
|
457 |
+
'sanitize' => 'text',
|
458 |
+
),
|
459 |
+
'_um_login_max_width' => array(
|
460 |
+
'sanitize' => 'text',
|
461 |
+
),
|
462 |
+
'_um_login_icons' => array(
|
463 |
+
'sanitize' => 'key',
|
464 |
+
),
|
465 |
+
'_um_login_primary_btn_word' => array(
|
466 |
+
'sanitize' => 'text',
|
467 |
+
),
|
468 |
+
'_um_login_secondary_btn' => array(
|
469 |
+
'sanitize' => 'bool',
|
470 |
+
),
|
471 |
+
'_um_login_secondary_btn_word' => array(
|
472 |
+
'sanitize' => 'text',
|
473 |
+
),
|
474 |
+
'_um_login_forgot_pass_link' => array(
|
475 |
+
'sanitize' => 'bool',
|
476 |
+
),
|
477 |
+
'_um_login_show_rememberme' => array(
|
478 |
+
'sanitize' => 'bool',
|
479 |
+
),
|
480 |
+
'_um_profile_metafields' => array(
|
481 |
+
'sanitize' => array( $this, 'sanitize_user_field' ),
|
482 |
+
),
|
483 |
+
'_um_profile_use_custom_settings' => array(
|
484 |
+
'sanitize' => 'bool',
|
485 |
+
),
|
486 |
+
'_um_profile_role' => array(
|
487 |
+
'sanitize' => array( $this, 'sanitize_existed_role' ),
|
488 |
+
),
|
489 |
+
'_um_profile_template' => array(
|
490 |
+
'sanitize' => 'text',
|
491 |
+
),
|
492 |
+
'_um_profile_max_width' => array(
|
493 |
+
'sanitize' => 'text',
|
494 |
+
),
|
495 |
+
'_um_profile_area_max_width' => array(
|
496 |
+
'sanitize' => 'text',
|
497 |
+
),
|
498 |
+
'_um_profile_icons' => array(
|
499 |
+
'sanitize' => 'key',
|
500 |
+
),
|
501 |
+
'_um_profile_primary_btn_word' => array(
|
502 |
+
'sanitize' => 'text',
|
503 |
+
),
|
504 |
+
'_um_profile_secondary_btn' => array(
|
505 |
+
'sanitize' => 'bool',
|
506 |
+
),
|
507 |
+
'_um_profile_secondary_btn_word' => array(
|
508 |
+
'sanitize' => 'text',
|
509 |
+
),
|
510 |
+
'_um_profile_cover_enabled' => array(
|
511 |
+
'sanitize' => 'bool',
|
512 |
+
),
|
513 |
+
'_um_profile_coversize' => array(
|
514 |
+
'sanitize' => 'absint',
|
515 |
+
),
|
516 |
+
'_um_profile_cover_ratio' => array(
|
517 |
+
'sanitize' => 'text',
|
518 |
+
),
|
519 |
+
'_um_profile_disable_photo_upload' => array(
|
520 |
+
'sanitize' => 'bool',
|
521 |
+
),
|
522 |
+
'_um_profile_photosize' => array(
|
523 |
+
'sanitize' => array( $this, 'sanitize_photosize' ),
|
524 |
+
),
|
525 |
+
'_um_profile_photo_required' => array(
|
526 |
+
'sanitize' => 'bool',
|
527 |
+
),
|
528 |
+
'_um_profile_show_name' => array(
|
529 |
+
'sanitize' => 'bool',
|
530 |
+
),
|
531 |
+
'_um_profile_show_social_links' => array(
|
532 |
+
'sanitize' => 'bool',
|
533 |
+
),
|
534 |
+
'_um_profile_show_bio' => array(
|
535 |
+
'sanitize' => 'bool',
|
536 |
+
),
|
537 |
+
|
538 |
+
)
|
539 |
+
);
|
540 |
+
|
541 |
+
$this->builder_input = apply_filters(
|
542 |
+
'um_builder_input_map',
|
543 |
+
array(
|
544 |
+
'_in_row' => array(
|
545 |
+
'sanitize' => 'key',
|
546 |
+
),
|
547 |
+
'_in_sub_row' => array(
|
548 |
+
'sanitize' => 'absint',
|
549 |
+
),
|
550 |
+
'_in_column' => array(
|
551 |
+
'sanitize' => 'absint',
|
552 |
+
),
|
553 |
+
'_in_group' => array(
|
554 |
+
'sanitize' => 'absint',
|
555 |
+
),
|
556 |
+
'_visibility' => array(
|
557 |
+
'sanitize' => 'key',
|
558 |
+
),
|
559 |
+
'_conditional_action' => array(
|
560 |
+
'sanitize' => 'key',
|
561 |
+
),
|
562 |
+
'_conditional_action1' => array(
|
563 |
+
'sanitize' => 'key',
|
564 |
+
),
|
565 |
+
'_conditional_action2' => array(
|
566 |
+
'sanitize' => 'key',
|
567 |
+
),
|
568 |
+
'_conditional_action3' => array(
|
569 |
+
'sanitize' => 'key',
|
570 |
+
),
|
571 |
+
'_conditional_action4' => array(
|
572 |
+
'sanitize' => 'key',
|
573 |
+
),
|
574 |
+
'_conditional_field' => array(
|
575 |
+
'sanitize' => 'text',
|
576 |
+
),
|
577 |
+
'_conditional_field1' => array(
|
578 |
+
'sanitize' => 'text',
|
579 |
+
),
|
580 |
+
'_conditional_field2' => array(
|
581 |
+
'sanitize' => 'text',
|
582 |
+
),
|
583 |
+
'_conditional_field3' => array(
|
584 |
+
'sanitize' => 'text',
|
585 |
+
),
|
586 |
+
'_conditional_field4' => array(
|
587 |
+
'sanitize' => 'text',
|
588 |
+
),
|
589 |
+
'_conditional_operator' => array(
|
590 |
+
'sanitize' => 'text',
|
591 |
+
),
|
592 |
+
'_conditional_operator1' => array(
|
593 |
+
'sanitize' => 'text',
|
594 |
+
),
|
595 |
+
'_conditional_operator2' => array(
|
596 |
+
'sanitize' => 'text',
|
597 |
+
),
|
598 |
+
'_conditional_operator3' => array(
|
599 |
+
'sanitize' => 'text',
|
600 |
+
),
|
601 |
+
'_conditional_operator4' => array(
|
602 |
+
'sanitize' => 'text',
|
603 |
+
),
|
604 |
+
'_conditional_value' => array(
|
605 |
+
'sanitize' => 'text',
|
606 |
+
),
|
607 |
+
'_conditional_value1' => array(
|
608 |
+
'sanitize' => 'text',
|
609 |
+
),
|
610 |
+
'_conditional_value2' => array(
|
611 |
+
'sanitize' => 'text',
|
612 |
+
),
|
613 |
+
'_conditional_value3' => array(
|
614 |
+
'sanitize' => 'text',
|
615 |
+
),
|
616 |
+
'_conditional_value4' => array(
|
617 |
+
'sanitize' => 'text',
|
618 |
+
),
|
619 |
+
'_validate' => array(
|
620 |
+
'sanitize' => 'key',
|
621 |
+
),
|
622 |
+
'_custom_validate' => array(
|
623 |
+
'sanitize' => 'text',
|
624 |
+
),
|
625 |
+
'_icon' => array(
|
626 |
+
'sanitize' => 'key',
|
627 |
+
),
|
628 |
+
'_css_class' => array(
|
629 |
+
'sanitize' => 'text',
|
630 |
+
),
|
631 |
+
'_width' => array(
|
632 |
+
'sanitize' => 'absint',
|
633 |
+
),
|
634 |
+
'_divider_text' => array(
|
635 |
+
'sanitize' => 'text',
|
636 |
+
),
|
637 |
+
'_padding' => array(
|
638 |
+
'sanitize' => 'text',
|
639 |
+
),
|
640 |
+
'_margin' => array(
|
641 |
+
'sanitize' => 'text',
|
642 |
+
),
|
643 |
+
'_border' => array(
|
644 |
+
'sanitize' => 'text',
|
645 |
+
),
|
646 |
+
'_borderstyle' => array(
|
647 |
+
'sanitize' => 'key',
|
648 |
+
),
|
649 |
+
'_borderradius' => array(
|
650 |
+
'sanitize' => 'text',
|
651 |
+
),
|
652 |
+
'_bordercolor' => array(
|
653 |
+
'sanitize' => 'text',
|
654 |
+
),
|
655 |
+
'_heading' => array(
|
656 |
+
'sanitize' => 'bool',
|
657 |
+
),
|
658 |
+
'_heading_text' => array(
|
659 |
+
'sanitize' => 'text',
|
660 |
+
),
|
661 |
+
'_background' => array(
|
662 |
+
'sanitize' => 'text',
|
663 |
+
),
|
664 |
+
'_heading_background_color' => array(
|
665 |
+
'sanitize' => 'text',
|
666 |
+
),
|
667 |
+
'_heading_text_color' => array(
|
668 |
+
'sanitize' => 'text',
|
669 |
+
),
|
670 |
+
'_text_color' => array(
|
671 |
+
'sanitize' => 'text',
|
672 |
+
),
|
673 |
+
'_icon_color' => array(
|
674 |
+
'sanitize' => 'text',
|
675 |
+
),
|
676 |
+
'_color' => array(
|
677 |
+
'sanitize' => 'text',
|
678 |
+
),
|
679 |
+
'_url_text' => array(
|
680 |
+
'sanitize' => 'text',
|
681 |
+
),
|
682 |
+
'_url_target' => array(
|
683 |
+
'sanitize' => 'key',
|
684 |
+
),
|
685 |
+
'_url_rel' => array(
|
686 |
+
'sanitize' => 'key',
|
687 |
+
),
|
688 |
+
'_force_good_pass' => array(
|
689 |
+
'sanitize' => 'bool',
|
690 |
+
),
|
691 |
+
'_force_confirm_pass' => array(
|
692 |
+
'sanitize' => 'bool',
|
693 |
+
),
|
694 |
+
'_style' => array(
|
695 |
+
'sanitize' => 'key',
|
696 |
+
),
|
697 |
+
'_intervals' => array(
|
698 |
+
'sanitize' => 'absint',
|
699 |
+
),
|
700 |
+
'_format' => array(
|
701 |
+
'sanitize' => 'text',
|
702 |
+
),
|
703 |
+
'_format_custom' => array(
|
704 |
+
'sanitize' => 'text',
|
705 |
+
),
|
706 |
+
'_pretty_format' => array(
|
707 |
+
'sanitize' => 'bool',
|
708 |
+
),
|
709 |
+
'_disabled_weekdays' => array(
|
710 |
+
'sanitize' => 'absint',
|
711 |
+
),
|
712 |
+
'_years' => array(
|
713 |
+
'sanitize' => 'absint',
|
714 |
+
),
|
715 |
+
'_years_x' => array(
|
716 |
+
'sanitize' => 'key',
|
717 |
+
),
|
718 |
+
'_range_start' => array(
|
719 |
+
'sanitize' => 'text',
|
720 |
+
),
|
721 |
+
'_range_end' => array(
|
722 |
+
'sanitize' => 'text',
|
723 |
+
),
|
724 |
+
'_range' => array(
|
725 |
+
'sanitize' => 'key',
|
726 |
+
),
|
727 |
+
'_content' => array(
|
728 |
+
'sanitize' => 'textarea',
|
729 |
+
),
|
730 |
+
'_crop' => array(
|
731 |
+
'sanitize' => 'int',
|
732 |
+
),
|
733 |
+
'_allowed_types' => array(
|
734 |
+
'sanitize' => 'key',
|
735 |
+
),
|
736 |
+
'_upload_text' => array(
|
737 |
+
'sanitize' => 'text',
|
738 |
+
),
|
739 |
+
'_upload_help_text' => array(
|
740 |
+
'sanitize' => 'text',
|
741 |
+
),
|
742 |
+
'_button_text' => array(
|
743 |
+
'sanitize' => 'text',
|
744 |
+
),
|
745 |
+
'_max_size' => array(
|
746 |
+
'sanitize' => 'absint',
|
747 |
+
),
|
748 |
+
'_height' => array(
|
749 |
+
'sanitize' => 'text',
|
750 |
+
),
|
751 |
+
'_spacing' => array(
|
752 |
+
'sanitize' => 'text',
|
753 |
+
),
|
754 |
+
'_is_multi' => array(
|
755 |
+
'sanitize' => 'bool',
|
756 |
+
),
|
757 |
+
'_max_selections' => array(
|
758 |
+
'sanitize' => 'absint',
|
759 |
+
),
|
760 |
+
'_min_selections' => array(
|
761 |
+
'sanitize' => 'absint',
|
762 |
+
),
|
763 |
+
'_max_entries' => array(
|
764 |
+
'sanitize' => 'absint',
|
765 |
+
),
|
766 |
+
'_max_words' => array(
|
767 |
+
'sanitize' => 'absint',
|
768 |
+
),
|
769 |
+
'_min' => array(
|
770 |
+
'sanitize' => 'empty_int',
|
771 |
+
),
|
772 |
+
'_max' => array(
|
773 |
+
'sanitize' => 'empty_int',
|
774 |
+
),
|
775 |
+
'_min_chars' => array(
|
776 |
+
'sanitize' => 'absint',
|
777 |
+
),
|
778 |
+
'_max_chars' => array(
|
779 |
+
'sanitize' => 'absint',
|
780 |
+
),
|
781 |
+
'_html' => array(
|
782 |
+
'sanitize' => 'bool',
|
783 |
+
),
|
784 |
+
'_options' => array(
|
785 |
+
'sanitize' => 'textarea',
|
786 |
+
),
|
787 |
+
'_title' => array(
|
788 |
+
'sanitize' => 'text',
|
789 |
+
),
|
790 |
+
'_id' => array(
|
791 |
+
'sanitize' => 'text',
|
792 |
+
),
|
793 |
+
'_metakey' => array(
|
794 |
+
'sanitize' => 'text',
|
795 |
+
),
|
796 |
+
'_help' => array(
|
797 |
+
'sanitize' => 'text',
|
798 |
+
),
|
799 |
+
'_default' => array(
|
800 |
+
'sanitize' => 'text',
|
801 |
+
),
|
802 |
+
'_label' => array(
|
803 |
+
'sanitize' => 'text',
|
804 |
+
),
|
805 |
+
'_label_confirm_pass' => array(
|
806 |
+
'sanitize' => 'text',
|
807 |
+
),
|
808 |
+
'_placeholder' => array(
|
809 |
+
'sanitize' => 'text',
|
810 |
+
),
|
811 |
+
'_public' => array(
|
812 |
+
'sanitize' => 'text',
|
813 |
+
),
|
814 |
+
'_roles' => array(
|
815 |
+
'sanitize' => array( $this, 'sanitize_existed_role' ),
|
816 |
+
),
|
817 |
+
'_required' => array(
|
818 |
+
'sanitize' => 'bool',
|
819 |
+
),
|
820 |
+
'_editable' => array(
|
821 |
+
'sanitize' => 'bool',
|
822 |
+
),
|
823 |
+
'_number' => array(
|
824 |
+
'sanitize' => 'absint',
|
825 |
+
),
|
826 |
+
'_custom_dropdown_options_source' => array(
|
827 |
+
'sanitize' => 'text',
|
828 |
+
),
|
829 |
+
'_parent_dropdown_relationship' => array(
|
830 |
+
'sanitize' => 'text',
|
831 |
+
),
|
832 |
+
)
|
833 |
+
);
|
834 |
+
}
|
835 |
+
|
836 |
+
|
837 |
+
/**
|
838 |
+
* @param array|string $value
|
839 |
+
*
|
840 |
+
* @return array|string
|
841 |
+
*/
|
842 |
+
public function sanitize_md_sorting_fields( $value ) {
|
843 |
+
$filter_fields = array_merge( UM()->member_directory()->sort_fields, array( 'other' => __( 'Other (Custom Field)', 'ultimate-member' ) ) );
|
844 |
+
$filter_fields = array_keys( $filter_fields );
|
845 |
+
|
846 |
+
if ( '' !== $value ) {
|
847 |
+
$value = array_filter(
|
848 |
+
$value,
|
849 |
+
function( $v, $k ) use ( $filter_fields ) {
|
850 |
+
if ( 'other_data' === $k ) {
|
851 |
+
return true;
|
852 |
+
} else {
|
853 |
+
return in_array( sanitize_text_field( $v ), $filter_fields, true );
|
854 |
+
}
|
855 |
+
},
|
856 |
+
ARRAY_FILTER_USE_BOTH
|
857 |
+
);
|
858 |
+
|
859 |
+
$value = array_map(
|
860 |
+
function( $item ) {
|
861 |
+
if ( is_array( $item ) ) {
|
862 |
+
if ( isset( $item['meta_key'] ) ) {
|
863 |
+
$item['meta_key'] = sanitize_text_field( $item['meta_key'] );
|
864 |
+
}
|
865 |
+
if ( isset( $item['label'] ) ) {
|
866 |
+
$item['label'] = sanitize_text_field( $item['label'] );
|
867 |
+
}
|
868 |
+
|
869 |
+
return $item;
|
870 |
+
} else {
|
871 |
+
return sanitize_text_field( $item );
|
872 |
+
}
|
873 |
+
},
|
874 |
+
$value
|
875 |
+
);
|
876 |
+
}
|
877 |
+
|
878 |
+
return $value;
|
879 |
+
}
|
880 |
+
|
881 |
+
|
882 |
+
/**
|
883 |
+
* @param array|string $value
|
884 |
+
*
|
885 |
+
* @return array|string
|
886 |
+
*/
|
887 |
+
public function sanitize_filter_fields( $value ) {
|
888 |
+
$filter_fields = array_keys( UM()->member_directory()->filter_fields );
|
889 |
+
|
890 |
+
if ( '' !== $value ) {
|
891 |
+
$value = array_filter(
|
892 |
+
$value,
|
893 |
+
function( $v, $k ) use ( $filter_fields ) {
|
894 |
+
return in_array( sanitize_text_field( $v ), $filter_fields, true );
|
895 |
+
},
|
896 |
+
ARRAY_FILTER_USE_BOTH
|
897 |
+
);
|
898 |
+
|
899 |
+
$value = array_map( 'sanitize_text_field', $value );
|
900 |
+
}
|
901 |
+
|
902 |
+
return $value;
|
903 |
+
}
|
904 |
+
|
905 |
+
|
906 |
+
/**
|
907 |
+
* @param array|string $value
|
908 |
+
*
|
909 |
+
* @return array|string
|
910 |
+
*/
|
911 |
+
public function sanitize_user_field( $value ) {
|
912 |
+
$user_fields = array_keys( UM()->builtin()->all_user_fields() );
|
913 |
+
|
914 |
+
if ( '' !== $value ) {
|
915 |
+
$value = array_filter(
|
916 |
+
$value,
|
917 |
+
function( $v, $k ) use ( $user_fields ) {
|
918 |
+
return in_array( sanitize_text_field( $v ), $user_fields, true );
|
919 |
+
},
|
920 |
+
ARRAY_FILTER_USE_BOTH
|
921 |
+
);
|
922 |
+
|
923 |
+
$value = array_map( 'sanitize_text_field', $value );
|
924 |
+
}
|
925 |
+
|
926 |
+
return $value;
|
927 |
+
}
|
928 |
+
|
929 |
+
|
930 |
+
/**
|
931 |
+
* @param array|string $value
|
932 |
+
*
|
933 |
+
* @return array|string
|
934 |
+
*/
|
935 |
+
public function sanitize_md_view_types( $value ) {
|
936 |
+
$view_types = array_map(
|
937 |
+
function ( $item ) {
|
938 |
+
return $item['title'];
|
939 |
+
},
|
940 |
+
UM()->member_directory()->view_types
|
941 |
+
);
|
942 |
+
$view_types = array_keys( $view_types );
|
943 |
+
|
944 |
+
if ( '' !== $value ) {
|
945 |
+
$value = array_filter(
|
946 |
+
$value,
|
947 |
+
function( $v, $k ) use ( $view_types ) {
|
948 |
+
return in_array( sanitize_key( $k ), $view_types, true ) && 1 === (int) $v;
|
949 |
+
},
|
950 |
+
ARRAY_FILTER_USE_BOTH
|
951 |
+
);
|
952 |
+
|
953 |
+
$value = array_map( 'sanitize_key', $value );
|
954 |
+
}
|
955 |
+
|
956 |
+
return $value;
|
957 |
+
}
|
958 |
+
|
959 |
+
|
960 |
+
/**
|
961 |
+
* @param array|string $value
|
962 |
+
*
|
963 |
+
* @return array|string
|
964 |
+
*/
|
965 |
+
public function sanitize_photosize( $value ) {
|
966 |
+
$sizes = UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' );
|
967 |
+
$sizes = array_keys( $sizes );
|
968 |
+
|
969 |
+
if ( '' !== $value ) {
|
970 |
+
$value = in_array( absint( $value ), $sizes, true ) ? absint( $value ) : '';
|
971 |
+
}
|
972 |
+
|
973 |
+
return $value;
|
974 |
+
}
|
975 |
+
|
976 |
+
|
977 |
+
/**
|
978 |
+
* @param array|string $value
|
979 |
+
*
|
980 |
+
* @return array|string
|
981 |
+
*/
|
982 |
+
public function sanitize_cover_photosize( $value ) {
|
983 |
+
$sizes = UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' );
|
984 |
+
$sizes = array_keys( $sizes );
|
985 |
+
|
986 |
+
if ( '' !== $value ) {
|
987 |
+
$value = in_array( absint( $value ), $sizes, true ) ? absint( $value ) : '';
|
988 |
+
}
|
989 |
+
|
990 |
+
return $value;
|
991 |
+
}
|
992 |
+
|
993 |
+
|
994 |
+
/**
|
995 |
+
* @param array|string $value
|
996 |
+
*
|
997 |
+
* @return array|string
|
998 |
+
*/
|
999 |
+
public function sanitize_restriction_existed_role( $value ) {
|
1000 |
+
$all_roles = array_keys( UM()->roles()->get_roles() );
|
1001 |
+
|
1002 |
+
if ( '' !== $value ) {
|
1003 |
+
$value = array_filter(
|
1004 |
+
$value,
|
1005 |
+
function( $v, $k ) use ( $all_roles ) {
|
1006 |
+
return in_array( sanitize_key( $k ), $all_roles, true ) && 1 === (int) $v;
|
1007 |
+
},
|
1008 |
+
ARRAY_FILTER_USE_BOTH
|
1009 |
+
);
|
1010 |
+
|
1011 |
+
$value = array_map( 'sanitize_key', $value );
|
1012 |
+
}
|
1013 |
+
|
1014 |
+
return $value;
|
1015 |
+
}
|
1016 |
+
|
1017 |
+
|
1018 |
+
/**
|
1019 |
+
* @param array|string $value
|
1020 |
+
*
|
1021 |
+
* @return array|string
|
1022 |
+
*/
|
1023 |
+
public function sanitize_existed_role( $value ) {
|
1024 |
+
$all_roles = array_keys( UM()->roles()->get_roles() );
|
1025 |
+
|
1026 |
+
if ( '' !== $value ) {
|
1027 |
+
$value = array_filter(
|
1028 |
+
$value,
|
1029 |
+
function( $v, $k ) use ( $all_roles ) {
|
1030 |
+
return in_array( sanitize_key( $v ), $all_roles, true );
|
1031 |
+
},
|
1032 |
+
ARRAY_FILTER_USE_BOTH
|
1033 |
+
);
|
1034 |
+
|
1035 |
+
$value = array_map( 'sanitize_key', $value );
|
1036 |
+
}
|
1037 |
+
|
1038 |
+
return $value;
|
1039 |
+
}
|
1040 |
+
|
1041 |
+
|
1042 |
+
/**
|
1043 |
+
* @param array|string $value
|
1044 |
+
*
|
1045 |
+
* @return array|string
|
1046 |
+
*/
|
1047 |
+
public function sanitize_tabs_privacy( $value ) {
|
1048 |
+
$all_privacy = array_keys( UM()->profile()->tabs_privacy() );
|
1049 |
+
|
1050 |
+
if ( '' !== $value ) {
|
1051 |
+
$value = in_array( absint( $value ), $all_privacy, true ) ? absint( $value ) : '';
|
1052 |
+
}
|
1053 |
+
|
1054 |
+
return $value;
|
1055 |
+
}
|
1056 |
+
|
1057 |
+
|
1058 |
+
/**
|
1059 |
+
* @param $value
|
1060 |
+
*
|
1061 |
+
* @return bool|string
|
1062 |
+
*/
|
1063 |
+
public function sanitize_profile_noindex( $value ) {
|
1064 |
+
$value = '' !== $value ? (bool) $value : $value;
|
1065 |
+
return $value;
|
1066 |
+
}
|
1067 |
+
|
1068 |
+
|
1069 |
+
/**
|
1070 |
+
* @param $value
|
1071 |
+
*
|
1072 |
+
* @return array
|
1073 |
+
*/
|
1074 |
+
public function sanitize_wp_capabilities( $value ) {
|
1075 |
+
$value = array_map( 'boolval', array_filter( $value ) );
|
1076 |
+
return $value;
|
1077 |
+
}
|
1078 |
+
|
1079 |
+
|
1080 |
+
/**
|
1081 |
+
* Sanitize role meta fields when wp-admin form has been submitted
|
1082 |
+
*
|
1083 |
+
* @param array $data
|
1084 |
+
*
|
1085 |
+
* @return array
|
1086 |
+
*/
|
1087 |
+
public function sanitize_role_meta( $data ) {
|
1088 |
+
$sanitized = array();
|
1089 |
+
foreach ( $data as $k => $v ) {
|
1090 |
+
if ( ! array_key_exists( $k, $this->role_meta ) ) {
|
1091 |
+
// @todo remove since 2.2.x and leave only continue
|
1092 |
+
$sanitized[ $k ] = $v;
|
1093 |
+
continue;
|
1094 |
+
}
|
1095 |
+
|
1096 |
+
if ( ! array_key_exists( 'sanitize', $this->role_meta[ $k ] ) ) {
|
1097 |
+
// @todo remove since 2.2.x and leave only continue
|
1098 |
+
$sanitized[ $k ] = $v;
|
1099 |
+
continue;
|
1100 |
+
}
|
1101 |
+
|
1102 |
+
if ( is_callable( $this->role_meta[ $k ]['sanitize'], true, $callable_name ) ) {
|
1103 |
+
add_filter( 'um_role_meta_sanitize_' . $k, $this->role_meta[ $k ]['sanitize'], 10, 1 );
|
1104 |
+
}
|
1105 |
+
|
1106 |
+
switch ( $this->role_meta[ $k ]['sanitize'] ) {
|
1107 |
+
default:
|
1108 |
+
$sanitized[ $k ] = apply_filters( 'um_role_meta_sanitize_' . $k, $data[ $k ] );
|
1109 |
+
break;
|
1110 |
+
case 'int':
|
1111 |
+
$sanitized[ $k ] = (int) $v;
|
1112 |
+
break;
|
1113 |
+
case 'bool':
|
1114 |
+
$sanitized[ $k ] = (bool) $v;
|
1115 |
+
break;
|
1116 |
+
case 'url':
|
1117 |
+
$sanitized[ $k ] = esc_url_raw( $v );
|
1118 |
+
break;
|
1119 |
+
case 'textarea':
|
1120 |
+
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1121 |
+
break;
|
1122 |
+
case 'sanitize_array_key':
|
1123 |
+
if ( ! array_key_exists( 'default', $this->role_meta[ $k ] ) || ! array_key_exists( 'array', $this->role_meta[ $k ] ) ) {
|
1124 |
+
continue 2;
|
1125 |
+
}
|
1126 |
+
|
1127 |
+
$sanitized[ $k ] = ! in_array( sanitize_key( $v ), $this->role_meta[ $k ]['array'], true ) ? $this->role_meta[ $k ]['default'] : sanitize_key( $v );
|
1128 |
+
break;
|
1129 |
+
}
|
1130 |
+
}
|
1131 |
+
|
1132 |
+
$data = $sanitized;
|
1133 |
+
|
1134 |
+
$data = apply_filters( 'um_save_role_meta_sanitize', $data );
|
1135 |
+
|
1136 |
+
return $data;
|
1137 |
+
}
|
1138 |
+
|
1139 |
+
|
1140 |
+
/**
|
1141 |
+
* Sanitize post restriction meta fields when wp-admin form has been submitted
|
1142 |
+
*
|
1143 |
+
* @param array $data
|
1144 |
+
*
|
1145 |
+
* @return array
|
1146 |
+
*/
|
1147 |
+
public function sanitize_post_restriction_meta( $data ) {
|
1148 |
+
$sanitized = array();
|
1149 |
+
foreach ( $data as $k => $v ) {
|
1150 |
+
if ( ! array_key_exists( $k, $this->restriction_post_meta ) ) {
|
1151 |
+
// @todo remove since 2.2.x and leave only continue
|
1152 |
+
$sanitized[ $k ] = $v;
|
1153 |
+
continue;
|
1154 |
+
}
|
1155 |
+
|
1156 |
+
if ( ! array_key_exists( 'sanitize', $this->restriction_post_meta[ $k ] ) ) {
|
1157 |
+
// @todo remove since 2.2.x and leave only continue
|
1158 |
+
$sanitized[ $k ] = $v;
|
1159 |
+
continue;
|
1160 |
+
}
|
1161 |
+
|
1162 |
+
if ( is_callable( $this->restriction_post_meta[ $k ]['sanitize'], true, $callable_name ) ) {
|
1163 |
+
add_filter( 'um_restriction_post_meta_sanitize_' . $k, $this->restriction_post_meta[ $k ]['sanitize'], 10, 1 );
|
1164 |
+
}
|
1165 |
+
|
1166 |
+
switch ( $this->restriction_post_meta[ $k ]['sanitize'] ) {
|
1167 |
+
default:
|
1168 |
+
$sanitized[ $k ] = apply_filters( 'um_restriction_post_meta_sanitize_' . $k, $data[ $k ] );
|
1169 |
+
break;
|
1170 |
+
case 'int':
|
1171 |
+
$sanitized[ $k ] = (int) $v;
|
1172 |
+
break;
|
1173 |
+
case 'bool':
|
1174 |
+
$sanitized[ $k ] = (bool) $v;
|
1175 |
+
break;
|
1176 |
+
case 'url':
|
1177 |
+
$sanitized[ $k ] = esc_url_raw( $v );
|
1178 |
+
break;
|
1179 |
+
case 'textarea':
|
1180 |
+
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1181 |
+
break;
|
1182 |
+
case 'wp_kses':
|
1183 |
+
$sanitized[ $k ] = wp_kses_post( $v );
|
1184 |
+
break;
|
1185 |
+
}
|
1186 |
+
}
|
1187 |
+
|
1188 |
+
$data = $sanitized;
|
1189 |
+
|
1190 |
+
$data = apply_filters( 'um_save_restriction_post_meta_sanitize', $data );
|
1191 |
+
|
1192 |
+
return $data;
|
1193 |
+
}
|
1194 |
+
|
1195 |
+
|
1196 |
+
/**
|
1197 |
+
* Sanitize term restriction meta fields when wp-admin form has been submitted
|
1198 |
+
*
|
1199 |
+
* @param array $data
|
1200 |
+
*
|
1201 |
+
* @return array
|
1202 |
+
*/
|
1203 |
+
public function sanitize_term_restriction_meta( $data ) {
|
1204 |
+
$sanitized = array();
|
1205 |
+
foreach ( $data as $k => $v ) {
|
1206 |
+
if ( ! array_key_exists( $k, $this->restriction_term_meta ) ) {
|
1207 |
+
// @todo remove since 2.2.x and leave only continue
|
1208 |
+
$sanitized[ $k ] = $v;
|
1209 |
+
continue;
|
1210 |
+
}
|
1211 |
+
|
1212 |
+
if ( ! array_key_exists( 'sanitize', $this->restriction_term_meta[ $k ] ) ) {
|
1213 |
+
// @todo remove since 2.2.x and leave only continue
|
1214 |
+
$sanitized[ $k ] = $v;
|
1215 |
+
continue;
|
1216 |
+
}
|
1217 |
+
|
1218 |
+
if ( is_callable( $this->restriction_term_meta[ $k ]['sanitize'], true, $callable_name ) ) {
|
1219 |
+
add_filter( 'um_restriction_term_meta_sanitize_' . $k, $this->restriction_term_meta[ $k ]['sanitize'], 10, 1 );
|
1220 |
+
}
|
1221 |
+
|
1222 |
+
switch ( $this->restriction_term_meta[ $k ]['sanitize'] ) {
|
1223 |
+
default:
|
1224 |
+
$sanitized[ $k ] = apply_filters( 'um_restriction_term_meta_sanitize_' . $k, $data[ $k ] );
|
1225 |
+
break;
|
1226 |
+
case 'int':
|
1227 |
+
$sanitized[ $k ] = (int) $v;
|
1228 |
+
break;
|
1229 |
+
case 'bool':
|
1230 |
+
$sanitized[ $k ] = (bool) $v;
|
1231 |
+
break;
|
1232 |
+
case 'url':
|
1233 |
+
$sanitized[ $k ] = esc_url_raw( $v );
|
1234 |
+
break;
|
1235 |
+
case 'textarea':
|
1236 |
+
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1237 |
+
break;
|
1238 |
+
case 'wp_kses':
|
1239 |
+
$sanitized[ $k ] = wp_kses_post( $v );
|
1240 |
+
break;
|
1241 |
+
}
|
1242 |
+
}
|
1243 |
+
|
1244 |
+
$data = $sanitized;
|
1245 |
+
|
1246 |
+
$data = apply_filters( 'um_save_restriction_term_meta_sanitize', $data );
|
1247 |
+
|
1248 |
+
return $data;
|
1249 |
+
}
|
1250 |
+
|
1251 |
+
|
1252 |
+
/**
|
1253 |
+
* Sanitize member directory meta when wp-admin form has been submitted
|
1254 |
+
*
|
1255 |
+
* @todo checking all sanitize types
|
1256 |
+
*
|
1257 |
+
* @param array $data
|
1258 |
+
*
|
1259 |
+
* @return array
|
1260 |
+
*/
|
1261 |
+
public function sanitize_member_directory_meta( $data ) {
|
1262 |
+
$sanitized = array();
|
1263 |
+
foreach ( $data as $k => $v ) {
|
1264 |
+
if ( ! array_key_exists( $k, $this->member_directory_meta ) ) {
|
1265 |
+
// @todo remove since 2.2.x and leave only continue
|
1266 |
+
$sanitized[ $k ] = $v;
|
1267 |
+
continue;
|
1268 |
+
}
|
1269 |
+
|
1270 |
+
if ( ! array_key_exists( 'sanitize', $this->member_directory_meta[ $k ] ) ) {
|
1271 |
+
// @todo remove since 2.2.x and leave only continue
|
1272 |
+
$sanitized[ $k ] = $v;
|
1273 |
+
continue;
|
1274 |
+
}
|
1275 |
+
|
1276 |
+
if ( is_callable( $this->member_directory_meta[ $k ]['sanitize'], true, $callable_name ) ) {
|
1277 |
+
add_filter( 'um_member_directory_meta_sanitize_' . $k, $this->member_directory_meta[ $k ]['sanitize'], 10, 1 );
|
1278 |
+
}
|
1279 |
+
|
1280 |
+
switch ( $this->member_directory_meta[ $k ]['sanitize'] ) {
|
1281 |
+
default:
|
1282 |
+
$sanitized[ $k ] = apply_filters( 'um_member_directory_meta_sanitize_' . $k, $data[ $k ] );
|
1283 |
+
break;
|
1284 |
+
case 'int':
|
1285 |
+
$sanitized[ $k ] = (int) $v;
|
1286 |
+
break;
|
1287 |
+
case 'bool':
|
1288 |
+
$sanitized[ $k ] = (bool) $v;
|
1289 |
+
break;
|
1290 |
+
case 'url':
|
1291 |
+
if ( is_array( $v ) ) {
|
1292 |
+
$sanitized[ $k ] = array_map( 'esc_url_raw', $v );
|
1293 |
+
} else {
|
1294 |
+
$sanitized[ $k ] = esc_url_raw( $v );
|
1295 |
+
}
|
1296 |
+
break;
|
1297 |
+
case 'text':
|
1298 |
+
$sanitized[ $k ] = sanitize_text_field( $v );
|
1299 |
+
break;
|
1300 |
+
case 'textarea':
|
1301 |
+
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1302 |
+
break;
|
1303 |
+
case 'key':
|
1304 |
+
if ( is_array( $v ) ) {
|
1305 |
+
$sanitized[ $k ] = array_map( 'sanitize_key', $v );
|
1306 |
+
} else {
|
1307 |
+
$sanitized[ $k ] = sanitize_key( $v );
|
1308 |
+
}
|
1309 |
+
break;
|
1310 |
+
case 'absint':
|
1311 |
+
if ( is_array( $v ) ) {
|
1312 |
+
$sanitized[ $k ] = array_map( 'absint', $v );
|
1313 |
+
} else {
|
1314 |
+
$sanitized[ $k ] = absint( $v );
|
1315 |
+
}
|
1316 |
+
break;
|
1317 |
+
}
|
1318 |
+
}
|
1319 |
+
|
1320 |
+
$data = $sanitized;
|
1321 |
+
|
1322 |
+
$data = apply_filters( 'um_save_member_directory_meta_sanitize', $data );
|
1323 |
+
|
1324 |
+
return $data;
|
1325 |
+
}
|
1326 |
+
|
1327 |
+
|
1328 |
+
/**
|
1329 |
+
* Sanitize builder field meta when wp-admin form has been submitted
|
1330 |
+
*
|
1331 |
+
* @todo checking all sanitize types
|
1332 |
+
*
|
1333 |
+
* @param array $data
|
1334 |
+
*
|
1335 |
+
* @return array
|
1336 |
+
*/
|
1337 |
+
public function sanitize_builder_field_meta( $data ) {
|
1338 |
+
$sanitized = array();
|
1339 |
+
foreach ( $data as $k => $v ) {
|
1340 |
+
if ( ! array_key_exists( $k, $this->builder_input ) ) {
|
1341 |
+
// @todo remove since 2.2.x and leave only continue
|
1342 |
+
$sanitized[ $k ] = $v;
|
1343 |
+
continue;
|
1344 |
+
}
|
1345 |
+
|
1346 |
+
if ( ! array_key_exists( 'sanitize', $this->builder_input[ $k ] ) ) {
|
1347 |
+
// @todo remove since 2.2.x and leave only continue
|
1348 |
+
$sanitized[ $k ] = $v;
|
1349 |
+
continue;
|
1350 |
+
}
|
1351 |
+
|
1352 |
+
if ( is_callable( $this->builder_input[ $k ]['sanitize'], true, $callable_name ) ) {
|
1353 |
+
add_filter( 'um_builder_input_sanitize_' . $k, $this->builder_input[ $k ]['sanitize'], 10, 1 );
|
1354 |
+
}
|
1355 |
+
|
1356 |
+
switch ( $this->builder_input[ $k ]['sanitize'] ) {
|
1357 |
+
default:
|
1358 |
+
$sanitized[ $k ] = apply_filters( 'um_builder_input_sanitize_' . $k, $data[ $k ] );
|
1359 |
+
break;
|
1360 |
+
case 'int':
|
1361 |
+
$sanitized[ $k ] = (int) $v;
|
1362 |
+
break;
|
1363 |
+
case 'empty_int':
|
1364 |
+
$sanitized[ $k ] = ( '' !== $v ) ? (int) $v : '';
|
1365 |
+
break;
|
1366 |
+
case 'bool':
|
1367 |
+
$sanitized[ $k ] = (bool) $v;
|
1368 |
+
break;
|
1369 |
+
case 'url':
|
1370 |
+
if ( is_array( $v ) ) {
|
1371 |
+
$sanitized[ $k ] = array_map( 'esc_url_raw', $v );
|
1372 |
+
} else {
|
1373 |
+
$sanitized[ $k ] = esc_url_raw( $v );
|
1374 |
+
}
|
1375 |
+
break;
|
1376 |
+
case 'text':
|
1377 |
+
$sanitized[ $k ] = sanitize_text_field( $v );
|
1378 |
+
break;
|
1379 |
+
case 'textarea':
|
1380 |
+
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1381 |
+
break;
|
1382 |
+
case 'wp_kses':
|
1383 |
+
$sanitized[ $k ] = wp_kses_post( $v );
|
1384 |
+
break;
|
1385 |
+
case 'key':
|
1386 |
+
if ( is_array( $v ) ) {
|
1387 |
+
$sanitized[ $k ] = array_map( 'sanitize_key', $v );
|
1388 |
+
} else {
|
1389 |
+
$sanitized[ $k ] = sanitize_key( $v );
|
1390 |
+
}
|
1391 |
+
break;
|
1392 |
+
case 'absint':
|
1393 |
+
if ( is_array( $v ) ) {
|
1394 |
+
$sanitized[ $k ] = array_map( 'absint', $v );
|
1395 |
+
} else {
|
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 |
+
|
1409 |
+
$data = $sanitized;
|
1410 |
+
|
1411 |
+
$data = apply_filters( 'um_save_builder_input_sanitize', $data );
|
1412 |
+
|
1413 |
+
return $data;
|
1414 |
+
}
|
1415 |
+
|
1416 |
+
|
1417 |
+
/**
|
1418 |
+
* Sanitize form meta when wp-admin form has been submitted
|
1419 |
+
*
|
1420 |
+
* @todo checking all sanitize types
|
1421 |
+
*
|
1422 |
+
* @param array $data
|
1423 |
+
*
|
1424 |
+
* @return array
|
1425 |
+
*/
|
1426 |
+
public function sanitize_form_meta( $data ) {
|
1427 |
+
$sanitized = array();
|
1428 |
+
foreach ( $data as $k => $v ) {
|
1429 |
+
if ( ! array_key_exists( $k, $this->form_meta ) ) {
|
1430 |
+
// @todo remove since 2.2.x and leave only continue
|
1431 |
+
$sanitized[ $k ] = $v;
|
1432 |
+
continue;
|
1433 |
+
}
|
1434 |
+
|
1435 |
+
if ( ! array_key_exists( 'sanitize', $this->form_meta[ $k ] ) ) {
|
1436 |
+
// @todo remove since 2.2.x and leave only continue
|
1437 |
+
$sanitized[ $k ] = $v;
|
1438 |
+
continue;
|
1439 |
+
}
|
1440 |
+
|
1441 |
+
if ( is_callable( $this->form_meta[ $k ]['sanitize'], true, $callable_name ) ) {
|
1442 |
+
add_filter( 'um_form_meta_sanitize_' . $k, $this->form_meta[ $k ]['sanitize'], 10, 1 );
|
1443 |
+
}
|
1444 |
+
|
1445 |
+
switch ( $this->form_meta[ $k ]['sanitize'] ) {
|
1446 |
+
default:
|
1447 |
+
$sanitized[ $k ] = apply_filters( 'um_form_meta_sanitize_' . $k, $data[ $k ] );
|
1448 |
+
break;
|
1449 |
+
case 'int':
|
1450 |
+
$sanitized[ $k ] = (int) $v;
|
1451 |
+
break;
|
1452 |
+
case 'bool':
|
1453 |
+
$sanitized[ $k ] = (bool) $v;
|
1454 |
+
break;
|
1455 |
+
case 'url':
|
1456 |
+
if ( is_array( $v ) ) {
|
1457 |
+
$sanitized[ $k ] = array_map( 'esc_url_raw', $v );
|
1458 |
+
} else {
|
1459 |
+
$sanitized[ $k ] = esc_url_raw( $v );
|
1460 |
+
}
|
1461 |
+
break;
|
1462 |
+
case 'text':
|
1463 |
+
$sanitized[ $k ] = sanitize_text_field( $v );
|
1464 |
+
break;
|
1465 |
+
case 'textarea':
|
1466 |
+
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1467 |
+
break;
|
1468 |
+
case 'key':
|
1469 |
+
if ( is_array( $v ) ) {
|
1470 |
+
$sanitized[ $k ] = array_map( 'sanitize_key', $v );
|
1471 |
+
} else {
|
1472 |
+
$sanitized[ $k ] = sanitize_key( $v );
|
1473 |
+
}
|
1474 |
+
break;
|
1475 |
+
case 'absint':
|
1476 |
+
if ( is_array( $v ) ) {
|
1477 |
+
$sanitized[ $k ] = array_map( 'absint', $v );
|
1478 |
+
} else {
|
1479 |
+
$sanitized[ $k ] = absint( $v );
|
1480 |
+
}
|
1481 |
+
break;
|
1482 |
+
}
|
1483 |
+
}
|
1484 |
+
|
1485 |
+
$data = $sanitized;
|
1486 |
+
|
1487 |
+
$data = apply_filters( 'um_save_form_meta_sanitize', $data );
|
1488 |
+
|
1489 |
+
return $data;
|
1490 |
+
}
|
1491 |
+
|
1492 |
+
|
1493 |
+
/**
|
1494 |
+
* Sanitize options when wp-admin form has been submitted
|
1495 |
+
*
|
1496 |
+
* @todo checking all sanitize types
|
1497 |
+
*
|
1498 |
+
* @param array $data
|
1499 |
+
*
|
1500 |
+
* @return array
|
1501 |
+
*/
|
1502 |
+
public function sanitize_options( $data ) {
|
1503 |
+
$sanitized = array();
|
1504 |
+
foreach ( $data as $k => $v ) {
|
1505 |
+
if ( ! array_key_exists( $k, UM()->admin_settings()->settings_map ) ) {
|
1506 |
+
// @todo remove since 2.2.x and leave only continue
|
1507 |
+
$sanitized[ $k ] = $v;
|
1508 |
+
continue;
|
1509 |
+
}
|
1510 |
+
|
1511 |
+
if ( ! array_key_exists( 'sanitize', UM()->admin_settings()->settings_map[ $k ] ) ) {
|
1512 |
+
// @todo remove since 2.2.x and leave only continue
|
1513 |
+
$sanitized[ $k ] = $v;
|
1514 |
+
continue;
|
1515 |
+
}
|
1516 |
+
|
1517 |
+
if ( is_callable( UM()->admin_settings()->settings_map[ $k ]['sanitize'], true, $callable_name ) ) {
|
1518 |
+
add_filter( 'um_settings_sanitize_' . $k, UM()->admin_settings()->settings_map[ $k ]['sanitize'], 10, 1 );
|
1519 |
+
}
|
1520 |
+
|
1521 |
+
switch ( UM()->admin_settings()->settings_map[ $k ]['sanitize'] ) {
|
1522 |
+
default:
|
1523 |
+
$sanitized[ $k ] = apply_filters( 'um_settings_sanitize_' . $k, $v );
|
1524 |
+
break;
|
1525 |
+
case 'int':
|
1526 |
+
$sanitized[ $k ] = (int) $v;
|
1527 |
+
break;
|
1528 |
+
case 'absint':
|
1529 |
+
if ( is_array( $v ) ) {
|
1530 |
+
$sanitized[ $k ] = array_map( 'absint', $v );
|
1531 |
+
} else {
|
1532 |
+
$sanitized[ $k ] = absint( $v );
|
1533 |
+
}
|
1534 |
+
break;
|
1535 |
+
case 'key':
|
1536 |
+
if ( is_array( $v ) ) {
|
1537 |
+
$sanitized[ $k ] = array_map( 'sanitize_key', $v );
|
1538 |
+
} else {
|
1539 |
+
$sanitized[ $k ] = sanitize_key( $v );
|
1540 |
+
}
|
1541 |
+
break;
|
1542 |
+
case 'bool':
|
1543 |
+
$sanitized[ $k ] = (bool) $v;
|
1544 |
+
break;
|
1545 |
+
case 'url':
|
1546 |
+
if ( is_array( $v ) ) {
|
1547 |
+
$sanitized[ $k ] = array_map( 'esc_url_raw', $v );
|
1548 |
+
} else {
|
1549 |
+
$sanitized[ $k ] = esc_url_raw( $v );
|
1550 |
+
}
|
1551 |
+
break;
|
1552 |
+
case 'wp_kses':
|
1553 |
+
$sanitized[ $k ] = wp_kses_post( $v );
|
1554 |
+
break;
|
1555 |
+
case 'textarea':
|
1556 |
+
$sanitized[ $k ] = sanitize_textarea_field( $v );
|
1557 |
+
break;
|
1558 |
+
case 'text':
|
1559 |
+
$sanitized[ $k ] = sanitize_text_field( $v );
|
1560 |
+
break;
|
1561 |
+
}
|
1562 |
+
}
|
1563 |
+
|
1564 |
+
$data = $sanitized;
|
1565 |
+
|
1566 |
+
$data = apply_filters( 'um_save_settings_sanitize', $data );
|
1567 |
+
|
1568 |
+
return $data;
|
1569 |
+
}
|
1570 |
+
|
1571 |
+
|
1572 |
+
/**
|
1573 |
+
* Adds class to our admin pages
|
1574 |
+
*
|
1575 |
+
* @param $classes
|
1576 |
+
*
|
1577 |
+
* @return string
|
1578 |
+
*/
|
1579 |
+
public function admin_body_class( $classes ) {
|
1580 |
+
if ( $this->is_um_screen() ) {
|
1581 |
+
return "$classes um-admin";
|
1582 |
+
}
|
1583 |
+
return $classes;
|
1584 |
+
}
|
1585 |
+
|
1586 |
+
|
1587 |
+
/**
|
1588 |
+
*
|
1589 |
+
*/
|
1590 |
+
public function manual_upgrades_request() {
|
1591 |
+
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
|
1592 |
+
die();
|
1593 |
+
}
|
1594 |
+
|
1595 |
+
$last_request = get_option( 'um_last_manual_upgrades_request', false );
|
1596 |
+
|
1597 |
+
if ( empty( $last_request ) || time() > $last_request + DAY_IN_SECONDS ) {
|
1598 |
+
|
1599 |
+
if ( is_multisite() ) {
|
1600 |
+
$blogs_ids = get_sites();
|
1601 |
+
foreach( $blogs_ids as $b ) {
|
1602 |
+
switch_to_blog( $b->blog_id );
|
1603 |
+
wp_clean_update_cache();
|
1604 |
+
|
1605 |
+
UM()->plugin_updater()->um_checklicenses();
|
1606 |
+
|
1607 |
+
update_option( 'um_last_manual_upgrades_request', time() );
|
1608 |
+
restore_current_blog();
|
1609 |
+
}
|
1610 |
+
} else {
|
1611 |
+
wp_clean_update_cache();
|
1612 |
+
|
1613 |
+
UM()->plugin_updater()->um_checklicenses();
|
1614 |
+
|
1615 |
+
update_option( 'um_last_manual_upgrades_request', time() );
|
1616 |
+
}
|
1617 |
+
|
1618 |
+
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'got_updates' ), admin_url( 'admin.php' ) );
|
1619 |
+
} else {
|
1620 |
+
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'often_updates' ), admin_url( 'admin.php' ) );
|
1621 |
+
}
|
1622 |
+
exit( wp_redirect( $url ) );
|
1623 |
+
}
|
1624 |
+
|
1625 |
+
|
1626 |
+
/**
|
1627 |
+
* Core pages installation
|
1628 |
+
*/
|
1629 |
+
function install_core_pages() {
|
1630 |
+
if ( ! is_admin() ) {
|
1631 |
+
die();
|
1632 |
+
}
|
1633 |
+
|
1634 |
+
UM()->setup()->install_default_pages();
|
1635 |
+
|
1636 |
+
//check empty pages in settings
|
1637 |
+
$empty_pages = array();
|
1638 |
+
|
1639 |
+
$pages = UM()->config()->permalinks;
|
1640 |
+
if ( $pages && is_array( $pages ) ) {
|
1641 |
+
foreach ( $pages as $slug => $page_id ) {
|
1642 |
+
$page = get_post( $page_id );
|
1643 |
+
|
1644 |
+
if ( ! isset( $page->ID ) && in_array( $slug, array_keys( UM()->config()->core_pages ) ) ) {
|
1645 |
+
$empty_pages[] = $slug;
|
1646 |
+
}
|
1647 |
+
}
|
1648 |
+
}
|
1649 |
+
|
1650 |
+
//if there aren't empty pages - then hide pages notice
|
1651 |
+
if ( empty( $empty_pages ) ) {
|
1652 |
+
$hidden_notices = get_option( 'um_hidden_admin_notices', array() );
|
1653 |
+
$hidden_notices[] = 'wrong_pages';
|
1654 |
+
|
1655 |
+
update_option( 'um_hidden_admin_notices', $hidden_notices );
|
1656 |
+
}
|
1657 |
+
|
1658 |
+
$url = add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) );
|
1659 |
+
exit( wp_redirect( $url ) );
|
1660 |
+
}
|
1661 |
+
|
1662 |
+
|
1663 |
+
/**
|
1664 |
+
* Clear all users cache
|
1665 |
+
*
|
1666 |
+
* @param $action
|
1667 |
+
*/
|
1668 |
+
function user_cache( $action ) {
|
1669 |
+
global $wpdb;
|
1670 |
+
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
|
1671 |
+
die();
|
1672 |
+
}
|
1673 |
+
|
1674 |
+
$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" );
|
1675 |
+
|
1676 |
+
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'cleared_cache' ), admin_url( 'admin.php' ) );
|
1677 |
+
exit( wp_redirect( $url ) );
|
1678 |
+
}
|
1679 |
+
|
1680 |
+
|
1681 |
+
/**
|
1682 |
+
* Purge temp uploads dir
|
1683 |
+
* @param $action
|
1684 |
+
*/
|
1685 |
+
function purge_temp( $action ) {
|
1686 |
+
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
|
1687 |
+
die();
|
1688 |
+
}
|
1689 |
+
|
1690 |
+
UM()->files()->remove_dir( UM()->files()->upload_temp );
|
1691 |
+
|
1692 |
+
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'purged_temp' ), admin_url( 'admin.php' ) );
|
1693 |
+
exit( wp_redirect( $url ) );
|
1694 |
+
}
|
1695 |
+
|
1696 |
+
|
1697 |
+
/**
|
1698 |
+
* Duplicate form
|
1699 |
+
*
|
1700 |
+
* @param $action
|
1701 |
+
*/
|
1702 |
+
function duplicate_form( $action ) {
|
1703 |
+
if ( ! is_admin() || ! current_user_can('manage_options') ) {
|
1704 |
+
die();
|
1705 |
+
}
|
1706 |
+
if ( ! isset( $_REQUEST['post_id'] ) || ! is_numeric( $_REQUEST['post_id'] ) ) {
|
1707 |
+
die();
|
1708 |
+
}
|
1709 |
+
|
1710 |
+
$post_id = absint( $_REQUEST['post_id'] );
|
1711 |
+
|
1712 |
+
$n = array(
|
1713 |
+
'post_type' => 'um_form',
|
1714 |
+
'post_title' => sprintf( __( 'Duplicate of %s', 'ultimate-member' ), get_the_title( $post_id ) ),
|
1715 |
+
'post_status' => 'publish',
|
1716 |
+
'post_author' => get_current_user_id(),
|
1717 |
+
);
|
1718 |
+
|
1719 |
+
$n_id = wp_insert_post( $n );
|
1720 |
+
|
1721 |
+
$n_fields = get_post_custom( $post_id );
|
1722 |
+
foreach ( $n_fields as $key => $value ) {
|
1723 |
+
|
1724 |
+
if ( $key == '_um_custom_fields' ) {
|
1725 |
+
$the_value = unserialize( $value[0] );
|
1726 |
+
} else {
|
1727 |
+
$the_value = $value[0];
|
1728 |
+
}
|
1729 |
+
|
1730 |
+
update_post_meta( $n_id, $key, $the_value );
|
1731 |
+
|
1732 |
+
}
|
1733 |
+
|
1734 |
+
delete_post_meta( $n_id, '_um_core' );
|
1735 |
+
|
1736 |
+
$url = admin_url( 'edit.php?post_type=um_form' );
|
1737 |
+
$url = add_query_arg( 'update', 'form_duplicated', $url );
|
1738 |
+
|
1739 |
+
exit( wp_redirect( $url ) );
|
1740 |
+
|
1741 |
+
}
|
1742 |
+
|
1743 |
+
|
1744 |
+
/**
|
1745 |
+
* Action to hide notices in admin
|
1746 |
+
*
|
1747 |
+
* @param $action
|
1748 |
+
*/
|
1749 |
+
function um_hide_notice( $action ) {
|
1750 |
+
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
|
1751 |
+
die();
|
1752 |
+
}
|
1753 |
+
|
1754 |
+
update_option( $action, 1 );
|
1755 |
+
exit( wp_redirect( remove_query_arg( 'um_adm_action' ) ) );
|
1756 |
+
}
|
1757 |
+
|
1758 |
+
|
1759 |
+
/**
|
1760 |
+
* Various user actions
|
1761 |
+
*
|
1762 |
+
* @param $action
|
1763 |
+
*/
|
1764 |
+
function user_action( $action ) {
|
1765 |
+
if ( ! is_admin() || ! current_user_can( 'edit_users' ) ) {
|
1766 |
+
die();
|
1767 |
+
}
|
1768 |
+
if ( ! isset( $_REQUEST['sub'] ) ) {
|
1769 |
+
die();
|
1770 |
+
}
|
1771 |
+
if ( ! isset( $_REQUEST['user_id'] ) ) {
|
1772 |
+
die();
|
1773 |
+
}
|
1774 |
+
|
1775 |
+
um_fetch_user( absint( $_REQUEST['user_id'] ) );
|
1776 |
+
|
1777 |
+
$subaction = sanitize_key( $_REQUEST['sub'] );
|
1778 |
+
|
1779 |
+
/**
|
1780 |
+
* UM hook
|
1781 |
+
*
|
1782 |
+
* @type action
|
1783 |
+
* @title um_admin_user_action_hook
|
1784 |
+
* @description Action on bulk user subaction
|
1785 |
+
* @input_vars
|
1786 |
+
* [{"var":"$subaction","type":"string","desc":"Bulk Subaction"}]
|
1787 |
+
* @change_log
|
1788 |
+
* ["Since: 2.0"]
|
1789 |
+
* @usage add_action( 'um_admin_user_action_hook', 'function_name', 10, 1 );
|
1790 |
+
* @example
|
1791 |
+
* <?php
|
1792 |
+
* add_action( 'um_admin_user_action_hook', 'my_admin_user_action', 10, 1 );
|
1793 |
+
* function my_admin_user_action( $subaction ) {
|
1794 |
+
* // your code here
|
1795 |
+
* }
|
1796 |
+
* ?>
|
1797 |
+
*/
|
1798 |
+
do_action( 'um_admin_user_action_hook', $subaction );
|
1799 |
+
/**
|
1800 |
+
* UM hook
|
1801 |
+
*
|
1802 |
+
* @type action
|
1803 |
+
* @title um_admin_user_action_{$subaction}_hook
|
1804 |
+
* @description Action on bulk user subaction
|
1805 |
+
* @change_log
|
1806 |
+
* ["Since: 2.0"]
|
1807 |
+
* @usage add_action( 'um_admin_user_action_{$subaction}_hook', 'function_name', 10 );
|
1808 |
+
* @example
|
1809 |
+
* <?php
|
1810 |
+
* add_action( 'um_admin_user_action_{$subaction}_hook', 'my_admin_user_action', 10 );
|
1811 |
+
* function my_admin_user_action() {
|
1812 |
+
* // your code here
|
1813 |
+
* }
|
1814 |
+
* ?>
|
1815 |
+
*/
|
1816 |
+
do_action( "um_admin_user_action_{$subaction}_hook" );
|
1817 |
+
|
1818 |
+
um_reset_user();
|
1819 |
+
|
1820 |
+
wp_redirect( add_query_arg( 'update', 'user_updated', admin_url( '?page=ultimatemember' ) ) );
|
1821 |
+
exit;
|
1822 |
+
|
1823 |
+
}
|
1824 |
+
|
1825 |
+
|
1826 |
+
/**
|
1827 |
+
* Add any custom links to plugin page
|
1828 |
+
*
|
1829 |
+
* @param array $links
|
1830 |
+
*
|
1831 |
+
* @return array
|
1832 |
+
*/
|
1833 |
+
function plugin_links( $links ) {
|
1834 |
+
$more_links[] = '<a href="http://docs.ultimatemember.com/">' . __( 'Docs', 'ultimate-member' ) . '</a>';
|
1835 |
+
$more_links[] = '<a href="'.admin_url().'admin.php?page=um_options">' . __( 'Settings', 'ultimate-member' ) . '</a>';
|
1836 |
+
|
1837 |
+
$links = $more_links + $links;
|
1838 |
+
return $links;
|
1839 |
+
}
|
1840 |
+
|
1841 |
+
|
1842 |
+
/**
|
1843 |
+
* Init admin action/filters + request handlers
|
1844 |
+
*/
|
1845 |
+
function admin_init() {
|
1846 |
+
$this->init_variables();
|
1847 |
+
|
1848 |
+
if ( is_admin() && current_user_can( 'manage_options' ) && ! empty( $_REQUEST['um_adm_action'] ) ) {
|
1849 |
+
$action = sanitize_key( $_REQUEST['um_adm_action'] );
|
1850 |
+
|
1851 |
+
/**
|
1852 |
+
* UM hook
|
1853 |
+
*
|
1854 |
+
* @type action
|
1855 |
+
* @title um_admin_do_action__
|
1856 |
+
* @description Make some action on custom admin action
|
1857 |
+
* @input_vars
|
1858 |
+
* [{"var":"$action","type":"string","desc":"Admin Action"}]
|
1859 |
+
* @change_log
|
1860 |
+
* ["Since: 2.0"]
|
1861 |
+
* @usage add_action( 'um_admin_do_action__', 'function_name', 10, 1 );
|
1862 |
+
* @example
|
1863 |
+
* <?php
|
1864 |
+
* add_action( 'um_admin_do_action__', 'my_admin_do_action', 10, 1 );
|
1865 |
+
* function my_admin_do_action( $action ) {
|
1866 |
+
* // your code here
|
1867 |
+
* }
|
1868 |
+
* ?>
|
1869 |
+
*/
|
1870 |
+
do_action( 'um_admin_do_action__', $action );
|
1871 |
+
/**
|
1872 |
+
* UM hook
|
1873 |
+
*
|
1874 |
+
* @type action
|
1875 |
+
* @title um_admin_do_action__{$action}
|
1876 |
+
* @description Make some action on custom admin $action
|
1877 |
+
* @input_vars
|
1878 |
+
* [{"var":"$action","type":"string","desc":"Admin Action"}]
|
1879 |
+
* @change_log
|
1880 |
+
* ["Since: 2.0"]
|
1881 |
+
* @usage add_action( 'um_admin_do_action__{$action}', 'function_name', 10, 1 );
|
1882 |
+
* @example
|
1883 |
+
* <?php
|
1884 |
+
* add_action( 'um_admin_do_action__{$action}', 'my_admin_do_action', 10, 1 );
|
1885 |
+
* function my_admin_do_action( $action ) {
|
1886 |
+
* // your code here
|
1887 |
+
* }
|
1888 |
+
* ?>
|
1889 |
+
*/
|
1890 |
+
do_action( "um_admin_do_action__{$action}", $action );
|
1891 |
+
}
|
1892 |
+
}
|
1893 |
+
|
1894 |
+
|
1895 |
+
/**
|
1896 |
+
* Updated post messages
|
1897 |
+
*
|
1898 |
+
* @param array $messages
|
1899 |
+
*
|
1900 |
+
* @return array
|
1901 |
+
*/
|
1902 |
+
function post_updated_messages( $messages ) {
|
1903 |
+
global $post_ID;
|
1904 |
+
|
1905 |
+
$post_type = get_post_type( $post_ID );
|
1906 |
+
|
1907 |
+
if ( $post_type == 'um_form' ) {
|
1908 |
+
$messages['um_form'] = array(
|
1909 |
+
0 => '',
|
1910 |
+
1 => __( 'Form updated.', 'ultimate-member' ),
|
1911 |
+
2 => __( 'Custom field updated.', 'ultimate-member' ),
|
1912 |
+
3 => __( 'Custom field deleted.', 'ultimate-member' ),
|
1913 |
+
4 => __( 'Form updated.', 'ultimate-member' ),
|
1914 |
+
5 => isset( $_GET['revision'] ) ? __( 'Form restored to revision.', 'ultimate-member' ) : false,
|
1915 |
+
6 => __( 'Form created.', 'ultimate-member' ),
|
1916 |
+
7 => __( 'Form saved.', 'ultimate-member' ),
|
1917 |
+
8 => __( 'Form submitted.', 'ultimate-member' ),
|
1918 |
+
9 => __( 'Form scheduled.', 'ultimate-member' ),
|
1919 |
+
10 => __( 'Form draft updated.', 'ultimate-member' ),
|
1920 |
+
);
|
1921 |
+
}
|
1922 |
+
|
1923 |
+
return $messages;
|
1924 |
+
}
|
1925 |
+
|
1926 |
+
|
1927 |
+
/**
|
1928 |
+
* Gettext filters
|
1929 |
+
*
|
1930 |
+
* @param $translation
|
1931 |
+
* @param $text
|
1932 |
+
* @param $domain
|
1933 |
+
*
|
1934 |
+
* @return string
|
1935 |
+
*/
|
1936 |
+
function gettext( $translation, $text, $domain ) {
|
1937 |
+
global $post;
|
1938 |
+
if ( isset( $post->post_type ) && $this->is_plugin_post_type() ) {
|
1939 |
+
$translations = get_translations_for_domain( $domain );
|
1940 |
+
if ( $text == 'Publish' ) {
|
1941 |
+
return $translations->translate( 'Create' );
|
1942 |
+
} elseif ( $text == 'Move to Trash' ) {
|
1943 |
+
return $translations->translate( 'Delete' );
|
1944 |
+
}
|
1945 |
+
}
|
1946 |
+
|
1947 |
+
return $translation;
|
1948 |
+
}
|
1949 |
+
|
1950 |
+
|
1951 |
+
/**
|
1952 |
+
* Fix parent file for correct highlighting
|
1953 |
+
*
|
1954 |
+
* @param $parent_file
|
1955 |
+
*
|
1956 |
+
* @return string
|
1957 |
+
*/
|
1958 |
+
function parent_file( $parent_file ) {
|
1959 |
+
global $current_screen;
|
1960 |
+
$screen_id = $current_screen->id;
|
1961 |
+
if ( strstr( $screen_id, 'um_' ) ) {
|
1962 |
+
$parent_file = 'ultimatemember';
|
1963 |
+
}
|
1964 |
+
return $parent_file;
|
1965 |
+
}
|
1966 |
+
|
1967 |
+
|
1968 |
+
/**
|
1969 |
+
* @since 2.0
|
1970 |
+
*
|
1971 |
+
* @return core\Admin_Notices()
|
1972 |
+
*/
|
1973 |
+
function notices() {
|
1974 |
+
if ( empty( UM()->classes['admin_notices'] ) ) {
|
1975 |
+
UM()->classes['admin_notices'] = new core\Admin_Notices();
|
1976 |
+
}
|
1977 |
+
return UM()->classes['admin_notices'];
|
1978 |
+
}
|
1979 |
+
}
|
1980 |
+
}
|
includes/core/class-fields.php
CHANGED
@@ -1,4902 +1,4912 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\core;
|
3 |
-
|
4 |
-
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
|
8 |
-
if ( ! class_exists( 'um\core\Fields' ) ) {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Fields
|
13 |
-
* @package um\core
|
14 |
-
*/
|
15 |
-
class Fields {
|
16 |
-
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @var string
|
20 |
-
*/
|
21 |
-
var $set_mode = '';
|
22 |
-
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @var int form_id
|
26 |
-
*/
|
27 |
-
public $set_id = null;
|
28 |
-
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Fields constructor.
|
32 |
-
*/
|
33 |
-
function __construct() {
|
34 |
-
$this->editing = false;
|
35 |
-
$this->viewing = false;
|
36 |
-
$this->timestamp = current_time( 'timestamp' );
|
37 |
-
}
|
38 |
-
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Standard checkbox field
|
42 |
-
*
|
43 |
-
* @param integer $id
|
44 |
-
* @param string $title
|
45 |
-
* @param bool $checked
|
46 |
-
*/
|
47 |
-
function checkbox( $id, $title, $checked = true ) {
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Set value on form submission
|
51 |
-
*/
|
52 |
-
if ( isset( $_REQUEST[ $id ] ) ) {
|
53 |
-
$checked = (bool) $_REQUEST[ $id ];
|
54 |
-
}
|
55 |
-
|
56 |
-
$class = $checked ? 'um-icon-android-checkbox-outline' : 'um-icon-android-checkbox-outline-blank';
|
57 |
-
|
58 |
-
?>
|
59 |
-
|
60 |
-
|
61 |
-
<div class="um-field um-field-c">
|
62 |
-
<div class="um-field-area">
|
63 |
-
<label class="um-field-checkbox<?php echo $checked ? ' active' : '' ?>">
|
64 |
-
<input type="checkbox" name="<?php echo esc_attr( $id ); ?>" value="1" <?php checked( $checked ) ?> />
|
65 |
-
<span class="um-field-checkbox-state"><i class="<?php echo esc_attr( $class ) ?>"></i></span>
|
66 |
-
<span class="um-field-checkbox-option"> <?php echo esc_html( $title ); ?></span>
|
67 |
-
</label>
|
68 |
-
</div>
|
69 |
-
</div>
|
70 |
-
|
71 |
-
<?php
|
72 |
-
}
|
73 |
-
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Shows social links
|
77 |
-
*/
|
78 |
-
function show_social_urls() {
|
79 |
-
$social = array();
|
80 |
-
|
81 |
-
$fields = UM()->builtin()->get_all_user_fields();
|
82 |
-
foreach ( $fields as $field => $args ) {
|
83 |
-
if ( isset( $args['advanced'] ) && $args['advanced'] == 'social' ) {
|
84 |
-
$social[ $field ] = $args;
|
85 |
-
}
|
86 |
-
}
|
87 |
-
|
88 |
-
foreach ( $social as $k => $arr ) {
|
89 |
-
if ( um_profile( $k ) ) { ?>
|
90 |
-
|
91 |
-
<a href="<?php echo esc_url( um_filtered_social_link( $k, $arr['match'] ) ); ?>"
|
92 |
-
style="background: <?php echo esc_attr( $arr['color'] ); ?>;" target="_blank" class="um-tip-n"
|
93 |
-
title="<?php echo esc_attr( $arr['title'] ); ?>"><i class="<?php echo esc_attr( $arr['icon'] ); ?>"></i></a>
|
94 |
-
|
95 |
-
<?php
|
96 |
-
}
|
97 |
-
}
|
98 |
-
}
|
99 |
-
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Hidden field inside a shortcode
|
103 |
-
*
|
104 |
-
* @param string $field
|
105 |
-
*/
|
106 |
-
function add_hidden_field( $field ) {
|
107 |
-
echo '<div style="display: none !important;">';
|
108 |
-
|
109 |
-
$fields = UM()->builtin()->get_specific_fields( $field );
|
110 |
-
|
111 |
-
$output = null;
|
112 |
-
|
113 |
-
foreach ( $fields as $key => $data ) {
|
114 |
-
$output .= UM()->fields()->edit_field( $key, $data );
|
115 |
-
}
|
116 |
-
|
117 |
-
echo $output;
|
118 |
-
|
119 |
-
echo '</div>';
|
120 |
-
}
|
121 |
-
|
122 |
-
|
123 |
-
/**
|
124 |
-
* Get hidden field
|
125 |
-
*
|
126 |
-
* @param string $key
|
127 |
-
* @param string $value
|
128 |
-
*
|
129 |
-
* @return string
|
130 |
-
*/
|
131 |
-
function disabled_hidden_field( $key, $value ) {
|
132 |
-
return '<input type="hidden" name="' . esc_attr( $key ) . '" value="' . esc_attr( $value ) . '"/>';
|
133 |
-
}
|
134 |
-
|
135 |
-
|
136 |
-
/**
|
137 |
-
* Updates a field globally
|
138 |
-
*
|
139 |
-
* @param integer $id
|
140 |
-
* @param array $args
|
141 |
-
*/
|
142 |
-
function globally_update_field( $id, $args ) {
|
143 |
-
$fields = UM()->builtin()->saved_fields;
|
144 |
-
|
145 |
-
$fields[ $id ] = $args;
|
146 |
-
|
147 |
-
if ( array_key_exists( 'custom_dropdown_options_source', $args ) ) {
|
148 |
-
if ( function_exists( wp_unslash( $args['custom_dropdown_options_source'] ) ) ) {
|
149 |
-
$allowed_callbacks = UM()->options()->get( 'allowed_choice_callbacks' );
|
150 |
-
if ( ! empty( $allowed_callbacks ) ) {
|
151 |
-
$allowed_callbacks = array_map( 'rtrim', explode( "\n", $allowed_callbacks ) );
|
152 |
-
$allowed_callbacks[] = $args['custom_dropdown_options_source'];
|
153 |
-
} else {
|
154 |
-
$allowed_callbacks = array( $args['custom_dropdown_options_source'] );
|
155 |
-
}
|
156 |
-
$allowed_callbacks = array_unique( $allowed_callbacks );
|
157 |
-
$allowed_callbacks = implode( "\r\n", $allowed_callbacks );
|
158 |
-
|
159 |
-
UM()->options()->update( 'allowed_choice_callbacks', $allowed_callbacks );
|
160 |
-
}
|
161 |
-
}
|
162 |
-
|
163 |
-
unset( $fields[ $id ]['in_row'] );
|
164 |
-
unset( $fields[ $id ]['in_sub_row'] );
|
165 |
-
unset( $fields[ $id ]['in_column'] );
|
166 |
-
unset( $fields[ $id ]['in_group'] );
|
167 |
-
unset( $fields[ $id ]['position'] );
|
168 |
-
|
169 |
-
do_action( 'um_add_new_field', $id, $args );
|
170 |
-
|
171 |
-
update_option( 'um_fields', $fields );
|
172 |
-
}
|
173 |
-
|
174 |
-
|
175 |
-
/**
|
176 |
-
* Updates a field in form only
|
177 |
-
*
|
178 |
-
* @param integer $id
|
179 |
-
* @param array $args
|
180 |
-
* @param integer $form_id
|
181 |
-
*/
|
182 |
-
function update_field( $id, $args, $form_id ) {
|
183 |
-
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
184 |
-
|
185 |
-
if ( $args['type'] == 'row' ) {
|
186 |
-
if ( isset( $fields[ $id ] ) ) {
|
187 |
-
$old_args = $fields[ $id ];
|
188 |
-
foreach ( $old_args as $k => $v ) {
|
189 |
-
if ( ! in_array( $k, array( 'sub_rows', 'cols' ) ) ) {
|
190 |
-
unset( $old_args[ $k ] );
|
191 |
-
}
|
192 |
-
}
|
193 |
-
$args = array_merge( $old_args, $args );
|
194 |
-
}
|
195 |
-
}
|
196 |
-
|
197 |
-
// custom fields support
|
198 |
-
if ( isset( UM()->builtin()->predefined_fields[ $id ] ) && isset( UM()->builtin()->predefined_fields[ $id ]['custom'] ) ) {
|
199 |
-
$args = array_merge( UM()->builtin()->predefined_fields[ $id ], $args );
|
200 |
-
}
|
201 |
-
|
202 |
-
if ( array_key_exists( 'custom_dropdown_options_source', $args ) ) {
|
203 |
-
if ( function_exists( wp_unslash( $args['custom_dropdown_options_source'] ) ) ) {
|
204 |
-
$allowed_callbacks = UM()->options()->get( 'allowed_choice_callbacks' );
|
205 |
-
if ( ! empty( $allowed_callbacks ) ) {
|
206 |
-
$allowed_callbacks = array_map( 'rtrim', explode( "\n", $allowed_callbacks ) );
|
207 |
-
$allowed_callbacks[] = $args['custom_dropdown_options_source'];
|
208 |
-
} else {
|
209 |
-
$allowed_callbacks = array( $args['custom_dropdown_options_source'] );
|
210 |
-
}
|
211 |
-
$allowed_callbacks = array_unique( $allowed_callbacks );
|
212 |
-
$allowed_callbacks = implode( "\r\n", $allowed_callbacks );
|
213 |
-
|
214 |
-
UM()->options()->update( 'allowed_choice_callbacks', $allowed_callbacks );
|
215 |
-
|
216 |
-
$args['custom_dropdown_options_source'] = wp_unslash( $args['custom_dropdown_options_source'] );
|
217 |
-
}
|
218 |
-
}
|
219 |
-
|
220 |
-
$fields[ $id ] = $args;
|
221 |
-
|
222 |
-
// for group field only
|
223 |
-
if ( $args['type'] == 'group' ) {
|
224 |
-
$fields[ $id ]['in_group'] = '';
|
225 |
-
}
|
226 |
-
|
227 |
-
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
228 |
-
}
|
229 |
-
|
230 |
-
|
231 |
-
/**
|
232 |
-
* Deletes a field in form only
|
233 |
-
*
|
234 |
-
* @param integer $id
|
235 |
-
* @param integer $form_id
|
236 |
-
*/
|
237 |
-
function delete_field_from_form( $id, $form_id ) {
|
238 |
-
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
239 |
-
|
240 |
-
if ( isset( $fields[ $id ] ) ) {
|
241 |
-
$condition_fields = get_option( 'um_fields' );
|
242 |
-
|
243 |
-
if( ! is_array( $condition_fields ) ) $condition_fields = array();
|
244 |
-
|
245 |
-
foreach ( $condition_fields as $key => $value ) {
|
246 |
-
$deleted_field = array_search( $id, $value );
|
247 |
-
|
248 |
-
if ( $key != $id && $deleted_field != false ) {
|
249 |
-
$deleted_field_id = str_replace( 'conditional_field', '', $deleted_field );
|
250 |
-
|
251 |
-
if ( $deleted_field_id == '' ) {
|
252 |
-
$arr_id = 0;
|
253 |
-
} else {
|
254 |
-
$arr_id = $deleted_field_id;
|
255 |
-
}
|
256 |
-
|
257 |
-
unset( $condition_fields[ $key ][ 'conditional_action' . $deleted_field_id ] );
|
258 |
-
unset( $condition_fields[ $key ][ $deleted_field ] );
|
259 |
-
unset( $condition_fields[ $key ][ 'conditional_operator' . $deleted_field_id ] );
|
260 |
-
unset( $condition_fields[ $key ][ 'conditional_value' . $deleted_field_id ] );
|
261 |
-
unset( $condition_fields[ $key ]['conditions'][ $arr_id ] );
|
262 |
-
|
263 |
-
unset( $fields[ $key ][ 'conditional_action' . $deleted_field_id ] );
|
264 |
-
unset( $fields[ $key ][ $deleted_field ] );
|
265 |
-
unset( $fields[ $key ][ 'conditional_operator' . $deleted_field_id ] );
|
266 |
-
unset( $fields[ $key ][ 'conditional_value' . $deleted_field_id ] );
|
267 |
-
unset( $fields[ $key ]['conditions'][ $arr_id ] );
|
268 |
-
}
|
269 |
-
}
|
270 |
-
|
271 |
-
update_option( 'um_fields' , $condition_fields );
|
272 |
-
unset( $fields[ $id ] );
|
273 |
-
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
274 |
-
}
|
275 |
-
}
|
276 |
-
|
277 |
-
|
278 |
-
/**
|
279 |
-
* Deletes a field from custom fields
|
280 |
-
*
|
281 |
-
* @param integer $id
|
282 |
-
*/
|
283 |
-
function delete_field_from_db( $id ) {
|
284 |
-
$fields = UM()->builtin()->saved_fields;
|
285 |
-
if ( isset( $fields[ $id ] ) ) {
|
286 |
-
$args = $fields[ $id ];
|
287 |
-
|
288 |
-
unset( $fields[ $id ] );
|
289 |
-
|
290 |
-
do_action( 'um_delete_custom_field', $id, $args );
|
291 |
-
|
292 |
-
update_option( 'um_fields', $fields );
|
293 |
-
|
294 |
-
global $wpdb;
|
295 |
-
$forms = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'um_form'" );
|
296 |
-
foreach ( $forms as $form_id ) {
|
297 |
-
$form_fields = get_post_meta( $form_id, '_um_custom_fields', true );
|
298 |
-
unset( $form_fields[ $id ] );
|
299 |
-
update_post_meta( $form_id, '_um_custom_fields', $form_fields );
|
300 |
-
}
|
301 |
-
|
302 |
-
$directories = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'um_directory'" );
|
303 |
-
foreach ( $directories as $directory_id ) {
|
304 |
-
// Frontend filters
|
305 |
-
$directory_search_fields = get_post_meta( $directory_id, '_um_search_fields', true );
|
306 |
-
$directory_search_fields = array_values( array_diff( $directory_search_fields, array( $id ) ) );
|
307 |
-
update_post_meta( $directory_id, '_um_search_fields', $directory_search_fields );
|
308 |
-
|
309 |
-
// Admin filtering
|
310 |
-
$directory_search_filters = get_post_meta( $directory_id, '_um_search_filters', true );
|
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 |
-
* @param
|
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 |
-
* @param
|
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 |
-
$duplicate['
|
440 |
-
|
441 |
-
$
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
unset( $all_fields[ $new_metakey ]['
|
448 |
-
unset( $all_fields[ $new_metakey ]['
|
449 |
-
unset( $all_fields[ $new_metakey ]['
|
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 |
-
$output = '';
|
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 |
-
$output = '';
|
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 |
-
* @param
|
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 |
-
* @param string $
|
692 |
-
*
|
693 |
-
* @
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
$classes
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
$classes .= '
|
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 |
-
* {"var":"$
|
736 |
-
*
|
737 |
-
*
|
738 |
-
* @
|
739 |
-
*
|
740 |
-
*
|
741 |
-
*
|
742 |
-
*
|
743 |
-
*
|
744 |
-
*
|
745 |
-
*
|
746 |
-
*
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
*
|
758 |
-
*
|
759 |
-
* @param
|
760 |
-
*
|
761 |
-
* @
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
return
|
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 |
-
* {"var":"$
|
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 |
-
} elseif ( !
|
984 |
-
$value = '';
|
985 |
-
}
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
*
|
992 |
-
*
|
993 |
-
* @
|
994 |
-
* @
|
995 |
-
*
|
996 |
-
*
|
997 |
-
* {"var":"$
|
998 |
-
* {"var":"$
|
999 |
-
* {"var":"$
|
1000 |
-
*
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
*
|
1010 |
-
*
|
1011 |
-
*
|
1012 |
-
*
|
1013 |
-
* @param
|
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 |
-
* {"var":"$value","type":"string","desc":"Selected filter value"}
|
1100 |
-
*
|
1101 |
-
*
|
1102 |
-
* @
|
1103 |
-
*
|
1104 |
-
*
|
1105 |
-
*
|
1106 |
-
*
|
1107 |
-
*
|
1108 |
-
*
|
1109 |
-
*
|
1110 |
-
*
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
*
|
1118 |
-
*
|
1119 |
-
* @
|
1120 |
-
* @
|
1121 |
-
*
|
1122 |
-
*
|
1123 |
-
* {"var":"$
|
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 |
-
* @param
|
1210 |
-
*
|
1211 |
-
* @
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
return true;
|
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 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
*
|
1297 |
-
*
|
1298 |
-
* @param string $
|
1299 |
-
*
|
1300 |
-
* @
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
$
|
1319 |
-
|
1320 |
-
$arr_options = call_user_func( $data['custom_dropdown_options_source'] );
|
1321 |
-
}
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
return $arr_options[ $
|
1330 |
-
}
|
1331 |
-
return '';
|
1332 |
-
}
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
$values =
|
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 |
-
$arr_options = call_user_func( $data['custom_dropdown_options_source'] );
|
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 |
-
$label =
|
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 |
-
case '
|
1563 |
-
case '
|
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 |
-
$array['borderwidth'] =
|
1742 |
-
}
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
$array['bordercolor'] = '
|
1748 |
-
}
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
$array['borderstyle'] = '
|
1754 |
-
}
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
$array['crop_data'] =
|
1772 |
-
} elseif ( $array['crop'] ==
|
1773 |
-
$array['crop_data'] = '
|
1774 |
-
}
|
1775 |
-
$array['crop_data'] = '
|
1776 |
-
}
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
$array['crop_class'] = '';
|
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 |
-
$array['allowed_types'] =
|
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 |
-
$array['allowed_types'] =
|
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 |
-
* @param
|
1992 |
-
* @param array $
|
1993 |
-
*
|
1994 |
-
* @
|
1995 |
-
*
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
$
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
* @var
|
2014 |
-
* @var
|
2015 |
-
* @var
|
2016 |
-
* @var
|
2017 |
-
* @var string $
|
2018 |
-
* @var
|
2019 |
-
* @var
|
2020 |
-
* @var string $
|
2021 |
-
* @var
|
2022 |
-
* @var string $
|
2023 |
-
* @var
|
2024 |
-
* @var
|
2025 |
-
* @var
|
2026 |
-
* @var boolean $
|
2027 |
-
* @var
|
2028 |
-
* @var
|
2029 |
-
* @var
|
2030 |
-
* @var string $
|
2031 |
-
* @var string $
|
2032 |
-
* @var string $
|
2033 |
-
* @var string $
|
2034 |
-
* @var string $
|
2035 |
-
* @var string $
|
2036 |
-
* @var string $
|
2037 |
-
* @var string $
|
2038 |
-
* @var string $
|
2039 |
-
* @var string $
|
2040 |
-
* @var string $
|
2041 |
-
* @var string $
|
2042 |
-
* @var string $
|
2043 |
-
* @var string $
|
2044 |
-
* @var string $
|
2045 |
-
* @var string $
|
2046 |
-
* @var string $
|
2047 |
-
* @var string $
|
2048 |
-
* @var string $
|
2049 |
-
* @var string $
|
2050 |
-
* @var string $
|
2051 |
-
* @var string $
|
2052 |
-
* @var string $
|
2053 |
-
* @var string $
|
2054 |
-
* @var string $
|
2055 |
-
* @var string $
|
2056 |
-
* @var string $
|
2057 |
-
* @var string $
|
2058 |
-
* @var string $
|
2059 |
-
* @var string $
|
2060 |
-
* @var string $
|
2061 |
-
* @var string $
|
2062 |
-
* @var string $
|
2063 |
-
* @var string $
|
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 |
-
* {"var":"$
|
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 |
-
case '
|
2252 |
-
case '
|
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 |
-
$output .= $this->
|
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 |
-
$output .= $this->
|
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 |
-
$output .= $this->
|
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 |
-
$output .= $this->
|
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 |
-
$output .= $this->
|
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 |
-
$output .= $this->
|
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 |
-
$placeholder =
|
2501 |
-
} elseif( isset( $data['label'] ) ) {
|
2502 |
-
$placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $
|
2503 |
-
}
|
2504 |
-
|
2505 |
-
|
2506 |
-
|
2507 |
-
|
2508 |
-
|
2509 |
-
|
2510 |
-
|
2511 |
-
|
2512 |
-
|
2513 |
-
|
2514 |
-
$output .= $this->
|
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 |
-
$output .= $this->
|
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 |
-
$output .= $this->
|
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 |
-
$output .= $this->
|
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 |
-
$output .= $this->
|
2693 |
-
}
|
2694 |
-
|
2695 |
-
|
2696 |
-
|
2697 |
-
|
2698 |
-
|
2699 |
-
|
2700 |
-
|
2701 |
-
|
2702 |
-
|
2703 |
-
|
2704 |
-
|
2705 |
-
|
2706 |
-
|
2707 |
-
|
2708 |
-
$output .= '<div class="um-
|
2709 |
-
|
2710 |
-
|
2711 |
-
|
2712 |
-
|
2713 |
-
|
2714 |
-
$output .= $this->
|
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 |
-
$field_value =
|
2742 |
-
}
|
2743 |
-
|
2744 |
-
|
2745 |
-
|
2746 |
-
|
2747 |
-
|
2748 |
-
|
2749 |
-
|
2750 |
-
|
2751 |
-
|
2752 |
-
|
2753 |
-
|
2754 |
-
|
2755 |
-
$image_info =
|
2756 |
-
}
|
2757 |
-
|
2758 |
-
|
2759 |
-
|
2760 |
-
|
2761 |
-
$imgValue = UM()->
|
2762 |
-
}
|
2763 |
-
|
2764 |
-
|
2765 |
-
$img = '';
|
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 |
-
$output .= '<div class="um-modal-
|
2795 |
-
|
2796 |
-
|
2797 |
-
|
2798 |
-
|
2799 |
-
$
|
2800 |
-
|
2801 |
-
|
2802 |
-
|
2803 |
-
|
2804 |
-
$
|
2805 |
-
$output .= '<div class="um-
|
2806 |
-
|
2807 |
-
|
2808 |
-
|
2809 |
-
|
2810 |
-
|
2811 |
-
|
2812 |
-
|
2813 |
-
|
2814 |
-
|
2815 |
-
|
2816 |
-
|
2817 |
-
|
2818 |
-
|
2819 |
-
$output .= $this->
|
2820 |
-
}
|
2821 |
-
|
2822 |
-
|
2823 |
-
|
2824 |
-
|
2825 |
-
|
2826 |
-
|
2827 |
-
|
2828 |
-
|
2829 |
-
|
2830 |
-
|
2831 |
-
|
2832 |
-
|
2833 |
-
|
2834 |
-
|
2835 |
-
$
|
2836 |
-
|
2837 |
-
|
2838 |
-
|
2839 |
-
|
2840 |
-
|
2841 |
-
|
2842 |
-
|
2843 |
-
$file_info =
|
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 |
-
$output .= '<div class="um-modal-
|
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 |
-
$output .= $this->
|
2927 |
-
}
|
2928 |
-
|
2929 |
-
|
2930 |
-
|
2931 |
-
|
2932 |
-
|
2933 |
-
|
2934 |
-
|
2935 |
-
|
2936 |
-
|
2937 |
-
|
2938 |
-
|
2939 |
-
|
2940 |
-
$class = 'um-
|
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 |
-
|
3046 |
-
|
3047 |
-
*
|
3048 |
-
*
|
3049 |
-
* @
|
3050 |
-
* @
|
3051 |
-
*
|
3052 |
-
*
|
3053 |
-
*
|
3054 |
-
*
|
3055 |
-
* @
|
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 |
-
$options =
|
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 |
-
|
3168 |
-
|
3169 |
-
|
3170 |
-
|
3171 |
-
|
3172 |
-
|
3173 |
-
|
3174 |
-
|
3175 |
-
|
3176 |
-
|
3177 |
-
|
3178 |
-
|
3179 |
-
|
3180 |
-
|
3181 |
-
|
3182 |
-
|
3183 |
-
$output .= '<
|
3184 |
-
|
3185 |
-
|
3186 |
-
|
3187 |
-
|
3188 |
-
|
3189 |
-
|
3190 |
-
|
3191 |
-
$
|
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 |
-
$output .= '</
|
3229 |
-
|
3230 |
-
|
3231 |
-
|
3232 |
-
|
3233 |
-
|
3234 |
-
$output .= $this->
|
3235 |
-
}
|
3236 |
-
|
3237 |
-
|
3238 |
-
|
3239 |
-
|
3240 |
-
|
3241 |
-
|
3242 |
-
|
3243 |
-
|
3244 |
-
|
3245 |
-
|
3246 |
-
$
|
3247 |
-
|
3248 |
-
|
3249 |
-
|
3250 |
-
|
3251 |
-
$class = 'um-
|
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 |
-
|
3388 |
-
$
|
3389 |
-
|
3390 |
-
|
3391 |
-
|
3392 |
-
|
3393 |
-
|
3394 |
-
|
3395 |
-
$
|
3396 |
-
|
3397 |
-
|
3398 |
-
|
3399 |
-
|
3400 |
-
|
3401 |
-
|
3402 |
-
|
3403 |
-
|
3404 |
-
|
3405 |
-
$
|
3406 |
-
|
3407 |
-
|
3408 |
-
|
3409 |
-
|
3410 |
-
|
3411 |
-
|
3412 |
-
|
3413 |
-
|
3414 |
-
|
3415 |
-
|
3416 |
-
|
3417 |
-
|
3418 |
-
|
3419 |
-
|
3420 |
-
|
3421 |
-
|
3422 |
-
|
3423 |
-
|
3424 |
-
|
3425 |
-
|
3426 |
-
|
3427 |
-
|
3428 |
-
|
3429 |
-
|
3430 |
-
|
3431 |
-
$output .= $this->
|
3432 |
-
}
|
3433 |
-
|
3434 |
-
|
3435 |
-
|
3436 |
-
|
3437 |
-
|
3438 |
-
|
3439 |
-
|
3440 |
-
|
3441 |
-
|
3442 |
-
|
3443 |
-
|
3444 |
-
*
|
3445 |
-
*
|
3446 |
-
* @
|
3447 |
-
* @
|
3448 |
-
*
|
3449 |
-
*
|
3450 |
-
*
|
3451 |
-
*
|
3452 |
-
* @
|
3453 |
-
*
|
3454 |
-
*
|
3455 |
-
*
|
3456 |
-
*
|
3457 |
-
*
|
3458 |
-
*
|
3459 |
-
*
|
3460 |
-
*
|
3461 |
-
|
3462 |
-
|
3463 |
-
|
3464 |
-
|
3465 |
-
|
3466 |
-
*
|
3467 |
-
*
|
3468 |
-
* @
|
3469 |
-
* @
|
3470 |
-
*
|
3471 |
-
* @
|
3472 |
-
* ["
|
3473 |
-
* @
|
3474 |
-
*
|
3475 |
-
*
|
3476 |
-
*
|
3477 |
-
*
|
3478 |
-
*
|
3479 |
-
*
|
3480 |
-
*
|
3481 |
-
*
|
3482 |
-
|
3483 |
-
|
3484 |
-
|
3485 |
-
|
3486 |
-
|
3487 |
-
|
3488 |
-
|
3489 |
-
|
3490 |
-
|
3491 |
-
|
3492 |
-
|
3493 |
-
|
3494 |
-
$
|
3495 |
-
|
3496 |
-
|
3497 |
-
|
3498 |
-
|
3499 |
-
|
3500 |
-
|
3501 |
-
|
3502 |
-
|
3503 |
-
*
|
3504 |
-
*
|
3505 |
-
* @
|
3506 |
-
* @
|
3507 |
-
*
|
3508 |
-
*
|
3509 |
-
|
3510 |
-
|
3511 |
-
|
3512 |
-
|
3513 |
-
|
3514 |
-
|
3515 |
-
|
3516 |
-
|
3517 |
-
|
3518 |
-
$
|
3519 |
-
|
3520 |
-
|
3521 |
-
|
3522 |
-
|
3523 |
-
|
3524 |
-
|
3525 |
-
|
3526 |
-
|
3527 |
-
|
3528 |
-
|
3529 |
-
|
3530 |
-
|
3531 |
-
|
3532 |
-
|
3533 |
-
|
3534 |
-
|
3535 |
-
|
3536 |
-
$col_class = '';
|
3537 |
-
}
|
3538 |
-
|
3539 |
-
|
3540 |
-
|
3541 |
-
|
3542 |
-
|
3543 |
-
$
|
3544 |
-
|
3545 |
-
|
3546 |
-
|
3547 |
-
|
3548 |
-
|
3549 |
-
|
3550 |
-
|
3551 |
-
|
3552 |
-
|
3553 |
-
|
3554 |
-
$
|
3555 |
-
|
3556 |
-
$
|
3557 |
-
|
3558 |
-
|
3559 |
-
|
3560 |
-
|
3561 |
-
|
3562 |
-
|
3563 |
-
|
3564 |
-
|
3565 |
-
$output .= '
|
3566 |
-
|
3567 |
-
$output .= '
|
3568 |
-
|
3569 |
-
|
3570 |
-
|
3571 |
-
|
3572 |
-
|
3573 |
-
|
3574 |
-
|
3575 |
-
|
3576 |
-
|
3577 |
-
|
3578 |
-
|
3579 |
-
|
3580 |
-
|
3581 |
-
|
3582 |
-
|
3583 |
-
|
3584 |
-
$output .= '
|
3585 |
-
|
3586 |
-
|
3587 |
-
|
3588 |
-
|
3589 |
-
$output .= $this->
|
3590 |
-
}
|
3591 |
-
|
3592 |
-
|
3593 |
-
|
3594 |
-
|
3595 |
-
|
3596 |
-
|
3597 |
-
|
3598 |
-
|
3599 |
-
|
3600 |
-
|
3601 |
-
|
3602 |
-
*
|
3603 |
-
*
|
3604 |
-
* @
|
3605 |
-
* @
|
3606 |
-
*
|
3607 |
-
*
|
3608 |
-
*
|
3609 |
-
*
|
3610 |
-
* @
|
3611 |
-
*
|
3612 |
-
*
|
3613 |
-
*
|
3614 |
-
*
|
3615 |
-
*
|
3616 |
-
*
|
3617 |
-
*
|
3618 |
-
*
|
3619 |
-
|
3620 |
-
|
3621 |
-
|
3622 |
-
|
3623 |
-
|
3624 |
-
*
|
3625 |
-
*
|
3626 |
-
* @
|
3627 |
-
* @
|
3628 |
-
*
|
3629 |
-
* @
|
3630 |
-
* ["
|
3631 |
-
* @
|
3632 |
-
*
|
3633 |
-
*
|
3634 |
-
*
|
3635 |
-
*
|
3636 |
-
*
|
3637 |
-
*
|
3638 |
-
*
|
3639 |
-
*
|
3640 |
-
|
3641 |
-
|
3642 |
-
|
3643 |
-
|
3644 |
-
|
3645 |
-
|
3646 |
-
|
3647 |
-
|
3648 |
-
|
3649 |
-
|
3650 |
-
|
3651 |
-
|
3652 |
-
|
3653 |
-
|
3654 |
-
|
3655 |
-
|
3656 |
-
|
3657 |
-
|
3658 |
-
|
3659 |
-
$
|
3660 |
-
|
3661 |
-
|
3662 |
-
|
3663 |
-
$col_class = '';
|
3664 |
-
}
|
3665 |
-
|
3666 |
-
|
3667 |
-
|
3668 |
-
|
3669 |
-
|
3670 |
-
$
|
3671 |
-
|
3672 |
-
|
3673 |
-
|
3674 |
-
|
3675 |
-
|
3676 |
-
|
3677 |
-
|
3678 |
-
|
3679 |
-
|
3680 |
-
$
|
3681 |
-
|
3682 |
-
$
|
3683 |
-
|
3684 |
-
$
|
3685 |
-
|
3686 |
-
|
3687 |
-
|
3688 |
-
|
3689 |
-
|
3690 |
-
|
3691 |
-
|
3692 |
-
|
3693 |
-
|
3694 |
-
|
3695 |
-
|
3696 |
-
|
3697 |
-
|
3698 |
-
|
3699 |
-
|
3700 |
-
|
3701 |
-
*
|
3702 |
-
*
|
3703 |
-
* @
|
3704 |
-
* @
|
3705 |
-
*
|
3706 |
-
*
|
3707 |
-
* {"var":"$
|
3708 |
-
* {"var":"$
|
3709 |
-
*
|
3710 |
-
*
|
3711 |
-
* @
|
3712 |
-
*
|
3713 |
-
*
|
3714 |
-
*
|
3715 |
-
*
|
3716 |
-
*
|
3717 |
-
*
|
3718 |
-
*
|
3719 |
-
*
|
3720 |
-
|
3721 |
-
|
3722 |
-
|
3723 |
-
$
|
3724 |
-
|
3725 |
-
|
3726 |
-
|
3727 |
-
|
3728 |
-
|
3729 |
-
|
3730 |
-
|
3731 |
-
|
3732 |
-
|
3733 |
-
$output .= '
|
3734 |
-
|
3735 |
-
|
3736 |
-
|
3737 |
-
|
3738 |
-
|
3739 |
-
$output .= $this->
|
3740 |
-
}
|
3741 |
-
|
3742 |
-
|
3743 |
-
|
3744 |
-
|
3745 |
-
|
3746 |
-
|
3747 |
-
|
3748 |
-
|
3749 |
-
|
3750 |
-
|
3751 |
-
|
3752 |
-
|
3753 |
-
|
3754 |
-
|
3755 |
-
|
3756 |
-
|
3757 |
-
$content =
|
3758 |
-
}
|
3759 |
-
|
3760 |
-
|
3761 |
-
|
3762 |
-
|
3763 |
-
|
3764 |
-
|
3765 |
-
|
3766 |
-
|
3767 |
-
|
3768 |
-
|
3769 |
-
|
3770 |
-
|
3771 |
-
$output .= '<div class="um-field-group
|
3772 |
-
|
3773 |
-
|
3774 |
-
|
3775 |
-
|
3776 |
-
|
3777 |
-
|
3778 |
-
|
3779 |
-
|
3780 |
-
|
3781 |
-
|
3782 |
-
|
3783 |
-
|
3784 |
-
|
3785 |
-
|
3786 |
-
|
3787 |
-
|
3788 |
-
|
3789 |
-
|
3790 |
-
|
3791 |
-
*
|
3792 |
-
*
|
3793 |
-
* @
|
3794 |
-
* @
|
3795 |
-
*
|
3796 |
-
*
|
3797 |
-
*
|
3798 |
-
*
|
3799 |
-
* @
|
3800 |
-
*
|
3801 |
-
*
|
3802 |
-
*
|
3803 |
-
*
|
3804 |
-
*
|
3805 |
-
*
|
3806 |
-
*
|
3807 |
-
*
|
3808 |
-
|
3809 |
-
|
3810 |
-
|
3811 |
-
|
3812 |
-
|
3813 |
-
|
3814 |
-
|
3815 |
-
|
3816 |
-
|
3817 |
-
|
3818 |
-
|
3819 |
-
*
|
3820 |
-
*
|
3821 |
-
* @
|
3822 |
-
|
3823 |
-
|
3824 |
-
|
3825 |
-
|
3826 |
-
|
3827 |
-
|
3828 |
-
|
3829 |
-
|
3830 |
-
|
3831 |
-
|
3832 |
-
|
3833 |
-
|
3834 |
-
|
3835 |
-
$
|
3836 |
-
|
3837 |
-
|
3838 |
-
|
3839 |
-
|
3840 |
-
|
3841 |
-
|
3842 |
-
|
3843 |
-
|
3844 |
-
|
3845 |
-
|
3846 |
-
|
3847 |
-
|
3848 |
-
|
3849 |
-
$intersected_options[ $
|
3850 |
-
}
|
3851 |
-
|
3852 |
-
|
3853 |
-
|
3854 |
-
|
3855 |
-
$options = $
|
3856 |
-
}
|
3857 |
-
|
3858 |
-
|
3859 |
-
|
3860 |
-
|
3861 |
-
|
3862 |
-
|
3863 |
-
|
3864 |
-
|
3865 |
-
*
|
3866 |
-
*
|
3867 |
-
* @param
|
3868 |
-
*
|
3869 |
-
* @
|
3870 |
-
|
3871 |
-
|
3872 |
-
|
3873 |
-
|
3874 |
-
|
3875 |
-
|
3876 |
-
|
3877 |
-
|
3878 |
-
|
3879 |
-
|
3880 |
-
|
3881 |
-
|
3882 |
-
|
3883 |
-
}
|
3884 |
-
|
3885 |
-
|
3886 |
-
|
3887 |
-
|
3888 |
-
|
3889 |
-
|
3890 |
-
|
3891 |
-
|
3892 |
-
|
3893 |
-
|
3894 |
-
|
3895 |
-
*
|
3896 |
-
*
|
3897 |
-
* @
|
3898 |
-
|
3899 |
-
|
3900 |
-
|
3901 |
-
|
3902 |
-
|
3903 |
-
|
3904 |
-
|
3905 |
-
|
3906 |
-
|
3907 |
-
|
3908 |
-
|
3909 |
-
|
3910 |
-
|
3911 |
-
|
3912 |
-
|
3913 |
-
|
3914 |
-
|
3915 |
-
|
3916 |
-
|
3917 |
-
*
|
3918 |
-
*
|
3919 |
-
*
|
3920 |
-
* @
|
3921 |
-
|
3922 |
-
|
3923 |
-
|
3924 |
-
|
3925 |
-
|
3926 |
-
|
3927 |
-
|
3928 |
-
|
3929 |
-
|
3930 |
-
|
3931 |
-
|
3932 |
-
|
3933 |
-
|
3934 |
-
|
3935 |
-
|
3936 |
-
|
3937 |
-
|
3938 |
-
|
3939 |
-
*
|
3940 |
-
*
|
3941 |
-
* @
|
3942 |
-
|
3943 |
-
|
3944 |
-
|
3945 |
-
|
3946 |
-
|
3947 |
-
|
3948 |
-
|
3949 |
-
|
3950 |
-
|
3951 |
-
|
3952 |
-
|
3953 |
-
|
3954 |
-
|
3955 |
-
|
3956 |
-
|
3957 |
-
*
|
3958 |
-
*
|
3959 |
-
*
|
3960 |
-
* @
|
3961 |
-
|
3962 |
-
|
3963 |
-
|
3964 |
-
|
3965 |
-
|
3966 |
-
|
3967 |
-
|
3968 |
-
|
3969 |
-
|
3970 |
-
|
3971 |
-
|
3972 |
-
|
3973 |
-
|
3974 |
-
|
3975 |
-
|
3976 |
-
*
|
3977 |
-
*
|
3978 |
-
*
|
3979 |
-
* @
|
3980 |
-
*
|
3981 |
-
|
3982 |
-
|
3983 |
-
|
3984 |
-
|
3985 |
-
$
|
3986 |
-
|
3987 |
-
|
3988 |
-
|
3989 |
-
|
3990 |
-
|
3991 |
-
|
3992 |
-
|
3993 |
-
|
3994 |
-
|
3995 |
-
|
3996 |
-
|
3997 |
-
$this->
|
3998 |
-
|
3999 |
-
|
4000 |
-
|
4001 |
-
|
4002 |
-
|
4003 |
-
|
4004 |
-
|
4005 |
-
|
4006 |
-
|
4007 |
-
|
4008 |
-
|
4009 |
-
|
4010 |
-
|
4011 |
-
|
4012 |
-
|
4013 |
-
|
4014 |
-
|
4015 |
-
|
4016 |
-
|
4017 |
-
|
4018 |
-
'
|
4019 |
-
'
|
4020 |
-
|
4021 |
-
|
4022 |
-
|
4023 |
-
|
4024 |
-
|
4025 |
-
|
4026 |
-
|
4027 |
-
|
4028 |
-
|
4029 |
-
|
4030 |
-
|
4031 |
-
|
4032 |
-
$
|
4033 |
-
|
4034 |
-
|
4035 |
-
|
4036 |
-
|
4037 |
-
|
4038 |
-
|
4039 |
-
|
4040 |
-
|
4041 |
-
|
4042 |
-
|
4043 |
-
$col_split =
|
4044 |
-
}
|
4045 |
-
|
4046 |
-
|
4047 |
-
|
4048 |
-
|
4049 |
-
|
4050 |
-
|
4051 |
-
|
4052 |
-
|
4053 |
-
|
4054 |
-
|
4055 |
-
|
4056 |
-
|
4057 |
-
|
4058 |
-
|
4059 |
-
|
4060 |
-
|
4061 |
-
|
4062 |
-
|
4063 |
-
|
4064 |
-
|
4065 |
-
|
4066 |
-
|
4067 |
-
|
4068 |
-
|
4069 |
-
|
4070 |
-
|
4071 |
-
|
4072 |
-
|
4073 |
-
|
4074 |
-
|
4075 |
-
|
4076 |
-
|
4077 |
-
|
4078 |
-
$output .= '
|
4079 |
-
|
4080 |
-
|
4081 |
-
|
4082 |
-
|
4083 |
-
|
4084 |
-
|
4085 |
-
|
4086 |
-
|
4087 |
-
|
4088 |
-
|
4089 |
-
|
4090 |
-
|
4091 |
-
|
4092 |
-
|
4093 |
-
|
4094 |
-
|
4095 |
-
|
4096 |
-
|
4097 |
-
|
4098 |
-
$output .= '
|
4099 |
-
|
4100 |
-
|
4101 |
-
|
4102 |
-
|
4103 |
-
|
4104 |
-
|
4105 |
-
|
4106 |
-
|
4107 |
-
$output .= '
|
4108 |
-
|
4109 |
-
|
4110 |
-
|
4111 |
-
|
4112 |
-
|
4113 |
-
|
4114 |
-
|
4115 |
-
|
4116 |
-
|
4117 |
-
|
4118 |
-
|
4119 |
-
|
4120 |
-
|
4121 |
-
|
4122 |
-
|
4123 |
-
|
4124 |
-
|
4125 |
-
|
4126 |
-
|
4127 |
-
|
4128 |
-
|
4129 |
-
|
4130 |
-
|
4131 |
-
|
4132 |
-
|
4133 |
-
|
4134 |
-
|
4135 |
-
|
4136 |
-
|
4137 |
-
*
|
4138 |
-
*
|
4139 |
-
* @param
|
4140 |
-
*
|
4141 |
-
* @
|
4142 |
-
*
|
4143 |
-
|
4144 |
-
|
4145 |
-
|
4146 |
-
|
4147 |
-
|
4148 |
-
|
4149 |
-
|
4150 |
-
|
4151 |
-
|
4152 |
-
|
4153 |
-
|
4154 |
-
|
4155 |
-
* @var $
|
4156 |
-
* @var $
|
4157 |
-
* @var $
|
4158 |
-
* @var $
|
4159 |
-
* @var $
|
4160 |
-
* @var $
|
4161 |
-
* @var $
|
4162 |
-
* @var $
|
4163 |
-
* @var $
|
4164 |
-
* @var $
|
4165 |
-
|
4166 |
-
|
4167 |
-
|
4168 |
-
|
4169 |
-
|
4170 |
-
|
4171 |
-
|
4172 |
-
|
4173 |
-
|
4174 |
-
|
4175 |
-
|
4176 |
-
|
4177 |
-
|
4178 |
-
|
4179 |
-
|
4180 |
-
|
4181 |
-
|
4182 |
-
|
4183 |
-
|
4184 |
-
|
4185 |
-
|
4186 |
-
if
|
4187 |
-
|
4188 |
-
|
4189 |
-
|
4190 |
-
|
4191 |
-
|
4192 |
-
|
4193 |
-
|
4194 |
-
|
4195 |
-
|
4196 |
-
|
4197 |
-
|
4198 |
-
|
4199 |
-
|
4200 |
-
|
4201 |
-
|
4202 |
-
|
4203 |
-
|
4204 |
-
|
4205 |
-
|
4206 |
-
|
4207 |
-
|
4208 |
-
|
4209 |
-
|
4210 |
-
|
4211 |
-
|
4212 |
-
|
4213 |
-
|
4214 |
-
|
4215 |
-
|
4216 |
-
|
4217 |
-
|
4218 |
-
|
4219 |
-
|
4220 |
-
|
4221 |
-
|
4222 |
-
|
4223 |
-
|
4224 |
-
|
4225 |
-
|
4226 |
-
|
4227 |
-
|
4228 |
-
|
4229 |
-
|
4230 |
-
|
4231 |
-
|
4232 |
-
|
4233 |
-
|
4234 |
-
|
4235 |
-
|
4236 |
-
|
4237 |
-
|
4238 |
-
|
4239 |
-
|
4240 |
-
|
4241 |
-
|
4242 |
-
|
4243 |
-
$res =
|
4244 |
-
}
|
4245 |
-
|
4246 |
-
|
4247 |
-
|
4248 |
-
|
4249 |
-
|
4250 |
-
|
4251 |
-
|
4252 |
-
|
4253 |
-
*
|
4254 |
-
*
|
4255 |
-
* @
|
4256 |
-
* @
|
4257 |
-
*
|
4258 |
-
*
|
4259 |
-
* {"var":"$
|
4260 |
-
*
|
4261 |
-
*
|
4262 |
-
* @
|
4263 |
-
*
|
4264 |
-
*
|
4265 |
-
*
|
4266 |
-
*
|
4267 |
-
*
|
4268 |
-
*
|
4269 |
-
*
|
4270 |
-
*
|
4271 |
-
|
4272 |
-
|
4273 |
-
|
4274 |
-
|
4275 |
-
|
4276 |
-
*
|
4277 |
-
*
|
4278 |
-
* @
|
4279 |
-
* @
|
4280 |
-
*
|
4281 |
-
*
|
4282 |
-
*
|
4283 |
-
*
|
4284 |
-
* @
|
4285 |
-
*
|
4286 |
-
*
|
4287 |
-
*
|
4288 |
-
*
|
4289 |
-
*
|
4290 |
-
*
|
4291 |
-
*
|
4292 |
-
*
|
4293 |
-
|
4294 |
-
|
4295 |
-
|
4296 |
-
$
|
4297 |
-
|
4298 |
-
|
4299 |
-
|
4300 |
-
|
4301 |
-
|
4302 |
-
|
4303 |
-
|
4304 |
-
$output
|
4305 |
-
|
4306 |
-
$output .= '
|
4307 |
-
|
4308 |
-
$output .= '</div>';
|
4309 |
-
|
4310 |
-
|
4311 |
-
|
4312 |
-
|
4313 |
-
|
4314 |
-
|
4315 |
-
|
4316 |
-
|
4317 |
-
|
4318 |
-
|
4319 |
-
|
4320 |
-
|
4321 |
-
|
4322 |
-
|
4323 |
-
|
4324 |
-
|
4325 |
-
|
4326 |
-
$content =
|
4327 |
-
}
|
4328 |
-
|
4329 |
-
|
4330 |
-
|
4331 |
-
|
4332 |
-
|
4333 |
-
|
4334 |
-
|
4335 |
-
|
4336 |
-
|
4337 |
-
|
4338 |
-
|
4339 |
-
|
4340 |
-
|
4341 |
-
|
4342 |
-
|
4343 |
-
|
4344 |
-
|
4345 |
-
|
4346 |
-
|
4347 |
-
|
4348 |
-
|
4349 |
-
|
4350 |
-
|
4351 |
-
|
4352 |
-
|
4353 |
-
|
4354 |
-
|
4355 |
-
|
4356 |
-
|
4357 |
-
|
4358 |
-
|
4359 |
-
|
4360 |
-
|
4361 |
-
|
4362 |
-
|
4363 |
-
|
4364 |
-
|
4365 |
-
|
4366 |
-
|
4367 |
-
|
4368 |
-
|
4369 |
-
|
4370 |
-
|
4371 |
-
|
4372 |
-
|
4373 |
-
|
4374 |
-
|
4375 |
-
|
4376 |
-
|
4377 |
-
*
|
4378 |
-
*
|
4379 |
-
* @
|
4380 |
-
* @
|
4381 |
-
*
|
4382 |
-
*
|
4383 |
-
*
|
4384 |
-
*
|
4385 |
-
* @
|
4386 |
-
*
|
4387 |
-
*
|
4388 |
-
*
|
4389 |
-
*
|
4390 |
-
*
|
4391 |
-
*
|
4392 |
-
*
|
4393 |
-
*
|
4394 |
-
|
4395 |
-
|
4396 |
-
|
4397 |
-
|
4398 |
-
|
4399 |
-
*
|
4400 |
-
*
|
4401 |
-
* @
|
4402 |
-
* @
|
4403 |
-
*
|
4404 |
-
*
|
4405 |
-
*
|
4406 |
-
*
|
4407 |
-
* @
|
4408 |
-
*
|
4409 |
-
*
|
4410 |
-
*
|
4411 |
-
*
|
4412 |
-
*
|
4413 |
-
*
|
4414 |
-
*
|
4415 |
-
*
|
4416 |
-
|
4417 |
-
|
4418 |
-
|
4419 |
-
|
4420 |
-
|
4421 |
-
|
4422 |
-
|
4423 |
-
|
4424 |
-
|
4425 |
-
|
4426 |
-
|
4427 |
-
*
|
4428 |
-
*
|
4429 |
-
* @
|
4430 |
-
|
4431 |
-
|
4432 |
-
|
4433 |
-
|
4434 |
-
|
4435 |
-
*
|
4436 |
-
*
|
4437 |
-
* @
|
4438 |
-
* @
|
4439 |
-
*
|
4440 |
-
* @
|
4441 |
-
* ["
|
4442 |
-
* @
|
4443 |
-
*
|
4444 |
-
*
|
4445 |
-
*
|
4446 |
-
*
|
4447 |
-
*
|
4448 |
-
*
|
4449 |
-
*
|
4450 |
-
*
|
4451 |
-
|
4452 |
-
|
4453 |
-
|
4454 |
-
|
4455 |
-
|
4456 |
-
|
4457 |
-
|
4458 |
-
|
4459 |
-
*
|
4460 |
-
*
|
4461 |
-
*
|
4462 |
-
* @
|
4463 |
-
*
|
4464 |
-
|
4465 |
-
|
4466 |
-
|
4467 |
-
|
4468 |
-
$
|
4469 |
-
|
4470 |
-
|
4471 |
-
|
4472 |
-
|
4473 |
-
|
4474 |
-
|
4475 |
-
$this->
|
4476 |
-
|
4477 |
-
|
4478 |
-
|
4479 |
-
|
4480 |
-
|
4481 |
-
|
4482 |
-
|
4483 |
-
|
4484 |
-
|
4485 |
-
|
4486 |
-
$emo =
|
4487 |
-
}
|
4488 |
-
|
4489 |
-
|
4490 |
-
|
4491 |
-
|
4492 |
-
|
4493 |
-
|
4494 |
-
|
4495 |
-
|
4496 |
-
|
4497 |
-
|
4498 |
-
|
4499 |
-
|
4500 |
-
|
4501 |
-
|
4502 |
-
|
4503 |
-
|
4504 |
-
|
4505 |
-
|
4506 |
-
|
4507 |
-
|
4508 |
-
|
4509 |
-
|
4510 |
-
|
4511 |
-
|
4512 |
-
|
4513 |
-
|
4514 |
-
|
4515 |
-
|
4516 |
-
|
4517 |
-
|
4518 |
-
|
4519 |
-
|
4520 |
-
|
4521 |
-
|
4522 |
-
|
4523 |
-
|
4524 |
-
|
4525 |
-
|
4526 |
-
|
4527 |
-
|
4528 |
-
|
4529 |
-
|
4530 |
-
|
4531 |
-
|
4532 |
-
|
4533 |
-
|
4534 |
-
|
4535 |
-
|
4536 |
-
|
4537 |
-
|
4538 |
-
|
4539 |
-
|
4540 |
-
|
4541 |
-
|
4542 |
-
|
4543 |
-
|
4544 |
-
|
4545 |
-
|
4546 |
-
|
4547 |
-
|
4548 |
-
|
4549 |
-
|
4550 |
-
|
4551 |
-
|
4552 |
-
|
4553 |
-
|
4554 |
-
|
4555 |
-
|
4556 |
-
|
4557 |
-
|
4558 |
-
|
4559 |
-
|
4560 |
-
|
4561 |
-
|
4562 |
-
|
4563 |
-
$output .= '
|
4564 |
-
|
4565 |
-
|
4566 |
-
|
4567 |
-
|
4568 |
-
|
4569 |
-
|
4570 |
-
|
4571 |
-
|
4572 |
-
|
4573 |
-
|
4574 |
-
|
4575 |
-
|
4576 |
-
|
4577 |
-
$output .= '
|
4578 |
-
|
4579 |
-
$
|
4580 |
-
|
4581 |
-
|
4582 |
-
|
4583 |
-
|
4584 |
-
|
4585 |
-
|
4586 |
-
|
4587 |
-
|
4588 |
-
|
4589 |
-
$output .= '
|
4590 |
-
|
4591 |
-
|
4592 |
-
|
4593 |
-
|
4594 |
-
|
4595 |
-
|
4596 |
-
|
4597 |
-
|
4598 |
-
|
4599 |
-
|
4600 |
-
|
4601 |
-
|
4602 |
-
|
4603 |
-
$output .= '
|
4604 |
-
|
4605 |
-
$
|
4606 |
-
|
4607 |
-
|
4608 |
-
|
4609 |
-
|
4610 |
-
|
4611 |
-
|
4612 |
-
|
4613 |
-
|
4614 |
-
|
4615 |
-
$output .= '
|
4616 |
-
|
4617 |
-
$
|
4618 |
-
|
4619 |
-
|
4620 |
-
|
4621 |
-
|
4622 |
-
|
4623 |
-
|
4624 |
-
|
4625 |
-
|
4626 |
-
|
4627 |
-
$output .= '
|
4628 |
-
|
4629 |
-
|
4630 |
-
|
4631 |
-
|
4632 |
-
|
4633 |
-
|
4634 |
-
|
4635 |
-
|
4636 |
-
|
4637 |
-
|
4638 |
-
|
4639 |
-
|
4640 |
-
|
4641 |
-
|
4642 |
-
|
4643 |
-
|
4644 |
-
|
4645 |
-
|
4646 |
-
|
4647 |
-
|
4648 |
-
|
4649 |
-
|
4650 |
-
|
4651 |
-
|
4652 |
-
|
4653 |
-
|
4654 |
-
|
4655 |
-
|
4656 |
-
|
4657 |
-
|
4658 |
-
|
4659 |
-
|
4660 |
-
|
4661 |
-
|
4662 |
-
|
4663 |
-
|
4664 |
-
|
4665 |
-
|
4666 |
-
$
|
4667 |
-
|
4668 |
-
|
4669 |
-
|
4670 |
-
$
|
4671 |
-
$
|
4672 |
-
$
|
4673 |
-
$
|
4674 |
-
$
|
4675 |
-
$
|
4676 |
-
$
|
4677 |
-
$
|
4678 |
-
$
|
4679 |
-
|
4680 |
-
$
|
4681 |
-
$
|
4682 |
-
|
4683 |
-
|
4684 |
-
|
4685 |
-
|
4686 |
-
|
4687 |
-
|
4688 |
-
|
4689 |
-
|
4690 |
-
|
4691 |
-
|
4692 |
-
|
4693 |
-
|
4694 |
-
|
4695 |
-
|
4696 |
-
|
4697 |
-
|
4698 |
-
|
4699 |
-
|
4700 |
-
$
|
4701 |
-
}
|
4702 |
-
|
4703 |
-
|
4704 |
-
|
4705 |
-
|
4706 |
-
|
4707 |
-
|
4708 |
-
|
4709 |
-
|
4710 |
-
$
|
4711 |
-
}
|
4712 |
-
|
4713 |
-
|
4714 |
-
|
4715 |
-
|
4716 |
-
|
4717 |
-
|
4718 |
-
|
4719 |
-
|
4720 |
-
|
4721 |
-
|
4722 |
-
|
4723 |
-
|
4724 |
-
|
4725 |
-
|
4726 |
-
|
4727 |
-
|
4728 |
-
|
4729 |
-
|
4730 |
-
|
4731 |
-
|
4732 |
-
|
4733 |
-
|
4734 |
-
|
4735 |
-
|
4736 |
-
|
4737 |
-
|
4738 |
-
|
4739 |
-
$
|
4740 |
-
|
4741 |
-
|
4742 |
-
|
4743 |
-
|
4744 |
-
|
4745 |
-
|
4746 |
-
|
4747 |
-
|
4748 |
-
|
4749 |
-
|
4750 |
-
|
4751 |
-
|
4752 |
-
|
4753 |
-
|
4754 |
-
|
4755 |
-
|
4756 |
-
|
4757 |
-
|
4758 |
-
|
4759 |
-
|
4760 |
-
|
4761 |
-
|
4762 |
-
|
4763 |
-
|
4764 |
-
|
4765 |
-
|
4766 |
-
|
4767 |
-
|
4768 |
-
|
4769 |
-
|
4770 |
-
|
4771 |
-
|
4772 |
-
|
4773 |
-
|
4774 |
-
|
4775 |
-
|
4776 |
-
|
4777 |
-
|
4778 |
-
|
4779 |
-
|
4780 |
-
|
4781 |
-
|
4782 |
-
|
4783 |
-
|
4784 |
-
|
4785 |
-
|
4786 |
-
|
4787 |
-
|
4788 |
-
|
4789 |
-
|
4790 |
-
|
4791 |
-
|
4792 |
-
|
4793 |
-
|
4794 |
-
|
4795 |
-
|
4796 |
-
|
4797 |
-
|
4798 |
-
|
4799 |
-
|
4800 |
-
|
4801 |
-
|
4802 |
-
|
4803 |
-
|
4804 |
-
|
4805 |
-
|
4806 |
-
|
4807 |
-
|
4808 |
-
|
4809 |
-
|
4810 |
-
|
4811 |
-
|
4812 |
-
|
4813 |
-
|
4814 |
-
|
4815 |
-
|
4816 |
-
|
4817 |
-
|
4818 |
-
|
4819 |
-
|
4820 |
-
|
4821 |
-
|
4822 |
-
|
4823 |
-
|
4824 |
-
|
4825 |
-
|
4826 |
-
|
4827 |
-
|
4828 |
-
|
4829 |
-
|
4830 |
-
|
4831 |
-
*
|
4832 |
-
|
4833 |
-
|
4834 |
-
|
4835 |
-
|
4836 |
-
|
4837 |
-
|
4838 |
-
|
4839 |
-
|
4840 |
-
|
4841 |
-
|
4842 |
-
|
4843 |
-
|
4844 |
-
|
4845 |
-
|
4846 |
-
);
|
4847 |
-
|
4848 |
-
$
|
4849 |
-
|
4850 |
-
|
4851 |
-
|
4852 |
-
|
4853 |
-
|
4854 |
-
|
4855 |
-
|
4856 |
-
|
4857 |
-
|
4858 |
-
|
4859 |
-
|
4860 |
-
|
4861 |
-
|
4862 |
-
|
4863 |
-
|
4864 |
-
|
4865 |
-
|
4866 |
-
|
4867 |
-
|
4868 |
-
|
4869 |
-
|
4870 |
-
|
4871 |
-
|
4872 |
-
|
4873 |
-
|
4874 |
-
|
4875 |
-
|
4876 |
-
|
4877 |
-
|
4878 |
-
*
|
4879 |
-
*
|
4880 |
-
* @
|
4881 |
-
*
|
4882 |
-
*
|
4883 |
-
*
|
4884 |
-
*
|
4885 |
-
*
|
4886 |
-
* }
|
4887 |
-
*
|
4888 |
-
|
4889 |
-
|
4890 |
-
|
4891 |
-
|
4892 |
-
|
4893 |
-
|
4894 |
-
|
4895 |
-
|
4896 |
-
|
4897 |
-
|
4898 |
-
|
4899 |
-
|
4900 |
-
|
4901 |
-
|
4902 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace um\core;
|
3 |
+
|
4 |
+
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\core\Fields' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Fields
|
13 |
+
* @package um\core
|
14 |
+
*/
|
15 |
+
class Fields {
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
var $set_mode = '';
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var int form_id
|
26 |
+
*/
|
27 |
+
public $set_id = null;
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Fields constructor.
|
32 |
+
*/
|
33 |
+
function __construct() {
|
34 |
+
$this->editing = false;
|
35 |
+
$this->viewing = false;
|
36 |
+
$this->timestamp = current_time( 'timestamp' );
|
37 |
+
}
|
38 |
+
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Standard checkbox field
|
42 |
+
*
|
43 |
+
* @param integer $id
|
44 |
+
* @param string $title
|
45 |
+
* @param bool $checked
|
46 |
+
*/
|
47 |
+
function checkbox( $id, $title, $checked = true ) {
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Set value on form submission
|
51 |
+
*/
|
52 |
+
if ( isset( $_REQUEST[ $id ] ) ) {
|
53 |
+
$checked = (bool) $_REQUEST[ $id ];
|
54 |
+
}
|
55 |
+
|
56 |
+
$class = $checked ? 'um-icon-android-checkbox-outline' : 'um-icon-android-checkbox-outline-blank';
|
57 |
+
|
58 |
+
?>
|
59 |
+
|
60 |
+
|
61 |
+
<div class="um-field um-field-c">
|
62 |
+
<div class="um-field-area">
|
63 |
+
<label class="um-field-checkbox<?php echo $checked ? ' active' : '' ?>">
|
64 |
+
<input type="checkbox" name="<?php echo esc_attr( $id ); ?>" value="1" <?php checked( $checked ) ?> />
|
65 |
+
<span class="um-field-checkbox-state"><i class="<?php echo esc_attr( $class ) ?>"></i></span>
|
66 |
+
<span class="um-field-checkbox-option"> <?php echo esc_html( $title ); ?></span>
|
67 |
+
</label>
|
68 |
+
</div>
|
69 |
+
</div>
|
70 |
+
|
71 |
+
<?php
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Shows social links
|
77 |
+
*/
|
78 |
+
function show_social_urls() {
|
79 |
+
$social = array();
|
80 |
+
|
81 |
+
$fields = UM()->builtin()->get_all_user_fields();
|
82 |
+
foreach ( $fields as $field => $args ) {
|
83 |
+
if ( isset( $args['advanced'] ) && $args['advanced'] == 'social' ) {
|
84 |
+
$social[ $field ] = $args;
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
foreach ( $social as $k => $arr ) {
|
89 |
+
if ( um_profile( $k ) ) { ?>
|
90 |
+
|
91 |
+
<a href="<?php echo esc_url( um_filtered_social_link( $k, $arr['match'] ) ); ?>"
|
92 |
+
style="background: <?php echo esc_attr( $arr['color'] ); ?>;" target="_blank" class="um-tip-n"
|
93 |
+
title="<?php echo esc_attr( $arr['title'] ); ?>"><i class="<?php echo esc_attr( $arr['icon'] ); ?>"></i></a>
|
94 |
+
|
95 |
+
<?php
|
96 |
+
}
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Hidden field inside a shortcode
|
103 |
+
*
|
104 |
+
* @param string $field
|
105 |
+
*/
|
106 |
+
function add_hidden_field( $field ) {
|
107 |
+
echo '<div style="display: none !important;">';
|
108 |
+
|
109 |
+
$fields = UM()->builtin()->get_specific_fields( $field );
|
110 |
+
|
111 |
+
$output = null;
|
112 |
+
|
113 |
+
foreach ( $fields as $key => $data ) {
|
114 |
+
$output .= UM()->fields()->edit_field( $key, $data );
|
115 |
+
}
|
116 |
+
|
117 |
+
echo $output;
|
118 |
+
|
119 |
+
echo '</div>';
|
120 |
+
}
|
121 |
+
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Get hidden field
|
125 |
+
*
|
126 |
+
* @param string $key
|
127 |
+
* @param string $value
|
128 |
+
*
|
129 |
+
* @return string
|
130 |
+
*/
|
131 |
+
function disabled_hidden_field( $key, $value ) {
|
132 |
+
return '<input type="hidden" name="' . esc_attr( $key ) . '" value="' . esc_attr( $value ) . '"/>';
|
133 |
+
}
|
134 |
+
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Updates a field globally
|
138 |
+
*
|
139 |
+
* @param integer $id
|
140 |
+
* @param array $args
|
141 |
+
*/
|
142 |
+
function globally_update_field( $id, $args ) {
|
143 |
+
$fields = UM()->builtin()->saved_fields;
|
144 |
+
|
145 |
+
$fields[ $id ] = $args;
|
146 |
+
|
147 |
+
if ( array_key_exists( 'custom_dropdown_options_source', $args ) ) {
|
148 |
+
if ( function_exists( wp_unslash( $args['custom_dropdown_options_source'] ) ) ) {
|
149 |
+
$allowed_callbacks = UM()->options()->get( 'allowed_choice_callbacks' );
|
150 |
+
if ( ! empty( $allowed_callbacks ) ) {
|
151 |
+
$allowed_callbacks = array_map( 'rtrim', explode( "\n", $allowed_callbacks ) );
|
152 |
+
$allowed_callbacks[] = $args['custom_dropdown_options_source'];
|
153 |
+
} else {
|
154 |
+
$allowed_callbacks = array( $args['custom_dropdown_options_source'] );
|
155 |
+
}
|
156 |
+
$allowed_callbacks = array_unique( $allowed_callbacks );
|
157 |
+
$allowed_callbacks = implode( "\r\n", $allowed_callbacks );
|
158 |
+
|
159 |
+
UM()->options()->update( 'allowed_choice_callbacks', $allowed_callbacks );
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
unset( $fields[ $id ]['in_row'] );
|
164 |
+
unset( $fields[ $id ]['in_sub_row'] );
|
165 |
+
unset( $fields[ $id ]['in_column'] );
|
166 |
+
unset( $fields[ $id ]['in_group'] );
|
167 |
+
unset( $fields[ $id ]['position'] );
|
168 |
+
|
169 |
+
do_action( 'um_add_new_field', $id, $args );
|
170 |
+
|
171 |
+
update_option( 'um_fields', $fields );
|
172 |
+
}
|
173 |
+
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Updates a field in form only
|
177 |
+
*
|
178 |
+
* @param integer $id
|
179 |
+
* @param array $args
|
180 |
+
* @param integer $form_id
|
181 |
+
*/
|
182 |
+
function update_field( $id, $args, $form_id ) {
|
183 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
184 |
+
|
185 |
+
if ( $args['type'] == 'row' ) {
|
186 |
+
if ( isset( $fields[ $id ] ) ) {
|
187 |
+
$old_args = $fields[ $id ];
|
188 |
+
foreach ( $old_args as $k => $v ) {
|
189 |
+
if ( ! in_array( $k, array( 'sub_rows', 'cols' ) ) ) {
|
190 |
+
unset( $old_args[ $k ] );
|
191 |
+
}
|
192 |
+
}
|
193 |
+
$args = array_merge( $old_args, $args );
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
// custom fields support
|
198 |
+
if ( isset( UM()->builtin()->predefined_fields[ $id ] ) && isset( UM()->builtin()->predefined_fields[ $id ]['custom'] ) ) {
|
199 |
+
$args = array_merge( UM()->builtin()->predefined_fields[ $id ], $args );
|
200 |
+
}
|
201 |
+
|
202 |
+
if ( array_key_exists( 'custom_dropdown_options_source', $args ) ) {
|
203 |
+
if ( function_exists( wp_unslash( $args['custom_dropdown_options_source'] ) ) ) {
|
204 |
+
$allowed_callbacks = UM()->options()->get( 'allowed_choice_callbacks' );
|
205 |
+
if ( ! empty( $allowed_callbacks ) ) {
|
206 |
+
$allowed_callbacks = array_map( 'rtrim', explode( "\n", $allowed_callbacks ) );
|
207 |
+
$allowed_callbacks[] = $args['custom_dropdown_options_source'];
|
208 |
+
} else {
|
209 |
+
$allowed_callbacks = array( $args['custom_dropdown_options_source'] );
|
210 |
+
}
|
211 |
+
$allowed_callbacks = array_unique( $allowed_callbacks );
|
212 |
+
$allowed_callbacks = implode( "\r\n", $allowed_callbacks );
|
213 |
+
|
214 |
+
UM()->options()->update( 'allowed_choice_callbacks', $allowed_callbacks );
|
215 |
+
|
216 |
+
$args['custom_dropdown_options_source'] = wp_unslash( $args['custom_dropdown_options_source'] );
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
$fields[ $id ] = $args;
|
221 |
+
|
222 |
+
// for group field only
|
223 |
+
if ( $args['type'] == 'group' ) {
|
224 |
+
$fields[ $id ]['in_group'] = '';
|
225 |
+
}
|
226 |
+
|
227 |
+
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
228 |
+
}
|
229 |
+
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Deletes a field in form only
|
233 |
+
*
|
234 |
+
* @param integer $id
|
235 |
+
* @param integer $form_id
|
236 |
+
*/
|
237 |
+
function delete_field_from_form( $id, $form_id ) {
|
238 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
239 |
+
|
240 |
+
if ( isset( $fields[ $id ] ) ) {
|
241 |
+
$condition_fields = get_option( 'um_fields' );
|
242 |
+
|
243 |
+
if( ! is_array( $condition_fields ) ) $condition_fields = array();
|
244 |
+
|
245 |
+
foreach ( $condition_fields as $key => $value ) {
|
246 |
+
$deleted_field = array_search( $id, $value );
|
247 |
+
|
248 |
+
if ( $key != $id && $deleted_field != false ) {
|
249 |
+
$deleted_field_id = str_replace( 'conditional_field', '', $deleted_field );
|
250 |
+
|
251 |
+
if ( $deleted_field_id == '' ) {
|
252 |
+
$arr_id = 0;
|
253 |
+
} else {
|
254 |
+
$arr_id = $deleted_field_id;
|
255 |
+
}
|
256 |
+
|
257 |
+
unset( $condition_fields[ $key ][ 'conditional_action' . $deleted_field_id ] );
|
258 |
+
unset( $condition_fields[ $key ][ $deleted_field ] );
|
259 |
+
unset( $condition_fields[ $key ][ 'conditional_operator' . $deleted_field_id ] );
|
260 |
+
unset( $condition_fields[ $key ][ 'conditional_value' . $deleted_field_id ] );
|
261 |
+
unset( $condition_fields[ $key ]['conditions'][ $arr_id ] );
|
262 |
+
|
263 |
+
unset( $fields[ $key ][ 'conditional_action' . $deleted_field_id ] );
|
264 |
+
unset( $fields[ $key ][ $deleted_field ] );
|
265 |
+
unset( $fields[ $key ][ 'conditional_operator' . $deleted_field_id ] );
|
266 |
+
unset( $fields[ $key ][ 'conditional_value' . $deleted_field_id ] );
|
267 |
+
unset( $fields[ $key ]['conditions'][ $arr_id ] );
|
268 |
+
}
|
269 |
+
}
|
270 |
+
|
271 |
+
update_option( 'um_fields' , $condition_fields );
|
272 |
+
unset( $fields[ $id ] );
|
273 |
+
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
274 |
+
}
|
275 |
+
}
|
276 |
+
|
277 |
+
|
278 |
+
/**
|
279 |
+
* Deletes a field from custom fields
|
280 |
+
*
|
281 |
+
* @param integer $id
|
282 |
+
*/
|
283 |
+
function delete_field_from_db( $id ) {
|
284 |
+
$fields = UM()->builtin()->saved_fields;
|
285 |
+
if ( isset( $fields[ $id ] ) ) {
|
286 |
+
$args = $fields[ $id ];
|
287 |
+
|
288 |
+
unset( $fields[ $id ] );
|
289 |
+
|
290 |
+
do_action( 'um_delete_custom_field', $id, $args );
|
291 |
+
|
292 |
+
update_option( 'um_fields', $fields );
|
293 |
+
|
294 |
+
global $wpdb;
|
295 |
+
$forms = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'um_form'" );
|
296 |
+
foreach ( $forms as $form_id ) {
|
297 |
+
$form_fields = get_post_meta( $form_id, '_um_custom_fields', true );
|
298 |
+
unset( $form_fields[ $id ] );
|
299 |
+
update_post_meta( $form_id, '_um_custom_fields', $form_fields );
|
300 |
+
}
|
301 |
+
|
302 |
+
$directories = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'um_directory'" );
|
303 |
+
foreach ( $directories as $directory_id ) {
|
304 |
+
// Frontend filters
|
305 |
+
$directory_search_fields = get_post_meta( $directory_id, '_um_search_fields', true );
|
306 |
+
$directory_search_fields = array_values( array_diff( $directory_search_fields, array( $id ) ) );
|
307 |
+
update_post_meta( $directory_id, '_um_search_fields', $directory_search_fields );
|
308 |
+
|
309 |
+
// Admin filtering
|
310 |
+
$directory_search_filters = get_post_meta( $directory_id, '_um_search_filters', true );
|
311 |
+
if ( isset( $directory_search_filters[ $id ] ) ) {
|
312 |
+
unset( $directory_search_filters[ $id ] );
|
313 |
+
}
|
314 |
+
update_post_meta( $directory_id, '_um_search_filters', $directory_search_filters );
|
315 |
+
|
316 |
+
// display in tagline
|
317 |
+
$directory_reveal_fields = get_post_meta( $directory_id, '_um_reveal_fields', true );
|
318 |
+
$directory_reveal_fields = array_values( array_diff( $directory_reveal_fields, array( $id ) ) );
|
319 |
+
update_post_meta( $directory_id, '_um_reveal_fields', $directory_reveal_fields );
|
320 |
+
|
321 |
+
// extra user information section
|
322 |
+
$directory_tagline_fields = get_post_meta( $directory_id, '_um_tagline_fields', true );
|
323 |
+
$directory_tagline_fields = array_values( array_diff( $directory_tagline_fields, array( $id ) ) );
|
324 |
+
update_post_meta( $directory_id, '_um_tagline_fields', $directory_tagline_fields );
|
325 |
+
|
326 |
+
// Custom fields selected in "Choose field(s) to enable in sorting"
|
327 |
+
$directory_sorting_fields = get_post_meta( $directory_id, '_um_sorting_fields', true );
|
328 |
+
foreach ( $directory_sorting_fields as $key => $sorting_data ) {
|
329 |
+
if ( is_array( $sorting_data ) && array_key_exists( $id, $sorting_data ) ) {
|
330 |
+
unset( $directory_sorting_fields[ $key ] );
|
331 |
+
}
|
332 |
+
}
|
333 |
+
$directory_sorting_fields = array_values( $directory_sorting_fields );
|
334 |
+
update_post_meta( $directory_id, '_um_sorting_fields', $directory_sorting_fields );
|
335 |
+
|
336 |
+
// If "Default sort users by" = "Other (Custom Field)" is selected when delete this custom field and set default sorting
|
337 |
+
$directory_sortby_custom = get_post_meta( $directory_id, '_um_sortby_custom', true );
|
338 |
+
if ( $directory_sortby_custom === $id ) {
|
339 |
+
$directory_sortby = get_post_meta( $directory_id, '_um_sortby', true );
|
340 |
+
if ( 'other' === $directory_sortby ) {
|
341 |
+
update_post_meta( $directory_id, '_um_sortby', 'user_registered_desc' );
|
342 |
+
}
|
343 |
+
update_post_meta( $directory_id, '_um_sortby_custom', '' );
|
344 |
+
update_post_meta( $directory_id, '_um_sortby_custom_label', '' );
|
345 |
+
}
|
346 |
+
}
|
347 |
+
|
348 |
+
}
|
349 |
+
}
|
350 |
+
|
351 |
+
|
352 |
+
/**
|
353 |
+
* Quickly adds a field from custom fields
|
354 |
+
*
|
355 |
+
* @param integer $global_id
|
356 |
+
* @param integer $form_id
|
357 |
+
* @param array $position
|
358 |
+
*/
|
359 |
+
function add_field_from_list( $global_id, $form_id, $position = array() ) {
|
360 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
361 |
+
$field_scope = UM()->builtin()->saved_fields;
|
362 |
+
|
363 |
+
if ( ! isset( $fields[ $global_id ] ) ) {
|
364 |
+
|
365 |
+
$count = 1;
|
366 |
+
if ( ! empty( $fields ) ) {
|
367 |
+
$count = count( $fields ) + 1;
|
368 |
+
}
|
369 |
+
|
370 |
+
$fields[ $global_id ] = $field_scope[ $global_id ];
|
371 |
+
$fields[ $global_id ]['position'] = $count;
|
372 |
+
|
373 |
+
// set position
|
374 |
+
if ( $position ) {
|
375 |
+
foreach ( $position as $key => $val) {
|
376 |
+
$fields[ $global_id ][ $key ] = $val;
|
377 |
+
}
|
378 |
+
}
|
379 |
+
|
380 |
+
// add field to form
|
381 |
+
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
382 |
+
|
383 |
+
}
|
384 |
+
}
|
385 |
+
|
386 |
+
|
387 |
+
/**
|
388 |
+
* Quickly adds a field from pre-defined fields
|
389 |
+
*
|
390 |
+
* @param integer $global_id
|
391 |
+
* @param integer $form_id
|
392 |
+
* @param array $position
|
393 |
+
*/
|
394 |
+
function add_field_from_predefined( $global_id, $form_id, $position = array() ) {
|
395 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
396 |
+
$field_scope = UM()->builtin()->predefined_fields;
|
397 |
+
|
398 |
+
if ( ! isset( $fields[ $global_id ] ) ) {
|
399 |
+
|
400 |
+
$count = 1;
|
401 |
+
if ( ! empty( $fields ) ) {
|
402 |
+
$count = count( $fields ) + 1;
|
403 |
+
}
|
404 |
+
|
405 |
+
$fields[ $global_id ] = $field_scope[ $global_id ];
|
406 |
+
$fields[ $global_id ]['position'] = $count;
|
407 |
+
|
408 |
+
// set position
|
409 |
+
if ( $position ) {
|
410 |
+
foreach ( $position as $key => $val ) {
|
411 |
+
$fields[ $global_id ][ $key ] = $val;
|
412 |
+
}
|
413 |
+
}
|
414 |
+
|
415 |
+
// add field to form
|
416 |
+
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
417 |
+
}
|
418 |
+
}
|
419 |
+
|
420 |
+
|
421 |
+
/**
|
422 |
+
* Duplicates a frield by meta key
|
423 |
+
*
|
424 |
+
* @param integer $id
|
425 |
+
* @param integer $form_id
|
426 |
+
*/
|
427 |
+
function duplicate_field( $id, $form_id ) {
|
428 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
429 |
+
$all_fields = UM()->builtin()->saved_fields;
|
430 |
+
|
431 |
+
$inc = count( $fields ) + 1;
|
432 |
+
|
433 |
+
$duplicate = $fields[ $id ];
|
434 |
+
|
435 |
+
$new_metakey = $id . "_" . $inc;
|
436 |
+
$new_title = $fields[ $id ]['title'] . " #" . $inc;
|
437 |
+
$new_position = $inc;
|
438 |
+
|
439 |
+
$duplicate['title'] = $new_title;
|
440 |
+
$duplicate['metakey'] = $new_metakey;
|
441 |
+
$duplicate['position'] = $new_position;
|
442 |
+
|
443 |
+
$fields[ $new_metakey ] = $duplicate;
|
444 |
+
$all_fields[ $new_metakey ] = $duplicate;
|
445 |
+
|
446 |
+
// not global attributes
|
447 |
+
unset( $all_fields[ $new_metakey ]['in_row'] );
|
448 |
+
unset( $all_fields[ $new_metakey ]['in_sub_row'] );
|
449 |
+
unset( $all_fields[ $new_metakey ]['in_column'] );
|
450 |
+
unset( $all_fields[ $new_metakey ]['in_group'] );
|
451 |
+
unset( $all_fields[ $new_metakey ]['position'] );
|
452 |
+
|
453 |
+
|
454 |
+
do_action( 'um_add_new_field', $new_metakey, $duplicate );
|
455 |
+
|
456 |
+
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
457 |
+
update_option( 'um_fields', $all_fields );
|
458 |
+
}
|
459 |
+
|
460 |
+
|
461 |
+
/**
|
462 |
+
* Print field error
|
463 |
+
*
|
464 |
+
* @param string $text
|
465 |
+
* @param bool $force_show
|
466 |
+
*
|
467 |
+
* @return string
|
468 |
+
*/
|
469 |
+
function field_error( $text, $force_show = false ) {
|
470 |
+
|
471 |
+
if ( empty( $text ) ) {
|
472 |
+
return '';
|
473 |
+
}
|
474 |
+
|
475 |
+
if ( $force_show ) {
|
476 |
+
$output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
477 |
+
return $output;
|
478 |
+
}
|
479 |
+
|
480 |
+
|
481 |
+
if ( isset( $this->set_id ) && UM()->form()->processing == $this->set_id ) {
|
482 |
+
$output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
483 |
+
} else {
|
484 |
+
$output = '';
|
485 |
+
}
|
486 |
+
|
487 |
+
if ( ! UM()->form()->processing ) {
|
488 |
+
$output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
489 |
+
}
|
490 |
+
|
491 |
+
return $output;
|
492 |
+
}
|
493 |
+
|
494 |
+
|
495 |
+
/**
|
496 |
+
* Print field notice
|
497 |
+
*
|
498 |
+
* @param string $text
|
499 |
+
* @param bool $force_show
|
500 |
+
*
|
501 |
+
* @return string
|
502 |
+
*/
|
503 |
+
function field_notice( $text, $force_show = false ) {
|
504 |
+
|
505 |
+
if ( empty( $text ) ) {
|
506 |
+
return '';
|
507 |
+
}
|
508 |
+
|
509 |
+
if ( $force_show ) {
|
510 |
+
$output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
511 |
+
return $output;
|
512 |
+
}
|
513 |
+
|
514 |
+
|
515 |
+
if ( isset( $this->set_id ) && UM()->form()->processing == $this->set_id ) {
|
516 |
+
$output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
517 |
+
} else {
|
518 |
+
$output = '';
|
519 |
+
}
|
520 |
+
|
521 |
+
if ( ! UM()->form()->processing ) {
|
522 |
+
$output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
523 |
+
}
|
524 |
+
|
525 |
+
return $output;
|
526 |
+
}
|
527 |
+
|
528 |
+
|
529 |
+
/**
|
530 |
+
* Checks if field has a server-side error
|
531 |
+
*
|
532 |
+
* @param string $key
|
533 |
+
*
|
534 |
+
* @return boolean
|
535 |
+
*/
|
536 |
+
function is_error( $key ) {
|
537 |
+
return UM()->form()->has_error( $key );
|
538 |
+
}
|
539 |
+
|
540 |
+
/**
|
541 |
+
* Checks if field has a notice
|
542 |
+
*
|
543 |
+
* @param string $key
|
544 |
+
*
|
545 |
+
* @return boolean
|
546 |
+
*/
|
547 |
+
function is_notice( $key ) {
|
548 |
+
return UM()->form()->has_notice( $key );
|
549 |
+
}
|
550 |
+
|
551 |
+
|
552 |
+
/**
|
553 |
+
* Returns field error
|
554 |
+
*
|
555 |
+
* @param string $key
|
556 |
+
*
|
557 |
+
* @return string
|
558 |
+
*/
|
559 |
+
function show_error( $key ) {
|
560 |
+
return UM()->form()->errors[ $key ];
|
561 |
+
}
|
562 |
+
|
563 |
+
/**
|
564 |
+
* Returns field notices
|
565 |
+
*
|
566 |
+
* @param string $key
|
567 |
+
*
|
568 |
+
* @return string
|
569 |
+
*/
|
570 |
+
function show_notice( $key ) {
|
571 |
+
return UM()->form()->notices[ $key ];
|
572 |
+
}
|
573 |
+
|
574 |
+
|
575 |
+
/**
|
576 |
+
* Display field label
|
577 |
+
*
|
578 |
+
* @param string $label
|
579 |
+
* @param string $key
|
580 |
+
* @param array $data
|
581 |
+
*
|
582 |
+
* @return string
|
583 |
+
*/
|
584 |
+
function field_label( $label, $key, $data ) {
|
585 |
+
$output = null;
|
586 |
+
$output .= '<div class="um-field-label">';
|
587 |
+
|
588 |
+
if ( isset( $data['icon'] ) && $data['icon'] != '' && isset( $this->field_icons ) && $this->field_icons != 'off' && ( $this->field_icons == 'label' || $this->viewing == true ) ) {
|
589 |
+
$output .= '<div class="um-field-label-icon"><i class="' . esc_attr( $data['icon'] ) . '" aria-label="' . esc_attr( $label ) . '"></i></div>';
|
590 |
+
}
|
591 |
+
|
592 |
+
if ( $this->viewing == true ) {
|
593 |
+
/**
|
594 |
+
* UM hook
|
595 |
+
*
|
596 |
+
* @type filter
|
597 |
+
* @title um_view_label_{$key}
|
598 |
+
* @description Change field label on view by field $key
|
599 |
+
* @input_vars
|
600 |
+
* [{"var":"$label","type":"string","desc":"Field Label"}]
|
601 |
+
* @change_log
|
602 |
+
* ["Since: 2.0"]
|
603 |
+
* @usage add_filter( 'um_view_label_{$key}', 'function_name', 10, 1 );
|
604 |
+
* @example
|
605 |
+
* <?php
|
606 |
+
* add_filter( 'um_view_label_{$key}', 'my_view_label', 10, 1 );
|
607 |
+
* function my_view_label( $label ) {
|
608 |
+
* // your code here
|
609 |
+
* return $label;
|
610 |
+
* }
|
611 |
+
* ?>
|
612 |
+
*/
|
613 |
+
$label = apply_filters( "um_view_label_{$key}", $label );
|
614 |
+
} else {
|
615 |
+
/**
|
616 |
+
* UM hook
|
617 |
+
*
|
618 |
+
* @type filter
|
619 |
+
* @title um_edit_label_{$key}
|
620 |
+
* @description Change field label on edit by field $key
|
621 |
+
* @input_vars
|
622 |
+
* [{"var":"$label","type":"string","desc":"Field Label"}]
|
623 |
+
* @change_log
|
624 |
+
* ["Since: 2.0"]
|
625 |
+
* @usage add_filter( 'um_edit_label_{$key}', 'function_name', 10, 1 );
|
626 |
+
* @example
|
627 |
+
* <?php
|
628 |
+
* add_filter( 'um_edit_label_{$key}', 'my_edit_label', 10, 1 );
|
629 |
+
* function my_edit_label( $label ) {
|
630 |
+
* // your code here
|
631 |
+
* return $label;
|
632 |
+
* }
|
633 |
+
* ?>
|
634 |
+
*/
|
635 |
+
$label = apply_filters( "um_edit_label_{$key}", $label );
|
636 |
+
/**
|
637 |
+
* UM hook
|
638 |
+
*
|
639 |
+
* @type filter
|
640 |
+
* @title um_edit_label_all_fields
|
641 |
+
* @description Change field label on view by field $key
|
642 |
+
* @input_vars
|
643 |
+
* [{"var":"$label","type":"string","desc":"Field Label"},
|
644 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
645 |
+
* @change_log
|
646 |
+
* ["Since: 2.0"]
|
647 |
+
* @usage add_filter( 'um_edit_label_all_fields', 'function_name', 10, 2 );
|
648 |
+
* @example
|
649 |
+
* <?php
|
650 |
+
* add_filter( 'um_edit_label_all_fields', 'my_edit_label_all_fields', 10, 2 );
|
651 |
+
* function my_edit_label_all_fields( $label, $data ) {
|
652 |
+
* // your code here
|
653 |
+
* return $label;
|
654 |
+
* }
|
655 |
+
* ?>
|
656 |
+
*/
|
657 |
+
$label = apply_filters( 'um_edit_label_all_fields', $label, $data );
|
658 |
+
}
|
659 |
+
|
660 |
+
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
661 |
+
$for_attr = '';
|
662 |
+
if ( ! in_array( $data['type'], $fields_without_metakey ) ) {
|
663 |
+
$for_attr = ' for="' . esc_attr( $key . UM()->form()->form_suffix ) . '"';
|
664 |
+
}
|
665 |
+
|
666 |
+
$output .= '<label' . $for_attr . '>' . __( $label, 'ultimate-member' ) . '</label>';
|
667 |
+
|
668 |
+
if ( ! empty( $data['help'] ) && $this->viewing == false && ! strstr( $key, 'confirm_user_pass' ) ) {
|
669 |
+
|
670 |
+
if ( ! UM()->mobile()->isMobile() ) {
|
671 |
+
if ( ! isset( $this->disable_tooltips ) ) {
|
672 |
+
$output .= '<span class="um-tip um-tip-' . ( is_rtl() ? 'e' : 'w' ) . '" title="' . esc_attr__( $data['help'], 'ultimate-member' ) . '"><i class="um-icon-help-circled"></i></span>';
|
673 |
+
}
|
674 |
+
}
|
675 |
+
|
676 |
+
if ( UM()->mobile()->isMobile() || isset( $this->disable_tooltips ) ) {
|
677 |
+
$output .= '<span class="um-tip-text">' . __( $data['help'], 'ultimate-member' ) . '</span>';
|
678 |
+
}
|
679 |
+
|
680 |
+
}
|
681 |
+
|
682 |
+
$output .= '<div class="um-clear"></div></div>';
|
683 |
+
|
684 |
+
return $output;
|
685 |
+
}
|
686 |
+
|
687 |
+
|
688 |
+
/**
|
689 |
+
* Output field classes
|
690 |
+
*
|
691 |
+
* @param string $key
|
692 |
+
* @param array $data
|
693 |
+
* @param string $add
|
694 |
+
*
|
695 |
+
* @return string
|
696 |
+
*/
|
697 |
+
function get_class( $key, $data, $add = null ) {
|
698 |
+
$classes = null;
|
699 |
+
|
700 |
+
$classes .= 'um-form-field ';
|
701 |
+
|
702 |
+
if ( $this->is_error( $key ) ) {
|
703 |
+
$classes .= 'um-error ';
|
704 |
+
} else {
|
705 |
+
$classes .= 'valid ';
|
706 |
+
}
|
707 |
+
|
708 |
+
if ( ! isset( $data['required'] ) ) {
|
709 |
+
$classes .= 'not-required ';
|
710 |
+
}
|
711 |
+
|
712 |
+
if ( $data['type'] == 'date' ) {
|
713 |
+
$classes .= 'um-datepicker ';
|
714 |
+
}
|
715 |
+
|
716 |
+
if ( $data['type'] == 'time' ) {
|
717 |
+
$classes .= 'um-timepicker ';
|
718 |
+
}
|
719 |
+
|
720 |
+
if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
721 |
+
$classes .= 'um-iconed ';
|
722 |
+
}
|
723 |
+
|
724 |
+
if ( $add ) {
|
725 |
+
$classes .= $add . ' ';
|
726 |
+
}
|
727 |
+
|
728 |
+
/**
|
729 |
+
* UM hook
|
730 |
+
*
|
731 |
+
* @type filter
|
732 |
+
* @title um_extend_field_classes
|
733 |
+
* @description Change field classes
|
734 |
+
* @input_vars
|
735 |
+
* [{"var":"$classes","type":"string","desc":"Field Classes"},
|
736 |
+
* {"var":"$key","type":"string","desc":"Field Key"},
|
737 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
738 |
+
* @change_log
|
739 |
+
* ["Since: 2.0"]
|
740 |
+
* @usage add_filter( 'um_extend_field_classes', 'function_name', 10, 3 );
|
741 |
+
* @example
|
742 |
+
* <?php
|
743 |
+
* add_filter( 'um_extend_field_classes', 'my_extend_field_classes', 10, 3 );
|
744 |
+
* function my_extend_field_classes( $classes, $key, $data ) {
|
745 |
+
* // your code here
|
746 |
+
* return $classes;
|
747 |
+
* }
|
748 |
+
* ?>
|
749 |
+
*/
|
750 |
+
$classes = apply_filters( 'um_extend_field_classes', $classes, $key, $data );
|
751 |
+
|
752 |
+
return $classes;
|
753 |
+
}
|
754 |
+
|
755 |
+
|
756 |
+
/**
|
757 |
+
* Gets field value
|
758 |
+
*
|
759 |
+
* @param string $key
|
760 |
+
* @param boolean $default
|
761 |
+
* @param array $data
|
762 |
+
*
|
763 |
+
* @return mixed
|
764 |
+
*/
|
765 |
+
function field_value( $key, $default = false, $data = null ) {
|
766 |
+
// preview in backend
|
767 |
+
if ( isset( UM()->user()->preview ) && UM()->user()->preview ) {
|
768 |
+
if ( $this->set_mode == 'login' || $this->set_mode == 'register' ) {
|
769 |
+
return '';
|
770 |
+
} else {
|
771 |
+
$val = um_user( $key );
|
772 |
+
if ( ! empty( $val ) ) {
|
773 |
+
return $val;
|
774 |
+
} else {
|
775 |
+
return '';
|
776 |
+
}
|
777 |
+
}
|
778 |
+
}
|
779 |
+
|
780 |
+
if ( isset( $_SESSION ) && isset( $_SESSION['um_social_profile'][ $key ] ) && isset( $this->set_mode ) && $this->set_mode == 'register' ) {
|
781 |
+
return $_SESSION['um_social_profile'][ $key ];
|
782 |
+
}
|
783 |
+
|
784 |
+
$type = ( isset( $data['type'] ) ) ? $data['type'] : '';
|
785 |
+
|
786 |
+
// normal state
|
787 |
+
if ( isset( UM()->form()->post_form[ $key ] ) ) {
|
788 |
+
//show empty value for password fields
|
789 |
+
if ( strstr( $key, 'user_pass' ) && $this->set_mode != 'password' ) {
|
790 |
+
return '';
|
791 |
+
}
|
792 |
+
|
793 |
+
if ( 'profile' === $this->set_mode ) {
|
794 |
+
if ( ! isset( UM()->form()->post_form['profile_nonce'] ) || false === wp_verify_nonce( UM()->form()->post_form['profile_nonce'], 'um-profile-nonce' . UM()->user()->target_id ) ) {
|
795 |
+
return '';
|
796 |
+
}
|
797 |
+
}
|
798 |
+
|
799 |
+
return stripslashes_deep( UM()->form()->post_form[ $key ] );
|
800 |
+
|
801 |
+
} elseif ( um_user( $key ) && $this->editing == true ) {
|
802 |
+
|
803 |
+
//show empty value for password fields
|
804 |
+
if ( strstr( $key, 'user_pass' ) || $type == 'password' ) {
|
805 |
+
return '';
|
806 |
+
}
|
807 |
+
|
808 |
+
$value = um_user( $key );
|
809 |
+
/**
|
810 |
+
* UM hook
|
811 |
+
*
|
812 |
+
* @type filter
|
813 |
+
* @title um_edit_{$key}_field_value
|
814 |
+
* @description Change field value on edit by field $key
|
815 |
+
* @input_vars
|
816 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
817 |
+
* {"var":"$key","type":"string","desc":"Field Key"}]
|
818 |
+
* @change_log
|
819 |
+
* ["Since: 2.0"]
|
820 |
+
* @usage add_filter( 'um_edit_{$key}_field_value', 'function_name', 10, 2 );
|
821 |
+
* @example
|
822 |
+
* <?php
|
823 |
+
* add_filter( 'um_edit_{$key}_field_value', 'my_edit_field_value', 10, 2 );
|
824 |
+
* function my_edit_field_value( $value, $key ) {
|
825 |
+
* // your code here
|
826 |
+
* return $value;
|
827 |
+
* }
|
828 |
+
* ?>
|
829 |
+
*/
|
830 |
+
$value = apply_filters( "um_edit_{$key}_field_value", $value, $key );
|
831 |
+
/**
|
832 |
+
* UM hook
|
833 |
+
*
|
834 |
+
* @type filter
|
835 |
+
* @title um_edit_{$type}_field_value
|
836 |
+
* @description Change field value on edit by field $type
|
837 |
+
* @input_vars
|
838 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
839 |
+
* {"var":"$key","type":"string","desc":"Field Key"}]
|
840 |
+
* @change_log
|
841 |
+
* ["Since: 2.0"]
|
842 |
+
* @usage add_filter( 'um_edit_{$type}_field_value', 'function_name', 10, 2 );
|
843 |
+
* @example
|
844 |
+
* <?php
|
845 |
+
* add_filter( 'um_edit_{$type}_field_value', 'my_edit_field_value', 10, 2 );
|
846 |
+
* function my_edit_field_value( $value, $key ) {
|
847 |
+
* // your code here
|
848 |
+
* return $value;
|
849 |
+
* }
|
850 |
+
* ?>
|
851 |
+
*/
|
852 |
+
$value = apply_filters( "um_edit_{$type}_field_value", $value, $key );
|
853 |
+
|
854 |
+
} elseif ( ( um_user( $key ) || isset( $data['show_anyway'] ) ) && $this->viewing == true ) {
|
855 |
+
|
856 |
+
return um_filtered_value( $key, $data );
|
857 |
+
|
858 |
+
} elseif ( isset( UM()->user()->profile[ $key ] ) ) {
|
859 |
+
|
860 |
+
$value = UM()->user()->profile[ $key ];
|
861 |
+
/**
|
862 |
+
* UM hook
|
863 |
+
*
|
864 |
+
* @type filter
|
865 |
+
* @title um_edit_{$key}_field_value
|
866 |
+
* @description Change field value on edit by field $key
|
867 |
+
* @input_vars
|
868 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
869 |
+
* {"var":"$key","type":"string","desc":"Field Key"}]
|
870 |
+
* @change_log
|
871 |
+
* ["Since: 2.0"]
|
872 |
+
* @usage add_filter( 'um_edit_{$key}_field_value', 'function_name', 10, 2 );
|
873 |
+
* @example
|
874 |
+
* <?php
|
875 |
+
* add_filter( 'um_edit_{$key}_field_value', 'my_edit_field_value', 10, 2 );
|
876 |
+
* function my_edit_field_value( $value, $key ) {
|
877 |
+
* // your code here
|
878 |
+
* return $value;
|
879 |
+
* }
|
880 |
+
* ?>
|
881 |
+
*/
|
882 |
+
$value = apply_filters( "um_edit_{$key}_field_value", $value, $key );
|
883 |
+
$value = maybe_unserialize( $value );
|
884 |
+
|
885 |
+
} elseif ( $default ) {
|
886 |
+
|
887 |
+
/**
|
888 |
+
* UM hook
|
889 |
+
*
|
890 |
+
* @type filter
|
891 |
+
* @title um_field_default_value
|
892 |
+
* @description Change field default value
|
893 |
+
* @input_vars
|
894 |
+
* [{"var":"$default","type":"string","desc":"Field Default Value"},
|
895 |
+
* {"var":"$data","type":"array","desc":"Field Data"},
|
896 |
+
* {"var":"$type","type":"string","desc":"Field Type"}]
|
897 |
+
* @change_log
|
898 |
+
* ["Since: 2.0"]
|
899 |
+
* @usage add_filter( 'um_field_default_value', 'function_name', 10, 2 );
|
900 |
+
* @example
|
901 |
+
* <?php
|
902 |
+
* add_filter( 'um_field_default_value', 'my_field_default_value', 10, 2 );
|
903 |
+
* function my_field_default_value( $default, $data, $type ) {
|
904 |
+
* // your code here
|
905 |
+
* return $default;
|
906 |
+
* }
|
907 |
+
* ?>
|
908 |
+
*/
|
909 |
+
$default = apply_filters( 'um_field_default_value', $default, $data, $type );
|
910 |
+
/**
|
911 |
+
* UM hook
|
912 |
+
*
|
913 |
+
* @type filter
|
914 |
+
* @title um_field_{$key}_default_value
|
915 |
+
* @description Change field default value by $key
|
916 |
+
* @input_vars
|
917 |
+
* [{"var":"$default","type":"string","desc":"Field Default Value"},
|
918 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
919 |
+
* @change_log
|
920 |
+
* ["Since: 2.0"]
|
921 |
+
* @usage add_filter( 'um_field_{$key}_default_value', 'function_name', 10, 2 );
|
922 |
+
* @example
|
923 |
+
* <?php
|
924 |
+
* add_filter( 'um_field_{$key}_default_value', 'my_field_default_value', 10, 2 );
|
925 |
+
* function my_field_default_value( $default, $data ) {
|
926 |
+
* // your code here
|
927 |
+
* return $default;
|
928 |
+
* }
|
929 |
+
* ?>
|
930 |
+
*/
|
931 |
+
$default = apply_filters( "um_field_{$key}_default_value", $default, $data );
|
932 |
+
/**
|
933 |
+
* UM hook
|
934 |
+
*
|
935 |
+
* @type filter
|
936 |
+
* @title um_field_{$type}_default_value
|
937 |
+
* @description Change field default value by $type
|
938 |
+
* @input_vars
|
939 |
+
* [{"var":"$default","type":"string","desc":"Field Default Value"},
|
940 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
941 |
+
* @change_log
|
942 |
+
* ["Since: 2.0"]
|
943 |
+
* @usage add_filter( 'um_field_{$type}_default_value', 'function_name', 10, 2 );
|
944 |
+
* @example
|
945 |
+
* <?php
|
946 |
+
* add_filter( 'um_field_{$type}_default_value', 'my_field_default_value', 10, 2 );
|
947 |
+
* function my_field_default_value( $default, $data ) {
|
948 |
+
* // your code here
|
949 |
+
* return $default;
|
950 |
+
* }
|
951 |
+
* ?>
|
952 |
+
*/
|
953 |
+
$default = apply_filters( "um_field_{$type}_default_value", $default, $data );
|
954 |
+
|
955 |
+
}
|
956 |
+
|
957 |
+
// Default Value for Registration Form and Profile Form editing
|
958 |
+
if ( ! isset( $value ) && ( $this->set_mode == 'register' || $this->editing == true ) ) {
|
959 |
+
|
960 |
+
/**
|
961 |
+
* UM hook
|
962 |
+
*
|
963 |
+
* @type filter
|
964 |
+
* @title um_edit_{$key}_field_value
|
965 |
+
* @description Change field value on edit by field $key
|
966 |
+
* @input_vars
|
967 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
968 |
+
* {"var":"$key","type":"string","desc":"Field Key"}]
|
969 |
+
* @change_log
|
970 |
+
* ["Since: 2.0"]
|
971 |
+
* @usage add_filter( 'um_edit_{$key}_field_value', 'function_name', 10, 2 );
|
972 |
+
* @example
|
973 |
+
* <?php
|
974 |
+
* add_filter( 'um_edit_{$key}_field_value', 'my_edit_field_value', 10, 2 );
|
975 |
+
* function my_edit_field_value( $value, $key ) {
|
976 |
+
* // your code here
|
977 |
+
* return $value;
|
978 |
+
* }
|
979 |
+
* ?>
|
980 |
+
*/
|
981 |
+
$value = apply_filters( "um_edit_{$key}_field_value", $default, $key );
|
982 |
+
|
983 |
+
} elseif ( isset( $value ) && is_array( $value ) && ! count( $value ) ) {
|
984 |
+
$value = '';
|
985 |
+
} elseif ( ! isset( $value ) ) {
|
986 |
+
$value = '';
|
987 |
+
}
|
988 |
+
|
989 |
+
|
990 |
+
/**
|
991 |
+
* UM hook
|
992 |
+
*
|
993 |
+
* @type filter
|
994 |
+
* @title um_field_value
|
995 |
+
* @description Change field value
|
996 |
+
* @input_vars
|
997 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
998 |
+
* {"var":"$key","type":"string","desc":"Field Key"},,
|
999 |
+
* {"var":"$type","type":"string","desc":"Field Type"}
|
1000 |
+
* {"var":"$default","type":"string","desc":"Field Default Value"},
|
1001 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
1002 |
+
* @usage add_filter( 'um_field_value', 'function_name', 10, 5 );
|
1003 |
+
*/
|
1004 |
+
return apply_filters( 'um_field_value', $value, $default, $key, $type, $data );
|
1005 |
+
}
|
1006 |
+
|
1007 |
+
|
1008 |
+
/**
|
1009 |
+
* Checks if an option is selected
|
1010 |
+
*
|
1011 |
+
* is used by Select, Multiselect and Checkbox fields
|
1012 |
+
*
|
1013 |
+
* @param string $key
|
1014 |
+
* @param string $value
|
1015 |
+
* @param array $data
|
1016 |
+
*
|
1017 |
+
* @return boolean
|
1018 |
+
*/
|
1019 |
+
function is_selected( $key, $value, $data ) {
|
1020 |
+
global $wpdb;
|
1021 |
+
|
1022 |
+
/**
|
1023 |
+
* UM hook
|
1024 |
+
*
|
1025 |
+
* @type filter
|
1026 |
+
* @title um_is_selected_filter_key
|
1027 |
+
* @description Change is selected filter key
|
1028 |
+
* @input_vars
|
1029 |
+
* [{"var":"$key","type":"string","desc":"Selected filter key"}]
|
1030 |
+
* @change_log
|
1031 |
+
* ["Since: 2.0"]
|
1032 |
+
* @usage add_filter( 'um_is_selected_filter_key', 'function_name', 10, 1 );
|
1033 |
+
* @example
|
1034 |
+
* <?php
|
1035 |
+
* add_filter( 'um_is_selected_filter_key', 'my_selected_filter_key', 10, 1 );
|
1036 |
+
* function my_selected_filter_key( $key ) {
|
1037 |
+
* // your code here
|
1038 |
+
* return $key;
|
1039 |
+
* }
|
1040 |
+
* ?>
|
1041 |
+
*/
|
1042 |
+
$key = apply_filters( 'um_is_selected_filter_key', $key );
|
1043 |
+
|
1044 |
+
if ( isset( UM()->form()->post_form[ $key ] ) ) {
|
1045 |
+
|
1046 |
+
if ( is_array( UM()->form()->post_form[ $key ] ) ) {
|
1047 |
+
|
1048 |
+
if ( in_array( $value, UM()->form()->post_form[ $key ] ) ) {
|
1049 |
+
return true;
|
1050 |
+
}
|
1051 |
+
|
1052 |
+
$stripslashed = array_map( 'stripslashes', UM()->form()->post_form[ $key ] );
|
1053 |
+
if ( in_array( $value, $stripslashed ) ) {
|
1054 |
+
return true;
|
1055 |
+
}
|
1056 |
+
|
1057 |
+
if ( in_array( html_entity_decode( $value ), UM()->form()->post_form[ $key ] ) ) {
|
1058 |
+
return true;
|
1059 |
+
}
|
1060 |
+
} else {
|
1061 |
+
|
1062 |
+
if ( $value == UM()->form()->post_form[ $key ] ) {
|
1063 |
+
return true;
|
1064 |
+
}
|
1065 |
+
|
1066 |
+
}
|
1067 |
+
|
1068 |
+
} else {
|
1069 |
+
|
1070 |
+
$field_value = um_user( $key );
|
1071 |
+
if ( ! $field_value ) {
|
1072 |
+
$field_value = 0;
|
1073 |
+
}
|
1074 |
+
|
1075 |
+
if ( $field_value == 0 && $value == '0' ) {
|
1076 |
+
$value = (int) $value;
|
1077 |
+
}
|
1078 |
+
|
1079 |
+
if ( strstr( $key, 'role_' ) || $key == 'role' ) {
|
1080 |
+
$field_value = strtolower( UM()->roles()->get_editable_priority_user_role( um_user( 'ID' ) ) );
|
1081 |
+
|
1082 |
+
$role_keys = get_option( 'um_roles', array() );
|
1083 |
+
|
1084 |
+
if ( ! empty( $role_keys ) ) {
|
1085 |
+
if ( in_array( $field_value, $role_keys ) ) {
|
1086 |
+
$field_value = 'um_' . $field_value;
|
1087 |
+
}
|
1088 |
+
}
|
1089 |
+
}
|
1090 |
+
|
1091 |
+
|
1092 |
+
/**
|
1093 |
+
* UM hook
|
1094 |
+
*
|
1095 |
+
* @type filter
|
1096 |
+
* @title um_is_selected_filter_value
|
1097 |
+
* @description Change is selected filter value
|
1098 |
+
* @input_vars
|
1099 |
+
* [{"var":"$value","type":"string","desc":"Selected filter value"},
|
1100 |
+
* {"var":"$key","type":"string","desc":"Selected filter key"},
|
1101 |
+
* {"var":"$value","type":"string","desc":"Selected filter value"}]
|
1102 |
+
* @change_log
|
1103 |
+
* ["Since: 2.0"]
|
1104 |
+
* @usage add_filter( 'um_is_selected_filter_value', 'function_name', 10, 2 );
|
1105 |
+
* @example
|
1106 |
+
* <?php
|
1107 |
+
* add_filter( 'um_is_selected_filter_value', 'my_selected_filter_value', 10, 2 );
|
1108 |
+
* function my_selected_filter_value( $value, $key ) {
|
1109 |
+
* // your code here
|
1110 |
+
* return $field_value;
|
1111 |
+
* }
|
1112 |
+
* ?>
|
1113 |
+
*/
|
1114 |
+
$field_value = apply_filters( 'um_is_selected_filter_value', $field_value, $key, $value );
|
1115 |
+
|
1116 |
+
/**
|
1117 |
+
* UM hook
|
1118 |
+
*
|
1119 |
+
* @type filter
|
1120 |
+
* @title um_is_selected_filter_data
|
1121 |
+
* @description Change is selected filter data
|
1122 |
+
* @input_vars
|
1123 |
+
* [{"var":"$data","type":"array","desc":"Selected filter value"},
|
1124 |
+
* {"var":"$key","type":"string","desc":"Selected filter key"},
|
1125 |
+
* {"var":"$value","type":"string","desc":"Selected filter value"}]
|
1126 |
+
* @change_log
|
1127 |
+
* ["Since: 2.0"]
|
1128 |
+
* @usage add_filter( 'um_is_selected_filter_data', 'function_name', 10, 3 );
|
1129 |
+
* @example
|
1130 |
+
* <?php
|
1131 |
+
* add_filter( 'um_is_selected_filter_data', 'my_selected_filter_data', 10, 3 );
|
1132 |
+
* function my_selected_filter_data( $data, $key, $value ) {
|
1133 |
+
* // your code here
|
1134 |
+
* return $data;
|
1135 |
+
* }
|
1136 |
+
* ?>
|
1137 |
+
*/
|
1138 |
+
$data = apply_filters( 'um_is_selected_filter_data', $data, $key, $field_value );
|
1139 |
+
|
1140 |
+
if ( ! $this->editing || 'custom' == $this->set_mode ) {
|
1141 |
+
// show default on register screen if there is default
|
1142 |
+
if ( isset( $data['default'] ) ) {
|
1143 |
+
|
1144 |
+
if ( ! is_array( $data['default'] ) && $data['default'] === $value ) {
|
1145 |
+
return true;
|
1146 |
+
}
|
1147 |
+
|
1148 |
+
if ( is_array( $data['default'] ) && in_array( $value, $data['default'] ) ) {
|
1149 |
+
return true;
|
1150 |
+
}
|
1151 |
+
|
1152 |
+
if ( is_array( $data['default'] ) && array_intersect( $data['options'], $data['default'] ) ) {
|
1153 |
+
return true;
|
1154 |
+
}
|
1155 |
+
|
1156 |
+
// default value with comma
|
1157 |
+
if ( is_string( $data['default'] ) && strstr( $data['default'], ',' ) ) {
|
1158 |
+
$choices = array_map( 'trim', explode( ',', $data['default'] ) );
|
1159 |
+
if ( in_array( $value, $choices ) ) {
|
1160 |
+
return true;
|
1161 |
+
}
|
1162 |
+
}
|
1163 |
+
|
1164 |
+
}
|
1165 |
+
} else {
|
1166 |
+
|
1167 |
+
if ( $field_value && is_array( $field_value ) && ( in_array( $value, $field_value ) || in_array( html_entity_decode( $value ), $field_value ) ) ) {
|
1168 |
+
return true;
|
1169 |
+
}
|
1170 |
+
|
1171 |
+
if ( $field_value == 0 && ! is_array( $field_value ) && $field_value === $value ) {
|
1172 |
+
return true;
|
1173 |
+
}
|
1174 |
+
|
1175 |
+
if ( $field_value && ! is_array( $field_value ) && $field_value == $value ) {
|
1176 |
+
return true;
|
1177 |
+
}
|
1178 |
+
|
1179 |
+
if ( $field_value && ! is_array( $field_value ) && html_entity_decode( $field_value ) == html_entity_decode( $value ) ) {
|
1180 |
+
return true;
|
1181 |
+
}
|
1182 |
+
|
1183 |
+
// show default on edit screen if there isn't meta row in usermeta table
|
1184 |
+
$direct_db_value = $wpdb->get_var( $wpdb->prepare( "SELECT ISNULL( meta_value ) FROM {$wpdb->usermeta} WHERE user_id = %d AND meta_key = %s", um_user( 'ID' ), $key ) );
|
1185 |
+
if ( ! isset( $direct_db_value ) && isset( $data['default'] ) ) {
|
1186 |
+
if ( ! is_array( $data['default'] ) && strstr( $data['default'], ', ' ) ) {
|
1187 |
+
$data['default'] = explode( ', ', $data['default'] );
|
1188 |
+
}
|
1189 |
+
|
1190 |
+
if ( ! is_array( $data['default'] ) && $data['default'] === $value ) {
|
1191 |
+
return true;
|
1192 |
+
}
|
1193 |
+
|
1194 |
+
if ( is_array( $data['default'] ) && in_array( $value, $data['default'] ) ) {
|
1195 |
+
return true;
|
1196 |
+
}
|
1197 |
+
}
|
1198 |
+
}
|
1199 |
+
|
1200 |
+
}
|
1201 |
+
|
1202 |
+
return false;
|
1203 |
+
}
|
1204 |
+
|
1205 |
+
|
1206 |
+
/**
|
1207 |
+
* Checks if a radio button is selected
|
1208 |
+
*
|
1209 |
+
* @param string $key
|
1210 |
+
* @param string $value
|
1211 |
+
* @param array $data
|
1212 |
+
*
|
1213 |
+
* @return boolean
|
1214 |
+
*/
|
1215 |
+
function is_radio_checked( $key, $value, $data ) {
|
1216 |
+
global $wpdb;
|
1217 |
+
|
1218 |
+
if ( isset( UM()->form()->post_form[ $key ] ) ) {
|
1219 |
+
if ( is_array( UM()->form()->post_form[ $key ] ) && in_array( $value, UM()->form()->post_form[ $key ] ) ) {
|
1220 |
+
return true;
|
1221 |
+
} elseif ( $value == UM()->form()->post_form[ $key ] ) {
|
1222 |
+
return true;
|
1223 |
+
}
|
1224 |
+
} else {
|
1225 |
+
|
1226 |
+
if ( $this->editing && 'custom' !== $this->set_mode ) {
|
1227 |
+
if ( um_user( $key ) ) {
|
1228 |
+
|
1229 |
+
$um_user_value = um_user( $key );
|
1230 |
+
|
1231 |
+
if ( strstr( $key, 'role_' ) || $key == 'role' ) {
|
1232 |
+
$um_user_value = strtolower( UM()->roles()->get_editable_priority_user_role( um_user( 'ID' ) ) );
|
1233 |
+
|
1234 |
+
$role_keys = get_option( 'um_roles', array() );
|
1235 |
+
|
1236 |
+
if ( ! empty( $role_keys ) ) {
|
1237 |
+
if ( in_array( $um_user_value, $role_keys ) ) {
|
1238 |
+
$um_user_value = 'um_' . $um_user_value;
|
1239 |
+
}
|
1240 |
+
}
|
1241 |
+
}
|
1242 |
+
|
1243 |
+
if ( $um_user_value == $value ) {
|
1244 |
+
return true;
|
1245 |
+
}
|
1246 |
+
|
1247 |
+
if ( is_array( $um_user_value ) && in_array( $value, $um_user_value ) ) {
|
1248 |
+
return true;
|
1249 |
+
}
|
1250 |
+
|
1251 |
+
if ( is_array( $um_user_value ) ) {
|
1252 |
+
foreach ( $um_user_value as $u ) {
|
1253 |
+
if ( $u == html_entity_decode( $value ) ) {
|
1254 |
+
return true;
|
1255 |
+
}
|
1256 |
+
}
|
1257 |
+
}
|
1258 |
+
} else {
|
1259 |
+
|
1260 |
+
// show default on edit screen if there isn't meta row in usermeta table
|
1261 |
+
$direct_db_value = $wpdb->get_var( $wpdb->prepare( "SELECT ISNULL( meta_value ) FROM {$wpdb->usermeta} WHERE user_id = %d AND meta_key = %s", um_user( 'ID' ), $key ) );
|
1262 |
+
if ( ! isset( $direct_db_value ) && isset( $data['default'] ) && $data['default'] == $value ) {
|
1263 |
+
return true;
|
1264 |
+
}
|
1265 |
+
|
1266 |
+
}
|
1267 |
+
} else {
|
1268 |
+
if ( isset( $data['default'] ) && $data['default'] == $value ) {
|
1269 |
+
return true;
|
1270 |
+
}
|
1271 |
+
}
|
1272 |
+
}
|
1273 |
+
|
1274 |
+
return false;
|
1275 |
+
}
|
1276 |
+
|
1277 |
+
|
1278 |
+
/**
|
1279 |
+
* Get field icon
|
1280 |
+
*
|
1281 |
+
* @param string $key
|
1282 |
+
*
|
1283 |
+
* @return string
|
1284 |
+
*/
|
1285 |
+
function get_field_icon( $key ) {
|
1286 |
+
$fields = UM()->builtin()->all_user_fields;
|
1287 |
+
if ( isset( $fields[ $key ]['icon'] ) ) {
|
1288 |
+
return $fields[ $key ]['icon'];
|
1289 |
+
}
|
1290 |
+
|
1291 |
+
return '';
|
1292 |
+
}
|
1293 |
+
|
1294 |
+
|
1295 |
+
/**
|
1296 |
+
* Gets selected option value from a callback function
|
1297 |
+
*
|
1298 |
+
* @param string $value
|
1299 |
+
* @param array $data
|
1300 |
+
* @param string $type
|
1301 |
+
*
|
1302 |
+
* @return string
|
1303 |
+
*/
|
1304 |
+
function get_option_value_from_callback( $value, $data, $type ) {
|
1305 |
+
|
1306 |
+
if ( in_array( $type, array( 'select', 'multiselect' ) ) && ! empty( $data['custom_dropdown_options_source'] ) ) {
|
1307 |
+
|
1308 |
+
$has_custom_source = apply_filters( "um_has_dropdown_options_source__{$data['metakey']}", false );
|
1309 |
+
|
1310 |
+
if ( $has_custom_source ) {
|
1311 |
+
|
1312 |
+
$opts = apply_filters( "um_get_field__{$data['metakey']}", array() );
|
1313 |
+
$arr_options = $opts['options'];
|
1314 |
+
|
1315 |
+
} elseif ( function_exists( $data['custom_dropdown_options_source'] ) ) {
|
1316 |
+
if ( isset( $data['parent_dropdown_relationship'] ) ) {
|
1317 |
+
$_POST['parent_option_name'] = $data['parent_dropdown_relationship'];
|
1318 |
+
$_POST['parent_option'] = um_user( $data['parent_dropdown_relationship'] );
|
1319 |
+
|
1320 |
+
$arr_options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
1321 |
+
} else {
|
1322 |
+
$arr_options = call_user_func( $data['custom_dropdown_options_source'] );
|
1323 |
+
}
|
1324 |
+
}
|
1325 |
+
|
1326 |
+
if ( $has_custom_source || function_exists( $data['custom_dropdown_options_source'] ) ) {
|
1327 |
+
if ( $type == 'select' ) {
|
1328 |
+
if ( ! empty( $arr_options[ $value ] ) ) {
|
1329 |
+
return $arr_options[ $value ];
|
1330 |
+
} elseif ( ! empty( $data['default'] ) && empty( $arr_options[ $value ] ) ) {
|
1331 |
+
return $arr_options[ $data['default'] ];
|
1332 |
+
} else {
|
1333 |
+
return '';
|
1334 |
+
}
|
1335 |
+
} elseif ( $type == 'multiselect' ) {
|
1336 |
+
|
1337 |
+
if ( is_array( $value ) ) {
|
1338 |
+
$values = $value;
|
1339 |
+
} else {
|
1340 |
+
$values = explode( ', ', $value );
|
1341 |
+
}
|
1342 |
+
|
1343 |
+
$arr_paired_options = array();
|
1344 |
+
|
1345 |
+
foreach ( $values as $option ) {
|
1346 |
+
if ( isset( $arr_options[ $option ] ) ) {
|
1347 |
+
$arr_paired_options[] = $arr_options[ $option ];
|
1348 |
+
}
|
1349 |
+
}
|
1350 |
+
|
1351 |
+
return implode( ', ', $arr_paired_options );
|
1352 |
+
}
|
1353 |
+
}
|
1354 |
+
|
1355 |
+
|
1356 |
+
}
|
1357 |
+
|
1358 |
+
return $value;
|
1359 |
+
}
|
1360 |
+
|
1361 |
+
|
1362 |
+
/**
|
1363 |
+
* Get select options from a callback function
|
1364 |
+
*
|
1365 |
+
* @param array $data
|
1366 |
+
* @param string $type
|
1367 |
+
*
|
1368 |
+
* @return array $arr_options
|
1369 |
+
*/
|
1370 |
+
function get_options_from_callback( $data, $type ) {
|
1371 |
+
$arr_options = array();
|
1372 |
+
|
1373 |
+
if ( in_array( $type, array( 'select', 'multiselect' ) ) && ! empty( $data['custom_dropdown_options_source'] ) ) {
|
1374 |
+
|
1375 |
+
if ( function_exists( $data['custom_dropdown_options_source'] ) ) {
|
1376 |
+
if ( isset( $data['parent_dropdown_relationship'] ) ) {
|
1377 |
+
$arr_options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
1378 |
+
} else {
|
1379 |
+
$arr_options = call_user_func( $data['custom_dropdown_options_source'] );
|
1380 |
+
}
|
1381 |
+
}
|
1382 |
+
|
1383 |
+
}
|
1384 |
+
|
1385 |
+
return $arr_options;
|
1386 |
+
}
|
1387 |
+
|
1388 |
+
|
1389 |
+
/**
|
1390 |
+
* Get field type
|
1391 |
+
*
|
1392 |
+
* @param string $key
|
1393 |
+
*
|
1394 |
+
* @return string
|
1395 |
+
*/
|
1396 |
+
function get_field_type( $key ) {
|
1397 |
+
$fields = UM()->builtin()->all_user_fields;
|
1398 |
+
if ( isset( $fields[ $key ]['type'] ) ) {
|
1399 |
+
return $fields[ $key ]['type'];
|
1400 |
+
}
|
1401 |
+
|
1402 |
+
return '';
|
1403 |
+
}
|
1404 |
+
|
1405 |
+
|
1406 |
+
/**
|
1407 |
+
* Get field label
|
1408 |
+
*
|
1409 |
+
* @param string $key
|
1410 |
+
*
|
1411 |
+
* @return string
|
1412 |
+
*/
|
1413 |
+
function get_label( $key ) {
|
1414 |
+
$label = '';
|
1415 |
+
|
1416 |
+
$fields = UM()->builtin()->all_user_fields;
|
1417 |
+
if ( isset( $fields[ $key ]['label'] ) ) {
|
1418 |
+
$label = stripslashes( $fields[ $key ]['label'] );
|
1419 |
+
}
|
1420 |
+
|
1421 |
+
if ( empty( $label ) && isset( $fields[ $key ]['title'] ) ) {
|
1422 |
+
$label = stripslashes( $fields[ $key ]['title'] );
|
1423 |
+
}
|
1424 |
+
|
1425 |
+
/**
|
1426 |
+
* UM hook
|
1427 |
+
*
|
1428 |
+
* @type filter
|
1429 |
+
* @title um_change_field_label
|
1430 |
+
* @description Change Field Label
|
1431 |
+
* @input_vars
|
1432 |
+
* [{"var":"$label","type":"string","desc":"Field Label"},
|
1433 |
+
* {"var":"$key","type":"string","desc":"Field Key"}]
|
1434 |
+
* @change_log
|
1435 |
+
* ["Since: 2.0.30"]
|
1436 |
+
* @usage add_filter( 'um_change_field_label', 'function_name', 10, 2 );
|
1437 |
+
* @example
|
1438 |
+
* <?php
|
1439 |
+
* add_filter( 'um_change_field_label', 'my_change_field_label', 10, 2 );
|
1440 |
+
* function my_form_fields( $label, $key ) {
|
1441 |
+
* // your code here
|
1442 |
+
* return $label;
|
1443 |
+
* }
|
1444 |
+
* ?>
|
1445 |
+
*/
|
1446 |
+
$label = apply_filters( 'um_change_field_label', $label, $key );
|
1447 |
+
|
1448 |
+
$label = sprintf( __( '%s', 'ultimate-member' ), $label );
|
1449 |
+
return $label;
|
1450 |
+
}
|
1451 |
+
|
1452 |
+
|
1453 |
+
/**
|
1454 |
+
* Get field title
|
1455 |
+
*
|
1456 |
+
* @param string $key
|
1457 |
+
*
|
1458 |
+
* @return string
|
1459 |
+
*/
|
1460 |
+
function get_field_title( $key ) {
|
1461 |
+
$fields = UM()->builtin()->all_user_fields;
|
1462 |
+
if ( isset( $fields[ $key ]['title'] ) ) {
|
1463 |
+
return $fields[ $key ]['title'];
|
1464 |
+
}
|
1465 |
+
if ( isset( $fields[ $key ]['label'] ) ) {
|
1466 |
+
return $fields[ $key ]['label'];
|
1467 |
+
}
|
1468 |
+
|
1469 |
+
return __( 'Custom Field', 'ultimate-member' );
|
1470 |
+
}
|
1471 |
+
|
1472 |
+
|
1473 |
+
/**
|
1474 |
+
* Get form fields
|
1475 |
+
*
|
1476 |
+
* @return array
|
1477 |
+
*/
|
1478 |
+
function get_fields() {
|
1479 |
+
/**
|
1480 |
+
* UM hook
|
1481 |
+
*
|
1482 |
+
* @type filter
|
1483 |
+
* @title um_get_form_fields
|
1484 |
+
* @description Extend form fields
|
1485 |
+
* @input_vars
|
1486 |
+
* [{"var":"$fields","type":"array","desc":"Selected filter value"}]
|
1487 |
+
* @change_log
|
1488 |
+
* ["Since: 2.0"]
|
1489 |
+
* @usage add_filter( 'um_get_form_fields', 'function_name', 10, 1 );
|
1490 |
+
* @example
|
1491 |
+
* <?php
|
1492 |
+
* add_filter( 'um_get_form_fields', 'my_form_fields', 10, 1 );
|
1493 |
+
* function my_form_fields( $fields ) {
|
1494 |
+
* // your code here
|
1495 |
+
* return $fields;
|
1496 |
+
* }
|
1497 |
+
* ?>
|
1498 |
+
*/
|
1499 |
+
$this->fields = apply_filters( 'um_get_form_fields', array() );
|
1500 |
+
return $this->fields;
|
1501 |
+
}
|
1502 |
+
|
1503 |
+
|
1504 |
+
/**
|
1505 |
+
* Get specific field
|
1506 |
+
*
|
1507 |
+
* @param $key
|
1508 |
+
*
|
1509 |
+
* @return mixed
|
1510 |
+
* @throws \Exception
|
1511 |
+
*/
|
1512 |
+
function get_field( $key ) {
|
1513 |
+
$fields = $this->get_fields();
|
1514 |
+
|
1515 |
+
if ( isset( $fields ) && is_array( $fields ) && isset( $fields[ $key ] ) ) {
|
1516 |
+
$array = $fields[ $key ];
|
1517 |
+
} else {
|
1518 |
+
if ( ! isset( UM()->builtin()->predefined_fields[ $key ] ) && ! isset( UM()->builtin()->all_user_fields[ $key ] ) ) {
|
1519 |
+
return '';
|
1520 |
+
}
|
1521 |
+
$array = ( isset( UM()->builtin()->predefined_fields[ $key ] ) ) ? UM()->builtin()->predefined_fields[ $key ] : UM()->builtin()->all_user_fields[ $key ];
|
1522 |
+
}
|
1523 |
+
|
1524 |
+
$array['classes'] = null;
|
1525 |
+
|
1526 |
+
if ( ! isset( $array['placeholder'] ) ) {
|
1527 |
+
$array['placeholder'] = null;
|
1528 |
+
}
|
1529 |
+
if ( ! isset( $array['required'] ) ) {
|
1530 |
+
$array['required'] = null;
|
1531 |
+
}
|
1532 |
+
if ( ! isset( $array['validate'] ) ) {
|
1533 |
+
$array['validate'] = null;
|
1534 |
+
}
|
1535 |
+
if ( ! isset( $array['default'] ) ) {
|
1536 |
+
$array['default'] = null;
|
1537 |
+
}
|
1538 |
+
|
1539 |
+
if ( isset( $array['conditions'] ) && is_array( $array['conditions'] ) && ! $this->viewing ) {
|
1540 |
+
$array['conditional'] = '';
|
1541 |
+
|
1542 |
+
foreach ( $array['conditions'] as $cond_id => $cond ) {
|
1543 |
+
$array['conditional'] .= ' data-cond-' . $cond_id . '-action="' . esc_attr( $cond[0] ) . '" data-cond-' . $cond_id . '-field="' . esc_attr( $cond[1] ) . '" data-cond-' . $cond_id . '-operator="' . esc_attr( $cond[2] ) . '" data-cond-' . $cond_id . '-value="' . esc_attr( $cond[3] ) . '"';
|
1544 |
+
}
|
1545 |
+
|
1546 |
+
$array['classes'] .= ' um-is-conditional';
|
1547 |
+
|
1548 |
+
} else {
|
1549 |
+
$array['conditional'] = null;
|
1550 |
+
}
|
1551 |
+
|
1552 |
+
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
1553 |
+
|
1554 |
+
if ( ! in_array( $array['type'], $fields_without_metakey ) ) {
|
1555 |
+
$array['classes'] .= ' um-field-' . esc_attr( $key );
|
1556 |
+
}
|
1557 |
+
$array['classes'] .= ' um-field-' . esc_attr( $array['type'] );
|
1558 |
+
$array['classes'] .= ' um-field-type_' . esc_attr( $array['type'] );
|
1559 |
+
|
1560 |
+
switch ( $array['type'] ) {
|
1561 |
+
|
1562 |
+
case 'googlemap':
|
1563 |
+
case 'youtube_video':
|
1564 |
+
case 'vimeo_video':
|
1565 |
+
case 'soundcloud_track':
|
1566 |
+
$array['disabled'] = '';
|
1567 |
+
$array['input'] = 'text';
|
1568 |
+
break;
|
1569 |
+
|
1570 |
+
case 'text':
|
1571 |
+
|
1572 |
+
$array['disabled'] = '';
|
1573 |
+
|
1574 |
+
if ( $key == 'user_login' && isset( $this->set_mode ) && $this->set_mode == 'account' ) {
|
1575 |
+
$array['disabled'] = 'disabled="disabled"';
|
1576 |
+
}
|
1577 |
+
|
1578 |
+
$array['input'] = 'text';
|
1579 |
+
|
1580 |
+
break;
|
1581 |
+
|
1582 |
+
case 'password':
|
1583 |
+
|
1584 |
+
$array['input'] = 'password';
|
1585 |
+
|
1586 |
+
break;
|
1587 |
+
|
1588 |
+
case 'number':
|
1589 |
+
|
1590 |
+
$array['disabled'] = '';
|
1591 |
+
|
1592 |
+
break;
|
1593 |
+
|
1594 |
+
case 'url':
|
1595 |
+
|
1596 |
+
$array['input'] = 'text';
|
1597 |
+
|
1598 |
+
break;
|
1599 |
+
|
1600 |
+
case 'date':
|
1601 |
+
|
1602 |
+
$array['input'] = 'text';
|
1603 |
+
|
1604 |
+
if ( ! isset( $array['format'] ) ) {
|
1605 |
+
$array['format'] = 'j M Y';
|
1606 |
+
}
|
1607 |
+
|
1608 |
+
switch ( $array['format'] ) {
|
1609 |
+
case 'j M Y':
|
1610 |
+
$js_format = 'd mmm yyyy';
|
1611 |
+
break;
|
1612 |
+
case 'j F Y':
|
1613 |
+
$js_format = 'd mmmm yyyy';
|
1614 |
+
break;
|
1615 |
+
case 'M j Y':
|
1616 |
+
$js_format = 'mmm d yyyy';
|
1617 |
+
break;
|
1618 |
+
case 'F j Y':
|
1619 |
+
$js_format = 'mmmm d yyyy';
|
1620 |
+
break;
|
1621 |
+
}
|
1622 |
+
|
1623 |
+
$array['js_format'] = $js_format;
|
1624 |
+
|
1625 |
+
if ( ! isset( $array['range'] ) ) {
|
1626 |
+
$array['range'] = 'years';
|
1627 |
+
}
|
1628 |
+
if ( ! isset( $array['years'] ) ) {
|
1629 |
+
$array['years'] = 100;
|
1630 |
+
}
|
1631 |
+
if ( ! isset( $array['years_x'] ) ) {
|
1632 |
+
$array['years_x'] = 'past';
|
1633 |
+
}
|
1634 |
+
if ( ! isset( $array['disabled_weekdays'] ) ) {
|
1635 |
+
$array['disabled_weekdays'] = '';
|
1636 |
+
}
|
1637 |
+
|
1638 |
+
if ( ! empty( $array['disabled_weekdays'] ) ) {
|
1639 |
+
$array['disabled_weekdays'] = '[' . implode( ',', $array['disabled_weekdays'] ) . ']';
|
1640 |
+
}
|
1641 |
+
|
1642 |
+
// When date range is strictly defined
|
1643 |
+
if ( $array['range'] == 'date_range' ) {
|
1644 |
+
|
1645 |
+
$array['date_min'] = str_replace( '/', ',', $array['range_start'] );
|
1646 |
+
$array['date_max'] = str_replace( '/', ',', $array['range_end'] );
|
1647 |
+
|
1648 |
+
} else {
|
1649 |
+
|
1650 |
+
if ( $array['years_x'] == 'past' ) {
|
1651 |
+
|
1652 |
+
$date = new \DateTime( date( 'Y-n-d' ) );
|
1653 |
+
$past = $date->modify( '-' . $array['years'] . ' years' );
|
1654 |
+
$past = $date->format( 'Y,n,d' );
|
1655 |
+
|
1656 |
+
$array['date_min'] = $past;
|
1657 |
+
$array['date_max'] = date( 'Y,n,d' );
|
1658 |
+
|
1659 |
+
} elseif ( $array['years_x'] == 'future' ) {
|
1660 |
+
|
1661 |
+
$date = new \DateTime( date( 'Y-n-d' ) );
|
1662 |
+
$future = $date->modify( '+' . $array['years'] . ' years' );
|
1663 |
+
$future = $date->format( 'Y,n,d' );
|
1664 |
+
|
1665 |
+
$array['date_min'] = date( 'Y,n,d' );
|
1666 |
+
$array['date_max'] = $future;
|
1667 |
+
|
1668 |
+
} else {
|
1669 |
+
|
1670 |
+
$date = new \DateTime( date( 'Y-n-d' ) );
|
1671 |
+
$date_f = new \DateTime( date( 'Y-n-d' ) );
|
1672 |
+
$past = $date->modify( '-' . ( $array['years'] / 2 ) . ' years' );
|
1673 |
+
$past = $date->format( 'Y,n,d' );
|
1674 |
+
$future = $date_f->modify( '+' . ( $array['years'] / 2 ) . ' years' );
|
1675 |
+
$future = $date_f->format( 'Y,n,d' );
|
1676 |
+
|
1677 |
+
$array['date_min'] = $past;
|
1678 |
+
$array['date_max'] = $future;
|
1679 |
+
|
1680 |
+
}
|
1681 |
+
|
1682 |
+
}
|
1683 |
+
|
1684 |
+
break;
|
1685 |
+
|
1686 |
+
case 'time':
|
1687 |
+
|
1688 |
+
$array['input'] = 'text';
|
1689 |
+
|
1690 |
+
if ( ! isset( $array['format'] ) ) {
|
1691 |
+
$array['format'] = 'g:i a';
|
1692 |
+
}
|
1693 |
+
|
1694 |
+
switch ( $array['format'] ) {
|
1695 |
+
case 'g:i a':
|
1696 |
+
$js_format = 'h:i a';
|
1697 |
+
break;
|
1698 |
+
case 'g:i A':
|
1699 |
+
$js_format = 'h:i A';
|
1700 |
+
break;
|
1701 |
+
case 'H:i':
|
1702 |
+
$js_format = 'HH:i';
|
1703 |
+
break;
|
1704 |
+
}
|
1705 |
+
|
1706 |
+
$array['js_format'] = $js_format;
|
1707 |
+
|
1708 |
+
if ( ! isset( $array['intervals'] ) ) {
|
1709 |
+
$array['intervals'] = 60;
|
1710 |
+
}
|
1711 |
+
|
1712 |
+
break;
|
1713 |
+
|
1714 |
+
case 'textarea':
|
1715 |
+
|
1716 |
+
if ( ! isset( $array['height'] ) ) {
|
1717 |
+
$array['height'] = '100px';
|
1718 |
+
}
|
1719 |
+
|
1720 |
+
break;
|
1721 |
+
|
1722 |
+
case 'rating':
|
1723 |
+
|
1724 |
+
if ( ! isset( $array['number'] ) ) {
|
1725 |
+
$array['number'] = 5;
|
1726 |
+
}
|
1727 |
+
|
1728 |
+
break;
|
1729 |
+
|
1730 |
+
case 'spacing':
|
1731 |
+
|
1732 |
+
if ( ! isset( $array['spacing'] ) ) {
|
1733 |
+
$array['spacing'] = '20px';
|
1734 |
+
}
|
1735 |
+
|
1736 |
+
break;
|
1737 |
+
|
1738 |
+
case 'divider':
|
1739 |
+
|
1740 |
+
if ( isset( $array['width'] ) ) {
|
1741 |
+
$array['borderwidth'] = $array['width'];
|
1742 |
+
} else {
|
1743 |
+
$array['borderwidth'] = 4;
|
1744 |
+
}
|
1745 |
+
|
1746 |
+
if ( isset( $array['color'] ) ) {
|
1747 |
+
$array['bordercolor'] = $array['color'];
|
1748 |
+
} else {
|
1749 |
+
$array['bordercolor'] = '#eee';
|
1750 |
+
}
|
1751 |
+
|
1752 |
+
if ( isset( $array['style'] ) ) {
|
1753 |
+
$array['borderstyle'] = $array['style'];
|
1754 |
+
} else {
|
1755 |
+
$array['borderstyle'] = 'solid';
|
1756 |
+
}
|
1757 |
+
|
1758 |
+
if ( ! isset( $array['divider_text'] ) ) {
|
1759 |
+
$array['divider_text'] = '';
|
1760 |
+
}
|
1761 |
+
|
1762 |
+
break;
|
1763 |
+
|
1764 |
+
case 'image':
|
1765 |
+
|
1766 |
+
if ( ! isset( $array['crop'] ) ) {
|
1767 |
+
$array['crop'] = 0;
|
1768 |
+
}
|
1769 |
+
|
1770 |
+
if ( $array['crop'] == 0 ) {
|
1771 |
+
$array['crop_data'] = 0;
|
1772 |
+
} elseif ( $array['crop'] == 1 ) {
|
1773 |
+
$array['crop_data'] = 'square';
|
1774 |
+
} elseif ( $array['crop'] == 2 ) {
|
1775 |
+
$array['crop_data'] = 'cover';
|
1776 |
+
} else {
|
1777 |
+
$array['crop_data'] = 'user';
|
1778 |
+
}
|
1779 |
+
|
1780 |
+
if ( ! isset( $array['modal_size'] ) ) {
|
1781 |
+
$array['modal_size'] = 'normal';
|
1782 |
+
}
|
1783 |
+
|
1784 |
+
if ( $array['crop'] > 0 ) {
|
1785 |
+
$array['crop_class'] = 'crop';
|
1786 |
+
} else {
|
1787 |
+
$array['crop_class'] = '';
|
1788 |
+
}
|
1789 |
+
|
1790 |
+
if ( ! isset( $array['ratio'] ) ) {
|
1791 |
+
$array['ratio'] = 1.0;
|
1792 |
+
}
|
1793 |
+
|
1794 |
+
if ( ! isset( $array['min_width'] ) ) {
|
1795 |
+
$array['min_width'] = '';
|
1796 |
+
}
|
1797 |
+
if ( ! isset( $array['min_height'] ) ) {
|
1798 |
+
$array['min_height'] = '';
|
1799 |
+
}
|
1800 |
+
|
1801 |
+
if ( $array['min_width'] == '' && $array['crop'] == 1 ) {
|
1802 |
+
$array['min_width'] = 600;
|
1803 |
+
}
|
1804 |
+
if ( $array['min_height'] == '' && $array['crop'] == 1 ) {
|
1805 |
+
$array['min_height'] = 600;
|
1806 |
+
}
|
1807 |
+
|
1808 |
+
if ( $array['min_width'] == '' && $array['crop'] == 3 ) {
|
1809 |
+
$array['min_width'] = 600;
|
1810 |
+
}
|
1811 |
+
if ( $array['min_height'] == '' && $array['crop'] == 3 ) {
|
1812 |
+
$array['min_height'] = 600;
|
1813 |
+
}
|
1814 |
+
|
1815 |
+
if ( ! isset( $array['invalid_image'] ) ) {
|
1816 |
+
$array['invalid_image'] = __( 'Please upload a valid image!', 'ultimate-member' );
|
1817 |
+
}
|
1818 |
+
if ( ! isset( $array['allowed_types'] ) ) {
|
1819 |
+
$array['allowed_types'] = 'gif,jpg,jpeg,png';
|
1820 |
+
} else {
|
1821 |
+
$array['allowed_types'] = implode( ',', $array['allowed_types'] );
|
1822 |
+
}
|
1823 |
+
if ( ! isset( $array['upload_text'] ) ) {
|
1824 |
+
$array['upload_text'] = '';
|
1825 |
+
}
|
1826 |
+
if ( ! isset( $array['button_text'] ) ) {
|
1827 |
+
$array['button_text'] = __( 'Upload', 'ultimate-member' );
|
1828 |
+
}
|
1829 |
+
if ( ! isset( $array['extension_error'] ) ) {
|
1830 |
+
$array['extension_error'] = __( 'Sorry this is not a valid image.', 'ultimate-member' );
|
1831 |
+
}
|
1832 |
+
if ( ! isset( $array['max_size_error'] ) ) {
|
1833 |
+
$array['max_size_error'] = __( 'This image is too large!', 'ultimate-member' );
|
1834 |
+
}
|
1835 |
+
if ( ! isset( $array['min_size_error'] ) ) {
|
1836 |
+
$array['min_size_error'] = __( 'This image is too small!', 'ultimate-member' );
|
1837 |
+
}
|
1838 |
+
if ( ! isset( $array['max_files_error'] ) ) {
|
1839 |
+
$array['max_files_error'] = __( 'You can only upload one image', 'ultimate-member' );
|
1840 |
+
}
|
1841 |
+
if ( empty( $array['max_size'] ) ) {
|
1842 |
+
$array['max_size'] = 999999999;
|
1843 |
+
}
|
1844 |
+
if ( ! isset( $array['upload_help_text'] ) ) {
|
1845 |
+
$array['upload_help_text'] = '';
|
1846 |
+
}
|
1847 |
+
if ( ! isset( $array['icon'] ) ) {
|
1848 |
+
$array['icon'] = '';
|
1849 |
+
}
|
1850 |
+
|
1851 |
+
break;
|
1852 |
+
|
1853 |
+
case 'file':
|
1854 |
+
|
1855 |
+
if ( ! isset( $array['modal_size'] ) ) {
|
1856 |
+
$array['modal_size'] = 'normal';
|
1857 |
+
}
|
1858 |
+
|
1859 |
+
if ( ! isset( $array['allowed_types'] ) ) {
|
1860 |
+
$array['allowed_types'] = 'pdf,txt';
|
1861 |
+
} else {
|
1862 |
+
$array['allowed_types'] = implode( ',', $array['allowed_types'] );
|
1863 |
+
}
|
1864 |
+
if ( ! isset( $array['upload_text'] ) ) {
|
1865 |
+
$array['upload_text'] = '';
|
1866 |
+
}
|
1867 |
+
if ( ! isset( $array['button_text'] ) ) {
|
1868 |
+
$array['button_text'] = __( 'Upload', 'ultimate-member' );
|
1869 |
+
}
|
1870 |
+
if ( ! isset( $array['extension_error'] ) ) {
|
1871 |
+
$array['extension_error'] = __( 'Sorry this is not a valid file.', 'ultimate-member' );
|
1872 |
+
}
|
1873 |
+
if ( ! isset( $array['max_size_error'] ) ) {
|
1874 |
+
$array['max_size_error'] = __( 'This file is too large!', 'ultimate-member' );
|
1875 |
+
}
|
1876 |
+
if ( ! isset( $array['min_size_error'] ) ) {
|
1877 |
+
$array['min_size_error'] = __( 'This file is too small!', 'ultimate-member' );
|
1878 |
+
}
|
1879 |
+
if ( ! isset( $array['max_files_error'] ) ) {
|
1880 |
+
$array['max_files_error'] = __( 'You can only upload one file', 'ultimate-member' );
|
1881 |
+
}
|
1882 |
+
if ( empty( $array['max_size'] ) ) {
|
1883 |
+
$array['max_size'] = 999999999;
|
1884 |
+
}
|
1885 |
+
if ( ! isset( $array['upload_help_text'] ) ) {
|
1886 |
+
$array['upload_help_text'] = '';
|
1887 |
+
}
|
1888 |
+
if ( ! isset( $array['icon'] ) ) {
|
1889 |
+
$array['icon'] = '';
|
1890 |
+
}
|
1891 |
+
|
1892 |
+
break;
|
1893 |
+
|
1894 |
+
case 'select':
|
1895 |
+
|
1896 |
+
break;
|
1897 |
+
|
1898 |
+
case 'multiselect':
|
1899 |
+
|
1900 |
+
break;
|
1901 |
+
|
1902 |
+
case 'group':
|
1903 |
+
|
1904 |
+
if ( ! isset( $array['max_entries'] ) ) {
|
1905 |
+
$array['max_entries'] = 0;
|
1906 |
+
}
|
1907 |
+
|
1908 |
+
break;
|
1909 |
+
|
1910 |
+
}
|
1911 |
+
|
1912 |
+
if ( ! isset( $array['visibility'] ) ) {
|
1913 |
+
$array['visibility'] = 'all';
|
1914 |
+
}
|
1915 |
+
|
1916 |
+
/**
|
1917 |
+
* UM hook
|
1918 |
+
*
|
1919 |
+
* @type filter
|
1920 |
+
* @title um_get_field__{$key}
|
1921 |
+
* @description Extend field data by field $key
|
1922 |
+
* @input_vars
|
1923 |
+
* [{"var":"$data","type":"array","desc":"Field Data"}]
|
1924 |
+
* @change_log
|
1925 |
+
* ["Since: 2.0"]
|
1926 |
+
* @usage add_filter( 'um_get_field__{$key}', 'function_name', 10, 1 );
|
1927 |
+
* @example
|
1928 |
+
* <?php
|
1929 |
+
* add_filter( 'um_get_field__{$key}', 'my_get_field', 10, 1 );
|
1930 |
+
* function my_get_field( $data ) {
|
1931 |
+
* // your code here
|
1932 |
+
* return $data;
|
1933 |
+
* }
|
1934 |
+
* ?>
|
1935 |
+
*/
|
1936 |
+
$array = apply_filters( "um_get_field__{$key}", $array );
|
1937 |
+
|
1938 |
+
return $array;
|
1939 |
+
}
|
1940 |
+
|
1941 |
+
|
1942 |
+
/**
|
1943 |
+
* @param $option_value
|
1944 |
+
*
|
1945 |
+
* @return mixed|void
|
1946 |
+
*/
|
1947 |
+
function filter_field_non_utf8_value( $option_value ) {
|
1948 |
+
/**
|
1949 |
+
* UM hook
|
1950 |
+
*
|
1951 |
+
* @type filter
|
1952 |
+
* @title um_field_non_utf8_value
|
1953 |
+
* @description Change dropdown option text
|
1954 |
+
* @input_vars
|
1955 |
+
* [{"var":"$value","type":"string","desc":"Option Value"}]
|
1956 |
+
* @change_log
|
1957 |
+
* ["Since: 2.0"]
|
1958 |
+
* @usage add_filter( 'um_field_non_utf8_value', 'function_name', 10, 1 );
|
1959 |
+
* @example
|
1960 |
+
* <?php
|
1961 |
+
* add_filter( 'um_field_non_utf8_value', 'my_field_non_utf8_value', 10, 1 );
|
1962 |
+
* function my_field_non_utf8_value( $value ) {
|
1963 |
+
* // your code here
|
1964 |
+
* return $value;
|
1965 |
+
* }
|
1966 |
+
* ?>
|
1967 |
+
*/
|
1968 |
+
return apply_filters( 'um_field_non_utf8_value', $option_value );
|
1969 |
+
}
|
1970 |
+
|
1971 |
+
|
1972 |
+
/**
|
1973 |
+
* Getting the fields that need to be disabled in edit mode (profile)
|
1974 |
+
*
|
1975 |
+
* @param bool $_um_profile_id
|
1976 |
+
*
|
1977 |
+
* @return array
|
1978 |
+
*/
|
1979 |
+
function get_restricted_fields_for_edit( $_um_profile_id = false ) {
|
1980 |
+
// fields that need to be disabled in edit mode (profile)
|
1981 |
+
$arr_restricted_fields = array( 'user_email', 'username', 'user_login', 'user_password', '_um_last_login' );
|
1982 |
+
$arr_restricted_fields = apply_filters( 'um_user_profile_restricted_edit_fields', $arr_restricted_fields, $_um_profile_id );
|
1983 |
+
|
1984 |
+
return $arr_restricted_fields;
|
1985 |
+
}
|
1986 |
+
|
1987 |
+
|
1988 |
+
/**
|
1989 |
+
* Gets a field in 'input mode'
|
1990 |
+
*
|
1991 |
+
* @param string $key
|
1992 |
+
* @param array $data
|
1993 |
+
* @param bool $rule
|
1994 |
+
* @param array $args
|
1995 |
+
*
|
1996 |
+
* @return string|null
|
1997 |
+
* @throws \Exception
|
1998 |
+
*/
|
1999 |
+
function edit_field( $key, $data, $rule = false, $args = array() ) {
|
2000 |
+
global $_um_profile_id;
|
2001 |
+
|
2002 |
+
$output = '';
|
2003 |
+
$disabled = '';
|
2004 |
+
if ( empty( $_um_profile_id ) ) {
|
2005 |
+
$_um_profile_id = um_user( 'ID' );
|
2006 |
+
}
|
2007 |
+
|
2008 |
+
// get whole field data
|
2009 |
+
if ( isset( $data ) && is_array( $data ) ) {
|
2010 |
+
$data = $this->get_field( $key );
|
2011 |
+
if ( is_array( $data ) ) {
|
2012 |
+
/**
|
2013 |
+
* @var string $in_row
|
2014 |
+
* @var boolean $in_sub_row
|
2015 |
+
* @var boolean $in_column
|
2016 |
+
* @var string $type
|
2017 |
+
* @var string $metakey
|
2018 |
+
* @var int $position
|
2019 |
+
* @var string $title
|
2020 |
+
* @var string $help
|
2021 |
+
* @var array $options
|
2022 |
+
* @var string $visibility
|
2023 |
+
* @var string $label
|
2024 |
+
* @var string $placeholder
|
2025 |
+
* @var boolean $public
|
2026 |
+
* @var boolean $editable
|
2027 |
+
* @var string $icon
|
2028 |
+
* @var boolean $in_group
|
2029 |
+
* @var boolean $required
|
2030 |
+
* @var string $validate
|
2031 |
+
* @var string $default
|
2032 |
+
* @var string $conditional
|
2033 |
+
* @var string $input
|
2034 |
+
* @var string $js_format
|
2035 |
+
* @var string $date_max
|
2036 |
+
* @var string $date_min
|
2037 |
+
* @var string $disabled_weekdays
|
2038 |
+
* @var string $years_x
|
2039 |
+
* @var string $years
|
2040 |
+
* @var string $range
|
2041 |
+
* @var string $intervals
|
2042 |
+
* @var string $height
|
2043 |
+
* @var string $spacing
|
2044 |
+
* @var string $borderwidth
|
2045 |
+
* @var string $borderstyle
|
2046 |
+
* @var string $bordercolor
|
2047 |
+
* @var string $divider_text
|
2048 |
+
* @var string $crop_class
|
2049 |
+
* @var string $crop_data
|
2050 |
+
* @var string $modal_size
|
2051 |
+
* @var string $ratio
|
2052 |
+
* @var string $min_width
|
2053 |
+
* @var string $min_height
|
2054 |
+
* @var string $button_text
|
2055 |
+
* @var string $max_size
|
2056 |
+
* @var string $max_size_error
|
2057 |
+
* @var string $extension_error
|
2058 |
+
* @var string $allowed_types
|
2059 |
+
* @var string $upload_text
|
2060 |
+
* @var string $max_files_error
|
2061 |
+
* @var string $upload_help_text
|
2062 |
+
* @var string $min_size_error
|
2063 |
+
* @var string $filter
|
2064 |
+
* @var string $content
|
2065 |
+
* @var string $max_entries
|
2066 |
+
*/
|
2067 |
+
extract( $data );
|
2068 |
+
}
|
2069 |
+
}
|
2070 |
+
|
2071 |
+
if ( ! isset( $data['type'] ) ) {
|
2072 |
+
return '';
|
2073 |
+
}
|
2074 |
+
|
2075 |
+
if ( isset( $data['in_group'] ) && $data['in_group'] != '' && $rule != 'group' ) {
|
2076 |
+
return '';
|
2077 |
+
}
|
2078 |
+
|
2079 |
+
// forbidden in edit mode? 'edit_forbidden' - it's field attribute predefined in the field data in code
|
2080 |
+
if ( isset( $data['edit_forbidden'] ) ) {
|
2081 |
+
return '';
|
2082 |
+
}
|
2083 |
+
|
2084 |
+
// required option? 'required_opt' - it's field attribute predefined in the field data in code
|
2085 |
+
if ( isset( $data['required_opt'] ) ) {
|
2086 |
+
$opt = $data['required_opt'];
|
2087 |
+
if ( UM()->options()->get( $opt[0] ) != $opt[1] ) {
|
2088 |
+
return '';
|
2089 |
+
}
|
2090 |
+
}
|
2091 |
+
|
2092 |
+
// required user permission 'required_perm' - it's field attribute predefined in the field data in code
|
2093 |
+
if ( isset( $data['required_perm'] ) ) {
|
2094 |
+
if ( ! UM()->roles()->um_user_can( $data['required_perm'] ) ) {
|
2095 |
+
return '';
|
2096 |
+
}
|
2097 |
+
}
|
2098 |
+
|
2099 |
+
// fields that need to be disabled in edit mode (profile) (email, username, etc.)
|
2100 |
+
$arr_restricted_fields = $this->get_restricted_fields_for_edit( $_um_profile_id );
|
2101 |
+
if ( in_array( $key, $arr_restricted_fields ) && $this->editing == true && $this->set_mode == 'profile' ) {
|
2102 |
+
return '';
|
2103 |
+
}
|
2104 |
+
|
2105 |
+
|
2106 |
+
if ( $visibility == 'view' && $this->set_mode != 'register' ) {
|
2107 |
+
return '';
|
2108 |
+
}
|
2109 |
+
|
2110 |
+
if ( ! um_can_view_field( $data ) ) {
|
2111 |
+
return '';
|
2112 |
+
}
|
2113 |
+
|
2114 |
+
um_fetch_user( $_um_profile_id );
|
2115 |
+
|
2116 |
+
// Stop return empty values build field attributes:
|
2117 |
+
|
2118 |
+
if ( $visibility == 'view' && $this->set_mode == 'register' ) {
|
2119 |
+
|
2120 |
+
um_fetch_user( get_current_user_id() );
|
2121 |
+
if ( ! um_user( 'can_edit_everyone' ) ) {
|
2122 |
+
$disabled = ' disabled="disabled" ';
|
2123 |
+
}
|
2124 |
+
|
2125 |
+
um_fetch_user( $_um_profile_id );
|
2126 |
+
if ( isset( $data['public'] ) && $data['public'] == '-2' && $data['roles'] ) {
|
2127 |
+
$current_user_roles = um_user( 'roles' );
|
2128 |
+
if ( ! empty( $current_user_roles ) && count( array_intersect( $current_user_roles, $data['roles'] ) ) > 0 ) {
|
2129 |
+
$disabled = '';
|
2130 |
+
}
|
2131 |
+
}
|
2132 |
+
}
|
2133 |
+
|
2134 |
+
if ( ! empty( $this->editing ) && $this->set_mode == 'profile' ) {
|
2135 |
+
if ( ! UM()->roles()->um_user_can( 'can_edit_everyone' ) ) {
|
2136 |
+
if ( isset( $data['editable'] ) && $data['editable'] == 0 ) {
|
2137 |
+
$disabled = ' disabled="disabled" ';
|
2138 |
+
}
|
2139 |
+
}
|
2140 |
+
}
|
2141 |
+
|
2142 |
+
$disabled = apply_filters( 'um_is_field_disabled', $disabled, $data );
|
2143 |
+
|
2144 |
+
if ( ! isset( $data['autocomplete'] ) ) {
|
2145 |
+
$autocomplete = 'off';
|
2146 |
+
}
|
2147 |
+
|
2148 |
+
if ( isset( $data['classes'] ) ) {
|
2149 |
+
$classes = explode( " ", $data['classes'] );
|
2150 |
+
}
|
2151 |
+
|
2152 |
+
um_fetch_user( $_um_profile_id );
|
2153 |
+
|
2154 |
+
/**
|
2155 |
+
* UM hook
|
2156 |
+
*
|
2157 |
+
* @type filter
|
2158 |
+
* @title um_hook_for_field_{$type}
|
2159 |
+
* @description Change field type
|
2160 |
+
* @input_vars
|
2161 |
+
* [{"var":"$type","type":"string","desc":"Field Type"}]
|
2162 |
+
* @change_log
|
2163 |
+
* ["Since: 2.0"]
|
2164 |
+
* @usage add_filter( 'um_hook_for_field_{$type}', 'function_name', 10, 1 );
|
2165 |
+
* @example
|
2166 |
+
* <?php
|
2167 |
+
* add_filter( 'um_hook_for_field_{$type}', 'my_field_type', 10, 1 );
|
2168 |
+
* function my_get_field( $type ) {
|
2169 |
+
* // your code here
|
2170 |
+
* return $type;
|
2171 |
+
* }
|
2172 |
+
* ?>
|
2173 |
+
*/
|
2174 |
+
$type = apply_filters( "um_hook_for_field_{$type}", $type );
|
2175 |
+
switch ( $type ) {
|
2176 |
+
|
2177 |
+
case 'textarea':
|
2178 |
+
case 'multiselect':
|
2179 |
+
$field_id = $field_name = $key;
|
2180 |
+
$field_value = $this->field_value( $key, $default, $data );
|
2181 |
+
break;
|
2182 |
+
|
2183 |
+
case 'select':
|
2184 |
+
case 'radio':
|
2185 |
+
$form_key = str_replace( array( 'role_select', 'role_radio' ), 'role', $key );
|
2186 |
+
$field_id = $form_key;
|
2187 |
+
break;
|
2188 |
+
default:
|
2189 |
+
$field_id = '';
|
2190 |
+
break;
|
2191 |
+
}
|
2192 |
+
|
2193 |
+
/**
|
2194 |
+
* UM hook
|
2195 |
+
*
|
2196 |
+
* @type filter
|
2197 |
+
* @title um_completeness_field_id
|
2198 |
+
* @description use for change core id not allowed duplicate
|
2199 |
+
* @input_vars
|
2200 |
+
* [{"var":"$field_id","type":"string","desc":"Field id"},
|
2201 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
2202 |
+
* {"var":"$args","type":"array","desc":"Optional field arguments"}]
|
2203 |
+
* @change_log
|
2204 |
+
* ["Since: 2.0.13"]
|
2205 |
+
* @usage add_filter( 'um_completeness_field_id', 'function_name', 10, 3 );
|
2206 |
+
* @example
|
2207 |
+
* <?php
|
2208 |
+
* add_filter( 'um_completeness_field_id', 'function_name', 10, 3 );
|
2209 |
+
* function function_name( $field_id, $data, $args ) {
|
2210 |
+
* // your code here
|
2211 |
+
* return $field_id;
|
2212 |
+
* }
|
2213 |
+
* ?>
|
2214 |
+
*/
|
2215 |
+
$field_id = apply_filters( 'um_completeness_field_id', $field_id, $data, $args );
|
2216 |
+
|
2217 |
+
|
2218 |
+
/* Begin by field type */
|
2219 |
+
switch ( $type ) {
|
2220 |
+
|
2221 |
+
/* Default: Integration */
|
2222 |
+
default:
|
2223 |
+
$mode = ( isset( $this->set_mode ) ) ? $this->set_mode : 'no_mode';
|
2224 |
+
|
2225 |
+
/**
|
2226 |
+
* UM hook
|
2227 |
+
*
|
2228 |
+
* @type filter
|
2229 |
+
* @title um_edit_field_{$mode}_{$type}
|
2230 |
+
* @description Change field html by $mode and field $type
|
2231 |
+
* @input_vars
|
2232 |
+
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
2233 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
2234 |
+
* @change_log
|
2235 |
+
* ["Since: 2.0"]
|
2236 |
+
* @usage add_filter( 'um_edit_field_{$mode}_{$type}', 'function_name', 10, 2 );
|
2237 |
+
* @example
|
2238 |
+
* <?php
|
2239 |
+
* add_filter( 'um_edit_field_{$mode}_{$type}', 'my_edit_field_html', 10, 2 );
|
2240 |
+
* function my_edit_field_html( $output, $data ) {
|
2241 |
+
* // your code here
|
2242 |
+
* return $output;
|
2243 |
+
* }
|
2244 |
+
* ?>
|
2245 |
+
*/
|
2246 |
+
|
2247 |
+
$output .= apply_filters( "um_edit_field_{$mode}_{$type}", $output, $data );
|
2248 |
+
break;
|
2249 |
+
|
2250 |
+
/* Other fields */
|
2251 |
+
case 'googlemap':
|
2252 |
+
case 'youtube_video':
|
2253 |
+
case 'vimeo_video':
|
2254 |
+
case 'soundcloud_track':
|
2255 |
+
|
2256 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2257 |
+
|
2258 |
+
if ( isset( $data['label'] ) ) {
|
2259 |
+
$output .= $this->field_label( $label, $key, $data );
|
2260 |
+
}
|
2261 |
+
|
2262 |
+
$output .= '<div class="um-field-area">';
|
2263 |
+
|
2264 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2265 |
+
|
2266 |
+
$output .= '<div class="um-field-icon"><i class="' . $icon . '"></i></div>';
|
2267 |
+
|
2268 |
+
}
|
2269 |
+
|
2270 |
+
$field_name = $key . UM()->form()->form_suffix;
|
2271 |
+
$field_value = htmlspecialchars( $this->field_value( $key, $default, $data ) );
|
2272 |
+
|
2273 |
+
$output .= '<input ' . $disabled . ' class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_name ) . '" value="' . esc_attr( $field_value ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2274 |
+
|
2275 |
+
</div>';
|
2276 |
+
|
2277 |
+
if ( ! empty( $disabled ) ) {
|
2278 |
+
$output .= $this->disabled_hidden_field( $field_name, $field_value );
|
2279 |
+
}
|
2280 |
+
|
2281 |
+
if ( $this->is_error( $key ) ) {
|
2282 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2283 |
+
}else if ( $this->is_notice( $key ) ) {
|
2284 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2285 |
+
}
|
2286 |
+
|
2287 |
+
$output .= '</div>';
|
2288 |
+
break;
|
2289 |
+
|
2290 |
+
/* Text */
|
2291 |
+
case 'text':
|
2292 |
+
|
2293 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2294 |
+
|
2295 |
+
if ( isset( $data['label'] ) ) {
|
2296 |
+
$output .= $this->field_label( $label, $key, $data );
|
2297 |
+
}
|
2298 |
+
|
2299 |
+
$output .= '<div class="um-field-area">';
|
2300 |
+
|
2301 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2302 |
+
|
2303 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2304 |
+
|
2305 |
+
}
|
2306 |
+
|
2307 |
+
$field_name = $key . UM()->form()->form_suffix;
|
2308 |
+
$field_value = htmlspecialchars( $this->field_value( $key, $default, $data ) );
|
2309 |
+
|
2310 |
+
$output .= '<input ' . $disabled . ' autocomplete="' . esc_attr( $autocomplete ) . '" class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_name ) . '" value="' . esc_attr( $field_value ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2311 |
+
|
2312 |
+
</div>';
|
2313 |
+
|
2314 |
+
if ( ! empty( $disabled ) ) {
|
2315 |
+
$output .= $this->disabled_hidden_field( $field_name, $field_value );
|
2316 |
+
}
|
2317 |
+
|
2318 |
+
if ( $this->is_error( $key ) ) {
|
2319 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2320 |
+
}else if ( $this->is_notice( $key ) ) {
|
2321 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2322 |
+
}
|
2323 |
+
|
2324 |
+
$output .= '</div>';
|
2325 |
+
break;
|
2326 |
+
|
2327 |
+
/* Number */
|
2328 |
+
case 'number':
|
2329 |
+
|
2330 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2331 |
+
|
2332 |
+
if ( isset( $data['label'] ) ) {
|
2333 |
+
$output .= $this->field_label( $label, $key, $data );
|
2334 |
+
}
|
2335 |
+
|
2336 |
+
$output .= '<div class="um-field-area">';
|
2337 |
+
|
2338 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2339 |
+
|
2340 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2341 |
+
|
2342 |
+
}
|
2343 |
+
|
2344 |
+
$number_limit = '';
|
2345 |
+
if ( isset( $min ) ) {
|
2346 |
+
$number_limit .= ' min="' . esc_attr( $min ) . '" ';
|
2347 |
+
}
|
2348 |
+
if ( isset( $max ) ) {
|
2349 |
+
$number_limit .= ' max="' . esc_attr( $max ) . '" ';
|
2350 |
+
}
|
2351 |
+
|
2352 |
+
$output .= '<input ' . $disabled . ' class="' . $this->get_class( $key, $data ) . '" type="number" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . esc_attr( htmlspecialchars( $this->field_value( $key, $default, $data ) ) ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" ' . $number_limit . ' />
|
2353 |
+
|
2354 |
+
</div>';
|
2355 |
+
|
2356 |
+
if ( $this->is_error( $key ) ) {
|
2357 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2358 |
+
}else if ( $this->is_notice( $key ) ) {
|
2359 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2360 |
+
}
|
2361 |
+
|
2362 |
+
$output .= '</div>';
|
2363 |
+
break;
|
2364 |
+
|
2365 |
+
/* Password */
|
2366 |
+
case 'password':
|
2367 |
+
|
2368 |
+
$original_key = $key;
|
2369 |
+
|
2370 |
+
if ( $key == 'single_user_password' ) {
|
2371 |
+
|
2372 |
+
$key = $original_key;
|
2373 |
+
|
2374 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2375 |
+
|
2376 |
+
if ( isset( $data['label'] ) ) {
|
2377 |
+
$output .= $this->field_label( $label, $key, $data );
|
2378 |
+
}
|
2379 |
+
|
2380 |
+
$output .= '<div class="um-field-area">';
|
2381 |
+
|
2382 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2383 |
+
|
2384 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2385 |
+
|
2386 |
+
}
|
2387 |
+
|
2388 |
+
$output .= '<input class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2389 |
+
|
2390 |
+
</div>';
|
2391 |
+
|
2392 |
+
if ( $this->is_error( $key ) ) {
|
2393 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2394 |
+
}else if ( $this->is_notice( $key ) ) {
|
2395 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2396 |
+
}
|
2397 |
+
|
2398 |
+
$output .= '</div>';
|
2399 |
+
|
2400 |
+
} else {
|
2401 |
+
|
2402 |
+
if ( UM()->account()->current_password_is_required( 'password' ) &&
|
2403 |
+
( $this->set_mode == 'account' || um_is_core_page( 'account' ) ) ) {
|
2404 |
+
|
2405 |
+
$key = 'current_' . $original_key;
|
2406 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2407 |
+
|
2408 |
+
if ( isset( $data['label'] ) ) {
|
2409 |
+
$output .= $this->field_label( __( 'Current Password', 'ultimate-member' ), $key, $data );
|
2410 |
+
}
|
2411 |
+
|
2412 |
+
$output .= '<div class="um-field-area">';
|
2413 |
+
|
2414 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field') {
|
2415 |
+
|
2416 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2417 |
+
|
2418 |
+
}
|
2419 |
+
|
2420 |
+
$output .= '<input class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2421 |
+
|
2422 |
+
</div>';
|
2423 |
+
|
2424 |
+
if ( $this->is_error( $key ) ) {
|
2425 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2426 |
+
} elseif ( $this->is_notice( $key ) ) {
|
2427 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2428 |
+
}
|
2429 |
+
|
2430 |
+
$output .= '</div>';
|
2431 |
+
|
2432 |
+
}
|
2433 |
+
|
2434 |
+
$key = $original_key;
|
2435 |
+
|
2436 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2437 |
+
|
2438 |
+
if ( $this->set_mode == 'account' && um_is_core_page( 'account' ) || $this->set_mode == 'password' && um_is_core_page( 'password-reset' ) ) {
|
2439 |
+
|
2440 |
+
$output .= $this->field_label( __( 'New Password', 'ultimate-member' ), $key, $data );
|
2441 |
+
|
2442 |
+
} elseif ( isset( $data['label'] ) ) {
|
2443 |
+
|
2444 |
+
$output .= $this->field_label( $label, $key, $data );
|
2445 |
+
|
2446 |
+
}
|
2447 |
+
|
2448 |
+
$output .= '<div class="um-field-area">';
|
2449 |
+
|
2450 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field') {
|
2451 |
+
|
2452 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2453 |
+
|
2454 |
+
}
|
2455 |
+
|
2456 |
+
$name = $key . UM()->form()->form_suffix;
|
2457 |
+
if ( $this->set_mode == 'password' && um_is_core_page( 'password-reset' ) ) {
|
2458 |
+
$name = $key;
|
2459 |
+
}
|
2460 |
+
|
2461 |
+
$output .= '<input class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $name ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2462 |
+
|
2463 |
+
</div>';
|
2464 |
+
|
2465 |
+
if ( $this->is_error( $key ) ) {
|
2466 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2467 |
+
} elseif ( $this->is_notice( $key ) ) {
|
2468 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2469 |
+
}
|
2470 |
+
|
2471 |
+
$output .= '</div>';
|
2472 |
+
|
2473 |
+
if ( $this->set_mode != 'login' && isset( $data['force_confirm_pass'] ) && $data['force_confirm_pass'] == 1 ) {
|
2474 |
+
|
2475 |
+
$key = 'confirm_' . $original_key;
|
2476 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2477 |
+
|
2478 |
+
if ( ! empty( $data['label_confirm_pass'] ) ) {
|
2479 |
+
$label_confirm_pass = __( $data['label_confirm_pass'], 'ultimate-member' );
|
2480 |
+
$output .= $this->field_label( $label_confirm_pass, $key, $data );
|
2481 |
+
} elseif ( isset( $data['label'] ) ) {
|
2482 |
+
$data['label'] = __( $data['label'], 'ultimate-member' );
|
2483 |
+
$output .= $this->field_label( sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] ), $key, $data );
|
2484 |
+
}
|
2485 |
+
|
2486 |
+
$output .= '<div class="um-field-area">';
|
2487 |
+
|
2488 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2489 |
+
|
2490 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2491 |
+
|
2492 |
+
}
|
2493 |
+
|
2494 |
+
$name = $key . UM()->form()->form_suffix;
|
2495 |
+
if ( $this->set_mode == 'password' && um_is_core_page( 'password-reset' ) ) {
|
2496 |
+
$name = $key;
|
2497 |
+
}
|
2498 |
+
|
2499 |
+
if ( ! empty( $label_confirm_pass ) ) {
|
2500 |
+
$placeholder = $label_confirm_pass;
|
2501 |
+
} elseif( ! empty( $placeholder ) && ! isset( $data['label'] ) ) {
|
2502 |
+
$placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $placeholder );
|
2503 |
+
} elseif( isset( $data['label'] ) ) {
|
2504 |
+
$placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] );
|
2505 |
+
}
|
2506 |
+
|
2507 |
+
|
2508 |
+
$output .= '<input class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $name ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />';
|
2509 |
+
|
2510 |
+
|
2511 |
+
$output .= '</div>';
|
2512 |
+
|
2513 |
+
if ( $this->is_error( $key ) ) {
|
2514 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2515 |
+
}else if ( $this->is_notice( $key ) ) {
|
2516 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2517 |
+
}
|
2518 |
+
|
2519 |
+
$output .= '</div>';
|
2520 |
+
|
2521 |
+
}
|
2522 |
+
|
2523 |
+
}
|
2524 |
+
|
2525 |
+
break;
|
2526 |
+
|
2527 |
+
/* URL */
|
2528 |
+
case 'url':
|
2529 |
+
|
2530 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2531 |
+
|
2532 |
+
if ( isset( $data['label'] ) ) {
|
2533 |
+
$output .= $this->field_label( $label, $key, $data );
|
2534 |
+
}
|
2535 |
+
|
2536 |
+
$output .= '<div class="um-field-area">';
|
2537 |
+
|
2538 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2539 |
+
|
2540 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2541 |
+
|
2542 |
+
}
|
2543 |
+
|
2544 |
+
$output .= '<input ' . $disabled . ' class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . esc_attr( $this->field_value( $key, $default, $data ) ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" />
|
2545 |
+
|
2546 |
+
</div>';
|
2547 |
+
|
2548 |
+
if ( $this->is_error( $key ) ) {
|
2549 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2550 |
+
}else if ( $this->is_notice( $key ) ) {
|
2551 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2552 |
+
}
|
2553 |
+
|
2554 |
+
$output .= '</div>';
|
2555 |
+
break;
|
2556 |
+
|
2557 |
+
/* Date */
|
2558 |
+
case 'date':
|
2559 |
+
|
2560 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2561 |
+
|
2562 |
+
if (isset( $data['label'] )) {
|
2563 |
+
$output .= $this->field_label( $label, $key, $data );
|
2564 |
+
}
|
2565 |
+
|
2566 |
+
$output .= '<div class="um-field-area">';
|
2567 |
+
|
2568 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2569 |
+
|
2570 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2571 |
+
|
2572 |
+
}
|
2573 |
+
|
2574 |
+
$output .= '<input ' . $disabled . ' class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" data-range="' . esc_attr( $range ) . '" data-years="' . esc_attr( $years ) . '" data-years_x="' . esc_attr( $years_x ) . '" data-disabled_weekdays="' . esc_attr( $disabled_weekdays ) . '" data-date_min="' . esc_attr( $date_min ) . '" data-date_max="' . esc_attr( $date_max ) . '" data-format="' . esc_attr( $js_format ) . '" data-value="' . $this->field_value( $key, $default, $data ) . '" />
|
2575 |
+
|
2576 |
+
</div>';
|
2577 |
+
|
2578 |
+
if ( $this->is_error( $key ) ) {
|
2579 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2580 |
+
}else if ( $this->is_notice( $key ) ) {
|
2581 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2582 |
+
}
|
2583 |
+
|
2584 |
+
$output .= '</div>';
|
2585 |
+
break;
|
2586 |
+
|
2587 |
+
/* Time */
|
2588 |
+
case 'time':
|
2589 |
+
|
2590 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2591 |
+
|
2592 |
+
if (isset( $data['label'] )) {
|
2593 |
+
$output .= $this->field_label( $label, $key, $data );
|
2594 |
+
}
|
2595 |
+
|
2596 |
+
$output .= '<div class="um-field-area">';
|
2597 |
+
|
2598 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2599 |
+
|
2600 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2601 |
+
|
2602 |
+
}
|
2603 |
+
|
2604 |
+
$output .= '<input ' . $disabled . ' class="' . $this->get_class( $key, $data ) . '" type="' . esc_attr( $input ) . '" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" placeholder="' . esc_attr( $placeholder ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" data-format="' . esc_attr( $js_format ) . '" data-intervals="' . esc_attr( $intervals ) . '" data-value="' . $this->field_value( $key, $default, $data ) . '" />
|
2605 |
+
|
2606 |
+
</div>';
|
2607 |
+
|
2608 |
+
if ( $this->is_error( $key ) ) {
|
2609 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2610 |
+
}else if ( $this->is_notice( $key ) ) {
|
2611 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2612 |
+
}
|
2613 |
+
|
2614 |
+
$output .= '</div>';
|
2615 |
+
break;
|
2616 |
+
|
2617 |
+
/* Row */
|
2618 |
+
case 'row':
|
2619 |
+
$output .= '';
|
2620 |
+
break;
|
2621 |
+
|
2622 |
+
/* Textarea */
|
2623 |
+
case 'textarea':
|
2624 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2625 |
+
|
2626 |
+
if ( isset( $data['label'] ) ) {
|
2627 |
+
$output .= $this->field_label( $label, $key, $data );
|
2628 |
+
}
|
2629 |
+
|
2630 |
+
$output .= '<div class="um-field-area">';
|
2631 |
+
|
2632 |
+
if ( isset( $data['html'] ) && $data['html'] != 0 && $key != "description" ) {
|
2633 |
+
|
2634 |
+
$textarea_settings = array(
|
2635 |
+
'media_buttons' => false,
|
2636 |
+
'wpautop' => false,
|
2637 |
+
'editor_class' => $this->get_class( $key, $data ),
|
2638 |
+
'editor_height' => $height,
|
2639 |
+
'tinymce' => array(
|
2640 |
+
'toolbar1' => 'formatselect,bullist,numlist,bold,italic,underline,forecolor,blockquote,hr,removeformat,link,unlink,undo,redo',
|
2641 |
+
'toolbar2' => '',
|
2642 |
+
)
|
2643 |
+
);
|
2644 |
+
|
2645 |
+
if ( ! empty( $disabled ) ) {
|
2646 |
+
$textarea_settings['tinymce']['readonly'] = true;
|
2647 |
+
}
|
2648 |
+
|
2649 |
+
/**
|
2650 |
+
* UM hook
|
2651 |
+
*
|
2652 |
+
* @type filter
|
2653 |
+
* @title um_form_fields_textarea_settings
|
2654 |
+
* @description Change WP Editor options for textarea init
|
2655 |
+
* @input_vars
|
2656 |
+
* [{"var":"$textarea_settings","type":"array","desc":"WP Editor settings"}]
|
2657 |
+
* @change_log
|
2658 |
+
* ["Since: 2.0"]
|
2659 |
+
* @usage add_filter( 'um_form_fields_textarea_settings', 'function_name', 10, 1 );
|
2660 |
+
* @example
|
2661 |
+
* <?php
|
2662 |
+
* add_filter( 'um_form_fields_textarea_settings', 'my_textarea_settings', 10, 1 );
|
2663 |
+
* function my_edit_field_html( $textarea_settings ) {
|
2664 |
+
* // your code here
|
2665 |
+
* return $textarea_settings;
|
2666 |
+
* }
|
2667 |
+
* ?>
|
2668 |
+
*/
|
2669 |
+
$textarea_settings = apply_filters( 'um_form_fields_textarea_settings', $textarea_settings );
|
2670 |
+
|
2671 |
+
// turn on the output buffer
|
2672 |
+
ob_start();
|
2673 |
+
|
2674 |
+
// echo the editor to the buffer
|
2675 |
+
wp_editor( $field_value, $key, $textarea_settings );
|
2676 |
+
|
2677 |
+
// add the contents of the buffer to the output variable
|
2678 |
+
$output .= ob_get_clean();
|
2679 |
+
$output .= '<br /><span class="description">' . $placeholder . '</span>';
|
2680 |
+
} else {
|
2681 |
+
$textarea_field_value = ! empty( $data['html'] ) ? $field_value : strip_tags( $field_value );
|
2682 |
+
$output .= '<textarea ' . $disabled . ' style="height: ' . esc_attr( $height ) . ';" class="' . $this->get_class( $key, $data ) . '" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" placeholder="' . esc_attr( $placeholder ) . '">' . esc_textarea( $textarea_field_value ) . '</textarea>';
|
2683 |
+
}
|
2684 |
+
|
2685 |
+
$output .= '</div>';
|
2686 |
+
|
2687 |
+
if ( ! empty( $disabled ) ) {
|
2688 |
+
$output .= $this->disabled_hidden_field( $field_name, $field_value );
|
2689 |
+
}
|
2690 |
+
|
2691 |
+
if ( $this->is_error( $key ) ) {
|
2692 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2693 |
+
}else if ( $this->is_notice( $key ) ) {
|
2694 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2695 |
+
}
|
2696 |
+
|
2697 |
+
$output .= '</div>';
|
2698 |
+
break;
|
2699 |
+
|
2700 |
+
/* Rating */
|
2701 |
+
case 'rating':
|
2702 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2703 |
+
|
2704 |
+
if ( isset( $data['label'] ) ) {
|
2705 |
+
$output .= $this->field_label( $label, $key, $data );
|
2706 |
+
}
|
2707 |
+
|
2708 |
+
$output .= '<div class="um-field-area">';
|
2709 |
+
|
2710 |
+
$output .= '<div class="um-rating um-raty" id="' . esc_attr( $key ) . '" data-key="' . esc_attr( $key ) . '" data-number="' . esc_attr( $data['number'] ) . '" data-score="' . $this->field_value( $key, $default, $data ) . '"></div>';
|
2711 |
+
$output .= '</div>';
|
2712 |
+
|
2713 |
+
if ( $this->is_error( $key ) ) {
|
2714 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2715 |
+
} elseif ( $this->is_notice( $key ) ) {
|
2716 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2717 |
+
}
|
2718 |
+
|
2719 |
+
$output .= '</div>';
|
2720 |
+
|
2721 |
+
break;
|
2722 |
+
|
2723 |
+
/* Gap/Space */
|
2724 |
+
case 'spacing':
|
2725 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data, array( 'height' => $spacing ) ) . '></div>';
|
2726 |
+
break;
|
2727 |
+
|
2728 |
+
/* A line divider */
|
2729 |
+
case 'divider':
|
2730 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data, array( 'border-bottom' => $borderwidth . 'px ' . $borderstyle . ' ' . $bordercolor ) ) . '>';
|
2731 |
+
if ( $divider_text ) {
|
2732 |
+
$output .= '<div class="um-field-divider-text"><span>' . esc_html( $divider_text ) . '</span></div>';
|
2733 |
+
}
|
2734 |
+
$output .= '</div>';
|
2735 |
+
break;
|
2736 |
+
|
2737 |
+
/* Single Image Upload */
|
2738 |
+
case 'image':
|
2739 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . ' data-mode="' . esc_attr( $this->set_mode ) . '" data-upload-label="' . ( ! empty( $data['button_text'] ) ? esc_attr( $data['button_text'] ) : esc_attr__( 'Upload', 'ultimate-member' ) ) . '">';
|
2740 |
+
if ( in_array( $key, array( 'profile_photo', 'cover_photo' ) ) ) {
|
2741 |
+
$field_value = '';
|
2742 |
+
} else {
|
2743 |
+
$field_value = $this->field_value( $key, $default, $data );
|
2744 |
+
}
|
2745 |
+
$output .= '<input type="hidden" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $field_value . '" />';
|
2746 |
+
if ( isset( $data['label'] ) ) {
|
2747 |
+
$output .= $this->field_label( $label, $key, $data );
|
2748 |
+
}
|
2749 |
+
$modal_label = ( isset( $data['label'] ) ) ? $data['label'] : __( 'Upload Photo', 'ultimate-member' );
|
2750 |
+
$output .= '<div class="um-field-area" style="text-align: center;">';
|
2751 |
+
|
2752 |
+
if ( ! empty( $field_value ) && $field_value != 'empty_file' ) {
|
2753 |
+
if ( ! in_array( $key, array( 'profile_photo', 'cover_photo' ) ) ) {
|
2754 |
+
if ( isset( $this->set_mode ) && 'register' == $this->set_mode ) {
|
2755 |
+
$image_info = get_transient("um_{$field_value}");
|
2756 |
+
} else {
|
2757 |
+
$image_info = um_user( $data['metakey']."_metadata" );
|
2758 |
+
}
|
2759 |
+
|
2760 |
+
if ( ( isset( $this->set_mode ) && $this->set_mode == 'register' ) || file_exists( UM()->uploader()->get_core_temp_dir() . DIRECTORY_SEPARATOR . $field_value ) ) {
|
2761 |
+
$imgValue = UM()->uploader()->get_core_temp_url() . "/" . $this->field_value( $key, $default, $data );
|
2762 |
+
} else {
|
2763 |
+
$imgValue = UM()->files()->get_download_link( $this->set_id, $key, um_user( 'ID' ) );
|
2764 |
+
}
|
2765 |
+
$img = '<img src="' . $imgValue . '" alt="" />';
|
2766 |
+
} else {
|
2767 |
+
$img = '';
|
2768 |
+
}
|
2769 |
+
$output .= '<div class="um-single-image-preview show ' . $crop_class . '" data-crop="' . $crop_data . '" data-key="' . $key . '">';
|
2770 |
+
if ( empty( $disabled ) ) {
|
2771 |
+
$output .= '<a href="javascript:void(0);" class="cancel"><i class="um-icon-close"></i></a>';
|
2772 |
+
}
|
2773 |
+
$output .= $img;
|
2774 |
+
$output .= '</div>';
|
2775 |
+
if ( empty( $disabled ) ) {
|
2776 |
+
$output .= '<a href="javascript:void(0);" data-modal="um_upload_single" data-modal-size="' . $modal_size . '" data-modal-copy="1" class="um-button um-btn-auto-width">' . __( 'Change photo', 'ultimate-member' ) . '</a>';
|
2777 |
+
}
|
2778 |
+
|
2779 |
+
|
2780 |
+
} else {
|
2781 |
+
$output .= '<div class="um-single-image-preview ' . $crop_class . '" data-crop="' . $crop_data . '" data-key="' . $key . '">';
|
2782 |
+
if ( empty( $disabled ) ) {
|
2783 |
+
$output .= '<a href="javascript:void(0);" class="cancel"><i class="um-icon-close"></i></a>';
|
2784 |
+
}
|
2785 |
+
$output .= '<img src="" alt="" /><div class="um-clear"></div></div>';
|
2786 |
+
if ( empty( $disabled ) ) {
|
2787 |
+
$output .= '<a href="javascript:void(0);" data-modal="um_upload_single" data-modal-size="' . $modal_size . '" data-modal-copy="1" class="um-button um-btn-auto-width">' . $button_text . '</a>';
|
2788 |
+
}
|
2789 |
+
|
2790 |
+
}
|
2791 |
+
$output .= '</div>';
|
2792 |
+
/* modal hidden */
|
2793 |
+
if ( empty( $disabled ) ) {
|
2794 |
+
$output .= '<div class="um-modal-hidden-content">';
|
2795 |
+
$output .= '<div class="um-modal-header"> ' . $modal_label . '</div>';
|
2796 |
+
$output .= '<div class="um-modal-body">';
|
2797 |
+
if ( isset( $this->set_id ) ) {
|
2798 |
+
$set_id = $this->set_id;
|
2799 |
+
$set_mode = $this->set_mode;
|
2800 |
+
} else {
|
2801 |
+
$set_id = 0;
|
2802 |
+
$set_mode = '';
|
2803 |
+
}
|
2804 |
+
$nonce = wp_create_nonce( 'um_upload_nonce-' . $this->timestamp );
|
2805 |
+
$output .= '<div class="um-single-image-preview ' . $crop_class . '" data-crop="' . $crop_data . '" data-ratio="' . $ratio . '" data-min_width="' . $min_width . '" data-min_height="' . $min_height . '" data-coord=""><a href="javascript:void(0);" class="cancel"><i class="um-icon-close"></i></a><img src="" alt="" /><div class="um-clear"></div></div><div class="um-clear"></div>';
|
2806 |
+
$output .= '<div class="um-single-image-upload" data-user_id="' . esc_attr( $_um_profile_id ) . '" data-nonce="' . $nonce . '" data-timestamp="' . esc_attr( $this->timestamp ) . '" data-icon="' . esc_attr( $icon ) . '" data-set_id="' . esc_attr( $set_id ) . '" data-set_mode="' . esc_attr( $set_mode ) . '" data-type="' . esc_attr( $type ) . '" data-key="' . esc_attr( $key ) . '" data-max_size="' . esc_attr( $max_size ) . '" data-max_size_error="' . esc_attr( $max_size_error ) . '" data-min_size_error="' . esc_attr( $min_size_error ) . '" data-extension_error="' . esc_attr( $extension_error ) . '" data-allowed_types="' . esc_attr( $allowed_types ) . '" data-upload_text="' . esc_attr( $upload_text ) . '" data-max_files_error="' . esc_attr( $max_files_error ) . '" data-upload_help_text="' . esc_attr( $upload_help_text ) . '">' . $button_text . '</div>';
|
2807 |
+
$output .= '<div class="um-modal-footer">
|
2808 |
+
<div class="um-modal-right">
|
2809 |
+
<a href="javascript:void(0);" class="um-modal-btn um-finish-upload image disabled" data-key="' . $key . '" data-change="' . __( 'Change photo', 'ultimate-member' ) . '" data-processing="' . __( 'Processing...', 'ultimate-member' ) . '"> ' . __( 'Apply', 'ultimate-member' ) . '</a>
|
2810 |
+
<a href="javascript:void(0);" class="um-modal-btn alt" data-action="um_remove_modal"> ' . __( 'Cancel', 'ultimate-member' ) . '</a>
|
2811 |
+
</div>
|
2812 |
+
<div class="um-clear"></div>
|
2813 |
+
</div>';
|
2814 |
+
$output .= '</div>';
|
2815 |
+
$output .= '</div>';
|
2816 |
+
}
|
2817 |
+
/* end */
|
2818 |
+
if ( $this->is_error( $key ) ) {
|
2819 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2820 |
+
}else if ( $this->is_notice( $key ) ) {
|
2821 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2822 |
+
}
|
2823 |
+
$output .= '</div>';
|
2824 |
+
|
2825 |
+
break;
|
2826 |
+
|
2827 |
+
/* Single File Upload */
|
2828 |
+
case 'file':
|
2829 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . ' data-mode="' . esc_attr( $this->set_mode ) . '" data-upload-label="' . ( ! empty( $data['button_text'] ) ? esc_attr( $data['button_text'] ) : esc_attr__( 'Upload', 'ultimate-member' ) ) . '">';
|
2830 |
+
$output .= '<input type="hidden" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $this->field_value( $key, $default, $data ) . '" />';
|
2831 |
+
if ( isset( $data['label'] ) ) {
|
2832 |
+
$output .= $this->field_label( $label, $key, $data );
|
2833 |
+
}
|
2834 |
+
$modal_label = ( isset( $data['label'] ) ) ? $data['label'] : __( 'Upload File', 'ultimate-member' );
|
2835 |
+
$output .= '<div class="um-field-area" style="text-align: center;">';
|
2836 |
+
|
2837 |
+
$file_field_value = $this->field_value( $key, $default, $data );
|
2838 |
+
|
2839 |
+
if ( ! empty( $file_field_value ) && 'empty_file' !== $file_field_value ) {
|
2840 |
+
$file_type = wp_check_filetype( $file_field_value );
|
2841 |
+
|
2842 |
+
if ( um_is_temp_file( $file_field_value ) ) {
|
2843 |
+
$file_info = get_transient( "um_{$file_field_value}" );
|
2844 |
+
} else {
|
2845 |
+
$file_info = um_user( $data['metakey'] . "_metadata" );
|
2846 |
+
}
|
2847 |
+
|
2848 |
+
$file_field_name = $file_field_value;
|
2849 |
+
if ( ! empty( $file_info['original_name'] ) ) {
|
2850 |
+
$file_field_name = $file_info['original_name'];
|
2851 |
+
}
|
2852 |
+
|
2853 |
+
if ( ( isset( $this->set_mode ) && 'register' == $this->set_mode ) || file_exists( UM()->uploader()->get_core_temp_dir() . DIRECTORY_SEPARATOR . $file_field_value ) ) {
|
2854 |
+
$file_url = UM()->uploader()->get_core_temp_url() . DIRECTORY_SEPARATOR . $file_field_value;
|
2855 |
+
$file_dir = UM()->uploader()->get_core_temp_dir() . DIRECTORY_SEPARATOR . $file_field_value;
|
2856 |
+
} else {
|
2857 |
+
$file_url = UM()->files()->get_download_link( $this->set_id, $key, um_user( 'ID' ) );
|
2858 |
+
$file_dir = UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $this->field_value( $key, $default, $data );
|
2859 |
+
}
|
2860 |
+
|
2861 |
+
//multisite fix for old customers
|
2862 |
+
if ( ! file_exists( $file_dir ) && is_multisite() ) {
|
2863 |
+
$file_dir = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $file_dir );
|
2864 |
+
}
|
2865 |
+
|
2866 |
+
if ( file_exists( $file_dir ) ) {
|
2867 |
+
$output .= "<div class=\"um-single-file-preview show\" data-key=\"{$key}\">";
|
2868 |
+
if ( empty( $disabled ) ) {
|
2869 |
+
$output .= "<a href=\"#\" class=\"cancel\"><i class=\"um-icon-close\"></i></a>";
|
2870 |
+
}
|
2871 |
+
$output .= "<div class=\"um-single-fileinfo\">
|
2872 |
+
<a href=\"{$file_url}\" target=\"_blank\">
|
2873 |
+
<span class=\"icon\" style=\"background:" . UM()->files()->get_fonticon_bg_by_ext( $file_type['ext'] ) . "\"><i class=\"" . UM()->files()->get_fonticon_by_ext( $file_type['ext'] ) . "\"></i></span>
|
2874 |
+
<span class=\"filename\">{$file_field_name}</span>
|
2875 |
+
</a>
|
2876 |
+
</div></div>";
|
2877 |
+
} else {
|
2878 |
+
$output .= "<div class=\"um-single-file-preview show\" data-key=\"{$key}\">" . __('This file has been removed.','ultimate-member') . "</div>";
|
2879 |
+
}
|
2880 |
+
|
2881 |
+
if ( empty( $disabled ) ) {
|
2882 |
+
$output .= "<a href=\"#\" data-modal=\"um_upload_single\" data-modal-size=\"{$modal_size}\" data-modal-copy=\"1\" class=\"um-button um-btn-auto-width\">" . __( 'Change file', 'ultimate-member' ) . "</a>";
|
2883 |
+
}
|
2884 |
+
} else {
|
2885 |
+
$output .= "<div class=\"um-single-file-preview\" data-key=\"{$key}\"></div>";
|
2886 |
+
if ( empty( $disabled ) ) {
|
2887 |
+
$output .= "<a href=\"#\" data-modal=\"um_upload_single\" data-modal-size=\"{$modal_size}\" data-modal-copy=\"1\" class=\"um-button um-btn-auto-width\">{$button_text}</a>";
|
2888 |
+
}
|
2889 |
+
}
|
2890 |
+
$output .= '</div>';
|
2891 |
+
/* modal hidden */
|
2892 |
+
if ( empty( $disabled ) ) {
|
2893 |
+
$output .= '<div class="um-modal-hidden-content">';
|
2894 |
+
$output .= '<div class="um-modal-header"> ' . $modal_label . '</div>';
|
2895 |
+
$output .= '<div class="um-modal-body">';
|
2896 |
+
if ( isset( $this->set_id ) ) {
|
2897 |
+
$set_id = $this->set_id;
|
2898 |
+
$set_mode = $this->set_mode;
|
2899 |
+
} else {
|
2900 |
+
$set_id = 0;
|
2901 |
+
$set_mode = '';
|
2902 |
+
}
|
2903 |
+
$output .= '<div class="um-single-file-preview">
|
2904 |
+
<a href="javascript:void(0);" class="cancel"><i class="um-icon-close"></i></a>
|
2905 |
+
<div class="um-single-fileinfo">
|
2906 |
+
<a href="" target="_blank">
|
2907 |
+
<span class="icon"><i></i></span>
|
2908 |
+
<span class="filename"></span>
|
2909 |
+
</a>
|
2910 |
+
</div>
|
2911 |
+
</div>';
|
2912 |
+
$nonce = wp_create_nonce( 'um_upload_nonce-' . $this->timestamp );
|
2913 |
+
$output .= '<div class="um-single-file-upload" data-user_id="' . esc_attr( $_um_profile_id ) . '" data-timestamp="' . esc_attr( $this->timestamp ) . '" data-nonce="' . $nonce . '" data-icon="' . esc_attr( $icon ) . '" data-set_id="' . esc_attr( $set_id ) . '" data-set_mode="' . esc_attr( $set_mode ) . '" data-type="' . esc_attr( $type ) . '" data-key="' . esc_attr( $key ) . '" data-max_size="' . esc_attr( $max_size ) . '" data-max_size_error="' . esc_attr( $max_size_error ) . '" data-min_size_error="' . esc_attr( $min_size_error ) . '" data-extension_error="' . esc_attr( $extension_error ) . '" data-allowed_types="' . esc_attr( $allowed_types ) . '" data-upload_text="' . esc_attr( $upload_text ) . '" data-max_files_error="' . esc_attr( $max_files_error ) . '" data-upload_help_text="' . esc_attr( $upload_help_text ) . '">' . $button_text . '</div>';
|
2914 |
+
$output .= '<div class="um-modal-footer">
|
2915 |
+
<div class="um-modal-right">
|
2916 |
+
<a href="javascript:void(0);" class="um-modal-btn um-finish-upload file disabled" data-key="' . esc_attr( $key ) . '" data-change="' . esc_attr__( 'Change file' ) . '" data-processing="' . esc_attr__( 'Processing...', 'ultimate-member' ) . '"> ' . __( 'Save', 'ultimate-member' ) . '</a>
|
2917 |
+
<a href="javascript:void(0);" class="um-modal-btn alt" data-action="um_remove_modal"> ' . __( 'Cancel', 'ultimate-member' ) . '</a>
|
2918 |
+
</div>
|
2919 |
+
<div class="um-clear"></div>
|
2920 |
+
</div>';
|
2921 |
+
$output .= '</div>';
|
2922 |
+
$output .= '</div>';
|
2923 |
+
}
|
2924 |
+
/* end */
|
2925 |
+
if ( $this->is_error( $key ) ) {
|
2926 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2927 |
+
}else if ( $this->is_notice( $key ) ) {
|
2928 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2929 |
+
}
|
2930 |
+
$output .= '</div>';
|
2931 |
+
|
2932 |
+
break;
|
2933 |
+
|
2934 |
+
/* Select dropdown */
|
2935 |
+
case 'select':
|
2936 |
+
|
2937 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2938 |
+
|
2939 |
+
if ( isset( $data['allowclear'] ) && $data['allowclear'] == 0 ) {
|
2940 |
+
$class = 'um-s2';
|
2941 |
+
} else {
|
2942 |
+
$class = 'um-s1';
|
2943 |
+
}
|
2944 |
+
|
2945 |
+
if ( isset( $data['label'] ) ) {
|
2946 |
+
$output .= $this->field_label( $label, $key, $data );
|
2947 |
+
}
|
2948 |
+
|
2949 |
+
$output .= '<div class="um-field-area ' . ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ? 'um-field-area-has-icon' : '' ) . ' ">';
|
2950 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2951 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2952 |
+
}
|
2953 |
+
|
2954 |
+
$options = array();
|
2955 |
+
$has_parent_option = false;
|
2956 |
+
$disabled_by_parent_option = '';
|
2957 |
+
$atts_ajax = '';
|
2958 |
+
$select_original_option_value = '';
|
2959 |
+
|
2960 |
+
if ( isset( $data[ 'options' ] ) && is_array( $data[ 'options' ] ) ) {
|
2961 |
+
$options = $data[ 'options' ];
|
2962 |
+
}
|
2963 |
+
|
2964 |
+
if ( ! empty( $data['parent_dropdown_relationship'] ) && ! UM()->user()->preview ) {
|
2965 |
+
|
2966 |
+
$disabled_by_parent_option = 'disabled = disabled';
|
2967 |
+
|
2968 |
+
$has_parent_option = true;
|
2969 |
+
|
2970 |
+
/**
|
2971 |
+
* UM hook
|
2972 |
+
*
|
2973 |
+
* @type filter
|
2974 |
+
* @title um_custom_dropdown_options_parent__{$form_key}
|
2975 |
+
* @description Change parent dropdown relationship by $form_key
|
2976 |
+
* @input_vars
|
2977 |
+
* [{"var":"$parent","type":"string","desc":"Parent dropdown relationship"},
|
2978 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
2979 |
+
* @change_log
|
2980 |
+
* ["Since: 2.0"]
|
2981 |
+
* @usage add_filter( 'um_custom_dropdown_options_parent__{$form_key}', 'function_name', 10, 2 );
|
2982 |
+
* @example
|
2983 |
+
* <?php
|
2984 |
+
* add_filter( 'um_custom_dropdown_options_parent__{$form_key}', 'my_custom_dropdown_options_parent', 10, 2 );
|
2985 |
+
* function my_custom_dropdown_options_parent( $parent, $data ) {
|
2986 |
+
* // your code here
|
2987 |
+
* return $parent;
|
2988 |
+
* }
|
2989 |
+
* ?>
|
2990 |
+
*/
|
2991 |
+
$parent_dropdown_relationship = apply_filters( "um_custom_dropdown_options_parent__{$form_key}", $data['parent_dropdown_relationship'], $data );
|
2992 |
+
$atts_ajax .= " data-um-parent='{$parent_dropdown_relationship}' ";
|
2993 |
+
|
2994 |
+
if ( ! empty( $data['custom_dropdown_options_source'] ) && $has_parent_option && function_exists( $data['custom_dropdown_options_source'] ) &&
|
2995 |
+
um_user( $data['parent_dropdown_relationship'] )
|
2996 |
+
) {
|
2997 |
+
$options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
2998 |
+
|
2999 |
+
$disabled_by_parent_option = '';
|
3000 |
+
if ( um_user( $form_key ) ) {
|
3001 |
+
$select_original_option_value = " data-um-original-value='" . um_user( $form_key ) . "' ";
|
3002 |
+
}
|
3003 |
+
}
|
3004 |
+
}
|
3005 |
+
|
3006 |
+
// Child dropdown option selected
|
3007 |
+
if ( isset( UM()->form()->post_form[ $form_key ] ) ) {
|
3008 |
+
$select_original_option_value = " data-um-original-value='" . esc_attr( UM()->form()->post_form[ $form_key ] ) . "' ";
|
3009 |
+
}
|
3010 |
+
|
3011 |
+
// Child dropdown
|
3012 |
+
if ( $has_parent_option ) {
|
3013 |
+
|
3014 |
+
if ( ! empty( $data['custom_dropdown_options_source'] ) && $has_parent_option &&
|
3015 |
+
function_exists( $data['custom_dropdown_options_source'] ) && isset( UM()->form()->post_form[ $form_key ] ) ) {
|
3016 |
+
$options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
3017 |
+
}
|
3018 |
+
}
|
3019 |
+
|
3020 |
+
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
|
3021 |
+
|
3022 |
+
/**
|
3023 |
+
* UM hook
|
3024 |
+
*
|
3025 |
+
* @type filter
|
3026 |
+
* @title um_custom_dropdown_options_source__{$form_key}
|
3027 |
+
* @description Change custom dropdown options source by $form_key
|
3028 |
+
* @input_vars
|
3029 |
+
* [{"var":"$source","type":"string","desc":"Dropdown options source"},
|
3030 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3031 |
+
* @change_log
|
3032 |
+
* ["Since: 2.0"]
|
3033 |
+
* @usage add_filter( 'um_custom_dropdown_options_source__{$form_key}', 'function_name', 10, 2 );
|
3034 |
+
* @example
|
3035 |
+
* <?php
|
3036 |
+
* add_filter( 'um_custom_dropdown_options_source__{$form_key}', 'my_custom_dropdown_options_source', 10, 2 );
|
3037 |
+
* function my_custom_dropdown_options_source( $source, $data ) {
|
3038 |
+
* // your code here
|
3039 |
+
* return $source;
|
3040 |
+
* }
|
3041 |
+
* ?>
|
3042 |
+
*/
|
3043 |
+
$ajax_source = apply_filters( "um_custom_dropdown_options_source__{$form_key}", $data['custom_dropdown_options_source'], $data );
|
3044 |
+
$atts_ajax .= ' data-um-ajax-source="' . esc_attr( $ajax_source ) . '" ';
|
3045 |
+
|
3046 |
+
/**
|
3047 |
+
* UM hook
|
3048 |
+
*
|
3049 |
+
* @type filter
|
3050 |
+
* @title um_custom_dropdown_options_source_url__{$form_key}
|
3051 |
+
* @description Change custom dropdown options source URL by $form_key
|
3052 |
+
* @input_vars
|
3053 |
+
* [{"var":"$url","type":"string","desc":"Dropdown options source URL"},
|
3054 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3055 |
+
* @change_log
|
3056 |
+
* ["Since: 2.0"]
|
3057 |
+
* @usage add_filter( 'um_custom_dropdown_options_source_url__{$form_key}', 'function_name', 10, 2 );
|
3058 |
+
* @example
|
3059 |
+
* <?php
|
3060 |
+
* add_filter( 'um_custom_dropdown_options_source_url__{$form_key}', 'my_custom_dropdown_options_source_url', 10, 2 );
|
3061 |
+
* function my_custom_dropdown_options_source( $url, $data ) {
|
3062 |
+
* // your code here
|
3063 |
+
* return $url;
|
3064 |
+
* }
|
3065 |
+
* ?>
|
3066 |
+
*/
|
3067 |
+
// todo maybe deprecate
|
3068 |
+
// $ajax_source_url = apply_filters( "um_custom_dropdown_options_source_url__{$form_key}", admin_url( 'admin-ajax.php' ), $data );
|
3069 |
+
// $atts_ajax .= ' data-um-ajax-url="' . esc_url( $ajax_source_url ) . '" ';
|
3070 |
+
|
3071 |
+
}
|
3072 |
+
|
3073 |
+
/**
|
3074 |
+
* UM hook
|
3075 |
+
*
|
3076 |
+
* @type filter
|
3077 |
+
* @title um_fields_options_enable_pairs__{$key}
|
3078 |
+
* @description Enable options pairs by field $key
|
3079 |
+
* @input_vars
|
3080 |
+
* [{"var":"$options_pairs","type":"string","desc":"Enable pairs"}]
|
3081 |
+
* @change_log
|
3082 |
+
* ["Since: 2.0"]
|
3083 |
+
* @usage add_filter( 'um_fields_options_enable_pairs__{$key}', 'function_name', 10, 1 );
|
3084 |
+
* @example
|
3085 |
+
* <?php
|
3086 |
+
* add_filter( 'um_fields_options_enable_pairs__{$key}', 'my_fields_options_enable_pairs', 10, 1 );
|
3087 |
+
* function my_fields_options_enable_pairs( $options_pairs ) {
|
3088 |
+
* // your code here
|
3089 |
+
* return $options_pairs;
|
3090 |
+
* }
|
3091 |
+
* ?>
|
3092 |
+
*/
|
3093 |
+
$enable_options_pair = apply_filters( "um_fields_options_enable_pairs__{$key}", false );
|
3094 |
+
|
3095 |
+
if ( ! $has_parent_option ) {
|
3096 |
+
if ( isset( $options ) && $options == 'builtin' ) {
|
3097 |
+
$options = UM()->builtin()->get ( $filter );
|
3098 |
+
}
|
3099 |
+
|
3100 |
+
// 'country'
|
3101 |
+
if ( $key === 'country' && empty( $options ) ) {
|
3102 |
+
$options = UM()->builtin()->get( 'countries' );
|
3103 |
+
} else if ( empty( $options ) && isset( $data['options'] ) ) {
|
3104 |
+
$options = $data['options'];
|
3105 |
+
}
|
3106 |
+
|
3107 |
+
$options = apply_filters( 'um_selectbox_options', $options, $key );
|
3108 |
+
|
3109 |
+
if ( isset( $options ) ) {
|
3110 |
+
/**
|
3111 |
+
* UM hook
|
3112 |
+
*
|
3113 |
+
* @type filter
|
3114 |
+
* @title um_select_dropdown_dynamic_options
|
3115 |
+
* @description Extend dropdown dynamic options
|
3116 |
+
* @input_vars
|
3117 |
+
* [{"var":"$options","type":"array","desc":"Dynamic options"},
|
3118 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3119 |
+
* @change_log
|
3120 |
+
* ["Since: 2.0"]
|
3121 |
+
* @usage add_filter( 'um_select_dropdown_dynamic_options', 'function_name', 10, 2 );
|
3122 |
+
* @example
|
3123 |
+
* <?php
|
3124 |
+
* add_filter( 'um_select_dropdown_dynamic_options', 'my_select_dropdown_dynamic_options', 10, 2 );
|
3125 |
+
* function my_select_dropdown_dynamic_options( $options, $data ) {
|
3126 |
+
* // your code here
|
3127 |
+
* return $options;
|
3128 |
+
* }
|
3129 |
+
* ?>
|
3130 |
+
*/
|
3131 |
+
$options = apply_filters( 'um_select_dropdown_dynamic_options', $options, $data );
|
3132 |
+
/**
|
3133 |
+
* UM hook
|
3134 |
+
*
|
3135 |
+
* @type filter
|
3136 |
+
* @title um_select_dropdown_dynamic_options_{$key}
|
3137 |
+
* @description Extend dropdown dynamic options by field $key
|
3138 |
+
* @input_vars
|
3139 |
+
* [{"var":"$options","type":"array","desc":"Dynamic options"}]
|
3140 |
+
* @change_log
|
3141 |
+
* ["Since: 2.0"]
|
3142 |
+
* @usage add_filter( 'um_select_dropdown_dynamic_options_{$key}', 'function_name', 10, 1 );
|
3143 |
+
* @example
|
3144 |
+
* <?php
|
3145 |
+
* add_filter( 'um_select_dropdown_dynamic_options_{$key}', 'my_select_dropdown_dynamic_options', 10, 1 );
|
3146 |
+
* function my_select_dropdown_dynamic_options( $options ) {
|
3147 |
+
* // your code here
|
3148 |
+
* return $options;
|
3149 |
+
* }
|
3150 |
+
* ?>
|
3151 |
+
*/
|
3152 |
+
$options = apply_filters( "um_select_dropdown_dynamic_options_{$key}", $options );
|
3153 |
+
}
|
3154 |
+
}
|
3155 |
+
|
3156 |
+
if ( $form_key === 'role' ) {
|
3157 |
+
$options = $this->get_available_roles( $form_key, $options );
|
3158 |
+
}
|
3159 |
+
|
3160 |
+
/**
|
3161 |
+
* UM hook
|
3162 |
+
*
|
3163 |
+
* @type filter
|
3164 |
+
* @title um_select_option_value
|
3165 |
+
* @description Enable options pair by field $data
|
3166 |
+
* @input_vars
|
3167 |
+
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
3168 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3169 |
+
*/
|
3170 |
+
$options_pair = apply_filters( 'um_select_options_pair', null, $data );
|
3171 |
+
|
3172 |
+
// switch options pair for custom options from a callback function
|
3173 |
+
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
|
3174 |
+
$options_pair = true;
|
3175 |
+
}
|
3176 |
+
|
3177 |
+
$field_value = '';
|
3178 |
+
|
3179 |
+
if ( ! empty( $placeholder ) && is_string( $placeholder ) ) {
|
3180 |
+
$placeholder = strip_tags( $placeholder );
|
3181 |
+
}
|
3182 |
+
|
3183 |
+
$output .= '<select data-default="' . $data['default'] . '" ' . $disabled . ' ' . $select_original_option_value . ' ' . $disabled_by_parent_option . ' name="' . esc_attr( $form_key ) . '" id="' . esc_attr( $field_id ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" class="' . $this->get_class( $key, $data, $class ) . '" style="width: 100%" data-placeholder="' . esc_attr( $placeholder ) . '" ' . $atts_ajax . '>';
|
3184 |
+
|
3185 |
+
$output .= '<option value=""></option>';
|
3186 |
+
|
3187 |
+
// add options
|
3188 |
+
if ( ! empty( $options ) ) {
|
3189 |
+
foreach ( $options as $k => $v ) {
|
3190 |
+
|
3191 |
+
$v = rtrim( $v );
|
3192 |
+
|
3193 |
+
$option_value = $v;
|
3194 |
+
$um_field_checkbox_item_title = $v;
|
3195 |
+
|
3196 |
+
|
3197 |
+
if ( ! is_numeric( $k ) && in_array( $form_key, array( 'role' ) ) ||
|
3198 |
+
( $this->set_mode == 'account' || um_is_core_page( 'account' ) ) ) {
|
3199 |
+
$option_value = $k;
|
3200 |
+
$um_field_checkbox_item_title = $v;
|
3201 |
+
}
|
3202 |
+
|
3203 |
+
if ( isset( $options_pair ) ) {
|
3204 |
+
$option_value = $k;
|
3205 |
+
$um_field_checkbox_item_title = $v;
|
3206 |
+
}
|
3207 |
+
|
3208 |
+
$option_value = $this->filter_field_non_utf8_value( $option_value );
|
3209 |
+
|
3210 |
+
$output .= '<option value="' . $option_value . '" ';
|
3211 |
+
|
3212 |
+
if ( $this->is_selected( $form_key, $option_value, $data ) ) {
|
3213 |
+
$output .= 'selected';
|
3214 |
+
$field_value = $option_value;
|
3215 |
+
} elseif ( ! isset( $options_pair ) && $this->is_selected( $form_key, $v, $data ) ) {
|
3216 |
+
$output .= 'selected';
|
3217 |
+
$field_value = $v;
|
3218 |
+
}
|
3219 |
+
|
3220 |
+
$output .= '>' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</option>';
|
3221 |
+
}
|
3222 |
+
}
|
3223 |
+
|
3224 |
+
if ( ! empty( $disabled ) ) {
|
3225 |
+
$output .= $this->disabled_hidden_field( $form_key, $field_value );
|
3226 |
+
}
|
3227 |
+
|
3228 |
+
$output .= '</select>';
|
3229 |
+
|
3230 |
+
$output .= '</div>';
|
3231 |
+
|
3232 |
+
|
3233 |
+
if ( $this->is_error( $form_key ) ) {
|
3234 |
+
$output .= $this->field_error( $this->show_error( $form_key ) );
|
3235 |
+
} elseif ( $this->is_notice( $form_key ) ) {
|
3236 |
+
$output .= $this->field_notice( $this->show_notice( $form_key ) );
|
3237 |
+
}
|
3238 |
+
|
3239 |
+
|
3240 |
+
$output .= '</div>';
|
3241 |
+
break;
|
3242 |
+
|
3243 |
+
/* Multi-Select dropdown */
|
3244 |
+
case 'multiselect':
|
3245 |
+
|
3246 |
+
$max_selections = ( isset( $max_selections ) ) ? absint( $max_selections ) : 0;
|
3247 |
+
|
3248 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
3249 |
+
|
3250 |
+
if ( isset( $data['allowclear'] ) && $data['allowclear'] == 0 ) {
|
3251 |
+
$class = 'um-s2';
|
3252 |
+
} else {
|
3253 |
+
$class = 'um-s1';
|
3254 |
+
}
|
3255 |
+
|
3256 |
+
if ( isset( $data['label'] ) ) {
|
3257 |
+
$output .= $this->field_label( $label, $key, $data );
|
3258 |
+
}
|
3259 |
+
|
3260 |
+
$field_icon = false;
|
3261 |
+
$field_icon_output = '';
|
3262 |
+
|
3263 |
+
/**
|
3264 |
+
* UM hook
|
3265 |
+
*
|
3266 |
+
* @type filter
|
3267 |
+
* @title um_multiselect_option_value
|
3268 |
+
* @description Change multiselect keyword data
|
3269 |
+
* @input_vars
|
3270 |
+
* [{"var":"$keyword","type":"int","desc":"Option Value"},
|
3271 |
+
* {"var":"$type","type":"string","desc":"Field Type"}]
|
3272 |
+
* @change_log
|
3273 |
+
* ["Since: 2.0"]
|
3274 |
+
* @usage add_filter( 'um_multiselect_option_value', 'function_name', 10, 2 );
|
3275 |
+
* @example
|
3276 |
+
* <?php
|
3277 |
+
* add_filter( 'um_multiselect_option_value', 'my_multiselect_option_value', 10, 2 );
|
3278 |
+
* function my_multiselect_option_value( $keyword, $type ) {
|
3279 |
+
* // your code here
|
3280 |
+
* return $keyword;
|
3281 |
+
* }
|
3282 |
+
* ?>
|
3283 |
+
*/
|
3284 |
+
$use_keyword = apply_filters( 'um_multiselect_option_value', 0, $data['type'] );
|
3285 |
+
|
3286 |
+
$output .= '<div class="um-field-area ' . (! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ? 'um-field-area-has-icon' : '' ) . ' ">';
|
3287 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field') {
|
3288 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
3289 |
+
}
|
3290 |
+
|
3291 |
+
$output .= '<select ' . $disabled . ' multiple="multiple" name="' . esc_attr( $field_name ) . '[]" id="' . esc_attr( $field_id ) . '" data-maxsize="' . esc_attr( $max_selections ) . '" data-validate="' . esc_attr( $validate ) . '" data-key="' . esc_attr( $key ) . '" class="' . $this->get_class( $key, $data, $class ) . ' um-user-keyword_' . $use_keyword . '" style="width: 100%" data-placeholder="' . esc_attr( $placeholder ) . '">';
|
3292 |
+
|
3293 |
+
|
3294 |
+
if ( isset( $options ) && $options == 'builtin' ) {
|
3295 |
+
$options = UM()->builtin()->get( $filter );
|
3296 |
+
}
|
3297 |
+
|
3298 |
+
if ( ! isset( $options ) ) {
|
3299 |
+
$options = UM()->builtin()->get( 'countries' );
|
3300 |
+
}
|
3301 |
+
|
3302 |
+
if ( isset( $options ) ) {
|
3303 |
+
/**
|
3304 |
+
* UM hook
|
3305 |
+
*
|
3306 |
+
* @type filter
|
3307 |
+
* @title um_multiselect_options
|
3308 |
+
* @description Extend multiselect options
|
3309 |
+
* @input_vars
|
3310 |
+
* [{"var":"$options","type":"array","desc":"Multiselect Options"},
|
3311 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3312 |
+
* @change_log
|
3313 |
+
* ["Since: 2.0"]
|
3314 |
+
* @usage add_filter( 'um_multiselect_options', 'function_name', 10, 2 );
|
3315 |
+
* @example
|
3316 |
+
* <?php
|
3317 |
+
* add_filter( 'um_multiselect_options', 'my_multiselect_options', 10, 2 );
|
3318 |
+
* function my_multiselect_options( $options, $data ) {
|
3319 |
+
* // your code here
|
3320 |
+
* return $options;
|
3321 |
+
* }
|
3322 |
+
* ?>
|
3323 |
+
*/
|
3324 |
+
$options = apply_filters( 'um_multiselect_options', $options, $data );
|
3325 |
+
/**
|
3326 |
+
* UM hook
|
3327 |
+
*
|
3328 |
+
* @type filter
|
3329 |
+
* @title um_multiselect_options_{$key}
|
3330 |
+
* @description Extend multiselect options by field $key
|
3331 |
+
* @input_vars
|
3332 |
+
* [{"var":"$options","type":"array","desc":"Multiselect Options"}]
|
3333 |
+
* @change_log
|
3334 |
+
* ["Since: 2.0"]
|
3335 |
+
* @usage add_filter( 'um_multiselect_options_{$key}', 'function_name', 10, 1 );
|
3336 |
+
* @example
|
3337 |
+
* <?php
|
3338 |
+
* add_filter( 'um_multiselect_options_{$key}', 'my_multiselect_options', 10, 1 );
|
3339 |
+
* function my_multiselect_options( $options ) {
|
3340 |
+
* // your code here
|
3341 |
+
* return $options;
|
3342 |
+
* }
|
3343 |
+
* ?>
|
3344 |
+
*/
|
3345 |
+
$options = apply_filters( "um_multiselect_options_{$key}", $options );
|
3346 |
+
/**
|
3347 |
+
* UM hook
|
3348 |
+
*
|
3349 |
+
* @type filter
|
3350 |
+
* @title um_multiselect_options_{$type}
|
3351 |
+
* @description Extend multiselect options by field $type
|
3352 |
+
* @input_vars
|
3353 |
+
* [{"var":"$options","type":"array","desc":"Multiselect Options"},
|
3354 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3355 |
+
* @change_log
|
3356 |
+
* ["Since: 2.0"]
|
3357 |
+
* @usage add_filter( 'um_multiselect_options_{$type}', 'function_name', 10, 2 );
|
3358 |
+
* @example
|
3359 |
+
* <?php
|
3360 |
+
* add_filter( 'um_multiselect_options_{$type}', 'my_multiselect_options', 10, 2 );
|
3361 |
+
* function my_multiselect_option_value( $options, $data ) {
|
3362 |
+
* // your code here
|
3363 |
+
* return $options;
|
3364 |
+
* }
|
3365 |
+
* ?>
|
3366 |
+
*/
|
3367 |
+
$options = apply_filters( "um_multiselect_options_{$data['type']}", $options, $data );
|
3368 |
+
}
|
3369 |
+
|
3370 |
+
/**
|
3371 |
+
* UM hook
|
3372 |
+
*
|
3373 |
+
* @type filter
|
3374 |
+
* @title um_select_option_value
|
3375 |
+
* @description Enable options pair by field $data
|
3376 |
+
* @input_vars
|
3377 |
+
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
3378 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3379 |
+
*/
|
3380 |
+
$use_keyword = apply_filters( 'um_select_options_pair', null, $data );
|
3381 |
+
|
3382 |
+
// switch options pair for custom options from a callback function
|
3383 |
+
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
|
3384 |
+
$use_keyword = true;
|
3385 |
+
}
|
3386 |
+
|
3387 |
+
// add an empty option!
|
3388 |
+
$output .= '<option value=""></option>';
|
3389 |
+
|
3390 |
+
$arr_selected = array();
|
3391 |
+
// add options
|
3392 |
+
if ( ! empty( $options ) && is_array( $options ) ) {
|
3393 |
+
foreach ( $options as $k => $v ) {
|
3394 |
+
|
3395 |
+
$v = rtrim( $v );
|
3396 |
+
|
3397 |
+
$um_field_checkbox_item_title = $v;
|
3398 |
+
$opt_value = $v;
|
3399 |
+
|
3400 |
+
if ( $use_keyword ) {
|
3401 |
+
$um_field_checkbox_item_title = $v;
|
3402 |
+
$opt_value = $k;
|
3403 |
+
}
|
3404 |
+
|
3405 |
+
$opt_value = $this->filter_field_non_utf8_value( $opt_value );
|
3406 |
+
|
3407 |
+
$output .= '<option value="' . $opt_value . '" ';
|
3408 |
+
if ( $this->is_selected( $key, $opt_value, $data ) ) {
|
3409 |
+
|
3410 |
+
$output .= 'selected';
|
3411 |
+
$arr_selected[ $opt_value ] = $opt_value;
|
3412 |
+
}
|
3413 |
+
|
3414 |
+
$output .= '>' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</option>';
|
3415 |
+
|
3416 |
+
}
|
3417 |
+
}
|
3418 |
+
|
3419 |
+
$output .= '</select>';
|
3420 |
+
|
3421 |
+
if ( ! empty( $disabled ) && ! empty( $arr_selected ) ) {
|
3422 |
+
foreach ( $arr_selected as $item ) {
|
3423 |
+
$output .= $this->disabled_hidden_field( $key . '[]', $item );
|
3424 |
+
}
|
3425 |
+
}
|
3426 |
+
|
3427 |
+
$output .= '</div>';
|
3428 |
+
|
3429 |
+
|
3430 |
+
if ( $this->is_error( $key ) ) {
|
3431 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
3432 |
+
}else if ( $this->is_notice( $key ) ) {
|
3433 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
3434 |
+
}
|
3435 |
+
|
3436 |
+
$output .= '</div>';
|
3437 |
+
break;
|
3438 |
+
|
3439 |
+
/* Radio */
|
3440 |
+
case 'radio':
|
3441 |
+
|
3442 |
+
if ( isset( $options ) ) {
|
3443 |
+
/**
|
3444 |
+
* UM hook
|
3445 |
+
*
|
3446 |
+
* @type filter
|
3447 |
+
* @title um_radio_field_options
|
3448 |
+
* @description Extend radio field options
|
3449 |
+
* @input_vars
|
3450 |
+
* [{"var":"$options","type":"array","desc":"Radio Field Options"},
|
3451 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3452 |
+
* @change_log
|
3453 |
+
* ["Since: 2.0"]
|
3454 |
+
* @usage add_filter( 'um_radio_field_options', 'function_name', 10, 2 );
|
3455 |
+
* @example
|
3456 |
+
* <?php
|
3457 |
+
* add_filter( 'um_radio_field_options', 'my_radio_field_options', 10, 2 );
|
3458 |
+
* function my_radio_field_options( $options, $data ) {
|
3459 |
+
* // your code here
|
3460 |
+
* return $options;
|
3461 |
+
* }
|
3462 |
+
* ?>
|
3463 |
+
*/
|
3464 |
+
$options = apply_filters( 'um_radio_field_options', $options, $data );
|
3465 |
+
/**
|
3466 |
+
* UM hook
|
3467 |
+
*
|
3468 |
+
* @type filter
|
3469 |
+
* @title um_radio_field_options_{$key}
|
3470 |
+
* @description Extend radio field options by field $key
|
3471 |
+
* @input_vars
|
3472 |
+
* [{"var":"$options","type":"array","desc":"Radio field Options"}]
|
3473 |
+
* @change_log
|
3474 |
+
* ["Since: 2.0"]
|
3475 |
+
* @usage add_filter( 'um_radio_field_options_{$key}', 'function_name', 10, 1 );
|
3476 |
+
* @example
|
3477 |
+
* <?php
|
3478 |
+
* add_filter( 'um_radio_field_options_{$key}', 'my_radio_field_options', 10, 1 );
|
3479 |
+
* function my_radio_field_options( $options ) {
|
3480 |
+
* // your code here
|
3481 |
+
* return $options;
|
3482 |
+
* }
|
3483 |
+
* ?>
|
3484 |
+
*/
|
3485 |
+
$options = apply_filters( "um_radio_field_options_{$key}", $options );
|
3486 |
+
}
|
3487 |
+
|
3488 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
3489 |
+
|
3490 |
+
if ( isset( $data['label'] ) ) {
|
3491 |
+
$output .= $this->field_label( $label, $key, $data );
|
3492 |
+
}
|
3493 |
+
|
3494 |
+
$output .= '<div class="um-field-area">';
|
3495 |
+
|
3496 |
+
$options = $this->get_available_roles( $form_key, $options );
|
3497 |
+
|
3498 |
+
// add options
|
3499 |
+
$i = 0;
|
3500 |
+
$field_value = array();
|
3501 |
+
|
3502 |
+
/**
|
3503 |
+
* UM hook
|
3504 |
+
*
|
3505 |
+
* @type filter
|
3506 |
+
* @title um_radio_option_value
|
3507 |
+
* @description Enable options pair by field $data
|
3508 |
+
* @input_vars
|
3509 |
+
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
3510 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3511 |
+
*/
|
3512 |
+
$options_pair = apply_filters( "um_radio_options_pair__{$key}", false, $data );
|
3513 |
+
|
3514 |
+
|
3515 |
+
if ( ! empty( $options ) ) {
|
3516 |
+
foreach ( $options as $k => $v ) {
|
3517 |
+
|
3518 |
+
$v = rtrim( $v );
|
3519 |
+
|
3520 |
+
$um_field_checkbox_item_title = $v;
|
3521 |
+
$option_value = $v;
|
3522 |
+
|
3523 |
+
if ( ! is_numeric( $k ) && in_array( $form_key, array( 'role' ) ) ||
|
3524 |
+
( $this->set_mode == 'account' || um_is_core_page( 'account' ) ) ) {
|
3525 |
+
$um_field_checkbox_item_title = $v;
|
3526 |
+
$option_value = $k;
|
3527 |
+
}
|
3528 |
+
|
3529 |
+
if( $options_pair ){
|
3530 |
+
$um_field_checkbox_item_title = $v;
|
3531 |
+
$option_value = $k;
|
3532 |
+
}
|
3533 |
+
|
3534 |
+
$i++;
|
3535 |
+
if ($i % 2 == 0) {
|
3536 |
+
$col_class = 'right';
|
3537 |
+
} else {
|
3538 |
+
$col_class = '';
|
3539 |
+
}
|
3540 |
+
|
3541 |
+
if ( $this->is_radio_checked( $key, $option_value, $data ) ) {
|
3542 |
+
$active = 'active';
|
3543 |
+
$class = "um-icon-android-radio-button-on";
|
3544 |
+
} else {
|
3545 |
+
$active = '';
|
3546 |
+
$class = "um-icon-android-radio-button-off";
|
3547 |
+
}
|
3548 |
+
|
3549 |
+
|
3550 |
+
if ( isset( $data['editable'] ) && $data['editable'] == 0 ) {
|
3551 |
+
$col_class .= " um-field-radio-state-disabled";
|
3552 |
+
}
|
3553 |
+
|
3554 |
+
$output .= '<label class="um-field-radio ' . esc_attr( $active ) . ' um-field-half ' . esc_attr( $col_class ) . '">';
|
3555 |
+
|
3556 |
+
$option_value = $this->filter_field_non_utf8_value( $option_value );
|
3557 |
+
|
3558 |
+
$output .= '<input ' . $disabled . ' type="radio" name="' . ( ( $form_key == 'role' ) ? esc_attr( $form_key ) : esc_attr( $form_key ) . '[]' ) . '" value="' . $option_value . '" ';
|
3559 |
+
|
3560 |
+
if ( $this->is_radio_checked( $key, $option_value, $data ) ) {
|
3561 |
+
$output .= 'checked';
|
3562 |
+
$field_value[ $key ] = $option_value;
|
3563 |
+
}
|
3564 |
+
|
3565 |
+
$output .= ' />';
|
3566 |
+
|
3567 |
+
$output .= '<span class="um-field-radio-state"><i class="' . esc_attr( $class ) . '"></i></span>';
|
3568 |
+
$output .= '<span class="um-field-radio-option">' . esc_html__( $um_field_checkbox_item_title, 'ultimate-member' ) . '</span>';
|
3569 |
+
$output .= '</label>';
|
3570 |
+
|
3571 |
+
if ( $i % 2 == 0 ) {
|
3572 |
+
$output .= '<div class="um-clear"></div>';
|
3573 |
+
}
|
3574 |
+
|
3575 |
+
}
|
3576 |
+
}
|
3577 |
+
|
3578 |
+
if ( ! empty( $disabled ) ) {
|
3579 |
+
foreach ( $field_value as $item ) {
|
3580 |
+
$output .= $this->disabled_hidden_field( $form_key, $item );
|
3581 |
+
}
|
3582 |
+
}
|
3583 |
+
|
3584 |
+
$output .= '<div class="um-clear"></div>';
|
3585 |
+
|
3586 |
+
$output .= '</div>';
|
3587 |
+
|
3588 |
+
if ( $this->is_error( $key ) ) {
|
3589 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
3590 |
+
}else if ( $this->is_notice( $key ) ) {
|
3591 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
3592 |
+
}
|
3593 |
+
|
3594 |
+
$output .= '</div>';
|
3595 |
+
break;
|
3596 |
+
|
3597 |
+
/* Checkbox */
|
3598 |
+
case 'checkbox':
|
3599 |
+
|
3600 |
+
if ( isset( $options ) ) {
|
3601 |
+
/**
|
3602 |
+
* UM hook
|
3603 |
+
*
|
3604 |
+
* @type filter
|
3605 |
+
* @title um_checkbox_field_options
|
3606 |
+
* @description Extend checkbox options
|
3607 |
+
* @input_vars
|
3608 |
+
* [{"var":"$options","type":"array","desc":"Checkbox Options"},
|
3609 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3610 |
+
* @change_log
|
3611 |
+
* ["Since: 2.0"]
|
3612 |
+
* @usage add_filter( 'um_checkbox_field_options', 'function_name', 10, 2 );
|
3613 |
+
* @example
|
3614 |
+
* <?php
|
3615 |
+
* add_filter( 'um_checkbox_field_options', 'my_checkbox_options', 10, 2 );
|
3616 |
+
* function my_checkbox_options( $options, $data ) {
|
3617 |
+
* // your code here
|
3618 |
+
* return $options;
|
3619 |
+
* }
|
3620 |
+
* ?>
|
3621 |
+
*/
|
3622 |
+
$options = apply_filters( 'um_checkbox_field_options', $options, $data );
|
3623 |
+
/**
|
3624 |
+
* UM hook
|
3625 |
+
*
|
3626 |
+
* @type filter
|
3627 |
+
* @title um_checkbox_field_options_{$key}
|
3628 |
+
* @description Extend checkbox options by field $key
|
3629 |
+
* @input_vars
|
3630 |
+
* [{"var":"$options","type":"array","desc":"Checkbox Options"}]
|
3631 |
+
* @change_log
|
3632 |
+
* ["Since: 2.0"]
|
3633 |
+
* @usage add_filter( 'um_checkbox_field_options_{$key}', 'function_name', 10, 1 );
|
3634 |
+
* @example
|
3635 |
+
* <?php
|
3636 |
+
* add_filter( 'um_checkbox_field_options_{$key}', 'my_checkbox_options', 10, 1 );
|
3637 |
+
* function my_checkbox_options( $options ) {
|
3638 |
+
* // your code here
|
3639 |
+
* return $options;
|
3640 |
+
* }
|
3641 |
+
* ?>
|
3642 |
+
*/
|
3643 |
+
$options = apply_filters( "um_checkbox_field_options_{$key}", $options );
|
3644 |
+
}
|
3645 |
+
|
3646 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
3647 |
+
|
3648 |
+
if ( isset( $data['label'] ) ) {
|
3649 |
+
$output .= $this->field_label( $label, $key, $data );
|
3650 |
+
}
|
3651 |
+
|
3652 |
+
$output .= '<div class="um-field-area">';
|
3653 |
+
|
3654 |
+
// add options
|
3655 |
+
$i = 0;
|
3656 |
+
|
3657 |
+
foreach ( $options as $k => $v ) {
|
3658 |
+
|
3659 |
+
$v = rtrim( $v );
|
3660 |
+
|
3661 |
+
$i++;
|
3662 |
+
if ( $i % 2 == 0 ) {
|
3663 |
+
$col_class = 'right';
|
3664 |
+
} else {
|
3665 |
+
$col_class = '';
|
3666 |
+
}
|
3667 |
+
|
3668 |
+
if ( $this->is_selected( $key, $v, $data ) ) {
|
3669 |
+
$active = 'active';
|
3670 |
+
$class = "um-icon-android-checkbox-outline";
|
3671 |
+
} else {
|
3672 |
+
$active = '';
|
3673 |
+
$class = "um-icon-android-checkbox-outline-blank";
|
3674 |
+
}
|
3675 |
+
|
3676 |
+
if ( isset( $data['editable'] ) && $data['editable'] == 0 ) {
|
3677 |
+
$col_class .= " um-field-radio-state-disabled";
|
3678 |
+
}
|
3679 |
+
|
3680 |
+
$output .= '<label class="um-field-checkbox ' . esc_attr( $active ) . ' um-field-half ' . esc_attr( $col_class ) . '">';
|
3681 |
+
|
3682 |
+
$um_field_checkbox_item_title = $v;
|
3683 |
+
|
3684 |
+
$v = $this->filter_field_non_utf8_value( $v );
|
3685 |
+
|
3686 |
+
$output .= '<input ' . $disabled . ' type="checkbox" name="' . esc_attr( $key ) . '[]" value="' . strip_tags( $v ) . '" ';
|
3687 |
+
|
3688 |
+
if ( $this->is_selected( $key, $v, $data ) ) {
|
3689 |
+
$output .= 'checked';
|
3690 |
+
}
|
3691 |
+
|
3692 |
+
$output .= ' />';
|
3693 |
+
|
3694 |
+
if ( ! empty( $disabled ) && $this->is_selected( $key, $v, $data ) ) {
|
3695 |
+
$output .= $this->disabled_hidden_field( $key . '[]', strip_tags( $v ) );
|
3696 |
+
}
|
3697 |
+
|
3698 |
+
|
3699 |
+
$output .= '<span class="um-field-checkbox-state"><i class="' . esc_attr( $class ) . '"></i></span>';
|
3700 |
+
/**
|
3701 |
+
* UM hook
|
3702 |
+
*
|
3703 |
+
* @type filter
|
3704 |
+
* @title um_field_checkbox_item_title
|
3705 |
+
* @description Change Checkbox item title
|
3706 |
+
* @input_vars
|
3707 |
+
* [{"var":"$checkbox_item_title","type":"array","desc":"Item Title"},
|
3708 |
+
* {"var":"$key","type":"string","desc":"Field Key"},
|
3709 |
+
* {"var":"$value","type":"string","desc":"Field Value"},
|
3710 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3711 |
+
* @change_log
|
3712 |
+
* ["Since: 2.0"]
|
3713 |
+
* @usage add_filter( 'um_field_checkbox_item_title', 'function_name', 10, 4 );
|
3714 |
+
* @example
|
3715 |
+
* <?php
|
3716 |
+
* add_filter( 'um_field_checkbox_item_title', 'my_checkbox_item_title', 10, 4 );
|
3717 |
+
* function my_checkbox_item_title( $checkbox_item_title, $key, $value, $data ) {
|
3718 |
+
* // your code here
|
3719 |
+
* return $checkbox_item_title;
|
3720 |
+
* }
|
3721 |
+
* ?>
|
3722 |
+
*/
|
3723 |
+
$um_field_checkbox_item_title = apply_filters( 'um_field_checkbox_item_title', $um_field_checkbox_item_title, $key, $v, $data );
|
3724 |
+
$output .= '<span class="um-field-checkbox-option">' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</span>';
|
3725 |
+
$output .= '</label>';
|
3726 |
+
|
3727 |
+
if ( $i % 2 == 0 ) {
|
3728 |
+
$output .= '<div class="um-clear"></div>';
|
3729 |
+
}
|
3730 |
+
|
3731 |
+
}
|
3732 |
+
|
3733 |
+
$output .= '<div class="um-clear"></div>';
|
3734 |
+
|
3735 |
+
$output .= '</div>';
|
3736 |
+
|
3737 |
+
|
3738 |
+
if ( $this->is_error( $key ) ) {
|
3739 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
3740 |
+
}else if ( $this->is_notice( $key ) ) {
|
3741 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
3742 |
+
}
|
3743 |
+
|
3744 |
+
$output .= '</div>';
|
3745 |
+
break;
|
3746 |
+
|
3747 |
+
/* HTML */
|
3748 |
+
case 'block':
|
3749 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '</div>';
|
3750 |
+
break;
|
3751 |
+
|
3752 |
+
/* Shortcode */
|
3753 |
+
case 'shortcode':
|
3754 |
+
|
3755 |
+
$content = str_replace( '{profile_id}', um_profile_id(), $content );
|
3756 |
+
if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
|
3757 |
+
$content = do_shortcode( $content );
|
3758 |
+
} else {
|
3759 |
+
$content = apply_shortcodes( $content );
|
3760 |
+
}
|
3761 |
+
|
3762 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '</div>';
|
3763 |
+
break;
|
3764 |
+
|
3765 |
+
/* Unlimited Group */
|
3766 |
+
case 'group':
|
3767 |
+
|
3768 |
+
$fields = $this->get_fields_in_group( $key );
|
3769 |
+
if ( ! empty( $fields ) ) {
|
3770 |
+
|
3771 |
+
$output .= '<div class="um-field-group" data-max_entries="' . $max_entries . '">
|
3772 |
+
<div class="um-field-group-head"><i class="um-icon-plus"></i>' . esc_html__( $label, 'ultimate-member' ) . '</div>';
|
3773 |
+
$output .= '<div class="um-field-group-body"><a href="javascript:void(0);" class="um-field-group-cancel"><i class="um-icon-close"></i></a>';
|
3774 |
+
|
3775 |
+
foreach ( $fields as $subkey => $subdata ) {
|
3776 |
+
$output .= $this->edit_field( $subkey, $subdata, 'group' );
|
3777 |
+
}
|
3778 |
+
|
3779 |
+
$output .= '</div>';
|
3780 |
+
$output .= '</div>';
|
3781 |
+
|
3782 |
+
}
|
3783 |
+
|
3784 |
+
break;
|
3785 |
+
|
3786 |
+
}
|
3787 |
+
|
3788 |
+
// Custom filter for field output
|
3789 |
+
if ( isset( $this->set_mode ) ) {
|
3790 |
+
/**
|
3791 |
+
* UM hook
|
3792 |
+
*
|
3793 |
+
* @type filter
|
3794 |
+
* @title um_{$key}_form_edit_field
|
3795 |
+
* @description Change field HTML on edit mode by field $key
|
3796 |
+
* @input_vars
|
3797 |
+
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
3798 |
+
* {"var":"$mode","type":"string","desc":"Fields Mode"}]
|
3799 |
+
* @change_log
|
3800 |
+
* ["Since: 2.0"]
|
3801 |
+
* @usage add_filter( 'um_{$key}_form_edit_field', 'function_name', 10, 2 );
|
3802 |
+
* @example
|
3803 |
+
* <?php
|
3804 |
+
* add_filter( 'um_{$key}_form_edit_field', 'my_form_edit_field', 10, 2 );
|
3805 |
+
* function my_form_edit_field( $output, $mode ) {
|
3806 |
+
* // your code here
|
3807 |
+
* return $output;
|
3808 |
+
* }
|
3809 |
+
* ?>
|
3810 |
+
*/
|
3811 |
+
$output = apply_filters( "um_{$key}_form_edit_field", $output, $this->set_mode );
|
3812 |
+
}
|
3813 |
+
|
3814 |
+
return $output;
|
3815 |
+
}
|
3816 |
+
|
3817 |
+
|
3818 |
+
/**
|
3819 |
+
* Filter for user roles
|
3820 |
+
*
|
3821 |
+
* @param $form_key
|
3822 |
+
* @param array $options
|
3823 |
+
* @return array
|
3824 |
+
*/
|
3825 |
+
function get_available_roles( $form_key, $options = array() ) {
|
3826 |
+
if ( $form_key != 'role' ) {
|
3827 |
+
return $options;
|
3828 |
+
}
|
3829 |
+
|
3830 |
+
// role field
|
3831 |
+
global $wp_roles;
|
3832 |
+
$role_keys = array_map( function( $item ) {
|
3833 |
+
return 'um_' . $item;
|
3834 |
+
}, get_option( 'um_roles', array() ) );
|
3835 |
+
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
3836 |
+
|
3837 |
+
$roles = UM()->roles()->get_roles( false, $exclude_roles );
|
3838 |
+
|
3839 |
+
if ( ! empty( $options ) ) {
|
3840 |
+
|
3841 |
+
$roles = array_map( function( $item ) {
|
3842 |
+
return html_entity_decode( $item, ENT_QUOTES );
|
3843 |
+
}, $roles );
|
3844 |
+
|
3845 |
+
//fix when customers change options for role (radio/dropdown) fields
|
3846 |
+
$intersected_options = array();
|
3847 |
+
foreach ( $options as $key => $title ) {
|
3848 |
+
if ( false !== $search_key = array_search( $title, $roles ) ) {
|
3849 |
+
$intersected_options[ $search_key ] = $title;
|
3850 |
+
} elseif ( isset( $roles[ $key ] ) ) {
|
3851 |
+
$intersected_options[ $key ] = $title;
|
3852 |
+
}
|
3853 |
+
}
|
3854 |
+
|
3855 |
+
$options = $intersected_options;
|
3856 |
+
} else {
|
3857 |
+
$options = $roles;
|
3858 |
+
}
|
3859 |
+
|
3860 |
+
return $options;
|
3861 |
+
}
|
3862 |
+
|
3863 |
+
|
3864 |
+
/**
|
3865 |
+
* Sorts columns array
|
3866 |
+
*
|
3867 |
+
* @param array $arr
|
3868 |
+
* @param string $col
|
3869 |
+
* @param string $dir
|
3870 |
+
*
|
3871 |
+
* @return array $arr
|
3872 |
+
*/
|
3873 |
+
function array_sort_by_column( $arr, $col, $dir = SORT_ASC ) {
|
3874 |
+
$sort_col = array();
|
3875 |
+
foreach ( $arr as $key => $row ) {
|
3876 |
+
if ( $key == 'form_id' ) {
|
3877 |
+
unset( $arr['form_id'] );
|
3878 |
+
continue;
|
3879 |
+
}
|
3880 |
+
|
3881 |
+
if ( isset( $row[ $col ] ) ) {
|
3882 |
+
$sort_col[ $key ] = $row[ $col ];
|
3883 |
+
} else {
|
3884 |
+
unset( $arr[ $key ] );
|
3885 |
+
}
|
3886 |
+
}
|
3887 |
+
|
3888 |
+
array_multisort( $sort_col, $dir, $arr );
|
3889 |
+
|
3890 |
+
return $arr;
|
3891 |
+
}
|
3892 |
+
|
3893 |
+
|
3894 |
+
/**
|
3895 |
+
* Get fields in row
|
3896 |
+
*
|
3897 |
+
* @param int $row_id
|
3898 |
+
*
|
3899 |
+
* @return string
|
3900 |
+
*/
|
3901 |
+
function get_fields_by_row( $row_id ) {
|
3902 |
+
if ( ! isset( $this->get_fields ) ) {
|
3903 |
+
return '';
|
3904 |
+
}
|
3905 |
+
|
3906 |
+
foreach ( $this->get_fields as $key => $array ) {
|
3907 |
+
if ( ! isset( $array['in_row'] ) || ( isset( $array['in_row'] ) && $array['in_row'] == $row_id ) ) {
|
3908 |
+
$results[ $key ] = $array;
|
3909 |
+
}
|
3910 |
+
}
|
3911 |
+
|
3912 |
+
return ( isset ( $results ) ) ? $results : '';
|
3913 |
+
}
|
3914 |
+
|
3915 |
+
|
3916 |
+
/**
|
3917 |
+
* Get fields by sub row
|
3918 |
+
*
|
3919 |
+
* @param string $row_fields
|
3920 |
+
* @param integer $subrow_id
|
3921 |
+
*
|
3922 |
+
* @return mixed
|
3923 |
+
*/
|
3924 |
+
function get_fields_in_subrow( $row_fields, $subrow_id ) {
|
3925 |
+
if ( ! is_array( $row_fields ) ) {
|
3926 |
+
return '';
|
3927 |
+
}
|
3928 |
+
foreach ( $row_fields as $key => $array ) {
|
3929 |
+
if ( ! isset( $array['in_sub_row'] ) || ( isset( $array['in_sub_row'] ) && $array['in_sub_row'] == $subrow_id ) ) {
|
3930 |
+
$results[ $key ] = $array;
|
3931 |
+
}
|
3932 |
+
}
|
3933 |
+
|
3934 |
+
return ( isset ( $results ) ) ? $results : '';
|
3935 |
+
}
|
3936 |
+
|
3937 |
+
|
3938 |
+
/**
|
3939 |
+
* Get fields in group
|
3940 |
+
*
|
3941 |
+
* @param integer $group_id
|
3942 |
+
*
|
3943 |
+
* @return mixed
|
3944 |
+
*/
|
3945 |
+
function get_fields_in_group( $group_id ) {
|
3946 |
+
foreach ( $this->get_fields as $key => $array ) {
|
3947 |
+
if ( isset( $array['in_group'] ) && $array['in_group'] == $group_id ) {
|
3948 |
+
$results[ $key ] = $array;
|
3949 |
+
}
|
3950 |
+
}
|
3951 |
+
|
3952 |
+
return ( isset ( $results ) ) ? $results : '';
|
3953 |
+
}
|
3954 |
+
|
3955 |
+
|
3956 |
+
/**
|
3957 |
+
* Get fields in column
|
3958 |
+
*
|
3959 |
+
* @param array $fields
|
3960 |
+
* @param integer $col_number
|
3961 |
+
*
|
3962 |
+
* @return mixed
|
3963 |
+
*/
|
3964 |
+
function get_fields_in_column( $fields, $col_number ) {
|
3965 |
+
foreach ( $fields as $key => $array ) {
|
3966 |
+
if ( isset( $array['in_column'] ) && $array['in_column'] == $col_number ) {
|
3967 |
+
$results[ $key ] = $array;
|
3968 |
+
}
|
3969 |
+
}
|
3970 |
+
|
3971 |
+
return ( isset ( $results ) ) ? $results : '';
|
3972 |
+
}
|
3973 |
+
|
3974 |
+
|
3975 |
+
/**
|
3976 |
+
* Display fields
|
3977 |
+
*
|
3978 |
+
* @param string $mode
|
3979 |
+
* @param array $args
|
3980 |
+
*
|
3981 |
+
* @return string|null
|
3982 |
+
* @throws \Exception
|
3983 |
+
*/
|
3984 |
+
function display( $mode, $args ) {
|
3985 |
+
$output = null;
|
3986 |
+
|
3987 |
+
$this->global_args = $args;
|
3988 |
+
|
3989 |
+
UM()->form()->form_suffix = '-' . $this->global_args['form_id'];
|
3990 |
+
|
3991 |
+
$this->set_mode = $mode;
|
3992 |
+
|
3993 |
+
if ( 'profile' === $mode ) {
|
3994 |
+
UM()->form()->nonce = wp_create_nonce( 'um-profile-nonce' . UM()->user()->target_id );
|
3995 |
+
}
|
3996 |
+
|
3997 |
+
$this->set_id = $this->global_args['form_id'];
|
3998 |
+
|
3999 |
+
$this->field_icons = ( isset( $this->global_args['icons'] ) ) ? $this->global_args['icons'] : 'label';
|
4000 |
+
|
4001 |
+
// start output here
|
4002 |
+
$this->get_fields = $this->get_fields();
|
4003 |
+
|
4004 |
+
if ( ! empty( $this->get_fields ) ) {
|
4005 |
+
|
4006 |
+
// find rows
|
4007 |
+
foreach ( $this->get_fields as $key => $array ) {
|
4008 |
+
if ( $array['type'] == 'row' ) {
|
4009 |
+
$this->rows[ $key ] = $array;
|
4010 |
+
unset( $this->get_fields[ $key ] ); // not needed anymore
|
4011 |
+
}
|
4012 |
+
}
|
4013 |
+
|
4014 |
+
// rows fallback
|
4015 |
+
if ( ! isset( $this->rows ) ) {
|
4016 |
+
$this->rows = array(
|
4017 |
+
'_um_row_1' => array(
|
4018 |
+
'type' => 'row',
|
4019 |
+
'id' => '_um_row_1',
|
4020 |
+
'sub_rows' => 1,
|
4021 |
+
'cols' => 1,
|
4022 |
+
),
|
4023 |
+
);
|
4024 |
+
}
|
4025 |
+
|
4026 |
+
// master rows
|
4027 |
+
foreach ( $this->rows as $row_id => $row_array ) {
|
4028 |
+
|
4029 |
+
$row_fields = $this->get_fields_by_row( $row_id );
|
4030 |
+
if ( $row_fields ) {
|
4031 |
+
|
4032 |
+
$output .= $this->new_row_output( $row_id, $row_array );
|
4033 |
+
|
4034 |
+
$sub_rows = ( isset( $row_array['sub_rows'] ) ) ? $row_array['sub_rows'] : 1;
|
4035 |
+
for ( $c = 0; $c < $sub_rows; $c++ ) {
|
4036 |
+
|
4037 |
+
// cols
|
4038 |
+
$cols = isset( $row_array['cols'] ) ? $row_array['cols'] : 1;
|
4039 |
+
if ( is_numeric( $cols ) ) {
|
4040 |
+
$cols_num = (int) $cols;
|
4041 |
+
} else {
|
4042 |
+
if ( strstr( $cols, ':' ) ) {
|
4043 |
+
$col_split = explode( ':', $cols );
|
4044 |
+
} else {
|
4045 |
+
$col_split = array( $cols );
|
4046 |
+
}
|
4047 |
+
$cols_num = $col_split[ $c ];
|
4048 |
+
}
|
4049 |
+
|
4050 |
+
// sub row fields
|
4051 |
+
$subrow_fields = null;
|
4052 |
+
$subrow_fields = $this->get_fields_in_subrow( $row_fields, $c );
|
4053 |
+
|
4054 |
+
if ( is_array( $subrow_fields ) ) {
|
4055 |
+
|
4056 |
+
$subrow_fields = $this->array_sort_by_column( $subrow_fields, 'position' );
|
4057 |
+
|
4058 |
+
if ( $cols_num == 1 ) {
|
4059 |
+
|
4060 |
+
$output .= '<div class="um-col-1">';
|
4061 |
+
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4062 |
+
if ( $col1_fields ) {
|
4063 |
+
foreach ( $col1_fields as $key => $data ) {
|
4064 |
+
$output .= $this->edit_field( $key, $data );
|
4065 |
+
}
|
4066 |
+
}
|
4067 |
+
$output .= '</div>';
|
4068 |
+
|
4069 |
+
} else if ($cols_num == 2) {
|
4070 |
+
|
4071 |
+
$output .= '<div class="um-col-121">';
|
4072 |
+
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4073 |
+
if ( $col1_fields ) {
|
4074 |
+
foreach ( $col1_fields as $key => $data ) {
|
4075 |
+
$output .= $this->edit_field( $key, $data );
|
4076 |
+
}
|
4077 |
+
}
|
4078 |
+
$output .= '</div>';
|
4079 |
+
|
4080 |
+
$output .= '<div class="um-col-122">';
|
4081 |
+
$col2_fields = $this->get_fields_in_column( $subrow_fields, 2 );
|
4082 |
+
if ( $col2_fields ) {
|
4083 |
+
foreach ( $col2_fields as $key => $data ) {
|
4084 |
+
$output .= $this->edit_field( $key, $data );
|
4085 |
+
}
|
4086 |
+
}
|
4087 |
+
$output .= '</div><div class="um-clear"></div>';
|
4088 |
+
|
4089 |
+
} else {
|
4090 |
+
|
4091 |
+
$output .= '<div class="um-col-131">';
|
4092 |
+
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4093 |
+
if ( $col1_fields ) {
|
4094 |
+
foreach ( $col1_fields as $key => $data ) {
|
4095 |
+
$output .= $this->edit_field( $key, $data );
|
4096 |
+
}
|
4097 |
+
}
|
4098 |
+
$output .= '</div>';
|
4099 |
+
|
4100 |
+
$output .= '<div class="um-col-132">';
|
4101 |
+
$col2_fields = $this->get_fields_in_column( $subrow_fields, 2 );
|
4102 |
+
if ( $col2_fields ) {
|
4103 |
+
foreach ( $col2_fields as $key => $data ) {
|
4104 |
+
$output .= $this->edit_field( $key, $data );
|
4105 |
+
}
|
4106 |
+
}
|
4107 |
+
$output .= '</div>';
|
4108 |
+
|
4109 |
+
$output .= '<div class="um-col-133">';
|
4110 |
+
$col3_fields = $this->get_fields_in_column( $subrow_fields, 3 );
|
4111 |
+
if ( $col3_fields ) {
|
4112 |
+
foreach ( $col3_fields as $key => $data ) {
|
4113 |
+
$output .= $this->edit_field( $key, $data );
|
4114 |
+
}
|
4115 |
+
}
|
4116 |
+
$output .= '</div><div class="um-clear"></div>';
|
4117 |
+
|
4118 |
+
}
|
4119 |
+
|
4120 |
+
}
|
4121 |
+
|
4122 |
+
}
|
4123 |
+
|
4124 |
+
$output .= '</div>';
|
4125 |
+
|
4126 |
+
}
|
4127 |
+
|
4128 |
+
}
|
4129 |
+
|
4130 |
+
}
|
4131 |
+
|
4132 |
+
return $output;
|
4133 |
+
}
|
4134 |
+
|
4135 |
+
|
4136 |
+
/**
|
4137 |
+
* Gets a field in `view mode`
|
4138 |
+
*
|
4139 |
+
* @param string $key
|
4140 |
+
* @param array $data
|
4141 |
+
* @param bool $rule
|
4142 |
+
*
|
4143 |
+
* @return string|null
|
4144 |
+
* @throws \Exception
|
4145 |
+
*/
|
4146 |
+
function view_field( $key, $data, $rule = false ) {
|
4147 |
+
$output = '';
|
4148 |
+
|
4149 |
+
// get whole field data
|
4150 |
+
if ( is_array( $data ) ) {
|
4151 |
+
$data = $this->get_field( $key );
|
4152 |
+
|
4153 |
+
if ( is_array( $data ) ) {
|
4154 |
+
/**
|
4155 |
+
* @var $visibility
|
4156 |
+
* @var $type
|
4157 |
+
* @var $default
|
4158 |
+
* @var $classes
|
4159 |
+
* @var $conditional
|
4160 |
+
* @var $content
|
4161 |
+
* @var $divider_text
|
4162 |
+
* @var $spacing
|
4163 |
+
* @var $borderwidth
|
4164 |
+
* @var $borderstyle
|
4165 |
+
* @var $bordercolor
|
4166 |
+
* @var $label
|
4167 |
+
*/
|
4168 |
+
extract( $data );
|
4169 |
+
}
|
4170 |
+
}
|
4171 |
+
|
4172 |
+
//hide if empty type
|
4173 |
+
if ( ! isset( $data['type'] ) ) {
|
4174 |
+
return '';
|
4175 |
+
}
|
4176 |
+
|
4177 |
+
if ( isset( $data['in_group'] ) && $data['in_group'] != '' && $rule != 'group' ) {
|
4178 |
+
return '';
|
4179 |
+
}
|
4180 |
+
|
4181 |
+
//invisible on profile page
|
4182 |
+
if ( $visibility == 'edit' || $type == 'password' ) {
|
4183 |
+
return '';
|
4184 |
+
}
|
4185 |
+
|
4186 |
+
//hide if empty
|
4187 |
+
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
4188 |
+
if ( ! in_array( $type, $fields_without_metakey ) ) {
|
4189 |
+
$_field_value = $this->field_value( $key, $default, $data );
|
4190 |
+
|
4191 |
+
if ( ! isset( $_field_value ) || $_field_value == '' ) {
|
4192 |
+
return '';
|
4193 |
+
}
|
4194 |
+
}
|
4195 |
+
|
4196 |
+
if ( ! um_can_view_field( $data ) ) {
|
4197 |
+
return '';
|
4198 |
+
}
|
4199 |
+
|
4200 |
+
// disable these fields in profile view only
|
4201 |
+
if ( in_array( $key, array( 'user_password' ) ) && $this->set_mode == 'profile' ) {
|
4202 |
+
return '';
|
4203 |
+
}
|
4204 |
+
|
4205 |
+
if ( ! um_field_conditions_are_met( $data ) ) {
|
4206 |
+
return '';
|
4207 |
+
}
|
4208 |
+
|
4209 |
+
|
4210 |
+
if ( isset( $data['classes'] ) ) {
|
4211 |
+
$classes = explode( " ", $data['classes'] );
|
4212 |
+
}
|
4213 |
+
|
4214 |
+
switch ( $type ) {
|
4215 |
+
|
4216 |
+
/* Default */
|
4217 |
+
default:
|
4218 |
+
|
4219 |
+
$_field_value = $this->field_value( $key, $default, $data );
|
4220 |
+
|
4221 |
+
if ( ! in_array( $type, $fields_without_metakey ) && ( ! isset( $_field_value ) || $_field_value == '' ) ) {
|
4222 |
+
$output = '';
|
4223 |
+
} else {
|
4224 |
+
|
4225 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
4226 |
+
|
4227 |
+
if ( isset( $data['label'] ) || ! empty( $data['icon'] ) ) {
|
4228 |
+
|
4229 |
+
if ( ! isset( $data['label'] ) ) {
|
4230 |
+
$data['label'] = '';
|
4231 |
+
}
|
4232 |
+
|
4233 |
+
$output .= $this->field_label( $data['label'], $key, $data );
|
4234 |
+
}
|
4235 |
+
|
4236 |
+
$res = $this->field_value( $key, $default, $data );
|
4237 |
+
|
4238 |
+
if ( ! empty( $res ) ) {
|
4239 |
+
$res = stripslashes( $res );
|
4240 |
+
}
|
4241 |
+
if ( 'description' === $data['metakey'] ) {
|
4242 |
+
if ( UM()->options()->get( 'profile_show_html_bio' ) ) {
|
4243 |
+
$res = make_clickable( wpautop( wp_kses_post( $res ) ) );
|
4244 |
+
} else {
|
4245 |
+
$res = esc_html( $res );
|
4246 |
+
}
|
4247 |
+
|
4248 |
+
$res = nl2br( $res );
|
4249 |
+
}
|
4250 |
+
|
4251 |
+
$data['is_view_field'] = true;
|
4252 |
+
/**
|
4253 |
+
* UM hook
|
4254 |
+
*
|
4255 |
+
* @type filter
|
4256 |
+
* @title um_view_field
|
4257 |
+
* @description Change field HTML on view mode
|
4258 |
+
* @input_vars
|
4259 |
+
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
4260 |
+
* {"var":"$data","type":"string","desc":"Field Data"},
|
4261 |
+
* {"var":"$type","type":"string","desc":"Field Type"}]
|
4262 |
+
* @change_log
|
4263 |
+
* ["Since: 2.0"]
|
4264 |
+
* @usage add_filter( 'um_view_field', 'function_name', 10, 3 );
|
4265 |
+
* @example
|
4266 |
+
* <?php
|
4267 |
+
* add_filter( 'um_view_field', 'my_view_field', 10, 3 );
|
4268 |
+
* function my_form_edit_field( $output, $data, $type ) {
|
4269 |
+
* // your code here
|
4270 |
+
* return $output;
|
4271 |
+
* }
|
4272 |
+
* ?>
|
4273 |
+
*/
|
4274 |
+
$res = apply_filters( 'um_view_field', $res, $data, $type );
|
4275 |
+
/**
|
4276 |
+
* UM hook
|
4277 |
+
*
|
4278 |
+
* @type filter
|
4279 |
+
* @title um_view_field_value_{$type}
|
4280 |
+
* @description Change field HTML on view mode by field type
|
4281 |
+
* @input_vars
|
4282 |
+
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
4283 |
+
* {"var":"$data","type":"string","desc":"Field Data"}]
|
4284 |
+
* @change_log
|
4285 |
+
* ["Since: 2.0"]
|
4286 |
+
* @usage add_filter( 'um_view_field_value_{$type}', 'function_name', 10, 2 );
|
4287 |
+
* @example
|
4288 |
+
* <?php
|
4289 |
+
* add_filter( 'um_view_field_value_{$type}', 'my_view_field', 10, 2 );
|
4290 |
+
* function my_form_edit_field( $output, $data ) {
|
4291 |
+
* // your code here
|
4292 |
+
* return $output;
|
4293 |
+
* }
|
4294 |
+
* ?>
|
4295 |
+
*/
|
4296 |
+
$res = apply_filters( "um_view_field_value_{$type}", $res, $data );
|
4297 |
+
|
4298 |
+
$id_attr = '';
|
4299 |
+
if ( ! in_array( $type, $fields_without_metakey ) ) {
|
4300 |
+
$id_attr = ' id="' . esc_attr( $key . UM()->form()->form_suffix ) . '"';
|
4301 |
+
}
|
4302 |
+
|
4303 |
+
if ( empty( $res ) ) {
|
4304 |
+
$output = '';
|
4305 |
+
} else {
|
4306 |
+
$output .= '<div class="um-field-area">';
|
4307 |
+
$output .= '<div class="um-field-value"' . $id_attr . '>' . $res . '</div>';
|
4308 |
+
$output .= '</div>';
|
4309 |
+
|
4310 |
+
$output .= '</div>';
|
4311 |
+
}
|
4312 |
+
}
|
4313 |
+
|
4314 |
+
break;
|
4315 |
+
|
4316 |
+
/* HTML */
|
4317 |
+
case 'block':
|
4318 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '</div>';
|
4319 |
+
break;
|
4320 |
+
|
4321 |
+
/* Shortcode */
|
4322 |
+
case 'shortcode':
|
4323 |
+
|
4324 |
+
$content = str_replace( '{profile_id}', um_profile_id(), $content );
|
4325 |
+
if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
|
4326 |
+
$content = do_shortcode( $content );
|
4327 |
+
} else {
|
4328 |
+
$content = apply_shortcodes( $content );
|
4329 |
+
}
|
4330 |
+
|
4331 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '</div>';
|
4332 |
+
break;
|
4333 |
+
|
4334 |
+
/* Gap/Space */
|
4335 |
+
case 'spacing':
|
4336 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data, array( 'height' => $spacing ) ) . '></div>';
|
4337 |
+
break;
|
4338 |
+
|
4339 |
+
/* A line divider */
|
4340 |
+
case 'divider':
|
4341 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data, array( 'border-bottom' => $borderwidth . 'px ' . $borderstyle . ' ' . $bordercolor ) ) . '>';
|
4342 |
+
if ( $divider_text ) {
|
4343 |
+
$output .= '<div class="um-field-divider-text"><span>' . $divider_text . '</span></div>';
|
4344 |
+
}
|
4345 |
+
$output .= '</div>';
|
4346 |
+
break;
|
4347 |
+
|
4348 |
+
/* Rating */
|
4349 |
+
case 'rating':
|
4350 |
+
|
4351 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
4352 |
+
|
4353 |
+
if ( isset( $data['label'] ) || ! empty( $data['icon'] ) ) {
|
4354 |
+
$output .= $this->field_label( $label, $key, $data );
|
4355 |
+
}
|
4356 |
+
|
4357 |
+
ob_start(); ?>
|
4358 |
+
|
4359 |
+
<div class="um-field-area">
|
4360 |
+
<div class="um-field-value">
|
4361 |
+
<div class="um-rating-readonly um-raty" id="<?php echo esc_attr( $key ) ?>"
|
4362 |
+
data-key="<?php echo esc_attr( $key ) ?>" data-number="<?php echo esc_attr( $data['number'] ) ?>"
|
4363 |
+
data-score="<?php echo $this->field_value( $key, $default, $data ) ?>"></div>
|
4364 |
+
</div>
|
4365 |
+
</div>
|
4366 |
+
|
4367 |
+
<?php $output .= ob_get_clean();
|
4368 |
+
$output .= '</div>';
|
4369 |
+
|
4370 |
+
break;
|
4371 |
+
|
4372 |
+
}
|
4373 |
+
|
4374 |
+
// Custom filter for field output
|
4375 |
+
if ( isset( $this->set_mode ) ) {
|
4376 |
+
/**
|
4377 |
+
* UM hook
|
4378 |
+
*
|
4379 |
+
* @type filter
|
4380 |
+
* @title um_{$key}_form_show_field
|
4381 |
+
* @description Change field HTML by field $key
|
4382 |
+
* @input_vars
|
4383 |
+
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
4384 |
+
* {"var":"$mode","type":"string","desc":"Form Mode"}]
|
4385 |
+
* @change_log
|
4386 |
+
* ["Since: 2.0"]
|
4387 |
+
* @usage add_filter( 'um_{$key}_form_show_field', 'function_name', 10, 2 );
|
4388 |
+
* @example
|
4389 |
+
* <?php
|
4390 |
+
* add_filter( 'um_{$key}_form_show_field', 'my_form_show_field', 10, 2 );
|
4391 |
+
* function my_form_show_field( $output, $mode ) {
|
4392 |
+
* // your code here
|
4393 |
+
* return $output;
|
4394 |
+
* }
|
4395 |
+
* ?>
|
4396 |
+
*/
|
4397 |
+
$output = apply_filters( "um_{$key}_form_show_field", $output, $this->set_mode );
|
4398 |
+
/**
|
4399 |
+
* UM hook
|
4400 |
+
*
|
4401 |
+
* @type filter
|
4402 |
+
* @title um_{$type}_form_show_field
|
4403 |
+
* @description Change field HTML by field $type
|
4404 |
+
* @input_vars
|
4405 |
+
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
4406 |
+
* {"var":"$mode","type":"string","desc":"Form Mode"}]
|
4407 |
+
* @change_log
|
4408 |
+
* ["Since: 2.0"]
|
4409 |
+
* @usage add_filter( 'um_{$type}_form_show_field', 'function_name', 10, 2 );
|
4410 |
+
* @example
|
4411 |
+
* <?php
|
4412 |
+
* add_filter( 'um_{$type}_form_show_field', 'my_form_show_field', 10, 2 );
|
4413 |
+
* function my_form_show_field( $output, $mode ) {
|
4414 |
+
* // your code here
|
4415 |
+
* return $output;
|
4416 |
+
* }
|
4417 |
+
* ?>
|
4418 |
+
*/
|
4419 |
+
$output = apply_filters( "um_{$type}_form_show_field", $output, $this->set_mode );
|
4420 |
+
}
|
4421 |
+
|
4422 |
+
return $output;
|
4423 |
+
}
|
4424 |
+
|
4425 |
+
|
4426 |
+
/**
|
4427 |
+
* Filter field data
|
4428 |
+
*
|
4429 |
+
* @param array $data
|
4430 |
+
*
|
4431 |
+
* @return array
|
4432 |
+
*/
|
4433 |
+
function view_field_output( $data ) {
|
4434 |
+
/**
|
4435 |
+
* UM hook
|
4436 |
+
*
|
4437 |
+
* @type filter
|
4438 |
+
* @title um_view_field_output_{$type}
|
4439 |
+
* @description Change field data output by $type
|
4440 |
+
* @input_vars
|
4441 |
+
* [{"var":"$data","type":"array","desc":"Field Data"}]
|
4442 |
+
* @change_log
|
4443 |
+
* ["Since: 2.0"]
|
4444 |
+
* @usage add_filter( 'um_view_field_output_{$type}', 'function_name', 10, 1 );
|
4445 |
+
* @example
|
4446 |
+
* <?php
|
4447 |
+
* add_filter( 'um_view_field_output_{$type}', 'my_view_field_output', 10, 1 );
|
4448 |
+
* function my_view_field_output( $data ) {
|
4449 |
+
* // your code here
|
4450 |
+
* return $data;
|
4451 |
+
* }
|
4452 |
+
* ?>
|
4453 |
+
*/
|
4454 |
+
return apply_filters( "um_view_field_output_" . $data['type'], $data );
|
4455 |
+
}
|
4456 |
+
|
4457 |
+
|
4458 |
+
/**
|
4459 |
+
* Display fields ( view mode )
|
4460 |
+
*
|
4461 |
+
* @param string $mode
|
4462 |
+
* @param array $args
|
4463 |
+
*
|
4464 |
+
* @return string|null
|
4465 |
+
* @throws \Exception
|
4466 |
+
*/
|
4467 |
+
function display_view( $mode, $args ) {
|
4468 |
+
$output = null;
|
4469 |
+
|
4470 |
+
$this->global_args = $args;
|
4471 |
+
|
4472 |
+
UM()->form()->form_suffix = '-' . $this->global_args['form_id'];
|
4473 |
+
|
4474 |
+
$this->set_mode = $mode;
|
4475 |
+
$this->set_id = $this->global_args['form_id'];
|
4476 |
+
|
4477 |
+
$this->field_icons = ( isset( $this->global_args['icons'] ) ) ? $this->global_args['icons'] : 'label';
|
4478 |
+
|
4479 |
+
// start output here
|
4480 |
+
$this->get_fields = $this->get_fields();
|
4481 |
+
|
4482 |
+
if ( UM()->options()->get( 'profile_empty_text' ) ) {
|
4483 |
+
|
4484 |
+
$emo = UM()->options()->get( 'profile_empty_text_emo' );
|
4485 |
+
if ( $emo ) {
|
4486 |
+
$emo = '<i class="um-faicon-frown-o"></i>';
|
4487 |
+
} else {
|
4488 |
+
$emo = false;
|
4489 |
+
}
|
4490 |
+
|
4491 |
+
if ( um_is_myprofile() ) {
|
4492 |
+
if ( isset( $_GET['profiletab'] ) && 'main' !== $_GET['profiletab'] ) {
|
4493 |
+
$tab = sanitize_key( $_GET['profiletab'] );
|
4494 |
+
$edit_action = 'edit_' . $tab;
|
4495 |
+
$profile_url = um_user_profile_url( um_profile_id() );
|
4496 |
+
$edit_url = add_query_arg( array( 'profiletab' => $tab, 'um_action' => $edit_action ), $profile_url );
|
4497 |
+
} else {
|
4498 |
+
$edit_url = um_edit_profile_url();
|
4499 |
+
}
|
4500 |
+
$output .= '<p class="um-profile-note">' . $emo . '<span>' . sprintf( __( 'Your profile is looking a little empty. Why not <a href="%s">add</a> some information!', 'ultimate-member' ), esc_url( $edit_url ) ) . '</span></p>';
|
4501 |
+
} else {
|
4502 |
+
$output .= '<p class="um-profile-note">' . $emo . '<span>' . __( 'This user has not added any information to their profile yet.', 'ultimate-member' ) . '</span></p>';
|
4503 |
+
}
|
4504 |
+
}
|
4505 |
+
|
4506 |
+
if ( ! empty( $this->get_fields ) ) {
|
4507 |
+
|
4508 |
+
// find rows
|
4509 |
+
foreach ( $this->get_fields as $key => $array ) {
|
4510 |
+
if ( $array['type'] == 'row' ) {
|
4511 |
+
$this->rows[ $key ] = $array;
|
4512 |
+
unset( $this->get_fields[ $key ] ); // not needed anymore
|
4513 |
+
}
|
4514 |
+
}
|
4515 |
+
|
4516 |
+
// rows fallback
|
4517 |
+
if ( ! isset( $this->rows ) ) {
|
4518 |
+
$this->rows = array(
|
4519 |
+
'_um_row_1' => array(
|
4520 |
+
'type' => 'row',
|
4521 |
+
'id' => '_um_row_1',
|
4522 |
+
'sub_rows' => 1,
|
4523 |
+
'cols' => 1,
|
4524 |
+
),
|
4525 |
+
);
|
4526 |
+
}
|
4527 |
+
|
4528 |
+
// master rows
|
4529 |
+
foreach ( $this->rows as $row_id => $row_array ) {
|
4530 |
+
|
4531 |
+
$row_fields = $this->get_fields_by_row( $row_id );
|
4532 |
+
|
4533 |
+
if ( $row_fields ) {
|
4534 |
+
|
4535 |
+
$output .= $this->new_row_output( $row_id, $row_array );
|
4536 |
+
|
4537 |
+
$sub_rows = ( isset( $row_array['sub_rows'] ) ) ? $row_array['sub_rows'] : 1;
|
4538 |
+
for ( $c = 0; $c < $sub_rows; $c++ ) {
|
4539 |
+
|
4540 |
+
// cols
|
4541 |
+
$cols = isset( $row_array['cols'] ) ? $row_array['cols'] : 1;
|
4542 |
+
if ( is_numeric( $cols ) ) {
|
4543 |
+
$cols_num = (int) $cols;
|
4544 |
+
} else {
|
4545 |
+
if ( strstr( $cols, ':' ) ) {
|
4546 |
+
$col_split = explode( ':', $cols );
|
4547 |
+
} else {
|
4548 |
+
$col_split = array( $cols );
|
4549 |
+
}
|
4550 |
+
$cols_num = $col_split[ $c ];
|
4551 |
+
}
|
4552 |
+
|
4553 |
+
// sub row fields
|
4554 |
+
$subrow_fields = null;
|
4555 |
+
$subrow_fields = $this->get_fields_in_subrow( $row_fields, $c );
|
4556 |
+
|
4557 |
+
if ( is_array( $subrow_fields ) ) {
|
4558 |
+
|
4559 |
+
$subrow_fields = $this->array_sort_by_column( $subrow_fields, 'position' );
|
4560 |
+
|
4561 |
+
if ( $cols_num == 1 ) {
|
4562 |
+
|
4563 |
+
$output .= '<div class="um-col-1">';
|
4564 |
+
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4565 |
+
if ( $col1_fields ) {
|
4566 |
+
foreach ( $col1_fields as $key => $data ) {
|
4567 |
+
|
4568 |
+
$data = $this->view_field_output( $data );
|
4569 |
+
$output .= $this->view_field( $key, $data );
|
4570 |
+
|
4571 |
+
}
|
4572 |
+
}
|
4573 |
+
$output .= '</div>';
|
4574 |
+
|
4575 |
+
} elseif ( $cols_num == 2 ) {
|
4576 |
+
|
4577 |
+
$output .= '<div class="um-col-121">';
|
4578 |
+
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4579 |
+
if ( $col1_fields ) {
|
4580 |
+
foreach ( $col1_fields as $key => $data ) {
|
4581 |
+
|
4582 |
+
$data = $this->view_field_output( $data );
|
4583 |
+
$output .= $this->view_field( $key, $data );
|
4584 |
+
|
4585 |
+
}
|
4586 |
+
}
|
4587 |
+
$output .= '</div>';
|
4588 |
+
|
4589 |
+
$output .= '<div class="um-col-122">';
|
4590 |
+
$col2_fields = $this->get_fields_in_column( $subrow_fields, 2 );
|
4591 |
+
if ( $col2_fields ) {
|
4592 |
+
foreach ( $col2_fields as $key => $data ) {
|
4593 |
+
|
4594 |
+
$data = $this->view_field_output( $data );
|
4595 |
+
$output .= $this->view_field( $key, $data );
|
4596 |
+
|
4597 |
+
}
|
4598 |
+
}
|
4599 |
+
$output .= '</div><div class="um-clear"></div>';
|
4600 |
+
|
4601 |
+
} else {
|
4602 |
+
|
4603 |
+
$output .= '<div class="um-col-131">';
|
4604 |
+
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4605 |
+
if ( $col1_fields ) {
|
4606 |
+
foreach ( $col1_fields as $key => $data ) {
|
4607 |
+
|
4608 |
+
$data = $this->view_field_output( $data );
|
4609 |
+
$output .= $this->view_field( $key, $data );
|
4610 |
+
|
4611 |
+
}
|
4612 |
+
}
|
4613 |
+
$output .= '</div>';
|
4614 |
+
|
4615 |
+
$output .= '<div class="um-col-132">';
|
4616 |
+
$col2_fields = $this->get_fields_in_column( $subrow_fields, 2 );
|
4617 |
+
if ( $col2_fields ) {
|
4618 |
+
foreach ( $col2_fields as $key => $data ) {
|
4619 |
+
|
4620 |
+
$data = $this->view_field_output( $data );
|
4621 |
+
$output .= $this->view_field( $key, $data );
|
4622 |
+
|
4623 |
+
}
|
4624 |
+
}
|
4625 |
+
$output .= '</div>';
|
4626 |
+
|
4627 |
+
$output .= '<div class="um-col-133">';
|
4628 |
+
$col3_fields = $this->get_fields_in_column( $subrow_fields, 3 );
|
4629 |
+
if ( $col3_fields ) {
|
4630 |
+
foreach ( $col3_fields as $key => $data ) {
|
4631 |
+
|
4632 |
+
$data = $this->view_field_output( $data );
|
4633 |
+
$output .= $this->view_field( $key, $data );
|
4634 |
+
|
4635 |
+
}
|
4636 |
+
}
|
4637 |
+
$output .= '</div><div class="um-clear"></div>';
|
4638 |
+
|
4639 |
+
}
|
4640 |
+
|
4641 |
+
}
|
4642 |
+
|
4643 |
+
}
|
4644 |
+
|
4645 |
+
$output .= '</div>';
|
4646 |
+
|
4647 |
+
}
|
4648 |
+
|
4649 |
+
}
|
4650 |
+
|
4651 |
+
}
|
4652 |
+
|
4653 |
+
return $output;
|
4654 |
+
}
|
4655 |
+
|
4656 |
+
|
4657 |
+
/**
|
4658 |
+
* Get new row in form
|
4659 |
+
*
|
4660 |
+
* @param string $row_id
|
4661 |
+
* @param array $row_array
|
4662 |
+
*
|
4663 |
+
* @return string
|
4664 |
+
*/
|
4665 |
+
function new_row_output( $row_id, $row_array ) {
|
4666 |
+
$output = null;
|
4667 |
+
extract( $row_array );
|
4668 |
+
|
4669 |
+
$padding = ( isset( $padding ) ) ? $padding : '';
|
4670 |
+
$margin = ( isset( $margin ) ) ? $margin : '';
|
4671 |
+
$background = ( isset( $background ) ) ? $background : '';
|
4672 |
+
$text_color = ( isset( $text_color ) ) ? $text_color : '';
|
4673 |
+
$borderradius = ( isset( $borderradius ) ) ? $borderradius : '';
|
4674 |
+
$border = ( isset( $border ) ) ? $border : '';
|
4675 |
+
$bordercolor = ( isset( $bordercolor ) ) ? $bordercolor : '';
|
4676 |
+
$borderstyle = ( isset( $borderstyle ) ) ? $borderstyle : '';
|
4677 |
+
$heading = ( isset( $heading ) ) ? $heading : '';
|
4678 |
+
$css_class = ( isset( $css_class ) ) ? $css_class : '';
|
4679 |
+
|
4680 |
+
$css_padding = '';
|
4681 |
+
$css_margin = '';
|
4682 |
+
$css_background = '';
|
4683 |
+
$css_borderradius = '';
|
4684 |
+
$css_border = '';
|
4685 |
+
$css_bordercolor = '';
|
4686 |
+
$css_borderstyle = '';
|
4687 |
+
$css_heading_background_color = '';
|
4688 |
+
$css_heading_padding = '';
|
4689 |
+
$css_heading_text_color = '';
|
4690 |
+
$css_heading_borderradius = '';
|
4691 |
+
$css_text_color = '';
|
4692 |
+
|
4693 |
+
// row css rules
|
4694 |
+
if ( $padding ) {
|
4695 |
+
$css_padding = 'padding: ' . $padding . ';';
|
4696 |
+
}
|
4697 |
+
if ( $margin ) {
|
4698 |
+
$css_margin = 'margin: ' . $margin . ';';
|
4699 |
+
} else {
|
4700 |
+
$css_margin = 'margin: 0 0 30px 0;';
|
4701 |
+
}
|
4702 |
+
|
4703 |
+
if ( $background ) {
|
4704 |
+
$css_background = 'background-color: ' . $background . ';';
|
4705 |
+
}
|
4706 |
+
if ( $borderradius ) {
|
4707 |
+
$css_borderradius = 'border-radius: 0px 0px ' . $borderradius . ' ' . $borderradius . ';';
|
4708 |
+
}
|
4709 |
+
if ( $border ) {
|
4710 |
+
$css_border = 'border-width: ' . $border . ';';
|
4711 |
+
}
|
4712 |
+
if ( $bordercolor ) {
|
4713 |
+
$css_bordercolor = 'border-color: ' . $bordercolor . ';';
|
4714 |
+
}
|
4715 |
+
if ( $borderstyle ) {
|
4716 |
+
$css_borderstyle = 'border-style: ' . $borderstyle . ';';
|
4717 |
+
}
|
4718 |
+
if ( $text_color ) {
|
4719 |
+
$css_text_color = 'color: ' . $text_color . ' !important;';
|
4720 |
+
$css_class .= ' um-customized-row';
|
4721 |
+
}
|
4722 |
+
|
4723 |
+
// show the heading
|
4724 |
+
if ( $heading ) {
|
4725 |
+
|
4726 |
+
if ( ! empty( $heading_background_color ) ) {
|
4727 |
+
$css_heading_background_color = "background-color: $heading_background_color;";
|
4728 |
+
$css_heading_padding = 'padding: 10px 15px;';
|
4729 |
+
}
|
4730 |
+
|
4731 |
+
$css_heading_borderradius = empty( $borderradius ) ? '' : "border-radius: $borderradius $borderradius 0px 0px;";
|
4732 |
+
$css_heading_border = $css_border . $css_borderstyle . $css_bordercolor . $css_heading_borderradius . 'border-bottom-width: 0px;';
|
4733 |
+
$css_heading_margin = $css_margin . 'margin-bottom: 0px;';
|
4734 |
+
$css_heading_text_color = empty( $heading_text_color ) ? '' : "color: $heading_text_color;";
|
4735 |
+
$css_icon_color = empty( $icon_color ) ? '' : "color: $icon_color;";
|
4736 |
+
|
4737 |
+
$output .= '<div class="um-row-heading" style="' . $css_heading_margin . $css_heading_padding . $css_heading_border . $css_heading_background_color . $css_heading_text_color . '">';
|
4738 |
+
|
4739 |
+
if ( ! empty( $icon ) ) {
|
4740 |
+
$output .= '<span class="um-row-heading-icon" style="' . $css_icon_color . '"><i class="' . $icon . '"></i></span>';
|
4741 |
+
}
|
4742 |
+
if ( ! empty( $heading_text ) ) {
|
4743 |
+
$output .= htmlspecialchars( $heading_text );
|
4744 |
+
}
|
4745 |
+
|
4746 |
+
$output .= '</div>';
|
4747 |
+
|
4748 |
+
$css_border .= 'border-top-width: 0px;';
|
4749 |
+
$css_margin .= 'margin-top: 0px;';
|
4750 |
+
|
4751 |
+
} else {
|
4752 |
+
|
4753 |
+
// no heading
|
4754 |
+
$css_borderradius = empty( $borderradius ) ? '' : "border-radius: $borderradius;";
|
4755 |
+
|
4756 |
+
}
|
4757 |
+
|
4758 |
+
$output .= '<div class="um-row ' . $row_id . ' ' . $css_class . '" style="' . $css_padding . $css_background . $css_margin . $css_border . $css_borderstyle . $css_bordercolor . $css_borderradius . $css_text_color . '">';
|
4759 |
+
|
4760 |
+
return $output;
|
4761 |
+
}
|
4762 |
+
|
4763 |
+
|
4764 |
+
/**
|
4765 |
+
*
|
4766 |
+
*/
|
4767 |
+
function do_ajax_action() {
|
4768 |
+
UM()->admin()->check_ajax_nonce();
|
4769 |
+
|
4770 |
+
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
|
4771 |
+
wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
|
4772 |
+
}
|
4773 |
+
|
4774 |
+
/**
|
4775 |
+
* @var $in_row
|
4776 |
+
* @var $in_sub_row
|
4777 |
+
* @var $in_column
|
4778 |
+
* @var $in_group
|
4779 |
+
* @var $act_id
|
4780 |
+
* @var $arg1
|
4781 |
+
* @var $arg2
|
4782 |
+
*/
|
4783 |
+
extract( $_POST );
|
4784 |
+
|
4785 |
+
$output = null;
|
4786 |
+
|
4787 |
+
$position = array();
|
4788 |
+
if ( ! empty( $in_column ) ) {
|
4789 |
+
$position['in_row'] = '_um_row_' . ( (int) $in_row + 1 );
|
4790 |
+
$position['in_sub_row'] = $in_sub_row;
|
4791 |
+
$position['in_column'] = $in_column;
|
4792 |
+
$position['in_group'] = $in_group;
|
4793 |
+
}
|
4794 |
+
|
4795 |
+
switch ( $act_id ) {
|
4796 |
+
|
4797 |
+
case 'um_admin_duplicate_field':
|
4798 |
+
$this->duplicate_field( $arg1, $arg2 );
|
4799 |
+
break;
|
4800 |
+
|
4801 |
+
case 'um_admin_remove_field_global':
|
4802 |
+
$this->delete_field_from_db( $arg1 );
|
4803 |
+
break;
|
4804 |
+
|
4805 |
+
case 'um_admin_remove_field':
|
4806 |
+
$this->delete_field_from_form( $arg1, $arg2 );
|
4807 |
+
break;
|
4808 |
+
|
4809 |
+
case 'um_admin_add_field_from_predefined':
|
4810 |
+
$this->add_field_from_predefined( $arg1, $arg2, $position );
|
4811 |
+
break;
|
4812 |
+
|
4813 |
+
case 'um_admin_add_field_from_list':
|
4814 |
+
$this->add_field_from_list( $arg1, $arg2, $position );
|
4815 |
+
break;
|
4816 |
+
|
4817 |
+
}
|
4818 |
+
|
4819 |
+
if ( is_array( $output ) ) {
|
4820 |
+
print_r( $output );
|
4821 |
+
} else {
|
4822 |
+
echo $output;
|
4823 |
+
}
|
4824 |
+
die;
|
4825 |
+
|
4826 |
+
}
|
4827 |
+
|
4828 |
+
|
4829 |
+
|
4830 |
+
/**
|
4831 |
+
* Get rendered field attributes
|
4832 |
+
*
|
4833 |
+
* @since 2.1.2
|
4834 |
+
*
|
4835 |
+
* @param string $key
|
4836 |
+
* @param array $classes
|
4837 |
+
* @param string $conditional
|
4838 |
+
* @param array $data
|
4839 |
+
* @param array $field_style
|
4840 |
+
*
|
4841 |
+
* @return string/html
|
4842 |
+
*/
|
4843 |
+
function get_atts( $key, $classes, $conditional, $data, $field_style = array() ) {
|
4844 |
+
|
4845 |
+
array_unshift( $classes, 'um-field-' . $data['type'] );
|
4846 |
+
array_unshift( $classes, 'um-field' );
|
4847 |
+
|
4848 |
+
$field_atts = array(
|
4849 |
+
'id' => array(
|
4850 |
+
"um_field_{$this->set_id}_{$key}",
|
4851 |
+
),
|
4852 |
+
'class' => $classes,
|
4853 |
+
'data-key' => array(
|
4854 |
+
esc_attr( $key )
|
4855 |
+
)
|
4856 |
+
);
|
4857 |
+
|
4858 |
+
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
4859 |
+
|
4860 |
+
if ( in_array( $data['type'], $fields_without_metakey ) ) {
|
4861 |
+
unset( $field_atts['id'] );
|
4862 |
+
|
4863 |
+
if ( empty( $field_atts['data-key'] ) ) {
|
4864 |
+
unset( $field_atts['data-key'] );
|
4865 |
+
}
|
4866 |
+
}
|
4867 |
+
|
4868 |
+
if ( ! empty( $field_style ) && is_array( $field_style ) ) {
|
4869 |
+
|
4870 |
+
$arr_inline_style = '';
|
4871 |
+
foreach ( $field_style as $style_attr => $style_value ) {
|
4872 |
+
$arr_inline_style .= esc_attr( $style_attr ) . ':' . esc_attr( $style_value ) . ';';
|
4873 |
+
}
|
4874 |
+
$field_atts['style'] = array( $arr_inline_style );
|
4875 |
+
}
|
4876 |
+
|
4877 |
+
/**
|
4878 |
+
* UM hook
|
4879 |
+
*
|
4880 |
+
* @type filter
|
4881 |
+
* @title um_field_extra_atts
|
4882 |
+
* @description user for adding extra field attributes
|
4883 |
+
* @input_vars
|
4884 |
+
* [{"var":"$field_atts","type":"array","desc":"Field attributes"},
|
4885 |
+
* [{"var":"$key","type":"string","desc":"Field id"},
|
4886 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
4887 |
+
* @change_log
|
4888 |
+
* ["Since: 2.0.57"]
|
4889 |
+
* @usage add_filter( 'um_field_extra_atts', 'function_name', 10, 3 );
|
4890 |
+
* @example
|
4891 |
+
* <?php
|
4892 |
+
* add_filter( 'um_field_extra_atts', 'function_name', 10, 3 );
|
4893 |
+
* function function_name( $field_atts, $key, $data ) {
|
4894 |
+
* // your code here
|
4895 |
+
* return $array_extra_atts;
|
4896 |
+
* }
|
4897 |
+
* ?>
|
4898 |
+
*/
|
4899 |
+
$field_atts = apply_filters( 'um_field_extra_atts', $field_atts, $key, $data );
|
4900 |
+
|
4901 |
+
$html_atts = '';
|
4902 |
+
foreach ( $field_atts as $att_name => $att_values ) {
|
4903 |
+
$att_values = implode( " ", $att_values );
|
4904 |
+
$html_atts .= " {$att_name}=\"" . esc_attr( $att_values ) . "\"";
|
4905 |
+
}
|
4906 |
+
|
4907 |
+
$html_atts .= $conditional;
|
4908 |
+
|
4909 |
+
return $html_atts;
|
4910 |
+
}
|
4911 |
+
}
|
4912 |
+
}
|
includes/core/class-member-directory-meta.php
CHANGED
@@ -1,898 +1,907 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\core;
|
3 |
-
|
4 |
-
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
|
8 |
-
if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Member_Directory_Meta
|
13 |
-
* @package um\core
|
14 |
-
*/
|
15 |
-
class Member_Directory_Meta extends Member_Directory {
|
16 |
-
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @var string
|
20 |
-
*/
|
21 |
-
var $joins = array();
|
22 |
-
var $where_clauses = array();
|
23 |
-
|
24 |
-
var $roles = array();
|
25 |
-
var $roles_in_query = false;
|
26 |
-
|
27 |
-
var $general_meta_joined = false;
|
28 |
-
|
29 |
-
var $having = '';
|
30 |
-
var $select = '';
|
31 |
-
var $sql_limit = '';
|
32 |
-
var $sql_order = '';
|
33 |
-
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Member_Directory_Meta constructor.
|
37 |
-
*/
|
38 |
-
function __construct() {
|
39 |
-
parent::__construct();
|
40 |
-
|
41 |
-
add_action( 'updated_user_meta', array( &$this, 'on_update_usermeta' ), 10, 4 );
|
42 |
-
add_action( 'added_user_meta', array( &$this, 'on_update_usermeta' ), 10, 4 );
|
43 |
-
add_action( 'deleted_user_meta', array( &$this, 'on_delete_usermeta' ), 10, 4 );
|
44 |
-
|
45 |
-
add_action( 'um_add_new_field', array( &$this, 'on_new_field_added' ), 10, 2 );
|
46 |
-
add_action( 'um_delete_custom_field', array( &$this, 'on_delete_custom_field' ), 10, 2 );
|
47 |
-
}
|
48 |
-
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Delete custom field and metakey from UM usermeta table
|
52 |
-
*
|
53 |
-
* @param $metakey
|
54 |
-
* @param $args
|
55 |
-
*/
|
56 |
-
function on_delete_custom_field( $metakey, $args ) {
|
57 |
-
$metakeys = get_option( 'um_usermeta_fields', array() );
|
58 |
-
|
59 |
-
if ( in_array( $metakey, $metakeys ) ) {
|
60 |
-
unset( $metakeys[ array_search( $metakey, $metakeys ) ] );
|
61 |
-
|
62 |
-
global $wpdb;
|
63 |
-
|
64 |
-
$wpdb->delete(
|
65 |
-
"{$wpdb->prefix}um_metadata",
|
66 |
-
array(
|
67 |
-
'um_key' => $metakey
|
68 |
-
),
|
69 |
-
array(
|
70 |
-
'%s'
|
71 |
-
)
|
72 |
-
);
|
73 |
-
|
74 |
-
update_option( 'um_usermeta_fields', array_values( $metakeys ) );
|
75 |
-
}
|
76 |
-
|
77 |
-
do_action( 'um_metadata_on_delete_custom_field', $metakeys, $metakey, $args );
|
78 |
-
}
|
79 |
-
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Add metakey to usermeta fields
|
83 |
-
*
|
84 |
-
* @param $metakey
|
85 |
-
* @param $args
|
86 |
-
*/
|
87 |
-
function on_new_field_added( $metakey, $args ) {
|
88 |
-
$metakeys = get_option( 'um_usermeta_fields', array() );
|
89 |
-
|
90 |
-
if ( ! in_array( $metakey, $metakeys ) ) {
|
91 |
-
$metakeys[] = $metakey;
|
92 |
-
update_option( 'um_usermeta_fields', array_values( $metakeys ) );
|
93 |
-
}
|
94 |
-
|
95 |
-
do_action( 'um_metadata_on_new_field_added', $metakeys, $metakey, $args );
|
96 |
-
}
|
97 |
-
|
98 |
-
|
99 |
-
/**
|
100 |
-
* When you delete usermeta - remove row from um_metadata
|
101 |
-
*
|
102 |
-
* @param int|array $meta_ids
|
103 |
-
* @param int $object_id
|
104 |
-
* @param string $meta_key
|
105 |
-
* @param mixed $_meta_value
|
106 |
-
*/
|
107 |
-
function on_delete_usermeta( $meta_ids, $object_id, $meta_key, $_meta_value ) {
|
108 |
-
$metakeys = get_option( 'um_usermeta_fields', array() );
|
109 |
-
if ( ! in_array( $meta_key, $metakeys ) ) {
|
110 |
-
return;
|
111 |
-
}
|
112 |
-
|
113 |
-
global $wpdb;
|
114 |
-
|
115 |
-
$wpdb->delete(
|
116 |
-
"{$wpdb->prefix}um_metadata",
|
117 |
-
array(
|
118 |
-
'user_id' => $object_id,
|
119 |
-
'um_key' => $meta_key
|
120 |
-
),
|
121 |
-
array(
|
122 |
-
'%d',
|
123 |
-
'%s'
|
124 |
-
)
|
125 |
-
);
|
126 |
-
}
|
127 |
-
|
128 |
-
|
129 |
-
/**
|
130 |
-
* When you add/update usermeta - add/update row from um_metadata
|
131 |
-
*
|
132 |
-
* @param int $meta_id
|
133 |
-
* @param int $object_id
|
134 |
-
* @param string $meta_key
|
135 |
-
* @param mixed $_meta_value
|
136 |
-
*/
|
137 |
-
function on_update_usermeta( $meta_id, $object_id, $meta_key, $_meta_value ) {
|
138 |
-
|
139 |
-
$metakeys = get_option( 'um_usermeta_fields', array() );
|
140 |
-
if ( ! in_array( $meta_key, $metakeys ) ) {
|
141 |
-
return;
|
142 |
-
}
|
143 |
-
|
144 |
-
global $wpdb;
|
145 |
-
|
146 |
-
$result = $wpdb->get_var( $wpdb->prepare(
|
147 |
-
"SELECT umeta_id
|
148 |
-
FROM {$wpdb->prefix}um_metadata
|
149 |
-
WHERE user_id = %d AND
|
150 |
-
um_key = %s
|
151 |
-
LIMIT 1",
|
152 |
-
$object_id,
|
153 |
-
$meta_key
|
154 |
-
) );
|
155 |
-
|
156 |
-
if ( empty( $result ) ) {
|
157 |
-
$wpdb->insert(
|
158 |
-
"{$wpdb->prefix}um_metadata",
|
159 |
-
array(
|
160 |
-
'user_id' => $object_id,
|
161 |
-
'um_key' => $meta_key,
|
162 |
-
'um_value' => maybe_serialize( $_meta_value ),
|
163 |
-
),
|
164 |
-
array(
|
165 |
-
'%d',
|
166 |
-
'%s',
|
167 |
-
'%s',
|
168 |
-
)
|
169 |
-
);
|
170 |
-
} else {
|
171 |
-
$wpdb->update(
|
172 |
-
"{$wpdb->prefix}um_metadata",
|
173 |
-
array(
|
174 |
-
'um_value' => maybe_serialize( $_meta_value ),
|
175 |
-
),
|
176 |
-
array(
|
177 |
-
'umeta_id' => $result,
|
178 |
-
),
|
179 |
-
array(
|
180 |
-
'%s',
|
181 |
-
),
|
182 |
-
array(
|
183 |
-
'%d',
|
184 |
-
)
|
185 |
-
);
|
186 |
-
}
|
187 |
-
}
|
188 |
-
|
189 |
-
|
190 |
-
/**
|
191 |
-
* @param $directory_data
|
192 |
-
* @param $field
|
193 |
-
* @param $value
|
194 |
-
* @param $i
|
195 |
-
* @param bool $is_default
|
196 |
-
*/
|
197 |
-
function handle_filter_query( $directory_data, $field, $value, $i, $is_default = false ) {
|
198 |
-
global $wpdb;
|
199 |
-
|
200 |
-
$join_slug = $is_default ? 'ummd' : 'umm' ;
|
201 |
-
|
202 |
-
$blog_id = get_current_blog_id();
|
203 |
-
|
204 |
-
switch ( $field ) {
|
205 |
-
default:
|
206 |
-
|
207 |
-
$filter_type = $this->filter_types[ $field ];
|
208 |
-
|
209 |
-
/**
|
210 |
-
* UM hook
|
211 |
-
*
|
212 |
-
* @type filter
|
213 |
-
* @title um_query_args_{$field}__filter
|
214 |
-
* @description Change field's query for search at Members Directory
|
215 |
-
* @input_vars
|
216 |
-
* [{"var":"$field_query","type":"array","desc":"Field query"}]
|
217 |
-
* @change_log
|
218 |
-
* ["Since: 2.0"]
|
219 |
-
* @usage
|
220 |
-
* <?php add_filter( 'um_query_args_{$field}__filter_meta', 'function_name', 10, 4 ); ?>
|
221 |
-
* @example
|
222 |
-
* <?php
|
223 |
-
* add_filter( 'um_query_args_{$field}__filter_meta', 'my_query_args_filter', 10, 4 );
|
224 |
-
* function my_query_args_filter( $field_query ) {
|
225 |
-
* // your code here
|
226 |
-
* return $field_query;
|
227 |
-
* }
|
228 |
-
* ?>
|
229 |
-
*/
|
230 |
-
$skip_default = apply_filters( "um_query_args_{$field}__filter_meta", false, $this, $field, $value, $filter_type, $is_default );
|
231 |
-
|
232 |
-
$skip_default = apply_filters( 'um_query_args_filter_global_meta', $skip_default, $this, $field, $value, $filter_type, $is_default );
|
233 |
-
|
234 |
-
if ( ! $skip_default ) {
|
235 |
-
|
236 |
-
switch ( $filter_type ) {
|
237 |
-
default:
|
238 |
-
|
239 |
-
do_action( "um_query_args_{$field}_{$filter_type}__filter_meta", $field, $value, $filter_type, $i, $is_default );
|
240 |
-
break;
|
241 |
-
|
242 |
-
case 'text':
|
243 |
-
|
244 |
-
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
|
245 |
-
|
246 |
-
$value = trim( stripslashes( $value ) );
|
247 |
-
|
248 |
-
$compare = apply_filters( 'um_members_directory_filter_text', '=', $field );
|
249 |
-
$value = apply_filters( 'um_members_directory_filter_text_meta_value', $value, $field );
|
250 |
-
|
251 |
-
$this->where_clauses[] = $wpdb->prepare( "{$join_slug}{$i}.um_key = %s AND {$join_slug}{$i}.um_value {$compare} %s", $field, $value );
|
252 |
-
|
253 |
-
if ( ! $is_default ) {
|
254 |
-
$this->custom_filters_in_query[ $field ] = $value;
|
255 |
-
}
|
256 |
-
|
257 |
-
break;
|
258 |
-
|
259 |
-
case 'select':
|
260 |
-
if ( ! is_array( $value ) ) {
|
261 |
-
$value = array( $value );
|
262 |
-
}
|
263 |
-
|
264 |
-
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
|
265 |
-
|
266 |
-
$values_array = array();
|
267 |
-
foreach ( $value as $single_val ) {
|
268 |
-
$single_val = trim( stripslashes( $single_val ) );
|
269 |
-
|
270 |
-
$values_array[] = $wpdb->prepare( "{$join_slug}{$i}.um_value LIKE %s", '%"' . $single_val . '"%' );
|
271 |
-
$values_array[] = $wpdb->prepare( "{$join_slug}{$i}.um_value LIKE %s", '%' . serialize( (string) $single_val ) . '%' );
|
272 |
-
$values_array[] = $wpdb->prepare( "{$join_slug}{$i}.um_value = %s", $single_val );
|
273 |
-
|
274 |
-
if ( is_numeric( $single_val ) ) {
|
275 |
-
$values_array[] = $wpdb->prepare( "{$join_slug}{$i}.um_value LIKE %s", '%' . serialize( (int) $single_val ) . '%' );
|
276 |
-
}
|
277 |
-
}
|
278 |
-
|
279 |
-
$values = implode( ' OR ', $values_array );
|
280 |
-
|
281 |
-
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = %s AND ( {$values} ) )", $field );
|
282 |
-
|
283 |
-
if ( ! $is_default ) {
|
284 |
-
$this->custom_filters_in_query[ $field ] = $value;
|
285 |
-
}
|
286 |
-
|
287 |
-
break;
|
288 |
-
case 'slider':
|
289 |
-
|
290 |
-
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
|
291 |
-
|
292 |
-
$min = min( $value );
|
293 |
-
$max = max( $value );
|
294 |
-
|
295 |
-
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = %s AND {$join_slug}{$i}.um_value BETWEEN %d AND %d )", $field, $min, $max );
|
296 |
-
|
297 |
-
if ( ! $is_default ) {
|
298 |
-
$this->custom_filters_in_query[ $field ] = $value;
|
299 |
-
}
|
300 |
-
|
301 |
-
break;
|
302 |
-
case 'datepicker':
|
303 |
-
|
304 |
-
$offset = 0;
|
305 |
-
if ( ! $is_default ) {
|
306 |
-
if ( isset( $_POST['gmt_offset'] ) && is_numeric( $_POST['gmt_offset'] ) ) {
|
307 |
-
$offset = (int) $_POST['gmt_offset'];
|
308 |
-
}
|
309 |
-
} else {
|
310 |
-
$gmt_offset = get_post_meta( $directory_data['form_id'], '_um_search_filters_gmt', true );
|
311 |
-
if ( is_numeric( $gmt_offset ) ) {
|
312 |
-
$offset = $gmt_offset;
|
313 |
-
}
|
314 |
-
}
|
315 |
-
|
316 |
-
$from_date = (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ); // client time zone offset
|
317 |
-
$to_date = (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1; // time 23:59
|
318 |
-
$from_date = date( 'Y/m/d', $from_date );
|
319 |
-
$to_date = date( 'Y/m/d', $to_date );
|
320 |
-
|
321 |
-
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
|
322 |
-
|
323 |
-
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = %s AND {$join_slug}{$i}.um_value BETWEEN %s AND %s )", $field, $from_date, $to_date );
|
324 |
-
|
325 |
-
if ( ! $is_default ) {
|
326 |
-
$this->custom_filters_in_query[ $field ] = array( $from_date, $to_date );
|
327 |
-
}
|
328 |
-
|
329 |
-
break;
|
330 |
-
case 'timepicker':
|
331 |
-
|
332 |
-
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
|
333 |
-
if ( $value[0] == $value[1] ) {
|
334 |
-
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = %s AND {$join_slug}{$i}.um_value = %s )", $field, $value[0] );
|
335 |
-
} else {
|
336 |
-
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = %s AND CAST( {$join_slug}{$i}.um_value AS TIME ) BETWEEN %s AND %s )", $field, $value[0], $value[1] );
|
337 |
-
}
|
338 |
-
|
339 |
-
if ( ! $is_default ) {
|
340 |
-
$this->custom_filters_in_query[ $field ] = $value;
|
341 |
-
}
|
342 |
-
|
343 |
-
break;
|
344 |
-
}
|
345 |
-
|
346 |
-
}
|
347 |
-
|
348 |
-
break;
|
349 |
-
case 'role':
|
350 |
-
$value = array_map( 'strtolower', $value );
|
351 |
-
|
352 |
-
if ( empty( $this->roles ) && ! is_multisite() ) {
|
353 |
-
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_roles ON ( umm_roles.user_id = u.ID AND umm_roles.um_key = '" . $wpdb->get_blog_prefix( $blog_id ) . "capabilities' )";
|
354 |
-
$this->roles = $value;
|
355 |
-
|
356 |
-
$this->roles_in_query = true;
|
357 |
-
}
|
358 |
-
|
359 |
-
$roles_clauses = array();
|
360 |
-
foreach ( $value as $role ) {
|
361 |
-
$roles_clauses[] = $wpdb->prepare( "umm_roles.um_value LIKE %s", '%"' . $role . '"%' );
|
362 |
-
}
|
363 |
-
|
364 |
-
$this->where_clauses[] = '( ' . implode( ' OR ', $roles_clauses ) . ' )';
|
365 |
-
|
366 |
-
if ( ! $is_default ) {
|
367 |
-
$this->custom_filters_in_query[ $field ] = $value;
|
368 |
-
}
|
369 |
-
|
370 |
-
break;
|
371 |
-
case 'birth_date':
|
372 |
-
|
373 |
-
$from_date = date( 'Y/m/d', mktime( 0,0,0, date( 'm', time() ), date( 'd', time() ), date( 'Y', time() - min( $value ) * YEAR_IN_SECONDS ) ) );
|
374 |
-
$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 ) ) );
|
375 |
-
|
376 |
-
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
|
377 |
-
|
378 |
-
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = 'birth_date' AND {$join_slug}{$i}.um_value BETWEEN %s AND %s )", $to_date, $from_date );
|
379 |
-
|
380 |
-
if ( ! $is_default ) {
|
381 |
-
$this->custom_filters_in_query[ $field ] = array( $to_date, $from_date );
|
382 |
-
}
|
383 |
-
|
384 |
-
break;
|
385 |
-
case 'user_registered':
|
386 |
-
|
387 |
-
$offset = 0;
|
388 |
-
if ( ! $is_default ) {
|
389 |
-
if ( isset( $_POST['gmt_offset'] ) && is_numeric( $_POST['gmt_offset'] ) ) {
|
390 |
-
$offset = (int) $_POST['gmt_offset'];
|
391 |
-
}
|
392 |
-
} else {
|
393 |
-
$gmt_offset = get_post_meta( $directory_data['form_id'], '_um_search_filters_gmt', true );
|
394 |
-
if ( is_numeric( $gmt_offset ) ) {
|
395 |
-
$offset = (int) $gmt_offset;
|
396 |
-
}
|
397 |
-
}
|
398 |
-
|
399 |
-
$from_date = date( 'Y-m-d H:s:i', strtotime( min( $value ) ) + $offset * HOUR_IN_SECONDS ); // client time zone offset
|
400 |
-
$to_date = date( 'Y-m-d H:s:i', strtotime( max( $value ) ) + $offset * HOUR_IN_SECONDS + DAY_IN_SECONDS - 1 ); // time 23:59
|
401 |
-
|
402 |
-
$this->where_clauses[] = $wpdb->prepare( "u.user_registered BETWEEN %s AND %s", $from_date, $to_date );
|
403 |
-
|
404 |
-
if ( ! $is_default ) {
|
405 |
-
$this->custom_filters_in_query[ $field ] = $value;
|
406 |
-
}
|
407 |
-
|
408 |
-
break;
|
409 |
-
case 'last_login':
|
410 |
-
|
411 |
-
$offset = 0;
|
412 |
-
if ( ! $is_default ) {
|
413 |
-
if ( isset( $_POST['gmt_offset'] ) && is_numeric( $_POST['gmt_offset'] ) ) {
|
414 |
-
$offset = (int) $_POST['gmt_offset'];
|
415 |
-
}
|
416 |
-
} else {
|
417 |
-
$gmt_offset = get_post_meta( $directory_data['form_id'], '_um_search_filters_gmt', true );
|
418 |
-
if ( is_numeric( $gmt_offset ) ) {
|
419 |
-
$offset = $gmt_offset;
|
420 |
-
}
|
421 |
-
}
|
422 |
-
|
423 |
-
$from_date = (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ); // client time zone offset
|
424 |
-
$to_date = (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1; // time 23:59
|
425 |
-
|
426 |
-
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
|
427 |
-
|
428 |
-
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = '_um_last_login' AND {$join_slug}{$i}.um_value BETWEEN %s AND %s )", $from_date, $to_date );
|
429 |
-
|
430 |
-
if ( ! $is_default ) {
|
431 |
-
$this->custom_filters_in_query[ $field ] = $value;
|
432 |
-
}
|
433 |
-
|
434 |
-
break;
|
435 |
-
}
|
436 |
-
}
|
437 |
-
|
438 |
-
|
439 |
-
/**
|
440 |
-
* Main Query function for getting members via AJAX
|
441 |
-
*/
|
442 |
-
function ajax_get_members() {
|
443 |
-
UM()->check_ajax_nonce();
|
444 |
-
|
445 |
-
global $wpdb;
|
446 |
-
|
447 |
-
$blog_id = get_current_blog_id();
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
$this->
|
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 |
-
if (
|
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 |
-
|
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 |
-
$this->
|
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 |
-
if (
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace um\core;
|
3 |
+
|
4 |
+
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Member_Directory_Meta
|
13 |
+
* @package um\core
|
14 |
+
*/
|
15 |
+
class Member_Directory_Meta extends Member_Directory {
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
var $joins = array();
|
22 |
+
var $where_clauses = array();
|
23 |
+
|
24 |
+
var $roles = array();
|
25 |
+
var $roles_in_query = false;
|
26 |
+
|
27 |
+
var $general_meta_joined = false;
|
28 |
+
|
29 |
+
var $having = '';
|
30 |
+
var $select = '';
|
31 |
+
var $sql_limit = '';
|
32 |
+
var $sql_order = '';
|
33 |
+
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Member_Directory_Meta constructor.
|
37 |
+
*/
|
38 |
+
function __construct() {
|
39 |
+
parent::__construct();
|
40 |
+
|
41 |
+
add_action( 'updated_user_meta', array( &$this, 'on_update_usermeta' ), 10, 4 );
|
42 |
+
add_action( 'added_user_meta', array( &$this, 'on_update_usermeta' ), 10, 4 );
|
43 |
+
add_action( 'deleted_user_meta', array( &$this, 'on_delete_usermeta' ), 10, 4 );
|
44 |
+
|
45 |
+
add_action( 'um_add_new_field', array( &$this, 'on_new_field_added' ), 10, 2 );
|
46 |
+
add_action( 'um_delete_custom_field', array( &$this, 'on_delete_custom_field' ), 10, 2 );
|
47 |
+
}
|
48 |
+
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Delete custom field and metakey from UM usermeta table
|
52 |
+
*
|
53 |
+
* @param $metakey
|
54 |
+
* @param $args
|
55 |
+
*/
|
56 |
+
function on_delete_custom_field( $metakey, $args ) {
|
57 |
+
$metakeys = get_option( 'um_usermeta_fields', array() );
|
58 |
+
|
59 |
+
if ( in_array( $metakey, $metakeys ) ) {
|
60 |
+
unset( $metakeys[ array_search( $metakey, $metakeys ) ] );
|
61 |
+
|
62 |
+
global $wpdb;
|
63 |
+
|
64 |
+
$wpdb->delete(
|
65 |
+
"{$wpdb->prefix}um_metadata",
|
66 |
+
array(
|
67 |
+
'um_key' => $metakey
|
68 |
+
),
|
69 |
+
array(
|
70 |
+
'%s'
|
71 |
+
)
|
72 |
+
);
|
73 |
+
|
74 |
+
update_option( 'um_usermeta_fields', array_values( $metakeys ) );
|
75 |
+
}
|
76 |
+
|
77 |
+
do_action( 'um_metadata_on_delete_custom_field', $metakeys, $metakey, $args );
|
78 |
+
}
|
79 |
+
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Add metakey to usermeta fields
|
83 |
+
*
|
84 |
+
* @param $metakey
|
85 |
+
* @param $args
|
86 |
+
*/
|
87 |
+
function on_new_field_added( $metakey, $args ) {
|
88 |
+
$metakeys = get_option( 'um_usermeta_fields', array() );
|
89 |
+
|
90 |
+
if ( ! in_array( $metakey, $metakeys ) ) {
|
91 |
+
$metakeys[] = $metakey;
|
92 |
+
update_option( 'um_usermeta_fields', array_values( $metakeys ) );
|
93 |
+
}
|
94 |
+
|
95 |
+
do_action( 'um_metadata_on_new_field_added', $metakeys, $metakey, $args );
|
96 |
+
}
|
97 |
+
|
98 |
+
|
99 |
+
/**
|
100 |
+
* When you delete usermeta - remove row from um_metadata
|
101 |
+
*
|
102 |
+
* @param int|array $meta_ids
|
103 |
+
* @param int $object_id
|
104 |
+
* @param string $meta_key
|
105 |
+
* @param mixed $_meta_value
|
106 |
+
*/
|
107 |
+
function on_delete_usermeta( $meta_ids, $object_id, $meta_key, $_meta_value ) {
|
108 |
+
$metakeys = get_option( 'um_usermeta_fields', array() );
|
109 |
+
if ( ! in_array( $meta_key, $metakeys ) ) {
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
|
113 |
+
global $wpdb;
|
114 |
+
|
115 |
+
$wpdb->delete(
|
116 |
+
"{$wpdb->prefix}um_metadata",
|
117 |
+
array(
|
118 |
+
'user_id' => $object_id,
|
119 |
+
'um_key' => $meta_key
|
120 |
+
),
|
121 |
+
array(
|
122 |
+
'%d',
|
123 |
+
'%s'
|
124 |
+
)
|
125 |
+
);
|
126 |
+
}
|
127 |
+
|
128 |
+
|
129 |
+
/**
|
130 |
+
* When you add/update usermeta - add/update row from um_metadata
|
131 |
+
*
|
132 |
+
* @param int $meta_id
|
133 |
+
* @param int $object_id
|
134 |
+
* @param string $meta_key
|
135 |
+
* @param mixed $_meta_value
|
136 |
+
*/
|
137 |
+
function on_update_usermeta( $meta_id, $object_id, $meta_key, $_meta_value ) {
|
138 |
+
|
139 |
+
$metakeys = get_option( 'um_usermeta_fields', array() );
|
140 |
+
if ( ! in_array( $meta_key, $metakeys ) ) {
|
141 |
+
return;
|
142 |
+
}
|
143 |
+
|
144 |
+
global $wpdb;
|
145 |
+
|
146 |
+
$result = $wpdb->get_var( $wpdb->prepare(
|
147 |
+
"SELECT umeta_id
|
148 |
+
FROM {$wpdb->prefix}um_metadata
|
149 |
+
WHERE user_id = %d AND
|
150 |
+
um_key = %s
|
151 |
+
LIMIT 1",
|
152 |
+
$object_id,
|
153 |
+
$meta_key
|
154 |
+
) );
|
155 |
+
|
156 |
+
if ( empty( $result ) ) {
|
157 |
+
$wpdb->insert(
|
158 |
+
"{$wpdb->prefix}um_metadata",
|
159 |
+
array(
|
160 |
+
'user_id' => $object_id,
|
161 |
+
'um_key' => $meta_key,
|
162 |
+
'um_value' => maybe_serialize( $_meta_value ),
|
163 |
+
),
|
164 |
+
array(
|
165 |
+
'%d',
|
166 |
+
'%s',
|
167 |
+
'%s',
|
168 |
+
)
|
169 |
+
);
|
170 |
+
} else {
|
171 |
+
$wpdb->update(
|
172 |
+
"{$wpdb->prefix}um_metadata",
|
173 |
+
array(
|
174 |
+
'um_value' => maybe_serialize( $_meta_value ),
|
175 |
+
),
|
176 |
+
array(
|
177 |
+
'umeta_id' => $result,
|
178 |
+
),
|
179 |
+
array(
|
180 |
+
'%s',
|
181 |
+
),
|
182 |
+
array(
|
183 |
+
'%d',
|
184 |
+
)
|
185 |
+
);
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
|
190 |
+
/**
|
191 |
+
* @param $directory_data
|
192 |
+
* @param $field
|
193 |
+
* @param $value
|
194 |
+
* @param $i
|
195 |
+
* @param bool $is_default
|
196 |
+
*/
|
197 |
+
function handle_filter_query( $directory_data, $field, $value, $i, $is_default = false ) {
|
198 |
+
global $wpdb;
|
199 |
+
|
200 |
+
$join_slug = $is_default ? 'ummd' : 'umm' ;
|
201 |
+
|
202 |
+
$blog_id = get_current_blog_id();
|
203 |
+
|
204 |
+
switch ( $field ) {
|
205 |
+
default:
|
206 |
+
|
207 |
+
$filter_type = $this->filter_types[ $field ];
|
208 |
+
|
209 |
+
/**
|
210 |
+
* UM hook
|
211 |
+
*
|
212 |
+
* @type filter
|
213 |
+
* @title um_query_args_{$field}__filter
|
214 |
+
* @description Change field's query for search at Members Directory
|
215 |
+
* @input_vars
|
216 |
+
* [{"var":"$field_query","type":"array","desc":"Field query"}]
|
217 |
+
* @change_log
|
218 |
+
* ["Since: 2.0"]
|
219 |
+
* @usage
|
220 |
+
* <?php add_filter( 'um_query_args_{$field}__filter_meta', 'function_name', 10, 4 ); ?>
|
221 |
+
* @example
|
222 |
+
* <?php
|
223 |
+
* add_filter( 'um_query_args_{$field}__filter_meta', 'my_query_args_filter', 10, 4 );
|
224 |
+
* function my_query_args_filter( $field_query ) {
|
225 |
+
* // your code here
|
226 |
+
* return $field_query;
|
227 |
+
* }
|
228 |
+
* ?>
|
229 |
+
*/
|
230 |
+
$skip_default = apply_filters( "um_query_args_{$field}__filter_meta", false, $this, $field, $value, $filter_type, $is_default );
|
231 |
+
|
232 |
+
$skip_default = apply_filters( 'um_query_args_filter_global_meta', $skip_default, $this, $field, $value, $filter_type, $is_default );
|
233 |
+
|
234 |
+
if ( ! $skip_default ) {
|
235 |
+
|
236 |
+
switch ( $filter_type ) {
|
237 |
+
default:
|
238 |
+
|
239 |
+
do_action( "um_query_args_{$field}_{$filter_type}__filter_meta", $field, $value, $filter_type, $i, $is_default );
|
240 |
+
break;
|
241 |
+
|
242 |
+
case 'text':
|
243 |
+
|
244 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
|
245 |
+
|
246 |
+
$value = trim( stripslashes( $value ) );
|
247 |
+
|
248 |
+
$compare = apply_filters( 'um_members_directory_filter_text', '=', $field );
|
249 |
+
$value = apply_filters( 'um_members_directory_filter_text_meta_value', $value, $field );
|
250 |
+
|
251 |
+
$this->where_clauses[] = $wpdb->prepare( "{$join_slug}{$i}.um_key = %s AND {$join_slug}{$i}.um_value {$compare} %s", $field, $value );
|
252 |
+
|
253 |
+
if ( ! $is_default ) {
|
254 |
+
$this->custom_filters_in_query[ $field ] = $value;
|
255 |
+
}
|
256 |
+
|
257 |
+
break;
|
258 |
+
|
259 |
+
case 'select':
|
260 |
+
if ( ! is_array( $value ) ) {
|
261 |
+
$value = array( $value );
|
262 |
+
}
|
263 |
+
|
264 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
|
265 |
+
|
266 |
+
$values_array = array();
|
267 |
+
foreach ( $value as $single_val ) {
|
268 |
+
$single_val = trim( stripslashes( $single_val ) );
|
269 |
+
|
270 |
+
$values_array[] = $wpdb->prepare( "{$join_slug}{$i}.um_value LIKE %s", '%"' . $single_val . '"%' );
|
271 |
+
$values_array[] = $wpdb->prepare( "{$join_slug}{$i}.um_value LIKE %s", '%' . serialize( (string) $single_val ) . '%' );
|
272 |
+
$values_array[] = $wpdb->prepare( "{$join_slug}{$i}.um_value = %s", $single_val );
|
273 |
+
|
274 |
+
if ( is_numeric( $single_val ) ) {
|
275 |
+
$values_array[] = $wpdb->prepare( "{$join_slug}{$i}.um_value LIKE %s", '%' . serialize( (int) $single_val ) . '%' );
|
276 |
+
}
|
277 |
+
}
|
278 |
+
|
279 |
+
$values = implode( ' OR ', $values_array );
|
280 |
+
|
281 |
+
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = %s AND ( {$values} ) )", $field );
|
282 |
+
|
283 |
+
if ( ! $is_default ) {
|
284 |
+
$this->custom_filters_in_query[ $field ] = $value;
|
285 |
+
}
|
286 |
+
|
287 |
+
break;
|
288 |
+
case 'slider':
|
289 |
+
|
290 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
|
291 |
+
|
292 |
+
$min = min( $value );
|
293 |
+
$max = max( $value );
|
294 |
+
|
295 |
+
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = %s AND {$join_slug}{$i}.um_value BETWEEN %d AND %d )", $field, $min, $max );
|
296 |
+
|
297 |
+
if ( ! $is_default ) {
|
298 |
+
$this->custom_filters_in_query[ $field ] = $value;
|
299 |
+
}
|
300 |
+
|
301 |
+
break;
|
302 |
+
case 'datepicker':
|
303 |
+
|
304 |
+
$offset = 0;
|
305 |
+
if ( ! $is_default ) {
|
306 |
+
if ( isset( $_POST['gmt_offset'] ) && is_numeric( $_POST['gmt_offset'] ) ) {
|
307 |
+
$offset = (int) $_POST['gmt_offset'];
|
308 |
+
}
|
309 |
+
} else {
|
310 |
+
$gmt_offset = get_post_meta( $directory_data['form_id'], '_um_search_filters_gmt', true );
|
311 |
+
if ( is_numeric( $gmt_offset ) ) {
|
312 |
+
$offset = $gmt_offset;
|
313 |
+
}
|
314 |
+
}
|
315 |
+
|
316 |
+
$from_date = (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ); // client time zone offset
|
317 |
+
$to_date = (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1; // time 23:59
|
318 |
+
$from_date = date( 'Y/m/d', $from_date );
|
319 |
+
$to_date = date( 'Y/m/d', $to_date );
|
320 |
+
|
321 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
|
322 |
+
|
323 |
+
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = %s AND {$join_slug}{$i}.um_value BETWEEN %s AND %s )", $field, $from_date, $to_date );
|
324 |
+
|
325 |
+
if ( ! $is_default ) {
|
326 |
+
$this->custom_filters_in_query[ $field ] = array( $from_date, $to_date );
|
327 |
+
}
|
328 |
+
|
329 |
+
break;
|
330 |
+
case 'timepicker':
|
331 |
+
|
332 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
|
333 |
+
if ( $value[0] == $value[1] ) {
|
334 |
+
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = %s AND {$join_slug}{$i}.um_value = %s )", $field, $value[0] );
|
335 |
+
} else {
|
336 |
+
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = %s AND CAST( {$join_slug}{$i}.um_value AS TIME ) BETWEEN %s AND %s )", $field, $value[0], $value[1] );
|
337 |
+
}
|
338 |
+
|
339 |
+
if ( ! $is_default ) {
|
340 |
+
$this->custom_filters_in_query[ $field ] = $value;
|
341 |
+
}
|
342 |
+
|
343 |
+
break;
|
344 |
+
}
|
345 |
+
|
346 |
+
}
|
347 |
+
|
348 |
+
break;
|
349 |
+
case 'role':
|
350 |
+
$value = array_map( 'strtolower', $value );
|
351 |
+
|
352 |
+
if ( empty( $this->roles ) && ! is_multisite() ) {
|
353 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_roles ON ( umm_roles.user_id = u.ID AND umm_roles.um_key = '" . $wpdb->get_blog_prefix( $blog_id ) . "capabilities' )";
|
354 |
+
$this->roles = $value;
|
355 |
+
|
356 |
+
$this->roles_in_query = true;
|
357 |
+
}
|
358 |
+
|
359 |
+
$roles_clauses = array();
|
360 |
+
foreach ( $value as $role ) {
|
361 |
+
$roles_clauses[] = $wpdb->prepare( "umm_roles.um_value LIKE %s", '%"' . $role . '"%' );
|
362 |
+
}
|
363 |
+
|
364 |
+
$this->where_clauses[] = '( ' . implode( ' OR ', $roles_clauses ) . ' )';
|
365 |
+
|
366 |
+
if ( ! $is_default ) {
|
367 |
+
$this->custom_filters_in_query[ $field ] = $value;
|
368 |
+
}
|
369 |
+
|
370 |
+
break;
|
371 |
+
case 'birth_date':
|
372 |
+
|
373 |
+
$from_date = date( 'Y/m/d', mktime( 0,0,0, date( 'm', time() ), date( 'd', time() ), date( 'Y', time() - min( $value ) * YEAR_IN_SECONDS ) ) );
|
374 |
+
$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 ) ) );
|
375 |
+
|
376 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
|
377 |
+
|
378 |
+
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = 'birth_date' AND {$join_slug}{$i}.um_value BETWEEN %s AND %s )", $to_date, $from_date );
|
379 |
+
|
380 |
+
if ( ! $is_default ) {
|
381 |
+
$this->custom_filters_in_query[ $field ] = array( $to_date, $from_date );
|
382 |
+
}
|
383 |
+
|
384 |
+
break;
|
385 |
+
case 'user_registered':
|
386 |
+
|
387 |
+
$offset = 0;
|
388 |
+
if ( ! $is_default ) {
|
389 |
+
if ( isset( $_POST['gmt_offset'] ) && is_numeric( $_POST['gmt_offset'] ) ) {
|
390 |
+
$offset = (int) $_POST['gmt_offset'];
|
391 |
+
}
|
392 |
+
} else {
|
393 |
+
$gmt_offset = get_post_meta( $directory_data['form_id'], '_um_search_filters_gmt', true );
|
394 |
+
if ( is_numeric( $gmt_offset ) ) {
|
395 |
+
$offset = (int) $gmt_offset;
|
396 |
+
}
|
397 |
+
}
|
398 |
+
|
399 |
+
$from_date = date( 'Y-m-d H:s:i', strtotime( min( $value ) ) + $offset * HOUR_IN_SECONDS ); // client time zone offset
|
400 |
+
$to_date = date( 'Y-m-d H:s:i', strtotime( max( $value ) ) + $offset * HOUR_IN_SECONDS + DAY_IN_SECONDS - 1 ); // time 23:59
|
401 |
+
|
402 |
+
$this->where_clauses[] = $wpdb->prepare( "u.user_registered BETWEEN %s AND %s", $from_date, $to_date );
|
403 |
+
|
404 |
+
if ( ! $is_default ) {
|
405 |
+
$this->custom_filters_in_query[ $field ] = $value;
|
406 |
+
}
|
407 |
+
|
408 |
+
break;
|
409 |
+
case 'last_login':
|
410 |
+
|
411 |
+
$offset = 0;
|
412 |
+
if ( ! $is_default ) {
|
413 |
+
if ( isset( $_POST['gmt_offset'] ) && is_numeric( $_POST['gmt_offset'] ) ) {
|
414 |
+
$offset = (int) $_POST['gmt_offset'];
|
415 |
+
}
|
416 |
+
} else {
|
417 |
+
$gmt_offset = get_post_meta( $directory_data['form_id'], '_um_search_filters_gmt', true );
|
418 |
+
if ( is_numeric( $gmt_offset ) ) {
|
419 |
+
$offset = $gmt_offset;
|
420 |
+
}
|
421 |
+
}
|
422 |
+
|
423 |
+
$from_date = (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ); // client time zone offset
|
424 |
+
$to_date = (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1; // time 23:59
|
425 |
+
|
426 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
|
427 |
+
|
428 |
+
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = '_um_last_login' AND {$join_slug}{$i}.um_value BETWEEN %s AND %s )", $from_date, $to_date );
|
429 |
+
|
430 |
+
if ( ! $is_default ) {
|
431 |
+
$this->custom_filters_in_query[ $field ] = $value;
|
432 |
+
}
|
433 |
+
|
434 |
+
break;
|
435 |
+
}
|
436 |
+
}
|
437 |
+
|
438 |
+
|
439 |
+
/**
|
440 |
+
* Main Query function for getting members via AJAX
|
441 |
+
*/
|
442 |
+
function ajax_get_members() {
|
443 |
+
UM()->check_ajax_nonce();
|
444 |
+
|
445 |
+
global $wpdb;
|
446 |
+
|
447 |
+
$blog_id = get_current_blog_id();
|
448 |
+
|
449 |
+
if ( empty( $_POST['directory_id'] ) ) {
|
450 |
+
wp_send_json_error( __( 'Wrong member directory data', 'ultimate-member' ) );
|
451 |
+
}
|
452 |
+
|
453 |
+
$directory_id = $this->get_directory_by_hash( sanitize_key( $_POST['directory_id'] ) );
|
454 |
+
|
455 |
+
if ( empty( $directory_id ) ) {
|
456 |
+
wp_send_json_error( __( 'Wrong member directory data', 'ultimate-member' ) );
|
457 |
+
}
|
458 |
+
|
459 |
+
$directory_data = UM()->query()->post_data( $directory_id );
|
460 |
+
|
461 |
+
//predefined result for user without capabilities to see other members
|
462 |
+
$this->predefined_no_caps( $directory_data );
|
463 |
+
|
464 |
+
do_action( 'um_member_directory_before_query' );
|
465 |
+
|
466 |
+
// Prepare for BIG SELECT query
|
467 |
+
$wpdb->query( 'SET SQL_BIG_SELECTS=1' );
|
468 |
+
|
469 |
+
|
470 |
+
if ( ! empty( $directory_data['show_these_users'] ) ) {
|
471 |
+
$show_these_users = maybe_unserialize( $directory_data['show_these_users'] );
|
472 |
+
|
473 |
+
if ( is_array( $show_these_users ) && ! empty( $show_these_users ) ) {
|
474 |
+
$users_array = array();
|
475 |
+
foreach ( $show_these_users as $username ) {
|
476 |
+
if ( false !== ( $exists_id = username_exists( $username ) ) ) {
|
477 |
+
$users_array[] = $exists_id;
|
478 |
+
}
|
479 |
+
}
|
480 |
+
|
481 |
+
if ( ! empty( $users_array ) ) {
|
482 |
+
$this->where_clauses[] = "u.ID IN ( '" . implode( "','", $users_array ) . "' )";
|
483 |
+
}
|
484 |
+
}
|
485 |
+
}
|
486 |
+
|
487 |
+
if ( ! empty( $directory_data['exclude_these_users'] ) ) {
|
488 |
+
$exclude_these_users = maybe_unserialize( $directory_data['exclude_these_users'] );
|
489 |
+
|
490 |
+
if ( is_array( $exclude_these_users ) && ! empty( $exclude_these_users ) ) {
|
491 |
+
$users_array = array();
|
492 |
+
foreach ( $exclude_these_users as $username ) {
|
493 |
+
if ( false !== ( $exists_id = username_exists( $username ) ) ) {
|
494 |
+
$users_array[] = $exists_id;
|
495 |
+
}
|
496 |
+
}
|
497 |
+
|
498 |
+
if ( ! empty( $users_array ) ) {
|
499 |
+
$this->where_clauses[] = "u.ID NOT IN ( '" . implode( "','", $users_array ) . "' )";
|
500 |
+
}
|
501 |
+
}
|
502 |
+
}
|
503 |
+
|
504 |
+
|
505 |
+
$profile_photo_where = '';
|
506 |
+
if ( $directory_data['has_profile_photo'] == 1 ) {
|
507 |
+
$profile_photo_where = " AND umm_general.um_value LIKE '%s:13:\"profile_photo\";b:1;%'";
|
508 |
+
}
|
509 |
+
|
510 |
+
$cover_photo_where = '';
|
511 |
+
if ( $directory_data['has_cover_photo'] == 1 ) {
|
512 |
+
$cover_photo_where = " AND umm_general.um_value LIKE '%s:11:\"cover_photo\";b:1;%'";
|
513 |
+
}
|
514 |
+
|
515 |
+
if ( ! UM()->roles()->um_user_can( 'can_edit_everyone' ) ) {
|
516 |
+
if ( ! $this->general_meta_joined ) {
|
517 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_general ON umm_general.user_id = u.ID";
|
518 |
+
$this->general_meta_joined = true;
|
519 |
+
}
|
520 |
+
$this->where_clauses[] = "( umm_general.um_key = 'um_member_directory_data' AND
|
521 |
+
umm_general.um_value LIKE '%s:14:\"account_status\";s:8:\"approved\";%' AND umm_general.um_value LIKE '%s:15:\"hide_in_members\";b:0;%'{$profile_photo_where}{$cover_photo_where} )";
|
522 |
+
} else {
|
523 |
+
if ( ! empty( $cover_photo_where ) || ! empty( $profile_photo_where ) ) {
|
524 |
+
if ( ! $this->general_meta_joined ) {
|
525 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_general ON umm_general.user_id = u.ID";
|
526 |
+
$this->general_meta_joined = true;
|
527 |
+
}
|
528 |
+
$this->where_clauses[] = "( umm_general.um_key = 'um_member_directory_data'{$profile_photo_where}{$cover_photo_where} )";
|
529 |
+
}
|
530 |
+
}
|
531 |
+
|
532 |
+
//$this->roles = array();
|
533 |
+
if ( UM()->roles()->um_user_can( 'can_view_all' ) ) {
|
534 |
+
$view_roles = um_user( 'can_view_roles' );
|
535 |
+
|
536 |
+
if ( ! $view_roles ) {
|
537 |
+
$view_roles = array();
|
538 |
+
} else {
|
539 |
+
$this->roles_in_query = true;
|
540 |
+
}
|
541 |
+
|
542 |
+
$this->roles = array_merge( $this->roles, maybe_unserialize( $view_roles ) );
|
543 |
+
}
|
544 |
+
|
545 |
+
if ( ! empty( $directory_data['roles'] ) ) {
|
546 |
+
if ( ! empty( $this->roles ) ) {
|
547 |
+
$this->roles = array_intersect( $this->roles, maybe_unserialize( $directory_data['roles'] ) );
|
548 |
+
} else {
|
549 |
+
$this->roles = array_merge( $this->roles, maybe_unserialize( $directory_data['roles'] ) );
|
550 |
+
}
|
551 |
+
|
552 |
+
$this->roles_in_query = true;
|
553 |
+
}
|
554 |
+
|
555 |
+
if ( ! empty( $this->roles ) ) {
|
556 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_roles ON ( umm_roles.user_id = u.ID AND umm_roles.um_key = '" . $wpdb->get_blog_prefix( $blog_id ) . "capabilities' )";
|
557 |
+
|
558 |
+
$roles_clauses = array();
|
559 |
+
foreach ( $this->roles as $role ) {
|
560 |
+
$roles_clauses[] = $wpdb->prepare( 'umm_roles.um_value LIKE %s', '%"' . $role . '"%' );
|
561 |
+
}
|
562 |
+
|
563 |
+
$this->where_clauses[] = '( ' . implode( ' OR ', $roles_clauses ) . ' )';
|
564 |
+
} else {
|
565 |
+
|
566 |
+
if ( ! $this->roles_in_query && is_multisite() ) {
|
567 |
+
// select users who have capabilities for current blog
|
568 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_roles ON ( umm_roles.user_id = u.ID AND umm_roles.um_key = '" . $wpdb->get_blog_prefix( $blog_id ) . "capabilities' )";
|
569 |
+
$this->where_clauses[] = "umm_roles.um_value IS NOT NULL";
|
570 |
+
} elseif ( $this->roles_in_query ) {
|
571 |
+
$member_directory_response = apply_filters( 'um_ajax_get_members_response', array(
|
572 |
+
'pagination' => $this->calculate_pagination( $directory_data, 0 ),
|
573 |
+
'users' => array(),
|
574 |
+
'is_search' => $this->is_search,
|
575 |
+
), $directory_data );
|
576 |
+
|
577 |
+
wp_send_json_success( $member_directory_response );
|
578 |
+
}
|
579 |
+
}
|
580 |
+
|
581 |
+
|
582 |
+
if ( ! empty( $_POST['search'] ) ) {
|
583 |
+
$search_line = trim( stripslashes( sanitize_text_field( $_POST['search'] ) ) );
|
584 |
+
|
585 |
+
$searches = array();
|
586 |
+
foreach ( $this->core_search_fields as $field ) {
|
587 |
+
$searches[] = $wpdb->prepare( "u.{$field} LIKE %s", '%' . $search_line . '%' );
|
588 |
+
}
|
589 |
+
|
590 |
+
$core_search = implode( ' OR ', $searches );
|
591 |
+
|
592 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_search ON umm_search.user_id = u.ID";
|
593 |
+
|
594 |
+
$additional_search = apply_filters( 'um_member_directory_meta_general_search_meta_query', '', stripslashes( sanitize_text_field( $_POST['search'] ) ) );
|
595 |
+
|
596 |
+
$search_like_string = apply_filters( 'um_member_directory_meta_search_like_type', '%' . $search_line . '%', $search_line );
|
597 |
+
|
598 |
+
$this->where_clauses[] = $wpdb->prepare( "( umm_search.um_value = %s OR umm_search.um_value LIKE %s OR umm_search.um_value LIKE %s OR {$core_search}{$additional_search})", $search_line, $search_like_string, '%' . serialize( (string) $search_line ) . '%' );
|
599 |
+
|
600 |
+
$this->is_search = true;
|
601 |
+
}
|
602 |
+
|
603 |
+
|
604 |
+
//filters
|
605 |
+
$filter_query = array();
|
606 |
+
if ( ! empty( $directory_data['search_fields'] ) ) {
|
607 |
+
$search_filters = maybe_unserialize( $directory_data['search_fields'] );
|
608 |
+
if ( ! empty( $search_filters ) && is_array( $search_filters ) ) {
|
609 |
+
$filter_query = array_intersect_key( $_POST, array_flip( $search_filters ) );
|
610 |
+
}
|
611 |
+
}
|
612 |
+
|
613 |
+
// added for user tags extension integration on individual tag page
|
614 |
+
$ignore_empty_filters = apply_filters( 'um_member_directory_ignore_empty_filters', false );
|
615 |
+
|
616 |
+
if ( ! empty( $filter_query ) || $ignore_empty_filters ) {
|
617 |
+
$this->is_search = true;
|
618 |
+
|
619 |
+
$i = 1;
|
620 |
+
foreach ( $filter_query as $field => $value ) {
|
621 |
+
|
622 |
+
$field = sanitize_text_field( $field );
|
623 |
+
if ( is_array( $value ) ) {
|
624 |
+
$value = array_map( 'sanitize_text_field', $value );
|
625 |
+
} else {
|
626 |
+
$value = sanitize_text_field( $value );
|
627 |
+
}
|
628 |
+
|
629 |
+
$attrs = UM()->fields()->get_field( $field );
|
630 |
+
// skip private invisible fields
|
631 |
+
if ( ! um_can_view_field( $attrs ) ) {
|
632 |
+
continue;
|
633 |
+
}
|
634 |
+
|
635 |
+
$this->handle_filter_query( $directory_data, $field, $value, $i );
|
636 |
+
|
637 |
+
$i++;
|
638 |
+
}
|
639 |
+
}
|
640 |
+
|
641 |
+
|
642 |
+
//unable default filter in case if we select other filters in frontend filters
|
643 |
+
//if ( empty( $this->custom_filters_in_query ) ) {
|
644 |
+
$default_filters = array();
|
645 |
+
if ( ! empty( $directory_data['search_filters'] ) ) {
|
646 |
+
$default_filters = maybe_unserialize( $directory_data['search_filters'] );
|
647 |
+
}
|
648 |
+
|
649 |
+
if ( ! empty( $default_filters ) ) {
|
650 |
+
$i = 1;
|
651 |
+
foreach ( $default_filters as $field => $value ) {
|
652 |
+
|
653 |
+
$this->handle_filter_query( $directory_data, $field, $value, $i, true );
|
654 |
+
|
655 |
+
$i++;
|
656 |
+
}
|
657 |
+
}
|
658 |
+
//}
|
659 |
+
|
660 |
+
$order = 'ASC';
|
661 |
+
$sortby = ! empty( $_POST['sorting'] ) ? sanitize_text_field( $_POST['sorting'] ) : $directory_data['sortby'];
|
662 |
+
$sortby = ( $sortby == 'other' ) ? $directory_data['sortby_custom'] : $sortby;
|
663 |
+
|
664 |
+
$custom_sort = array();
|
665 |
+
if ( ! empty( $directory_data['sorting_fields'] ) ) {
|
666 |
+
$sorting_fields = maybe_unserialize( $directory_data['sorting_fields'] );
|
667 |
+
foreach ( $sorting_fields as $field ) {
|
668 |
+
if ( is_array( $field ) ) {
|
669 |
+
$field_keys = array_keys( $field );
|
670 |
+
$custom_sort[] = $field_keys[0];
|
671 |
+
}
|
672 |
+
}
|
673 |
+
}
|
674 |
+
|
675 |
+
$numeric_sorting_keys = array();
|
676 |
+
|
677 |
+
if ( ! empty( UM()->builtin()->saved_fields ) ) {
|
678 |
+
foreach ( UM()->builtin()->saved_fields as $key => $data ) {
|
679 |
+
if ( $key == '_um_last_login' ) {
|
680 |
+
continue;
|
681 |
+
}
|
682 |
+
|
683 |
+
if ( isset( $data['type'] ) && 'number' === $data['type'] ) {
|
684 |
+
if ( array_key_exists( $key . '_desc', $this->sort_fields ) ) {
|
685 |
+
$numeric_sorting_keys[] = $key . '_desc';
|
686 |
+
}
|
687 |
+
if ( array_key_exists( $key . '_asc', $this->sort_fields ) ) {
|
688 |
+
$numeric_sorting_keys[] = $key . '_asc';
|
689 |
+
}
|
690 |
+
}
|
691 |
+
}
|
692 |
+
}
|
693 |
+
|
694 |
+
// handle sorting options
|
695 |
+
// sort members by
|
696 |
+
if ( $sortby == $directory_data['sortby_custom'] || in_array( $sortby, $custom_sort ) ) {
|
697 |
+
|
698 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = '{$sortby}' )";
|
699 |
+
|
700 |
+
$custom_sort_type = apply_filters( 'um_member_directory_custom_sorting_type', 'CHAR', $sortby, $directory_data );
|
701 |
+
|
702 |
+
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS {$custom_sort_type} ) {$order} ";
|
703 |
+
|
704 |
+
} elseif ( count( $numeric_sorting_keys ) && in_array( $sortby, $numeric_sorting_keys ) ) {
|
705 |
+
|
706 |
+
if ( strstr( $sortby, '_desc' ) ) {
|
707 |
+
$sortby = str_replace( '_desc', '', $sortby );
|
708 |
+
$order = 'DESC';
|
709 |
+
}
|
710 |
+
|
711 |
+
if ( strstr( $sortby, '_asc' ) ) {
|
712 |
+
$sortby = str_replace( '_asc', '', $sortby );
|
713 |
+
$order = 'ASC';
|
714 |
+
}
|
715 |
+
|
716 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = '{$sortby}' )";
|
717 |
+
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS SIGNED ) {$order}, u.user_registered DESC ";
|
718 |
+
|
719 |
+
} elseif ( 'username' == $sortby ) {
|
720 |
+
|
721 |
+
$this->sql_order = " ORDER BY u.user_login {$order} ";
|
722 |
+
|
723 |
+
} elseif ( 'display_name' == $sortby ) {
|
724 |
+
|
725 |
+
$display_name = UM()->options()->get( 'display_name' );
|
726 |
+
if ( $display_name == 'username' ) {
|
727 |
+
|
728 |
+
$this->sql_order = " ORDER BY u.user_login {$order} ";
|
729 |
+
|
730 |
+
} else {
|
731 |
+
|
732 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = 'full_name' )";
|
733 |
+
|
734 |
+
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS CHAR ) {$order}, u.display_name {$order} ";
|
735 |
+
|
736 |
+
}
|
737 |
+
|
738 |
+
} elseif ( in_array( $sortby, array( 'last_name', 'first_name', 'nickname' ) ) ) {
|
739 |
+
|
740 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = '{$sortby}' )";
|
741 |
+
|
742 |
+
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS CHAR ) {$order} ";
|
743 |
+
|
744 |
+
} elseif ( $sortby == 'last_login' ) {
|
745 |
+
|
746 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = '_um_last_login' )";
|
747 |
+
|
748 |
+
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS SIGNED ) DESC ";
|
749 |
+
|
750 |
+
} elseif ( $sortby == 'last_first_name' ) {
|
751 |
+
|
752 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = 'last_name' )";
|
753 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort2 ON ( umm_sort2.user_id = u.ID AND umm_sort2.um_key = 'first_name' )";
|
754 |
+
|
755 |
+
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS CHAR ) ASC, CAST( umm_sort2.um_value AS CHAR ) ASC ";
|
756 |
+
|
757 |
+
} elseif ( $sortby == 'random' ) {
|
758 |
+
|
759 |
+
if ( um_is_session_started() === false ) {
|
760 |
+
@session_start();
|
761 |
+
}
|
762 |
+
|
763 |
+
// Reset seed on load of initial
|
764 |
+
if ( empty( $_REQUEST['directory_id'] ) && isset( $_SESSION['um_member_directory_seed'] ) ) {
|
765 |
+
unset( $_SESSION['um_member_directory_seed'] );
|
766 |
+
}
|
767 |
+
|
768 |
+
// Get seed from session variable if it exists
|
769 |
+
$seed = false;
|
770 |
+
if ( isset( $_SESSION['um_member_directory_seed'] ) ) {
|
771 |
+
$seed = $_SESSION['um_member_directory_seed'];
|
772 |
+
}
|
773 |
+
|
774 |
+
// Set new seed if none exists
|
775 |
+
if ( ! $seed ) {
|
776 |
+
$seed = rand();
|
777 |
+
$_SESSION['um_member_directory_seed'] = $seed;
|
778 |
+
}
|
779 |
+
|
780 |
+
$this->sql_order = 'ORDER BY RAND(' . $seed . ')';
|
781 |
+
|
782 |
+
} else {
|
783 |
+
|
784 |
+
if ( strstr( $sortby, '_desc' ) ) {
|
785 |
+
$sortby = str_replace( '_desc', '', $sortby );
|
786 |
+
$order = 'DESC';
|
787 |
+
}
|
788 |
+
|
789 |
+
if ( strstr( $sortby, '_asc' ) ) {
|
790 |
+
$sortby = str_replace( '_asc', '', $sortby );
|
791 |
+
$order = 'ASC';
|
792 |
+
}
|
793 |
+
|
794 |
+
$metakeys = get_option( 'um_usermeta_fields', array() );
|
795 |
+
if ( false !== array_search( $sortby, $metakeys ) ) {
|
796 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = '{$sortby}' )";
|
797 |
+
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS CHAR ) {$order} ";
|
798 |
+
} else {
|
799 |
+
$this->sql_order = " ORDER BY u.{$sortby} {$order} ";
|
800 |
+
}
|
801 |
+
}
|
802 |
+
|
803 |
+
$this->sql_order = apply_filters( 'um_modify_sortby_parameter_meta', $this->sql_order, $sortby );
|
804 |
+
|
805 |
+
|
806 |
+
$profiles_per_page = $directory_data['profiles_per_page'];
|
807 |
+
if ( UM()->mobile()->isMobile() && isset( $directory_data['profiles_per_page_mobile'] ) ) {
|
808 |
+
$profiles_per_page = $directory_data['profiles_per_page_mobile'];
|
809 |
+
}
|
810 |
+
|
811 |
+
$query_number = ( ! empty( $directory_data['max_users'] ) && $directory_data['max_users'] <= $profiles_per_page ) ? $directory_data['max_users'] : $profiles_per_page;
|
812 |
+
$query_paged = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
|
813 |
+
|
814 |
+
$number = $query_number;
|
815 |
+
if ( ! empty( $directory_data['max_users'] ) && $query_paged*$query_number > $directory_data['max_users'] ) {
|
816 |
+
$number = ( $query_paged*$query_number - ( $query_paged*$query_number - $directory_data['max_users'] ) ) % $query_number;
|
817 |
+
}
|
818 |
+
|
819 |
+
// limit
|
820 |
+
if ( isset( $query_number ) && $query_number > 0 ) {
|
821 |
+
$this->sql_limit .= $wpdb->prepare( 'LIMIT %d, %d', $query_number * ( $query_paged - 1 ), $number );
|
822 |
+
}
|
823 |
+
|
824 |
+
do_action( 'um_pre_users_query', $this, $directory_data, $sortby );
|
825 |
+
|
826 |
+
$sql_join = implode( ' ', $this->joins );
|
827 |
+
$sql_where = implode( ' AND ', $this->where_clauses );
|
828 |
+
$sql_where = ! empty( $sql_where ) ? 'AND ' . $sql_where : '';
|
829 |
+
|
830 |
+
global $wpdb;
|
831 |
+
|
832 |
+
/*
|
833 |
+
*
|
834 |
+
* SQL_CALC_FOUND_ROWS is deprecated as of MySQL 8.0.17
|
835 |
+
* https://core.trac.wordpress.org/ticket/47280
|
836 |
+
*
|
837 |
+
* */
|
838 |
+
$user_ids = $wpdb->get_col(
|
839 |
+
"SELECT SQL_CALC_FOUND_ROWS DISTINCT u.ID
|
840 |
+
{$this->select}
|
841 |
+
FROM {$wpdb->users} AS u
|
842 |
+
{$sql_join}
|
843 |
+
WHERE 1=1 {$sql_where}
|
844 |
+
{$this->having}
|
845 |
+
{$this->sql_order}
|
846 |
+
{$this->sql_limit}"
|
847 |
+
);
|
848 |
+
|
849 |
+
$query = array(
|
850 |
+
'select' => $this->select,
|
851 |
+
'sql_where' => $sql_where,
|
852 |
+
'having' => $this->having,
|
853 |
+
'sql_limit' => $this->sql_limit,
|
854 |
+
);
|
855 |
+
|
856 |
+
$total_users = (int) $wpdb->get_var( 'SELECT FOUND_ROWS()' );
|
857 |
+
|
858 |
+
/**
|
859 |
+
* UM hook
|
860 |
+
*
|
861 |
+
* @type filter
|
862 |
+
* @title um_prepare_user_results_array_meta
|
863 |
+
* @description Extend member directory query result
|
864 |
+
* @input_vars
|
865 |
+
* [{"var":"$result","type":"array","desc":"Members Query Result"}]
|
866 |
+
* @change_log
|
867 |
+
* ["Since: 2.0"]
|
868 |
+
* @usage
|
869 |
+
* <?php add_filter( 'um_prepare_user_results_array', 'function_name', 10, 2 ); ?>
|
870 |
+
* @example
|
871 |
+
* <?php
|
872 |
+
* add_filter( 'um_prepare_user_results_array', 'my_prepare_user_results', 10, 2 );
|
873 |
+
* function my_prepare_user_results( $user_ids, $query ) {
|
874 |
+
* // your code here
|
875 |
+
* return $user_ids;
|
876 |
+
* }
|
877 |
+
* ?>
|
878 |
+
*/
|
879 |
+
$user_ids = apply_filters( 'um_prepare_user_results_array_meta', $user_ids, $query );
|
880 |
+
|
881 |
+
$pagination_data = $this->calculate_pagination( $directory_data, $total_users );
|
882 |
+
|
883 |
+
$sizes = UM()->options()->get( 'cover_thumb_sizes' );
|
884 |
+
|
885 |
+
$this->cover_size = UM()->mobile()->isTablet() ? $sizes[1] : end( $sizes );
|
886 |
+
|
887 |
+
$avatar_size = UM()->options()->get( 'profile_photosize' );
|
888 |
+
$this->avatar_size = str_replace( 'px', '', $avatar_size );
|
889 |
+
|
890 |
+
$users = array();
|
891 |
+
foreach ( $user_ids as $user_id ) {
|
892 |
+
$users[] = $this->build_user_card_data( $user_id, $directory_data );
|
893 |
+
}
|
894 |
+
|
895 |
+
um_reset_user();
|
896 |
+
// end of user card
|
897 |
+
|
898 |
+
$member_directory_response = apply_filters( 'um_ajax_get_members_response', array(
|
899 |
+
'pagination' => $pagination_data,
|
900 |
+
'users' => $users,
|
901 |
+
'is_search' => $this->is_search,
|
902 |
+
), $directory_data );
|
903 |
+
|
904 |
+
wp_send_json_success( $member_directory_response );
|
905 |
+
}
|
906 |
+
}
|
907 |
+
}
|
includes/core/class-member-directory.php
CHANGED
@@ -1,2722 +1,2731 @@
|
|
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 $sorting_supported_fields = array();
|
55 |
-
|
56 |
-
|
57 |
-
var $filter_types = array();
|
58 |
-
|
59 |
-
|
60 |
-
var $core_search_fields = array(
|
61 |
-
'user_login',
|
62 |
-
'user_url',
|
63 |
-
'display_name',
|
64 |
-
'user_email',
|
65 |
-
'user_nicename',
|
66 |
-
);
|
67 |
-
|
68 |
-
|
69 |
-
/**
|
70 |
-
* @var
|
71 |
-
*/
|
72 |
-
var $query_args;
|
73 |
-
|
74 |
-
|
75 |
-
/**
|
76 |
-
* @var User Card cover size
|
77 |
-
*/
|
78 |
-
var $cover_size;
|
79 |
-
|
80 |
-
|
81 |
-
/**
|
82 |
-
* @var User Avatar size
|
83 |
-
*/
|
84 |
-
var $avatar_size;
|
85 |
-
|
86 |
-
|
87 |
-
/**
|
88 |
-
* @var bool Searching marker
|
89 |
-
*/
|
90 |
-
var $is_search = false;
|
91 |
-
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Member_Directory constructor.
|
95 |
-
*/
|
96 |
-
function __construct() {
|
97 |
-
add_filter( 'init', array( &$this, 'init_variables' ) );
|
98 |
-
|
99 |
-
add_action( 'template_redirect', array( &$this, 'access_members' ), 555 );
|
100 |
-
}
|
101 |
-
|
102 |
-
|
103 |
-
/**
|
104 |
-
* @return bool
|
105 |
-
*/
|
106 |
-
function get_hide_in_members_default() {
|
107 |
-
$default = false;
|
108 |
-
$option = UM()->options()->get( 'account_hide_in_directory_default' );
|
109 |
-
if ( $option == 'Yes' ) {
|
110 |
-
$default = true;
|
111 |
-
}
|
112 |
-
|
113 |
-
$default = apply_filters( 'um_member_directory_hide_in_members_default', $default );
|
114 |
-
return $default;
|
115 |
-
}
|
116 |
-
|
117 |
-
|
118 |
-
/**
|
119 |
-
* Getting member directory post ID via hash
|
120 |
-
* Hash is unique attr, which we use visible at frontend
|
121 |
-
*
|
122 |
-
* @param string $hash
|
123 |
-
*
|
124 |
-
* @return bool|int
|
125 |
-
*/
|
126 |
-
function get_directory_by_hash( $hash ) {
|
127 |
-
global $wpdb;
|
128 |
-
|
129 |
-
$directory_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE SUBSTRING( MD5( ID ), 11, 5 ) = %s", $hash ) );
|
130 |
-
|
131 |
-
if ( empty( $directory_id ) ) {
|
132 |
-
return false;
|
133 |
-
}
|
134 |
-
|
135 |
-
return (int) $directory_id;
|
136 |
-
}
|
137 |
-
|
138 |
-
|
139 |
-
/**
|
140 |
-
* @param $id
|
141 |
-
*
|
142 |
-
* @return bool|string
|
143 |
-
*/
|
144 |
-
function get_directory_hash( $id ) {
|
145 |
-
$hash = substr( md5( $id ), 10, 5 );
|
146 |
-
return $hash;
|
147 |
-
}
|
148 |
-
|
149 |
-
|
150 |
-
/**
|
151 |
-
* Get view Type template
|
152 |
-
* @param string $type
|
153 |
-
*
|
154 |
-
* @return string
|
155 |
-
*/
|
156 |
-
function get_type_basename( $type ) {
|
157 |
-
return apply_filters( "um_member_directory_{$type}_type_template_basename", '' );
|
158 |
-
}
|
159 |
-
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Tag conversion for member directory
|
163 |
-
*
|
164 |
-
* @param string $string
|
165 |
-
* @param array $array
|
166 |
-
*
|
167 |
-
* @return string
|
168 |
-
*/
|
169 |
-
function convert_tags( $string, $array ) {
|
170 |
-
|
171 |
-
$search = array(
|
172 |
-
'{total_users}',
|
173 |
-
);
|
174 |
-
|
175 |
-
$replace = array(
|
176 |
-
$array['total_users'],
|
177 |
-
);
|
178 |
-
|
179 |
-
$string = str_replace( $search, $replace, $string );
|
180 |
-
return $string;
|
181 |
-
}
|
182 |
-
|
183 |
-
|
184 |
-
/**
|
185 |
-
* Members page allowed?
|
186 |
-
*
|
187 |
-
* can be disabled by "Enable Members Directory" option
|
188 |
-
*
|
189 |
-
*/
|
190 |
-
function access_members() {
|
191 |
-
if ( UM()->options()->get( 'members_page' ) == 0 && um_is_core_page( 'members' ) ) {
|
192 |
-
um_redirect_home();
|
193 |
-
}
|
194 |
-
}
|
195 |
-
|
196 |
-
|
197 |
-
/**
|
198 |
-
* @param $value
|
199 |
-
* @param $key
|
200 |
-
* @param $post_id
|
201 |
-
*
|
202 |
-
* @return array
|
203 |
-
*/
|
204 |
-
public function before_save_data( $value, $key, $post_id ) {
|
205 |
-
|
206 |
-
$post = get_post( $post_id );
|
207 |
-
|
208 |
-
if ( 'um_directory' === $post->post_type ) {
|
209 |
-
|
210 |
-
if ( ! empty( $value ) && in_array( $key, array( '_um_view_types', '_um_roles', '_um_roles_can_search', '_um_roles_can_filter' ), true ) ) {
|
211 |
-
$value = array_keys( $value );
|
212 |
-
} elseif ( '_um_search_filters' === $key ) {
|
213 |
-
|
214 |
-
$temp_value = array();
|
215 |
-
|
216 |
-
if ( ! empty( $value ) ) {
|
217 |
-
foreach ( $value as $k ) {
|
218 |
-
$filter_type = $this->filter_types[ $k ];
|
219 |
-
if ( ! empty( $filter_type ) ) {
|
220 |
-
if ( 'slider' === $filter_type ) {
|
221 |
-
if ( ! empty( $_POST[ $k ] ) ) {
|
222 |
-
if ( count( $_POST[ $k ] ) > 1 ) {
|
223 |
-
$temp_value[ $k ] = array_map( 'intval', $_POST[ $k ] );
|
224 |
-
} else {
|
225 |
-
$temp_value[ $k ] = (int) $_POST[ $k ];
|
226 |
-
}
|
227 |
-
}
|
228 |
-
} elseif ( 'timepicker' === $filter_type || 'datepicker' === $filter_type ) {
|
229 |
-
if ( ! empty( $_POST[ $k . '_from' ] ) && ! empty( $_POST[ $k . '_to' ] ) ) {
|
230 |
-
$temp_value[ $k ] = array(
|
231 |
-
sanitize_text_field( $_POST[ $k . '_from' ] ),
|
232 |
-
sanitize_text_field( $_POST[ $k . '_to' ] ),
|
233 |
-
);
|
234 |
-
}
|
235 |
-
} elseif ( 'select' === $filter_type ) {
|
236 |
-
if ( ! empty( $_POST[ $k ] ) ) {
|
237 |
-
if ( is_array( $_POST[ $k ] ) ) {
|
238 |
-
$temp_value[ $k ] = array_map( 'trim', $_POST[ $k ] );
|
239 |
-
} else {
|
240 |
-
$temp_value[ $k ] = array( trim( $_POST[ $k ] ) );
|
241 |
-
}
|
242 |
-
|
243 |
-
$temp_value[ $k ] = array_map( 'sanitize_text_field', $temp_value[ $k ] );
|
244 |
-
}
|
245 |
-
} else {
|
246 |
-
if ( ! empty( $_POST[ $k ] ) ) {
|
247 |
-
$temp_value[ $k ] = trim( sanitize_text_field( $_POST[ $k ] ) );
|
248 |
-
}
|
249 |
-
}
|
250 |
-
}
|
251 |
-
}
|
252 |
-
}
|
253 |
-
|
254 |
-
$value = $temp_value;
|
255 |
-
} elseif ( '_um_sorting_fields' === $key ) {
|
256 |
-
if ( ! empty( $value['other_data'] ) ) {
|
257 |
-
$other_data = $value['other_data'];
|
258 |
-
unset( $value['other_data'] );
|
259 |
-
|
260 |
-
foreach ( $value as $k => &$row ) {
|
261 |
-
if ( ! empty( $other_data[ $k ]['meta_key'] ) ) {
|
262 |
-
$metakey = sanitize_text_field( $other_data[ $k ]['meta_key'] );
|
263 |
-
if ( ! empty( $metakey ) ) {
|
264 |
-
if ( ! empty( $other_data[ $k ]['label'] ) ) {
|
265 |
-
$metalabel = wp_strip_all_tags( $other_data[ $k ]['label'] );
|
266 |
-
}
|
267 |
-
$row = array(
|
268 |
-
$metakey => ! empty( $metalabel ) ? $metalabel : $metakey,
|
269 |
-
);
|
270 |
-
}
|
271 |
-
}
|
272 |
-
}
|
273 |
-
}
|
274 |
-
} elseif ( '_um_sortby_custom' === $key ) {
|
275 |
-
$value = sanitize_text_field( $value );
|
276 |
-
} elseif ( '_um_sortby_custom_label' === $key ) {
|
277 |
-
$value = wp_strip_all_tags( $value );
|
278 |
-
}
|
279 |
-
}
|
280 |
-
|
281 |
-
return $value;
|
282 |
-
}
|
283 |
-
|
284 |
-
|
285 |
-
/**
|
286 |
-
*
|
287 |
-
*/
|
288 |
-
function init_variables() {
|
289 |
-
|
290 |
-
// Types
|
291 |
-
$this->view_types = apply_filters( 'um_member_directory_views', array(
|
292 |
-
'grid' => array( 'title' => __( 'Grid', 'ultimate-member' ), 'icon' => 'um-faicon-th' ),
|
293 |
-
'list' => array( 'title' => __( 'List', 'ultimate-member' ), 'icon' => 'um-faicon-list' ),
|
294 |
-
) );
|
295 |
-
|
296 |
-
// Sort
|
297 |
-
$this->sort_fields = apply_filters( 'um_members_directory_sort_fields', array(
|
298 |
-
'user_registered_desc' => __( 'New users first', 'ultimate-member' ),
|
299 |
-
'user_registered_asc' => __( 'Old users first', 'ultimate-member' ),
|
300 |
-
'username' => __( 'Username', 'ultimate-member' ),
|
301 |
-
'nickname' => __( 'Nickname', 'ultimate-member' ),
|
302 |
-
'first_name' => __( 'First name', 'ultimate-member' ),
|
303 |
-
'last_name' => __( 'Last name', 'ultimate-member' ),
|
304 |
-
'display_name' => __( 'Display name', 'ultimate-member' ),
|
305 |
-
'last_first_name' => __( 'Last & First name', 'ultimate-member' ),
|
306 |
-
'last_login' => __( 'Last login', 'ultimate-member' ),
|
307 |
-
) );
|
308 |
-
|
309 |
-
$this->sorting_supported_fields = apply_filters( 'um_members_directory_custom_field_types_supported_sorting', array( 'number' ) );
|
310 |
-
|
311 |
-
if ( ! empty( UM()->builtin()->saved_fields ) ) {
|
312 |
-
foreach ( UM()->builtin()->saved_fields as $key => $data ) {
|
313 |
-
if ( $key == '_um_last_login' ) {
|
314 |
-
continue;
|
315 |
-
}
|
316 |
-
|
317 |
-
if ( isset( $data['type'] ) && in_array( $data['type'], $this->sorting_supported_fields ) ) {
|
318 |
-
if ( isset( $data['title'] ) && array_search( sprintf( __( '%s DESC', 'ultimate-member' ), $data['title'] ), $this->sort_fields ) !== false ) {
|
319 |
-
$data['title'] = $data['title'] . ' (' . $key . ')';
|
320 |
-
}
|
321 |
-
|
322 |
-
$title = isset( $data['title'] ) ? $data['title'] : ( isset( $data['label'] ) ? $data['label'] : '' );
|
323 |
-
if ( empty( $title ) ) {
|
324 |
-
continue;
|
325 |
-
}
|
326 |
-
|
327 |
-
$this->sort_fields[ $key . '_desc' ] = sprintf( __( '%s DESC', 'ultimate-member' ), $title );
|
328 |
-
$this->sort_fields[ $key . '_asc' ] = sprintf( __( '%s ASC', 'ultimate-member' ), $title );
|
329 |
-
}
|
330 |
-
}
|
331 |
-
}
|
332 |
-
|
333 |
-
asort( $this->sort_fields );
|
334 |
-
|
335 |
-
$this->default_sorting = apply_filters( 'um_members_directory_default_sort', array_merge( $this->sort_fields, array(
|
336 |
-
'random' => __( 'Random', 'ultimate-member' ),
|
337 |
-
'other' => __( 'Other (Custom Field)', 'ultimate-member' ),
|
338 |
-
) ) );
|
339 |
-
|
340 |
-
asort( $this->default_sorting );
|
341 |
-
|
342 |
-
// Filters
|
343 |
-
$this->filter_fields = array(
|
344 |
-
'country' => __( 'Country', 'ultimate-member' ),
|
345 |
-
'gender' => __( 'Gender', 'ultimate-member' ),
|
346 |
-
'languages' => __( 'Languages', 'ultimate-member' ),
|
347 |
-
'role' => __( 'Roles', 'ultimate-member' ),
|
348 |
-
'birth_date' => __( 'Age', 'ultimate-member' ),
|
349 |
-
'last_login' => __( 'Last Login', 'ultimate-member' ),
|
350 |
-
'user_registered' => __( 'User Registered', 'ultimate-member' ),
|
351 |
-
'first_name' => __( 'First Name', 'ultimate-member' ),
|
352 |
-
'last_name' => __( 'Last Name', 'ultimate-member' ),
|
353 |
-
'nickname' => __( 'Nickname', 'ultimate-member' ),
|
354 |
-
'secondary_user_email' => __( 'Secondary E-mail Address', 'ultimate-member' ),
|
355 |
-
'description' => __( 'Biography', 'ultimate-member' ),
|
356 |
-
'phone_number' => __( 'Phone Number', 'ultimate-member' ),
|
357 |
-
'mobile_number' => __( 'Mobile Number', 'ultimate-member' ),
|
358 |
-
);
|
359 |
-
|
360 |
-
$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' ) );
|
361 |
-
|
362 |
-
if ( ! empty( UM()->builtin()->saved_fields ) ) {
|
363 |
-
foreach ( UM()->builtin()->saved_fields as $key => $data ) {
|
364 |
-
|
365 |
-
if ( $key == '_um_last_login' ) {
|
366 |
-
continue;
|
367 |
-
}
|
368 |
-
|
369 |
-
if ( isset( $data['type'] ) && in_array( $data['type'], $this->filter_supported_fields ) ) {
|
370 |
-
if ( isset( $data['title'] ) && array_search( $data['title'], $this->filter_fields ) !== false ) {
|
371 |
-
$data['title'] = $data['title'] . ' (' . $key . ')';
|
372 |
-
}
|
373 |
-
|
374 |
-
$title = isset( $data['title'] ) ? $data['title'] : ( isset( $data['label'] ) ? $data['label'] : '' );
|
375 |
-
if ( empty( $title ) ) {
|
376 |
-
continue;
|
377 |
-
}
|
378 |
-
|
379 |
-
$this->filter_fields[ $key ] = $title;
|
380 |
-
}
|
381 |
-
}
|
382 |
-
}
|
383 |
-
|
384 |
-
$this->filter_fields = apply_filters( 'um_members_directory_filter_fields', $this->filter_fields );
|
385 |
-
|
386 |
-
ksort( $this->filter_fields );
|
387 |
-
|
388 |
-
$this->filter_types = apply_filters( 'um_members_directory_filter_types', array(
|
389 |
-
'country' => 'select',
|
390 |
-
'gender' => 'select',
|
391 |
-
'languages' => 'select',
|
392 |
-
'role' => 'select',
|
393 |
-
'birth_date' => 'slider',
|
394 |
-
'last_login' => 'datepicker',
|
395 |
-
'user_registered' => 'datepicker',
|
396 |
-
'first_name' => 'text',
|
397 |
-
'last_name' => 'text',
|
398 |
-
'nickname' => 'text',
|
399 |
-
'secondary_user_email' => 'text',
|
400 |
-
'description' => 'text',
|
401 |
-
'phone_number' => 'text',
|
402 |
-
'mobile_number' => 'text',
|
403 |
-
) );
|
404 |
-
|
405 |
-
$fields = UM()->builtin()->all_user_fields;
|
406 |
-
|
407 |
-
$custom_fields_types = array_flip( array_keys( $this->filter_fields ) );
|
408 |
-
foreach ( $custom_fields_types as $key => &$value ) {
|
409 |
-
if ( ! isset( $fields[ $key ] ) ) {
|
410 |
-
unset( $custom_fields_types[ $key ] );
|
411 |
-
} else {
|
412 |
-
switch ( $fields[ $key ]['type'] ) {
|
413 |
-
default:
|
414 |
-
$value = apply_filters( 'um_custom_field_filter_type', 'select', $fields[ $key ] );
|
415 |
-
break;
|
416 |
-
case 'text':
|
417 |
-
case 'textarea':
|
418 |
-
$value = 'text';
|
419 |
-
break;
|
420 |
-
case 'date':
|
421 |
-
$value = 'datepicker';
|
422 |
-
break;
|
423 |
-
case 'time':
|
424 |
-
$value = 'timepicker';
|
425 |
-
break;
|
426 |
-
case 'select':
|
427 |
-
case 'multiselect':
|
428 |
-
case 'radio':
|
429 |
-
case 'checkbox':
|
430 |
-
$value = 'select';
|
431 |
-
break;
|
432 |
-
case 'number':
|
433 |
-
case 'rating':
|
434 |
-
$value = 'slider';
|
435 |
-
break;
|
436 |
-
}
|
437 |
-
}
|
438 |
-
}
|
439 |
-
|
440 |
-
$this->filter_types = array_merge( $custom_fields_types, $this->filter_types );
|
441 |
-
}
|
442 |
-
|
443 |
-
|
444 |
-
/**
|
445 |
-
* Render member's directory
|
446 |
-
* filters selectboxes
|
447 |
-
*
|
448 |
-
* @param string $filter
|
449 |
-
* @param array $directory_data
|
450 |
-
* @param mixed $default_value
|
451 |
-
* @param bool $admin
|
452 |
-
*
|
453 |
-
* @return string $filter
|
454 |
-
*/
|
455 |
-
function show_filter( $filter, $directory_data, $default_value = false, $admin = false ) {
|
456 |
-
|
457 |
-
if ( empty( $this->filter_types[ $filter ] ) ) {
|
458 |
-
return '';
|
459 |
-
}
|
460 |
-
|
461 |
-
if ( $default_value === false ) {
|
462 |
-
$default_filters = array();
|
463 |
-
if ( ! empty( $directory_data['search_filters'] ) ) {
|
464 |
-
$default_filters = maybe_unserialize( $directory_data['search_filters'] );
|
465 |
-
}
|
466 |
-
|
467 |
-
if ( ! empty( $default_filters[ $filter ] ) && $this->filter_types[ $filter ] != 'select' ) {
|
468 |
-
return '';
|
469 |
-
}
|
470 |
-
}
|
471 |
-
|
472 |
-
$field_key = $filter;
|
473 |
-
if ( $filter == 'last_login' ) {
|
474 |
-
$field_key = '_um_last_login';
|
475 |
-
}
|
476 |
-
if ( $filter == 'role' ) {
|
477 |
-
$field_key = 'role_select';
|
478 |
-
}
|
479 |
-
|
480 |
-
$fields = UM()->builtin()->all_user_fields;
|
481 |
-
|
482 |
-
if ( isset( $fields[ $field_key ] ) ) {
|
483 |
-
$attrs = $fields[ $field_key ];
|
484 |
-
} else {
|
485 |
-
/**
|
486 |
-
* UM hook
|
487 |
-
*
|
488 |
-
* @type filter
|
489 |
-
* @title um_custom_search_field_{$filter}
|
490 |
-
* @description Custom search settings by $filter
|
491 |
-
* @input_vars
|
492 |
-
* [{"var":"$settings","type":"array","desc":"Search Settings"}]
|
493 |
-
* @change_log
|
494 |
-
* ["Since: 2.0"]
|
495 |
-
* @usage
|
496 |
-
* <?php add_filter( 'um_custom_search_field_{$filter}', 'function_name', 10, 1 ); ?>
|
497 |
-
* @example
|
498 |
-
* <?php
|
499 |
-
* add_filter( 'um_custom_search_field_{$filter}', 'my_custom_search_field', 10, 1 );
|
500 |
-
* function my_change_email_template_file( $settings ) {
|
501 |
-
* // your code here
|
502 |
-
* return $settings;
|
503 |
-
* }
|
504 |
-
* ?>
|
505 |
-
*/
|
506 |
-
$attrs = apply_filters( "um_custom_search_field_{$filter}", array(), $field_key );
|
507 |
-
}
|
508 |
-
|
509 |
-
// skip private invisible fields
|
510 |
-
if ( ! um_can_view_field( $attrs ) ) {
|
511 |
-
return '';
|
512 |
-
}
|
513 |
-
|
514 |
-
/**
|
515 |
-
* UM hook
|
516 |
-
*
|
517 |
-
* @type filter
|
518 |
-
* @title um_search_fields
|
519 |
-
* @description Filter all search fields
|
520 |
-
* @input_vars
|
521 |
-
* [{"var":"$settings","type":"array","desc":"Search Fields"}]
|
522 |
-
* @change_log
|
523 |
-
* ["Since: 2.0"]
|
524 |
-
* @usage
|
525 |
-
* <?php add_filter( 'um_search_fields', 'function_name', 10, 1 ); ?>
|
526 |
-
* @example
|
527 |
-
* <?php
|
528 |
-
* add_filter( 'um_search_fields', 'my_search_fields', 10, 1 );
|
529 |
-
* function my_search_fields( $settings ) {
|
530 |
-
* // your code here
|
531 |
-
* return $settings;
|
532 |
-
* }
|
533 |
-
* ?>
|
534 |
-
*/
|
535 |
-
$attrs = apply_filters( 'um_search_fields', $attrs, $field_key, $directory_data['form_id'] );
|
536 |
-
|
537 |
-
$unique_hash = substr( md5( $directory_data['form_id'] ), 10, 5 );
|
538 |
-
|
539 |
-
ob_start();
|
540 |
-
|
541 |
-
switch ( $this->filter_types[ $filter ] ) {
|
542 |
-
default: {
|
543 |
-
|
544 |
-
do_action( "um_member_directory_filter_type_{$this->filter_types[ $filter ]}", $filter, $directory_data, $unique_hash, $attrs, $default_value );
|
545 |
-
|
546 |
-
break;
|
547 |
-
}
|
548 |
-
case 'text': {
|
549 |
-
$filter_from_url = ! empty( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) ? sanitize_text_field( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) : $default_value; ?>
|
550 |
-
<input type="text" autocomplete="off" id="<?php echo $filter; ?>" name="<?php echo $filter; ?>"
|
551 |
-
placeholder="<?php esc_attr_e( stripslashes( $attrs['label'] ), 'ultimate-member' ); ?>"
|
552 |
-
value="<?php echo esc_attr( $filter_from_url ) ?>" class="um-form-field"
|
553 |
-
aria-label="<?php esc_attr_e( stripslashes( $attrs['label'] ), 'ultimate-member' ); ?>" />
|
554 |
-
<?php
|
555 |
-
break;
|
556 |
-
}
|
557 |
-
case 'select': {
|
558 |
-
|
559 |
-
// getting value from GET line
|
560 |
-
$filter_from_url = ! empty( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) ? explode( '||', sanitize_text_field( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) ) : array();
|
561 |
-
|
562 |
-
// new
|
563 |
-
global $wpdb;
|
564 |
-
|
565 |
-
if ( $attrs['metakey'] != 'role_select' ) {
|
566 |
-
$values_array = $wpdb->get_col(
|
567 |
-
$wpdb->prepare(
|
568 |
-
"SELECT DISTINCT meta_value
|
569 |
-
FROM $wpdb->usermeta
|
570 |
-
WHERE meta_key = %s AND
|
571 |
-
meta_value != ''",
|
572 |
-
$attrs['metakey']
|
573 |
-
)
|
574 |
-
);
|
575 |
-
} else {
|
576 |
-
$users_roles = count_users();
|
577 |
-
$values_array = ( ! empty( $users_roles['avail_roles'] ) && is_array( $users_roles['avail_roles'] ) ) ? array_keys( array_filter( $users_roles['avail_roles'] ) ) : array();
|
578 |
-
}
|
579 |
-
|
580 |
-
if ( ! empty( $values_array ) && in_array( $attrs['type'], array( 'select', 'multiselect', 'checkbox', 'radio' ) ) ) {
|
581 |
-
$values_array = array_map( 'maybe_unserialize', $values_array );
|
582 |
-
$temp_values = array();
|
583 |
-
foreach ( $values_array as $values ) {
|
584 |
-
if ( is_array( $values ) ) {
|
585 |
-
$temp_values = array_merge( $temp_values, $values );
|
586 |
-
} else {
|
587 |
-
$temp_values[] = $values;
|
588 |
-
}
|
589 |
-
}
|
590 |
-
$values_array = array_unique( $temp_values );
|
591 |
-
}
|
592 |
-
|
593 |
-
if ( $attrs['metakey'] != 'online_status' && empty( $values_array ) ) {
|
594 |
-
ob_get_clean();
|
595 |
-
return '';
|
596 |
-
}
|
597 |
-
|
598 |
-
if ( isset( $attrs['metakey'] ) && strstr( $attrs['metakey'], 'role_' ) ) {
|
599 |
-
$shortcode_roles = get_post_meta( $directory_data['form_id'], '_um_roles', true );
|
600 |
-
$um_roles = UM()->roles()->get_roles( false );
|
601 |
-
|
602 |
-
if ( ! empty( $shortcode_roles ) && is_array( $shortcode_roles ) ) {
|
603 |
-
$attrs['options'] = array();
|
604 |
-
|
605 |
-
foreach ( $um_roles as $key => $value ) {
|
606 |
-
if ( in_array( $key, $shortcode_roles ) ) {
|
607 |
-
$attrs['options'][ $key ] = $value;
|
608 |
-
}
|
609 |
-
}
|
610 |
-
} else {
|
611 |
-
$attrs['options'] = array();
|
612 |
-
|
613 |
-
foreach ( $um_roles as $key => $value ) {
|
614 |
-
$attrs['options'][ $key ] = $value;
|
615 |
-
}
|
616 |
-
}
|
617 |
-
}
|
618 |
-
|
619 |
-
$custom_dropdown = '';
|
620 |
-
if ( ! empty( $attrs['custom_dropdown_options_source'] ) ) {
|
621 |
-
$attrs['custom'] = true;
|
622 |
-
|
623 |
-
if ( ! empty( $attrs['parent_dropdown_relationship'] ) ) {
|
624 |
-
|
625 |
-
$custom_dropdown .= ' data-member-directory="yes"';
|
626 |
-
$custom_dropdown .= ' data-um-parent="' . esc_attr( $attrs['parent_dropdown_relationship'] ) . '"';
|
627 |
-
|
628 |
-
if ( isset( $_GET[ 'filter_' . $attrs['parent_dropdown_relationship'] . '_' . $unique_hash ] ) ) {
|
629 |
-
$_POST['parent_option_name'] = $attrs['parent_dropdown_relationship'];
|
630 |
-
$_POST['parent_option'] = explode( '||', filter_input( INPUT_GET, 'filter_' . $attrs['parent_dropdown_relationship'] . '_' . $unique_hash ) );
|
631 |
-
}
|
632 |
-
}
|
633 |
-
|
634 |
-
$attrs['custom_dropdown_options_source'] = wp_unslash( $attrs['custom_dropdown_options_source'] );
|
635 |
-
|
636 |
-
$ajax_source = apply_filters( "um_custom_dropdown_options_source__{$filter}", $attrs['custom_dropdown_options_source'], $attrs );
|
637 |
-
$custom_dropdown .= ' data-um-ajax-source="' . esc_attr( $ajax_source ) . '" ';
|
638 |
-
|
639 |
-
$attrs['options'] = UM()->fields()->get_options_from_callback( $attrs, $attrs['type'] );
|
640 |
-
} else {
|
641 |
-
/**
|
642 |
-
* UM hook
|
643 |
-
*
|
644 |
-
* @type filter
|
645 |
-
* @title um_select_option_value
|
646 |
-
* @description Enable options pair by field $data
|
647 |
-
* @input_vars
|
648 |
-
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
649 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
650 |
-
*/
|
651 |
-
$option_pairs = apply_filters( 'um_select_options_pair', null, $attrs );
|
652 |
-
}
|
653 |
-
|
654 |
-
if ( $attrs['metakey'] != 'online_status' ) {
|
655 |
-
if ( $attrs['metakey'] != 'role_select' && $attrs['metakey'] != 'mycred_rank' && empty( $custom_dropdown ) && empty( $option_pairs ) ) {
|
656 |
-
$attrs['options'] = array_intersect( array_map( 'stripslashes', array_map( 'trim', $attrs['options'] ) ), $values_array );
|
657 |
-
} elseif ( ! empty( $custom_dropdown ) ) {
|
658 |
-
$attrs['options'] = array_intersect_key( array_map( 'trim', $attrs['options'] ), array_flip( $values_array ) );
|
659 |
-
} else {
|
660 |
-
$attrs['options'] = array_intersect_key( array_map( 'trim', $attrs['options'] ), array_flip( $values_array ) );
|
661 |
-
}
|
662 |
-
}
|
663 |
-
|
664 |
-
$attrs['options'] = apply_filters( 'um_member_directory_filter_select_options', $attrs['options'], $values_array, $attrs );
|
665 |
-
|
666 |
-
if ( empty( $attrs['options'] ) || ! is_array( $attrs['options'] ) ) {
|
667 |
-
ob_get_clean();
|
668 |
-
return '';
|
669 |
-
}
|
670 |
-
|
671 |
-
if ( ! empty( $attrs['custom_dropdown_options_source'] ) && ! empty( $attrs['parent_dropdown_relationship'] ) ) {
|
672 |
-
$attrs['options'] = array();
|
673 |
-
}
|
674 |
-
|
675 |
-
if ( isset( $attrs['label'] ) ) {
|
676 |
-
$attrs['label'] = strip_tags( $attrs['label'] );
|
677 |
-
}
|
678 |
-
|
679 |
-
if ( ! empty( $default_filters[ $filter ] ) ) {
|
680 |
-
$attrs['options'] = array_intersect( $attrs['options'], $default_filters[ $filter ] );
|
681 |
-
}
|
682 |
-
|
683 |
-
ksort( $attrs['options'] );
|
684 |
-
|
685 |
-
$attrs['options'] = apply_filters( 'um_member_directory_filter_select_options_sorted', $attrs['options'], $attrs );
|
686 |
-
|
687 |
-
$label = isset( $attrs['label'] ) ? $attrs['label'] : ''; ?>
|
688 |
-
|
689 |
-
<select class="um-s1" id="<?php echo esc_attr( $filter ); ?>" name="<?php echo esc_attr( $filter ); ?><?php if ( $admin && count( $attrs['options'] ) > 1 ) { ?>[]<?php } ?>"
|
690 |
-
data-placeholder="<?php esc_attr_e( stripslashes( $label ), 'ultimate-member' ); ?>"
|
691 |
-
aria-label="<?php esc_attr_e( stripslashes( $label ), 'ultimate-member' ); ?>"
|
692 |
-
<?php if ( $admin && count( $attrs['options'] ) > 1 ) { ?>multiple<?php } ?>
|
693 |
-
<?php echo $custom_dropdown; ?>>
|
694 |
-
|
695 |
-
<option></option>
|
696 |
-
|
697 |
-
<?php if ( ! empty( $attrs['options'] ) ) {
|
698 |
-
foreach ( $attrs['options'] as $k => $v ) {
|
699 |
-
|
700 |
-
$v = stripslashes( $v );
|
701 |
-
|
702 |
-
$opt = $v;
|
703 |
-
|
704 |
-
if ( strstr( $filter, 'role_' ) || $filter == 'role' ) {
|
705 |
-
$opt = $k;
|
706 |
-
}
|
707 |
-
|
708 |
-
if ( isset( $attrs['custom'] ) ) {
|
709 |
-
$opt = $k;
|
710 |
-
}
|
711 |
-
|
712 |
-
if ( ! empty( $option_pairs ) ) {
|
713 |
-
$opt = $k;
|
714 |
-
} ?>
|
715 |
-
|
716 |
-
<option value="<?php echo esc_attr( $opt ); ?>" data-value_label="<?php esc_attr_e( $v, 'ultimate-member' ); ?>"
|
717 |
-
<?php disabled( ! empty( $filter_from_url ) && in_array( $opt, $filter_from_url ) );
|
718 |
-
|
719 |
-
if ( $admin ) {
|
720 |
-
if ( ! is_array( $default_value ) ) {
|
721 |
-
$default_value = array( $default_value );
|
722 |
-
}
|
723 |
-
|
724 |
-
selected( in_array( $opt, $default_value ) );
|
725 |
-
} else {
|
726 |
-
selected( $opt === $default_value );
|
727 |
-
} ?>>
|
728 |
-
<?php _e( $v, 'ultimate-member' ); ?>
|
729 |
-
</option>
|
730 |
-
|
731 |
-
<?php }
|
732 |
-
} ?>
|
733 |
-
|
734 |
-
</select>
|
735 |
-
|
736 |
-
<?php break;
|
737 |
-
}
|
738 |
-
case 'slider': {
|
739 |
-
$range = $this->slider_filters_range( $filter, $directory_data );
|
740 |
-
if ( $range ) {
|
741 |
-
list( $single_placeholder, $plural_placeholder ) = $this->slider_range_placeholder( $filter, $attrs ); ?>
|
742 |
-
|
743 |
-
<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 ) ) : '' ?>" />
|
744 |
-
<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 ) ) : '' ?>" />
|
745 |
-
<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>
|
746 |
-
<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>
|
747 |
-
<?php }
|
748 |
-
|
749 |
-
break;
|
750 |
-
}
|
751 |
-
case 'datepicker': {
|
752 |
-
|
753 |
-
$range = $this->datepicker_filters_range( $filter );
|
754 |
-
|
755 |
-
$label = ! empty( $attrs['label'] ) ? $attrs['label'] : $attrs['title'];
|
756 |
-
|
757 |
-
if ( $range ) { ?>
|
758 |
-
|
759 |
-
<input type="text" id="<?php echo $filter; ?>_from" name="<?php echo $filter; ?>_from" class="um-datepicker-filter"
|
760 |
-
placeholder="<?php esc_attr_e( sprintf( '%s From', stripslashes( $label ) ), 'ultimate-member' ); ?>"
|
761 |
-
data-filter-label="<?php echo esc_attr( stripslashes( $label ) ); ?>"
|
762 |
-
data-date_min="<?php echo $range[0] ?>" data-date_max="<?php echo $range[1] ?>"
|
763 |
-
data-filter_name="<?php echo $filter; ?>" data-range="from" data-value="<?php echo ! empty( $default_value ) ? esc_attr( strtotime( min( $default_value ) ) ) : '' ?>" />
|
764 |
-
<input type="text" id="<?php echo $filter; ?>_to" name="<?php echo $filter; ?>_to" class="um-datepicker-filter"
|
765 |
-
placeholder="<?php esc_attr_e( sprintf( '%s To', stripslashes( $label ) ), 'ultimate-member' ); ?>"
|
766 |
-
data-filter-label="<?php echo esc_attr( stripslashes( $label ) ); ?>"
|
767 |
-
data-date_min="<?php echo $range[0] ?>" data-date_max="<?php echo $range[1] ?>"
|
768 |
-
data-filter_name="<?php echo $filter; ?>" data-range="to" data-value="<?php echo ! empty( $default_value ) ? esc_attr( strtotime( max( $default_value ) ) ) : '' ?>" />
|
769 |
-
|
770 |
-
<?php }
|
771 |
-
|
772 |
-
break;
|
773 |
-
}
|
774 |
-
case 'timepicker': {
|
775 |
-
|
776 |
-
$range = $this->timepicker_filters_range( $filter );
|
777 |
-
|
778 |
-
$label = ! empty( $attrs['label'] ) ? $attrs['label'] : $attrs['title'];
|
779 |
-
|
780 |
-
switch ( $attrs['format'] ) {
|
781 |
-
case 'g:i a':
|
782 |
-
$js_format = 'h:i a';
|
783 |
-
break;
|
784 |
-
case 'g:i A':
|
785 |
-
$js_format = 'h:i A';
|
786 |
-
break;
|
787 |
-
case 'H:i':
|
788 |
-
$js_format = 'HH:i';
|
789 |
-
break;
|
790 |
-
}
|
791 |
-
|
792 |
-
if ( $range ) { ?>
|
793 |
-
|
794 |
-
<input type="text" id="<?php echo $filter; ?>_from" name="<?php echo $filter; ?>_from" class="um-timepicker-filter"
|
795 |
-
placeholder="<?php esc_attr_e( sprintf( '%s From', stripslashes( $label ) ), 'ultimate-member' ); ?>"
|
796 |
-
data-filter-label="<?php echo esc_attr( stripslashes( $label ) ); ?>"
|
797 |
-
data-min="<?php echo $range[0] ?>" data-max="<?php echo $range[1] ?>"
|
798 |
-
data-format="<?php echo esc_attr( $js_format ) ?>" data-intervals="<?php echo esc_attr( $attrs['intervals'] ) ?>"
|
799 |
-
data-filter_name="<?php echo $filter; ?>" data-range="from" />
|
800 |
-
<input type="text" id="<?php echo $filter; ?>_to" name="<?php echo $filter; ?>_to" class="um-timepicker-filter"
|
801 |
-
placeholder="<?php esc_attr_e( sprintf( '%s To', stripslashes( $label ) ), 'ultimate-member' ); ?>"
|
802 |
-
data-filter-label="<?php echo esc_attr( stripslashes( $label ) ); ?>"
|
803 |
-
data-min="<?php echo $range[0] ?>" data-max="<?php echo $range[1] ?>"
|
804 |
-
data-format="<?php echo esc_attr( $js_format ) ?>" data-intervals="<?php echo esc_attr( $attrs['intervals'] ) ?>"
|
805 |
-
data-filter_name="<?php echo $filter; ?>" data-range="to" />
|
806 |
-
|
807 |
-
<?php }
|
808 |
-
|
809 |
-
break;
|
810 |
-
}
|
811 |
-
}
|
812 |
-
|
813 |
-
$filter = ob_get_clean();
|
814 |
-
return $filter;
|
815 |
-
}
|
816 |
-
|
817 |
-
|
818 |
-
/**
|
819 |
-
* @param string $filter
|
820 |
-
* @param array $directory_data
|
821 |
-
*
|
822 |
-
* @return mixed
|
823 |
-
*/
|
824 |
-
function slider_filters_range( $filter, $directory_data ) {
|
825 |
-
global $wpdb;
|
826 |
-
|
827 |
-
$range = false;
|
828 |
-
|
829 |
-
switch ( $filter ) {
|
830 |
-
|
831 |
-
default: {
|
832 |
-
|
833 |
-
$meta = $wpdb->get_row( $wpdb->prepare(
|
834 |
-
"SELECT MIN( CONVERT( meta_value, DECIMAL ) ) as min_meta,
|
835 |
-
MAX( CONVERT( meta_value, DECIMAL ) ) as max_meta,
|
836 |
-
COUNT( DISTINCT meta_value ) as amount
|
837 |
-
FROM {$wpdb->usermeta}
|
838 |
-
WHERE meta_key = %s",
|
839 |
-
$filter
|
840 |
-
), ARRAY_A );
|
841 |
-
|
842 |
-
if ( isset( $meta['min_meta'] ) && isset( $meta['max_meta'] ) && isset( $meta['amount'] ) && $meta['amount'] > 1 ) {
|
843 |
-
$range = array( (float) $meta['min_meta'], (float) $meta['max_meta'] );
|
844 |
-
}
|
845 |
-
|
846 |
-
$range = apply_filters( 'um_member_directory_filter_slider_common', $range, $directory_data, $filter );
|
847 |
-
$range = apply_filters( "um_member_directory_filter_{$filter}_slider", $range, $directory_data );
|
848 |
-
|
849 |
-
break;
|
850 |
-
}
|
851 |
-
case 'birth_date': {
|
852 |
-
|
853 |
-
// $meta = $wpdb->get_col(
|
854 |
-
// "SELECT meta_value
|
855 |
-
// FROM {$wpdb->usermeta}
|
856 |
-
// WHERE meta_key = 'birth_date' AND
|
857 |
-
// meta_value != ''"
|
858 |
-
// );
|
859 |
-
//
|
860 |
-
// if ( empty( $meta ) || count( $meta ) < 2 ) {
|
861 |
-
// $range = false;
|
862 |
-
// } elseif ( is_array( $meta ) ) {
|
863 |
-
// $birth_dates = array_filter( array_map( 'strtotime', $meta ), 'is_numeric' );
|
864 |
-
// sort( $birth_dates );
|
865 |
-
// $min_meta = array_shift( $birth_dates );
|
866 |
-
// $max_meta = array_pop( $birth_dates );
|
867 |
-
// $range = array( $this->borndate( $max_meta ), $this->borndate( $min_meta ) );
|
868 |
-
// }
|
869 |
-
|
870 |
-
$meta = $wpdb->get_row(
|
871 |
-
"SELECT MIN( meta_value ) as min_meta,
|
872 |
-
MAX( meta_value ) as max_meta,
|
873 |
-
COUNT( DISTINCT meta_value ) as amount
|
874 |
-
FROM {$wpdb->usermeta}
|
875 |
-
WHERE meta_key = 'birth_date' AND
|
876 |
-
meta_value != ''",
|
877 |
-
ARRAY_A );
|
878 |
-
|
879 |
-
if ( isset( $meta['min_meta'] ) && isset( $meta['max_meta'] ) && isset( $meta['amount'] ) && $meta['amount'] > 1 ) {
|
880 |
-
$range = array( $this->borndate( strtotime( $meta['max_meta'] ) ), $this->borndate( strtotime( $meta['min_meta'] ) ) );
|
881 |
-
}
|
882 |
-
|
883 |
-
break;
|
884 |
-
}
|
885 |
-
|
886 |
-
}
|
887 |
-
|
888 |
-
return $range;
|
889 |
-
}
|
890 |
-
|
891 |
-
|
892 |
-
/**
|
893 |
-
* @param $filter
|
894 |
-
*
|
895 |
-
* @return mixed
|
896 |
-
*/
|
897 |
-
function slider_range_placeholder( $filter, $attrs ) {
|
898 |
-
switch ( $filter ) {
|
899 |
-
default: {
|
900 |
-
$label = ! empty( $attrs['label'] ) ? $attrs['label'] : $filter;
|
901 |
-
$label = ucwords( str_replace( array( 'um_', '_' ), array( '', ' ' ), $label ) );
|
902 |
-
$placeholders = apply_filters( 'um_member_directory_filter_slider_range_placeholder', false, $filter );
|
903 |
-
|
904 |
-
if ( ! $placeholders ) {
|
905 |
-
switch ( $attrs['type'] ) {
|
906 |
-
default:
|
907 |
-
$placeholders = array(
|
908 |
-
"<strong>$label:</strong> {value}",
|
909 |
-
"<strong>$label:</strong> {min_range} - {max_range}",
|
910 |
-
);
|
911 |
-
break;
|
912 |
-
case 'rating':
|
913 |
-
$placeholders = array(
|
914 |
-
"<strong>$label:</strong> {value}" . __( ' stars', 'ultimate-member' ),
|
915 |
-
"<strong>$label:</strong> {min_range} - {max_range}" . __( ' stars', 'ultimate-member' )
|
916 |
-
);
|
917 |
-
break;
|
918 |
-
}
|
919 |
-
}
|
920 |
-
|
921 |
-
break;
|
922 |
-
}
|
923 |
-
case 'birth_date': {
|
924 |
-
$placeholders = array(
|
925 |
-
__( '<strong>Age:</strong> {value} years old', 'ultimate-member' ),
|
926 |
-
__( '<strong>Age:</strong> {min_range} - {max_range} years old', 'ultimate-member' )
|
927 |
-
);
|
928 |
-
break;
|
929 |
-
}
|
930 |
-
}
|
931 |
-
|
932 |
-
return $placeholders;
|
933 |
-
}
|
934 |
-
|
935 |
-
|
936 |
-
/**
|
937 |
-
* @param $filter
|
938 |
-
*
|
939 |
-
* @return mixed
|
940 |
-
*/
|
941 |
-
function datepicker_filters_range( $filter ) {
|
942 |
-
global $wpdb;
|
943 |
-
|
944 |
-
switch ( $filter ) {
|
945 |
-
|
946 |
-
default: {
|
947 |
-
|
948 |
-
global $wpdb;
|
949 |
-
$meta = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT meta_value
|
950 |
-
FROM {$wpdb->usermeta}
|
951 |
-
WHERE meta_key = %s
|
952 |
-
ORDER BY meta_value DESC", $filter ) );
|
953 |
-
|
954 |
-
if ( empty( $meta ) || count( $meta ) === 1 ) {
|
955 |
-
$range = false;
|
956 |
-
} elseif ( ! empty( $meta ) ) {
|
957 |
-
$range = array( strtotime( min( $meta ) ), strtotime( max( $meta ) ) );
|
958 |
-
}
|
959 |
-
|
960 |
-
$range = apply_filters( "um_member_directory_filter_{$filter}_datepicker", $range );
|
961 |
-
|
962 |
-
break;
|
963 |
-
}
|
964 |
-
case 'last_login': {
|
965 |
-
$meta = $wpdb->get_col( "SELECT DISTINCT meta_value
|
966 |
-
FROM {$wpdb->usermeta}
|
967 |
-
WHERE meta_key='_um_last_login'
|
968 |
-
ORDER BY meta_value DESC" );
|
969 |
-
|
970 |
-
if ( empty( $meta ) || count( $meta ) === 1 ) {
|
971 |
-
$range = false;
|
972 |
-
} elseif ( ! empty( $meta ) ) {
|
973 |
-
$range = array( min( $meta ), max( $meta ) );
|
974 |
-
}
|
975 |
-
|
976 |
-
break;
|
977 |
-
}
|
978 |
-
case 'user_registered': {
|
979 |
-
$meta = $wpdb->get_col(
|
980 |
-
"SELECT DISTINCT user_registered
|
981 |
-
FROM {$wpdb->users}
|
982 |
-
ORDER BY user_registered DESC"
|
983 |
-
);
|
984 |
-
|
985 |
-
if ( empty( $meta ) || count( $meta ) === 1 ) {
|
986 |
-
$range = false;
|
987 |
-
} elseif ( ! empty( $meta ) ) {
|
988 |
-
$range = array( strtotime( min( $meta ) ), strtotime( max( $meta ) ) );
|
989 |
-
}
|
990 |
-
|
991 |
-
break;
|
992 |
-
}
|
993 |
-
|
994 |
-
}
|
995 |
-
|
996 |
-
return $range;
|
997 |
-
}
|
998 |
-
|
999 |
-
|
1000 |
-
/**
|
1001 |
-
* @param $filter
|
1002 |
-
*
|
1003 |
-
* @return mixed
|
1004 |
-
*/
|
1005 |
-
function timepicker_filters_range( $filter ) {
|
1006 |
-
|
1007 |
-
switch ( $filter ) {
|
1008 |
-
|
1009 |
-
default: {
|
1010 |
-
|
1011 |
-
global $wpdb;
|
1012 |
-
$meta = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT meta_value
|
1013 |
-
FROM {$wpdb->usermeta}
|
1014 |
-
WHERE meta_key = %s
|
1015 |
-
ORDER BY meta_value DESC", $filter ) );
|
1016 |
-
|
1017 |
-
$meta = array_filter( $meta );
|
1018 |
-
|
1019 |
-
if ( empty( $meta ) || count( $meta ) === 1 ) {
|
1020 |
-
$range = false;
|
1021 |
-
} elseif ( ! empty( $meta ) ) {
|
1022 |
-
$range = array( min( $meta ), max( $meta ) );
|
1023 |
-
}
|
1024 |
-
|
1025 |
-
|
1026 |
-
$range = apply_filters( "um_member_directory_filter_{$filter}_timepicker", $range );
|
1027 |
-
|
1028 |
-
break;
|
1029 |
-
}
|
1030 |
-
|
1031 |
-
}
|
1032 |
-
|
1033 |
-
return $range;
|
1034 |
-
}
|
1035 |
-
|
1036 |
-
|
1037 |
-
/**
|
1038 |
-
* @param $borndate
|
1039 |
-
*
|
1040 |
-
* @return false|string
|
1041 |
-
*/
|
1042 |
-
function borndate( $borndate ) {
|
1043 |
-
if ( date('m', $borndate) > date('m') || date('m', $borndate) == date('m') && date('d', $borndate ) > date('d')) {
|
1044 |
-
return (date('Y') - date('Y', $borndate ) - 1);
|
1045 |
-
}
|
1046 |
-
return (date('Y') - date('Y', $borndate));
|
1047 |
-
}
|
1048 |
-
|
1049 |
-
|
1050 |
-
/**
|
1051 |
-
* Handle members can view restrictions
|
1052 |
-
*/
|
1053 |
-
function restriction_options() {
|
1054 |
-
$this->hide_not_approved();
|
1055 |
-
$this->hide_by_role();
|
1056 |
-
$this->hide_by_account_settings();
|
1057 |
-
|
1058 |
-
do_action( 'um_member_directory_restrictions_handle_extend' );
|
1059 |
-
}
|
1060 |
-
|
1061 |
-
|
1062 |
-
/**
|
1063 |
-
*
|
1064 |
-
*/
|
1065 |
-
function hide_not_approved() {
|
1066 |
-
if ( UM()->roles()->um_user_can( 'can_edit_everyone' ) ) {
|
1067 |
-
return;
|
1068 |
-
}
|
1069 |
-
|
1070 |
-
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( array(
|
1071 |
-
'key' => 'um_member_directory_data',
|
1072 |
-
'value' => 's:14:"account_status";s:8:"approved";',
|
1073 |
-
'compare' => 'LIKE'
|
1074 |
-
) ) );
|
1075 |
-
}
|
1076 |
-
|
1077 |
-
|
1078 |
-
/**
|
1079 |
-
*
|
1080 |
-
*/
|
1081 |
-
function hide_by_role() {
|
1082 |
-
if ( ! is_user_logged_in() ) {
|
1083 |
-
return;
|
1084 |
-
}
|
1085 |
-
|
1086 |
-
$roles = um_user( 'can_view_roles' );
|
1087 |
-
$roles = maybe_unserialize( $roles );
|
1088 |
-
|
1089 |
-
if ( UM()->roles()->um_user_can( 'can_view_all' ) && empty( $roles ) ) {
|
1090 |
-
return;
|
1091 |
-
}
|
1092 |
-
|
1093 |
-
if ( ! empty( $this->query_args['role__in'] ) ) {
|
1094 |
-
$this->query_args['role__in'] = is_array( $this->query_args['role__in'] ) ? $this->query_args['role__in'] : array( $this->query_args['role__in'] );
|
1095 |
-
$this->query_args['role__in'] = array_intersect( $this->query_args['role__in'], $roles );
|
1096 |
-
} else {
|
1097 |
-
$this->query_args['role__in'] = $roles;
|
1098 |
-
}
|
1099 |
-
}
|
1100 |
-
|
1101 |
-
|
1102 |
-
/**
|
1103 |
-
*
|
1104 |
-
*/
|
1105 |
-
function hide_by_account_settings() {
|
1106 |
-
if ( ! UM()->options()->get( 'account_hide_in_directory' ) ) {
|
1107 |
-
return;
|
1108 |
-
}
|
1109 |
-
|
1110 |
-
if ( UM()->roles()->um_user_can( 'can_edit_everyone' ) ) {
|
1111 |
-
return;
|
1112 |
-
}
|
1113 |
-
|
1114 |
-
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( array(
|
1115 |
-
'key' => 'um_member_directory_data',
|
1116 |
-
'value' => 's:15:"hide_in_members";b:0;',
|
1117 |
-
'compare' => 'LIKE'
|
1118 |
-
) ) );
|
1119 |
-
}
|
1120 |
-
|
1121 |
-
|
1122 |
-
/**
|
1123 |
-
* Handle "General Options" metabox settings
|
1124 |
-
*
|
1125 |
-
* @param array $directory_data
|
1126 |
-
*/
|
1127 |
-
function general_options( $directory_data ) {
|
1128 |
-
$this->show_selected_roles( $directory_data );
|
1129 |
-
$this->show_only_with_avatar( $directory_data );
|
1130 |
-
$this->show_only_with_cover( $directory_data );
|
1131 |
-
$this->show_only_these_users( $directory_data );
|
1132 |
-
$this->exclude_these_users( $directory_data );
|
1133 |
-
|
1134 |
-
do_action( 'um_member_directory_general_options_handle_extend', $directory_data );
|
1135 |
-
}
|
1136 |
-
|
1137 |
-
|
1138 |
-
/**
|
1139 |
-
* Handle "User Roles to Display" option
|
1140 |
-
*
|
1141 |
-
* @param array $directory_data
|
1142 |
-
*/
|
1143 |
-
function show_selected_roles( $directory_data ) {
|
1144 |
-
// add roles to appear in directory
|
1145 |
-
if ( ! empty( $directory_data['roles'] ) ) {
|
1146 |
-
//since WP4.4 use 'role__in' argument
|
1147 |
-
if ( ! empty( $this->query_args['role__in'] ) ) {
|
1148 |
-
$this->query_args['role__in'] = is_array( $this->query_args['role__in'] ) ? $this->query_args['role__in'] : array( $this->query_args['role__in'] );
|
1149 |
-
$this->query_args['role__in'] = array_intersect( $this->query_args['role__in'], maybe_unserialize( $directory_data['roles'] ) );
|
1150 |
-
} else {
|
1151 |
-
$this->query_args['role__in'] = maybe_unserialize( $directory_data['roles'] );
|
1152 |
-
}
|
1153 |
-
}
|
1154 |
-
}
|
1155 |
-
|
1156 |
-
|
1157 |
-
/**
|
1158 |
-
* Handle "Only show members who have uploaded a profile photo" option
|
1159 |
-
*
|
1160 |
-
* @param array $directory_data
|
1161 |
-
*/
|
1162 |
-
function show_only_with_avatar( $directory_data ) {
|
1163 |
-
if ( $directory_data['has_profile_photo'] == 1 ) {
|
1164 |
-
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( array(
|
1165 |
-
'key' => 'um_member_directory_data',
|
1166 |
-
'value' => 's:13:"profile_photo";b:1;',
|
1167 |
-
'compare' => 'LIKE'
|
1168 |
-
) ) );
|
1169 |
-
}
|
1170 |
-
}
|
1171 |
-
|
1172 |
-
|
1173 |
-
/**
|
1174 |
-
* Handle "Only show members who have uploaded a cover photo" option
|
1175 |
-
*
|
1176 |
-
* @param array $directory_data
|
1177 |
-
*/
|
1178 |
-
function show_only_with_cover( $directory_data ) {
|
1179 |
-
if ( $directory_data['has_cover_photo'] == 1 ) {
|
1180 |
-
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( array(
|
1181 |
-
'key' => 'um_member_directory_data',
|
1182 |
-
'value' => 's:11:"cover_photo";b:1;',
|
1183 |
-
'compare' => 'LIKE'
|
1184 |
-
) ) );
|
1185 |
-
}
|
1186 |
-
}
|
1187 |
-
|
1188 |
-
|
1189 |
-
/**
|
1190 |
-
* Handle "Only show specific users (Enter one username per line)" option
|
1191 |
-
*
|
1192 |
-
* @param array $directory_data
|
1193 |
-
*/
|
1194 |
-
function show_only_these_users( $directory_data ) {
|
1195 |
-
if ( ! empty( $directory_data['show_these_users'] ) ) {
|
1196 |
-
$show_these_users = maybe_unserialize( $directory_data['show_these_users'] );
|
1197 |
-
|
1198 |
-
if ( is_array( $show_these_users ) && ! empty( $show_these_users ) ) {
|
1199 |
-
|
1200 |
-
$users_array = array();
|
1201 |
-
|
1202 |
-
foreach ( $show_these_users as $username ) {
|
1203 |
-
if ( false !== ( $exists_id = username_exists( $username ) ) ) {
|
1204 |
-
$users_array[] = $exists_id;
|
1205 |
-
}
|
1206 |
-
}
|
1207 |
-
|
1208 |
-
if ( ! empty( $users_array ) ) {
|
1209 |
-
$this->query_args['include'] = $users_array;
|
1210 |
-
}
|
1211 |
-
|
1212 |
-
}
|
1213 |
-
}
|
1214 |
-
}
|
1215 |
-
|
1216 |
-
|
1217 |
-
/**
|
1218 |
-
* Handle "Exclude specific users (Enter one username per line)" option
|
1219 |
-
*
|
1220 |
-
* @param array $directory_data
|
1221 |
-
*/
|
1222 |
-
function exclude_these_users( $directory_data ) {
|
1223 |
-
if ( ! empty( $directory_data['exclude_these_users'] ) ) {
|
1224 |
-
$exclude_these_users = maybe_unserialize( $directory_data['exclude_these_users'] );
|
1225 |
-
|
1226 |
-
if ( is_array( $exclude_these_users ) && ! empty( $exclude_these_users ) ) {
|
1227 |
-
|
1228 |
-
$users_array = array();
|
1229 |
-
|
1230 |
-
foreach ( $exclude_these_users as $username ) {
|
1231 |
-
if ( false !== ( $exists_id = username_exists( $username ) ) ) {
|
1232 |
-
$users_array[] = $exists_id;
|
1233 |
-
}
|
1234 |
-
}
|
1235 |
-
|
1236 |
-
if ( ! empty( $users_array ) ) {
|
1237 |
-
$this->query_args['exclude'] = $users_array;
|
1238 |
-
}
|
1239 |
-
|
1240 |
-
}
|
1241 |
-
}
|
1242 |
-
}
|
1243 |
-
|
1244 |
-
|
1245 |
-
/**
|
1246 |
-
* Handle "Pagination Options" metabox settings
|
1247 |
-
*
|
1248 |
-
* @param array $directory_data
|
1249 |
-
*/
|
1250 |
-
function pagination_options( $directory_data ) {
|
1251 |
-
// number of profiles for mobile
|
1252 |
-
$profiles_per_page = $directory_data['profiles_per_page'];
|
1253 |
-
if ( UM()->mobile()->isMobile() && isset( $directory_data['profiles_per_page_mobile'] ) ) {
|
1254 |
-
$profiles_per_page = $directory_data['profiles_per_page_mobile'];
|
1255 |
-
}
|
1256 |
-
|
1257 |
-
$this->query_args['number'] = ( ! empty( $directory_data['max_users'] ) && $directory_data['max_users'] <= $profiles_per_page ) ? $directory_data['max_users'] : $profiles_per_page;
|
1258 |
-
$this->query_args['paged'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
|
1259 |
-
}
|
1260 |
-
|
1261 |
-
|
1262 |
-
/**
|
1263 |
-
* Add sorting attributes for \WP_Users_Query
|
1264 |
-
*
|
1265 |
-
* @param array $directory_data Member Directory options
|
1266 |
-
*/
|
1267 |
-
function sorting_query( $directory_data ) {
|
1268 |
-
// sort members by
|
1269 |
-
$this->query_args['order'] = 'ASC';
|
1270 |
-
$sortby = ! empty( $_POST['sorting'] ) ? sanitize_text_field( $_POST['sorting'] ) : $directory_data['sortby'];
|
1271 |
-
$sortby = ( $sortby == 'other' ) ? $directory_data['sortby_custom'] : $sortby;
|
1272 |
-
|
1273 |
-
$custom_sort = array();
|
1274 |
-
if ( ! empty( $directory_data['sorting_fields'] ) ) {
|
1275 |
-
$sorting_fields = maybe_unserialize( $directory_data['sorting_fields'] );
|
1276 |
-
foreach ( $sorting_fields as $field ) {
|
1277 |
-
if ( is_array( $field ) ) {
|
1278 |
-
$field_keys = array_keys( $field );
|
1279 |
-
$custom_sort[] = $field_keys[0];
|
1280 |
-
}
|
1281 |
-
}
|
1282 |
-
}
|
1283 |
-
|
1284 |
-
$numeric_sorting_keys = array();
|
1285 |
-
|
1286 |
-
if ( ! empty( UM()->builtin()->saved_fields ) ) {
|
1287 |
-
foreach ( UM()->builtin()->saved_fields as $key => $data ) {
|
1288 |
-
if ( $key == '_um_last_login' ) {
|
1289 |
-
continue;
|
1290 |
-
}
|
1291 |
-
|
1292 |
-
if ( isset( $data['type'] ) && 'number' === $data['type'] ) {
|
1293 |
-
if ( array_key_exists( $key . '_desc', $this->sort_fields ) ) {
|
1294 |
-
$numeric_sorting_keys[] = $key . '_desc';
|
1295 |
-
}
|
1296 |
-
if ( array_key_exists( $key . '_asc', $this->sort_fields ) ) {
|
1297 |
-
$numeric_sorting_keys[] = $key . '_asc';
|
1298 |
-
}
|
1299 |
-
}
|
1300 |
-
}
|
1301 |
-
}
|
1302 |
-
|
1303 |
-
if ( 'username' == $sortby ) {
|
1304 |
-
|
1305 |
-
$this->query_args['orderby'] = 'user_login';
|
1306 |
-
$this->query_args['order'] = 'ASC';
|
1307 |
-
|
1308 |
-
} elseif ( 'display_name' == $sortby ) {
|
1309 |
-
|
1310 |
-
$display_name = UM()->options()->get( 'display_name' );
|
1311 |
-
if ( $display_name == 'username' ) {
|
1312 |
-
$this->query_args['orderby'] = 'user_login';
|
1313 |
-
$this->query_args['order'] = 'ASC';
|
1314 |
-
} else {
|
1315 |
-
$this->query_args['meta_query'][] = array(
|
1316 |
-
'relation' => 'OR',
|
1317 |
-
'full_name' => array(
|
1318 |
-
'key' => 'full_name',
|
1319 |
-
'compare' => 'EXISTS'
|
1320 |
-
),
|
1321 |
-
array(
|
1322 |
-
'key' => 'full_name',
|
1323 |
-
'compare' => 'NOT EXISTS'
|
1324 |
-
)
|
1325 |
-
);
|
1326 |
-
|
1327 |
-
$this->query_args['orderby'] = 'full_name, display_name';
|
1328 |
-
$this->query_args['order'] = 'ASC';
|
1329 |
-
}
|
1330 |
-
|
1331 |
-
} elseif ( in_array( $sortby, array( 'last_name', 'first_name', 'nickname' ) ) ) {
|
1332 |
-
|
1333 |
-
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $sortby . '_c' => array(
|
1334 |
-
'key' => $sortby,
|
1335 |
-
'compare' => 'EXISTS',
|
1336 |
-
), ) );
|
1337 |
-
|
1338 |
-
$this->query_args['orderby'] = array( $sortby . '_c' => 'ASC' );
|
1339 |
-
unset( $this->query_args['order'] );
|
1340 |
-
|
1341 |
-
} elseif ( $sortby == 'last_login' ) {
|
1342 |
-
|
1343 |
-
$this->query_args['orderby'] = array( 'um_last_login' => 'DESC' );
|
1344 |
-
$this->query_args['meta_query'][] = array(
|
1345 |
-
'relation' => 'OR',
|
1346 |
-
array(
|
1347 |
-
'key' => '_um_last_login',
|
1348 |
-
'compare' => 'EXISTS',
|
1349 |
-
),
|
1350 |
-
'um_last_login' => array(
|
1351 |
-
'key' => '_um_last_login',
|
1352 |
-
'compare' => 'NOT EXISTS',
|
1353 |
-
),
|
1354 |
-
);
|
1355 |
-
unset( $this->query_args['order'] );
|
1356 |
-
|
1357 |
-
} elseif ( $sortby == 'last_first_name' ) {
|
1358 |
-
|
1359 |
-
$this->query_args['meta_query'][] = array(
|
1360 |
-
'last_name_c' => array(
|
1361 |
-
'key' => 'last_name',
|
1362 |
-
'compare' => 'EXISTS',
|
1363 |
-
),
|
1364 |
-
'first_name_c' => array(
|
1365 |
-
'key' => 'first_name',
|
1366 |
-
'compare' => 'EXISTS',
|
1367 |
-
),
|
1368 |
-
);
|
1369 |
-
|
1370 |
-
$this->query_args['orderby'] = array( 'last_name_c' => 'ASC', 'first_name_c' => 'ASC' );
|
1371 |
-
unset( $this->query_args['order'] );
|
1372 |
-
|
1373 |
-
} elseif ( count( $numeric_sorting_keys ) && in_array( $sortby, $numeric_sorting_keys ) ) {
|
1374 |
-
|
1375 |
-
$order = 'DESC';
|
1376 |
-
if ( strstr( $sortby, '_desc' ) ) {
|
1377 |
-
$sortby = str_replace( '_desc', '', $sortby );
|
1378 |
-
$order = 'DESC';
|
1379 |
-
}
|
1380 |
-
|
1381 |
-
if ( strstr( $sortby, '_asc' ) ) {
|
1382 |
-
$sortby = str_replace( '_asc', '', $sortby );
|
1383 |
-
$order = 'ASC';
|
1384 |
-
}
|
1385 |
-
|
1386 |
-
$this->query_args['meta_query'] = array_merge(
|
1387 |
-
$this->query_args['meta_query'],
|
1388 |
-
array(
|
1389 |
-
array(
|
1390 |
-
'relation' => 'OR',
|
1391 |
-
array(
|
1392 |
-
'key' => $sortby,
|
1393 |
-
'compare' => 'EXISTS',
|
1394 |
-
'type' => 'NUMERIC',
|
1395 |
-
),
|
1396 |
-
$sortby . '_ns' => array(
|
1397 |
-
'key' => $sortby,
|
1398 |
-
'compare' => 'NOT EXISTS',
|
1399 |
-
'type' => 'NUMERIC',
|
1400 |
-
),
|
1401 |
-
),
|
1402 |
-
)
|
1403 |
-
);
|
1404 |
-
|
1405 |
-
$this->query_args['orderby'] = array( $sortby . '_ns' => $order, 'user_registered' => 'DESC' );
|
1406 |
-
unset( $this->query_args['order'] );
|
1407 |
-
|
1408 |
-
} elseif ( ( ! empty( $directory_data['sortby_custom'] ) && $sortby == $directory_data['sortby_custom'] ) || in_array( $sortby, $custom_sort ) ) {
|
1409 |
-
|
1410 |
-
$custom_sort_type = apply_filters( 'um_member_directory_custom_sorting_type', 'CHAR', $sortby, $directory_data );
|
1411 |
-
|
1412 |
-
$this->query_args['meta_query'][] = array(
|
1413 |
-
'relation' => 'OR',
|
1414 |
-
$sortby . '_cs' => array(
|
1415 |
-
'key' => $sortby,
|
1416 |
-
'compare' => 'EXISTS',
|
1417 |
-
'type' => $custom_sort_type,
|
1418 |
-
),
|
1419 |
-
array(
|
1420 |
-
'key' => $sortby,
|
1421 |
-
'compare' => 'NOT EXISTS',
|
1422 |
-
)
|
1423 |
-
);
|
1424 |
-
|
1425 |
-
$this->query_args['orderby'] = array( $sortby . '_cs' => 'ASC', 'user_login' => 'ASC' );
|
1426 |
-
|
1427 |
-
} else {
|
1428 |
-
|
1429 |
-
if ( strstr( $sortby, '_desc' ) ) {
|
1430 |
-
$sortby = str_replace( '_desc', '', $sortby );
|
1431 |
-
$order = 'DESC';
|
1432 |
-
}
|
1433 |
-
|
1434 |
-
if ( strstr( $sortby, '_asc' ) ) {
|
1435 |
-
$sortby = str_replace( '_asc', '', $sortby );
|
1436 |
-
$order = 'ASC';
|
1437 |
-
}
|
1438 |
-
|
1439 |
-
$this->query_args['orderby'] = $sortby;
|
1440 |
-
if ( isset( $order ) ) {
|
1441 |
-
$this->query_args['order'] = $order;
|
1442 |
-
}
|
1443 |
-
|
1444 |
-
add_filter( 'pre_user_query', array( &$this, 'sortby_randomly' ), 10, 1 );
|
1445 |
-
}
|
1446 |
-
|
1447 |
-
|
1448 |
-
/**
|
1449 |
-
* UM hook
|
1450 |
-
*
|
1451 |
-
* @type filter
|
1452 |
-
* @title um_modify_sortby_parameter
|
1453 |
-
* @description Change query sort by attributes for search at Members Directory
|
1454 |
-
* @input_vars
|
1455 |
-
* [{"var":"$query_args","type":"array","desc":"Query Arguments"},
|
1456 |
-
* {"var":"$sortby","type":"string","desc":"Sort by"}]
|
1457 |
-
* @change_log
|
1458 |
-
* ["Since: 2.0"]
|
1459 |
-
* @usage
|
1460 |
-
* <?php add_filter( 'um_modify_sortby_parameter', 'function_name', 10, 2 ); ?>
|
1461 |
-
* @example
|
1462 |
-
* <?php
|
1463 |
-
* add_filter( 'um_modify_sortby_parameter', 'my_modify_sortby_parameter', 10, 2 );
|
1464 |
-
* function my_modify_sortby_parameter( $query_args, $sortby ) {
|
1465 |
-
* // your code here
|
1466 |
-
* return $query_args;
|
1467 |
-
* }
|
1468 |
-
* ?>
|
1469 |
-
*/
|
1470 |
-
$this->query_args = apply_filters( 'um_modify_sortby_parameter', $this->query_args, $sortby );
|
1471 |
-
}
|
1472 |
-
|
1473 |
-
|
1474 |
-
/**
|
1475 |
-
* Sorting random
|
1476 |
-
*
|
1477 |
-
* @param object $query
|
1478 |
-
*
|
1479 |
-
* @return mixed
|
1480 |
-
*/
|
1481 |
-
function sortby_randomly( $query ) {
|
1482 |
-
if ( 'random' == $query->query_vars['orderby'] ) {
|
1483 |
-
|
1484 |
-
if ( um_is_session_started() === false ) {
|
1485 |
-
@session_start();
|
1486 |
-
}
|
1487 |
-
|
1488 |
-
// Reset seed on load of initial
|
1489 |
-
if ( empty( $_REQUEST['directory_id'] ) && isset( $_SESSION['um_member_directory_seed'] ) ) {
|
1490 |
-
unset( $_SESSION['um_member_directory_seed'] );
|
1491 |
-
}
|
1492 |
-
|
1493 |
-
// Get seed from session variable if it exists
|
1494 |
-
$seed = false;
|
1495 |
-
if ( isset( $_SESSION['um_member_directory_seed'] ) ) {
|
1496 |
-
$seed = $_SESSION['um_member_directory_seed'];
|
1497 |
-
}
|
1498 |
-
|
1499 |
-
// Set new seed if none exists
|
1500 |
-
if ( ! $seed ) {
|
1501 |
-
$seed = rand();
|
1502 |
-
$_SESSION['um_member_directory_seed'] = $seed;
|
1503 |
-
}
|
1504 |
-
|
1505 |
-
$query->query_orderby = 'ORDER by RAND(' . $seed . ')';
|
1506 |
-
}
|
1507 |
-
|
1508 |
-
return $query;
|
1509 |
-
}
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
/**
|
1514 |
-
* Handle general search line request
|
1515 |
-
*/
|
1516 |
-
function general_search() {
|
1517 |
-
//general search
|
1518 |
-
if ( ! empty( $_POST['search'] ) ) {
|
1519 |
-
// complex using with change_meta_sql function
|
1520 |
-
|
1521 |
-
$search = trim( stripslashes( sanitize_text_field( $_POST['search'] ) ) );
|
1522 |
-
|
1523 |
-
$meta_query = array(
|
1524 |
-
'relation' => 'OR',
|
1525 |
-
array(
|
1526 |
-
'value' => $search,
|
1527 |
-
'compare' => '=',
|
1528 |
-
),
|
1529 |
-
array(
|
1530 |
-
'value' => $search,
|
1531 |
-
'compare' => 'LIKE',
|
1532 |
-
),
|
1533 |
-
array(
|
1534 |
-
'value' => serialize( (string) $search ),
|
1535 |
-
'compare' => 'LIKE',
|
1536 |
-
),
|
1537 |
-
);
|
1538 |
-
|
1539 |
-
$meta_query = apply_filters( 'um_member_directory_general_search_meta_query', $meta_query, stripslashes( sanitize_text_field( $_POST['search'] ) ) );
|
1540 |
-
|
1541 |
-
$this->query_args['meta_query'][] = $meta_query;
|
1542 |
-
|
1543 |
-
$this->is_search = true;
|
1544 |
-
}
|
1545 |
-
}
|
1546 |
-
|
1547 |
-
|
1548 |
-
/**
|
1549 |
-
* Change mySQL meta query join attribute
|
1550 |
-
* for search only by UM user meta fields and WP core fields in WP Users table
|
1551 |
-
*
|
1552 |
-
* @param array $sql Array containing the query's JOIN and WHERE clauses.
|
1553 |
-
* @param $queries
|
1554 |
-
* @param $type
|
1555 |
-
* @param $primary_table
|
1556 |
-
* @param $primary_id_column
|
1557 |
-
* @param \WP_User_Query $context
|
1558 |
-
*
|
1559 |
-
* @return mixed
|
1560 |
-
*/
|
1561 |
-
function change_meta_sql( $sql, $queries, $type, $primary_table, $primary_id_column, $context ) {
|
1562 |
-
if ( ! empty( $_POST['search'] ) ) {
|
1563 |
-
global $wpdb;
|
1564 |
-
$search = trim( stripslashes( sanitize_text_field( $_POST['search'] ) ) );
|
1565 |
-
if ( ! empty( $search ) ) {
|
1566 |
-
|
1567 |
-
$meta_value = '%' . $wpdb->esc_like( $search ) . '%';
|
1568 |
-
$search_meta = $wpdb->prepare( '%s', $meta_value );
|
1569 |
-
|
1570 |
-
preg_match(
|
1571 |
-
'/^(.*).meta_value LIKE ' . addslashes( $search_meta ) . '[^\)]/im',
|
1572 |
-
$sql['where'],
|
1573 |
-
$join_matches
|
1574 |
-
);
|
1575 |
-
|
1576 |
-
if ( isset( $join_matches[1] ) ) {
|
1577 |
-
$meta_join_for_search = trim( $join_matches[1] );
|
1578 |
-
|
1579 |
-
// skip private invisible fields
|
1580 |
-
$custom_fields = array();
|
1581 |
-
foreach ( array_keys( UM()->builtin()->all_user_fields ) as $field_key ) {
|
1582 |
-
$data = UM()->fields()->get_field( $field_key );
|
1583 |
-
if ( ! um_can_view_field( $data ) ) {
|
1584 |
-
continue;
|
1585 |
-
}
|
1586 |
-
|
1587 |
-
$custom_fields[] = $field_key;
|
1588 |
-
}
|
1589 |
-
|
1590 |
-
$custom_fields = apply_filters( 'um_general_search_custom_fields', $custom_fields );
|
1591 |
-
|
1592 |
-
if ( ! empty( $custom_fields ) ) {
|
1593 |
-
$sql['join'] = preg_replace(
|
1594 |
-
'/(' . $meta_join_for_search . ' ON \( ' . $wpdb->users . '\.ID = ' . $meta_join_for_search . '\.user_id )(\))/im',
|
1595 |
-
"$1 AND " . $meta_join_for_search . ".meta_key IN( '" . implode( "','", $custom_fields ) . "' ) $2",
|
1596 |
-
$sql['join']
|
1597 |
-
);
|
1598 |
-
}
|
1599 |
-
}
|
1600 |
-
|
1601 |
-
// Add OR instead AND to search in WP core fields user_email, user_login, user_display_name
|
1602 |
-
$search_where = $context->get_search_sql( $search, $this->core_search_fields, 'both' );
|
1603 |
-
|
1604 |
-
$search_where = preg_replace( '/ AND \((.*?)\)/im', "$1 OR", $search_where );
|
1605 |
-
|
1606 |
-
$sql['where'] = preg_replace(
|
1607 |
-
'/(' . $meta_join_for_search . '.meta_value = \'' . esc_attr( $search ) . '\')/im',
|
1608 |
-
trim( $search_where ) . " $1",
|
1609 |
-
$sql['where'],
|
1610 |
-
1
|
1611 |
-
);
|
1612 |
-
}
|
1613 |
-
}
|
1614 |
-
|
1615 |
-
return $sql;
|
1616 |
-
}
|
1617 |
-
|
1618 |
-
|
1619 |
-
/**
|
1620 |
-
* Handle filters request
|
1621 |
-
*/
|
1622 |
-
function filters( $directory_data ) {
|
1623 |
-
//filters
|
1624 |
-
$filter_query = array();
|
1625 |
-
if ( ! empty( $directory_data['search_fields'] ) ) {
|
1626 |
-
$search_filters = maybe_unserialize( $directory_data['search_fields'] );
|
1627 |
-
|
1628 |
-
if ( ! empty( $search_filters ) && is_array( $search_filters ) ) {
|
1629 |
-
$filter_query = array_intersect_key( $_POST, array_flip( $search_filters ) );
|
1630 |
-
}
|
1631 |
-
}
|
1632 |
-
|
1633 |
-
// added for user tags extension integration on individual tag page
|
1634 |
-
$ignore_empty_filters = apply_filters( 'um_member_directory_ignore_empty_filters', false );
|
1635 |
-
|
1636 |
-
if ( empty( $filter_query ) && ! $ignore_empty_filters ) {
|
1637 |
-
return;
|
1638 |
-
}
|
1639 |
-
|
1640 |
-
$this->is_search = true;
|
1641 |
-
foreach ( $filter_query as $field => $value ) {
|
1642 |
-
$field = sanitize_text_field( $field );
|
1643 |
-
if ( is_array( $value ) ) {
|
1644 |
-
$value = array_map( 'sanitize_text_field', $value );
|
1645 |
-
} else {
|
1646 |
-
$value = sanitize_text_field( $value );
|
1647 |
-
}
|
1648 |
-
|
1649 |
-
$attrs = UM()->fields()->get_field( $field );
|
1650 |
-
// skip private invisible fields
|
1651 |
-
if ( ! um_can_view_field( $attrs ) ) {
|
1652 |
-
continue;
|
1653 |
-
}
|
1654 |
-
|
1655 |
-
switch ( $field ) {
|
1656 |
-
default:
|
1657 |
-
|
1658 |
-
$filter_type = $this->filter_types[ $field ];
|
1659 |
-
|
1660 |
-
/**
|
1661 |
-
* UM hook
|
1662 |
-
*
|
1663 |
-
* @type filter
|
1664 |
-
* @title um_query_args_{$field}__filter
|
1665 |
-
* @description Change field's query for search at Members Directory
|
1666 |
-
* @input_vars
|
1667 |
-
* [{"var":"$field_query","type":"array","desc":"Field query"}]
|
1668 |
-
* @change_log
|
1669 |
-
* ["Since: 2.0"]
|
1670 |
-
* @usage
|
1671 |
-
* <?php add_filter( 'um_query_args_{$field}__filter', 'function_name', 10, 1 ); ?>
|
1672 |
-
* @example
|
1673 |
-
* <?php
|
1674 |
-
* add_filter( 'um_query_args_{$field}__filter', 'my_query_args_filter', 10, 1 );
|
1675 |
-
* function my_query_args_filter( $field_query ) {
|
1676 |
-
* // your code here
|
1677 |
-
* return $field_query;
|
1678 |
-
* }
|
1679 |
-
* ?>
|
1680 |
-
*/
|
1681 |
-
$field_query = apply_filters( "um_query_args_{$field}__filter", false, $field, $value, $filter_type );
|
1682 |
-
|
1683 |
-
$field_query = apply_filters( 'um_query_args_filter_global', $field_query, $field, $value, $filter_type );
|
1684 |
-
|
1685 |
-
if ( ! $field_query ) {
|
1686 |
-
|
1687 |
-
switch ( $filter_type ) {
|
1688 |
-
default:
|
1689 |
-
|
1690 |
-
$field_query = apply_filters( "um_query_args_{$field}_{$filter_type}__filter", false, $field, $value, $filter_type );
|
1691 |
-
|
1692 |
-
break;
|
1693 |
-
case 'text':
|
1694 |
-
|
1695 |
-
$value = stripslashes( $value );
|
1696 |
-
$field_query = array(
|
1697 |
-
'relation' => 'OR',
|
1698 |
-
array(
|
1699 |
-
'key' => $field,
|
1700 |
-
'value' => trim( $value ),
|
1701 |
-
'compare' => apply_filters( 'um_members_directory_filter_text', 'LIKE', $field )
|
1702 |
-
),
|
1703 |
-
);
|
1704 |
-
|
1705 |
-
$this->custom_filters_in_query[ $field ] = $value;
|
1706 |
-
|
1707 |
-
break;
|
1708 |
-
|
1709 |
-
case 'select':
|
1710 |
-
if ( is_array( $value ) ) {
|
1711 |
-
$field_query = array( 'relation' => 'OR' );
|
1712 |
-
|
1713 |
-
foreach ( $value as $single_val ) {
|
1714 |
-
$single_val = trim( stripslashes( $single_val ) );
|
1715 |
-
|
1716 |
-
$arr_meta_query = array(
|
1717 |
-
array(
|
1718 |
-
'key' => $field,
|
1719 |
-
'value' => $single_val,
|
1720 |
-
'compare' => '=',
|
1721 |
-
),
|
1722 |
-
array(
|
1723 |
-
'key' => $field,
|
1724 |
-
'value' => serialize( (string) $single_val ),
|
1725 |
-
'compare' => 'LIKE',
|
1726 |
-
),
|
1727 |
-
array(
|
1728 |
-
'key' => $field,
|
1729 |
-
'value' => '"' . $single_val . '"',
|
1730 |
-
'compare' => 'LIKE',
|
1731 |
-
)
|
1732 |
-
);
|
1733 |
-
|
1734 |
-
if ( is_numeric( $single_val ) ) {
|
1735 |
-
|
1736 |
-
$arr_meta_query[] = array(
|
1737 |
-
'key' => $field,
|
1738 |
-
'value' => serialize( (int) $single_val ),
|
1739 |
-
'compare' => 'LIKE',
|
1740 |
-
);
|
1741 |
-
|
1742 |
-
}
|
1743 |
-
|
1744 |
-
$field_query = array_merge( $field_query, $arr_meta_query );
|
1745 |
-
}
|
1746 |
-
}
|
1747 |
-
|
1748 |
-
$this->custom_filters_in_query[ $field ] = $value;
|
1749 |
-
|
1750 |
-
break;
|
1751 |
-
case 'slider':
|
1752 |
-
|
1753 |
-
$this->custom_filters_in_query[ $field ] = $value;
|
1754 |
-
|
1755 |
-
$field_query = array(
|
1756 |
-
'key' => $field,
|
1757 |
-
'value' => $value,
|
1758 |
-
'compare' => 'BETWEEN',
|
1759 |
-
'inclusive' => true,
|
1760 |
-
'type' => 'NUMERIC',
|
1761 |
-
);
|
1762 |
-
|
1763 |
-
break;
|
1764 |
-
case 'datepicker':
|
1765 |
-
|
1766 |
-
$offset = 0;
|
1767 |
-
if ( isset( $_POST['gmt_offset'] ) && is_numeric( $_POST['gmt_offset'] ) ) {
|
1768 |
-
$offset = (int) $_POST['gmt_offset'];
|
1769 |
-
}
|
1770 |
-
|
1771 |
-
$from_date = (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ); // client time zone offset
|
1772 |
-
$to_date = (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1; // time 23:59
|
1773 |
-
$from_date = date( 'Y/m/d', $from_date );
|
1774 |
-
$to_date = date( 'Y/m/d', $to_date );
|
1775 |
-
|
1776 |
-
$field_query = array(
|
1777 |
-
'key' => $field,
|
1778 |
-
'value' => array( $from_date, $to_date ),
|
1779 |
-
'compare' => 'BETWEEN',
|
1780 |
-
'inclusive' => true,
|
1781 |
-
);
|
1782 |
-
|
1783 |
-
$this->custom_filters_in_query[ $field ] = array( $from_date, $to_date );
|
1784 |
-
|
1785 |
-
break;
|
1786 |
-
case 'timepicker':
|
1787 |
-
|
1788 |
-
if ( $value[0] == $value[1] ) {
|
1789 |
-
$field_query = array(
|
1790 |
-
'key' => $field,
|
1791 |
-
'value' => $value[0],
|
1792 |
-
);
|
1793 |
-
} else {
|
1794 |
-
$field_query = array(
|
1795 |
-
'key' => $field,
|
1796 |
-
'value' => $value,
|
1797 |
-
'compare' => 'BETWEEN',
|
1798 |
-
'type' => 'TIME',
|
1799 |
-
'inclusive' => true,
|
1800 |
-
);
|
1801 |
-
}
|
1802 |
-
|
1803 |
-
$this->custom_filters_in_query[ $field ] = $value;
|
1804 |
-
|
1805 |
-
break;
|
1806 |
-
}
|
1807 |
-
|
1808 |
-
}
|
1809 |
-
|
1810 |
-
if ( ! empty( $field_query ) && $field_query !== true ) {
|
1811 |
-
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $field_query ) );
|
1812 |
-
}
|
1813 |
-
|
1814 |
-
break;
|
1815 |
-
case 'role':
|
1816 |
-
$value = array_map( 'strtolower', $value );
|
1817 |
-
|
1818 |
-
if ( ! empty( $this->query_args['role__in'] ) ) {
|
1819 |
-
$this->query_args['role__in'] = is_array( $this->query_args['role__in'] ) ? $this->query_args['role__in'] : array( $this->query_args['role__in'] );
|
1820 |
-
$default_role = array_intersect( $this->query_args['role__in'], $value );
|
1821 |
-
$um_role = array_diff( $value, $default_role );
|
1822 |
-
|
1823 |
-
foreach ( $um_role as $key => &$val ) {
|
1824 |
-
$val = 'um_' . str_replace( ' ', '-', $val );
|
1825 |
-
}
|
1826 |
-
$this->query_args['role__in'] = array_merge( $default_role, $um_role );
|
1827 |
-
} else {
|
1828 |
-
$this->query_args['role__in'] = $value;
|
1829 |
-
};
|
1830 |
-
|
1831 |
-
$this->custom_filters_in_query[ $field ] = $this->query_args['role__in'];
|
1832 |
-
|
1833 |
-
break;
|
1834 |
-
case 'birth_date':
|
1835 |
-
|
1836 |
-
$from_date = date( 'Y/m/d', mktime( 0,0,0, date( 'm', time() ), date( 'd', time() ), date( 'Y', time() - min( $value ) * YEAR_IN_SECONDS ) ) );
|
1837 |
-
$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 ) ) );
|
1838 |
-
|
1839 |
-
$meta_query = array(
|
1840 |
-
array(
|
1841 |
-
'key' => 'birth_date',
|
1842 |
-
'value' => array( $to_date, $from_date ),
|
1843 |
-
'compare' => 'BETWEEN',
|
1844 |
-
'type' => 'DATE',
|
1845 |
-
'inclusive' => true,
|
1846 |
-
)
|
1847 |
-
);
|
1848 |
-
|
1849 |
-
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $meta_query ) );
|
1850 |
-
|
1851 |
-
$this->custom_filters_in_query[ $field ] = array( $to_date, $from_date );
|
1852 |
-
|
1853 |
-
break;
|
1854 |
-
case 'user_registered':
|
1855 |
-
|
1856 |
-
$offset = 0;
|
1857 |
-
if ( isset( $_POST['gmt_offset'] ) && is_numeric( $_POST['gmt_offset'] ) ) {
|
1858 |
-
$offset = (int) $_POST['gmt_offset'];
|
1859 |
-
}
|
1860 |
-
|
1861 |
-
$from_date = date( 'Y-m-d H:s:i', strtotime( date( 'Y-m-d H:s:i', min( $value ) ) . "+$offset hours" ) );
|
1862 |
-
$to_date = date( 'Y-m-d H:s:i', strtotime( date( 'Y-m-d H:s:i', max( $value ) ) . "+$offset hours" ) );
|
1863 |
-
|
1864 |
-
$date_query = array(
|
1865 |
-
array(
|
1866 |
-
'column' => 'user_registered',
|
1867 |
-
'before' => $to_date,
|
1868 |
-
'after' => $from_date,
|
1869 |
-
'inclusive' => true,
|
1870 |
-
),
|
1871 |
-
);
|
1872 |
-
|
1873 |
-
if ( empty( $this->query_args['date_query'] ) ) {
|
1874 |
-
$this->query_args['date_query'] = $date_query;
|
1875 |
-
} else {
|
1876 |
-
$this->query_args['date_query'] = array_merge( $this->query_args['date_query'], array( $date_query ) );
|
1877 |
-
}
|
1878 |
-
|
1879 |
-
$this->custom_filters_in_query[ $field ] = $value;
|
1880 |
-
|
1881 |
-
break;
|
1882 |
-
case 'last_login':
|
1883 |
-
|
1884 |
-
$offset = 0;
|
1885 |
-
if ( isset( $_POST['gmt_offset'] ) && is_numeric( $_POST['gmt_offset'] ) ) {
|
1886 |
-
$offset = (int) $_POST['gmt_offset'];
|
1887 |
-
}
|
1888 |
-
|
1889 |
-
$from_date = (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ); // client time zone offset
|
1890 |
-
$to_date = (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1; // time 23:59
|
1891 |
-
$meta_query = array(
|
1892 |
-
array(
|
1893 |
-
'key' => '_um_last_login',
|
1894 |
-
'value' => array( $from_date, $to_date ),
|
1895 |
-
'compare' => 'BETWEEN',
|
1896 |
-
'inclusive' => true,
|
1897 |
-
)
|
1898 |
-
);
|
1899 |
-
|
1900 |
-
$this->custom_filters_in_query[ $field ] = $value;
|
1901 |
-
|
1902 |
-
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $meta_query ) );
|
1903 |
-
break;
|
1904 |
-
}
|
1905 |
-
|
1906 |
-
}
|
1907 |
-
}
|
1908 |
-
|
1909 |
-
|
1910 |
-
/**
|
1911 |
-
* Set default filters
|
1912 |
-
*
|
1913 |
-
* @param $directory_data
|
1914 |
-
*/
|
1915 |
-
function default_filters( $directory_data ) {
|
1916 |
-
$default_filters = array();
|
1917 |
-
if ( ! empty( $directory_data['search_filters'] ) ) {
|
1918 |
-
$default_filters = maybe_unserialize( $directory_data['search_filters'] );
|
1919 |
-
}
|
1920 |
-
|
1921 |
-
$gmt_offset = get_post_meta( $directory_data['form_id'], '_um_search_filters_gmt', true );
|
1922 |
-
|
1923 |
-
if ( empty( $default_filters ) ) {
|
1924 |
-
return;
|
1925 |
-
}
|
1926 |
-
|
1927 |
-
foreach ( $default_filters as $field => $value ) {
|
1928 |
-
|
1929 |
-
switch ( $field ) {
|
1930 |
-
default:
|
1931 |
-
|
1932 |
-
$filter_type = $this->filter_types[ $field ];
|
1933 |
-
|
1934 |
-
/**
|
1935 |
-
* UM hook
|
1936 |
-
*
|
1937 |
-
* @type filter
|
1938 |
-
* @title um_query_args_{$field}__filter
|
1939 |
-
* @description Change field's query for search at Members Directory
|
1940 |
-
* @input_vars
|
1941 |
-
* [{"var":"$field_query","type":"array","desc":"Field query"}]
|
1942 |
-
* @change_log
|
1943 |
-
* ["Since: 2.0"]
|
1944 |
-
* @usage
|
1945 |
-
* <?php add_filter( 'um_query_args_{$field}__filter', 'function_name', 10, 1 ); ?>
|
1946 |
-
* @example
|
1947 |
-
* <?php
|
1948 |
-
* add_filter( 'um_query_args_{$field}__filter', 'my_query_args_filter', 10, 1 );
|
1949 |
-
* function my_query_args_filter( $field_query ) {
|
1950 |
-
* // your code here
|
1951 |
-
* return $field_query;
|
1952 |
-
* }
|
1953 |
-
* ?>
|
1954 |
-
*/
|
1955 |
-
$field_query = apply_filters( "um_query_args_{$field}__filter", false, $field, $value, $filter_type );
|
1956 |
-
|
1957 |
-
if ( ! $field_query ) {
|
1958 |
-
|
1959 |
-
switch ( $filter_type ) {
|
1960 |
-
default:
|
1961 |
-
|
1962 |
-
$field_query = apply_filters( "um_query_args_{$field}_{$filter_type}__filter", false, $field, $value, $filter_type );
|
1963 |
-
|
1964 |
-
break;
|
1965 |
-
|
1966 |
-
case 'text':
|
1967 |
-
|
1968 |
-
$field_query = array(
|
1969 |
-
'key' => $field,
|
1970 |
-
'value' => $value,
|
1971 |
-
'compare' => apply_filters( 'um_members_directory_filter_text', '=', $field ),
|
1972 |
-
);
|
1973 |
-
|
1974 |
-
break;
|
1975 |
-
|
1976 |
-
case 'select':
|
1977 |
-
if ( ! is_array( $value ) ) {
|
1978 |
-
$value = array( $value );
|
1979 |
-
}
|
1980 |
-
|
1981 |
-
$field_query = array( 'relation' => 'OR' );
|
1982 |
-
|
1983 |
-
foreach ( $value as $single_val ) {
|
1984 |
-
$single_val = trim( $single_val );
|
1985 |
-
|
1986 |
-
$arr_meta_query = array(
|
1987 |
-
array(
|
1988 |
-
'key' => $field,
|
1989 |
-
'value' => $single_val,
|
1990 |
-
'compare' => '=',
|
1991 |
-
),
|
1992 |
-
array(
|
1993 |
-
'key' => $field,
|
1994 |
-
'value' => serialize( (string) $single_val ),
|
1995 |
-
'compare' => 'LIKE',
|
1996 |
-
),
|
1997 |
-
array(
|
1998 |
-
'key' => $field,
|
1999 |
-
'value' => '"' . $single_val . '"',
|
2000 |
-
'compare' => 'LIKE',
|
2001 |
-
)
|
2002 |
-
);
|
2003 |
-
|
2004 |
-
if ( is_numeric( $single_val ) ) {
|
2005 |
-
|
2006 |
-
$arr_meta_query[] = array(
|
2007 |
-
'key' => $field,
|
2008 |
-
'value' => serialize( (int) $single_val ),
|
2009 |
-
'compare' => 'LIKE',
|
2010 |
-
);
|
2011 |
-
|
2012 |
-
}
|
2013 |
-
|
2014 |
-
$field_query = array_merge( $field_query, $arr_meta_query );
|
2015 |
-
}
|
2016 |
-
|
2017 |
-
break;
|
2018 |
-
case 'slider':
|
2019 |
-
|
2020 |
-
$field_query = array(
|
2021 |
-
'key' => $field,
|
2022 |
-
'value' => $value,
|
2023 |
-
'compare' => 'BETWEEN',
|
2024 |
-
'inclusive' => true,
|
2025 |
-
);
|
2026 |
-
|
2027 |
-
break;
|
2028 |
-
case 'datepicker':
|
2029 |
-
|
2030 |
-
$offset = 0;
|
2031 |
-
if ( is_numeric( $gmt_offset ) ) {
|
2032 |
-
$offset = $gmt_offset;
|
2033 |
-
}
|
2034 |
-
|
2035 |
-
$from_date = (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ); // client time zone offset
|
2036 |
-
$to_date = (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1; // time 23:59
|
2037 |
-
$field_query = array(
|
2038 |
-
'key' => $field,
|
2039 |
-
'value' => array( $from_date, $to_date ),
|
2040 |
-
'compare' => 'BETWEEN',
|
2041 |
-
'inclusive' => true,
|
2042 |
-
);
|
2043 |
-
|
2044 |
-
break;
|
2045 |
-
case 'timepicker':
|
2046 |
-
|
2047 |
-
if ( $value[0] == $value[1] ) {
|
2048 |
-
$field_query = array(
|
2049 |
-
'key' => $field,
|
2050 |
-
'value' => $value[0],
|
2051 |
-
);
|
2052 |
-
} else {
|
2053 |
-
$field_query = array(
|
2054 |
-
'key' => $field,
|
2055 |
-
'value' => $value,
|
2056 |
-
'compare' => 'BETWEEN',
|
2057 |
-
'type' => 'TIME',
|
2058 |
-
'inclusive' => true,
|
2059 |
-
);
|
2060 |
-
}
|
2061 |
-
|
2062 |
-
break;
|
2063 |
-
}
|
2064 |
-
|
2065 |
-
}
|
2066 |
-
|
2067 |
-
if ( ! empty( $field_query ) && $field_query !== true ) {
|
2068 |
-
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $field_query ) );
|
2069 |
-
}
|
2070 |
-
|
2071 |
-
break;
|
2072 |
-
case 'role':
|
2073 |
-
$value = is_array( $value ) ? $value : explode( '||', $value );
|
2074 |
-
$value = array_map( 'strtolower', $value );
|
2075 |
-
|
2076 |
-
if ( ! empty( $this->query_args['role__in'] ) ) {
|
2077 |
-
$this->query_args['role__in'] = is_array( $this->query_args['role__in'] ) ? $this->query_args['role__in'] : array( $this->query_args['role__in'] );
|
2078 |
-
$default_role = array_intersect( $this->query_args['role__in'], $value );
|
2079 |
-
$um_role = array_diff( $value, $default_role );
|
2080 |
-
|
2081 |
-
foreach ( $um_role as $key => &$val ) {
|
2082 |
-
$val = 'um_' . str_replace( ' ', '-', $val );
|
2083 |
-
}
|
2084 |
-
$this->query_args['role__in'] = array_merge( $default_role, $um_role );
|
2085 |
-
} else {
|
2086 |
-
$this->query_args['role__in'] = $value;
|
2087 |
-
};
|
2088 |
-
|
2089 |
-
break;
|
2090 |
-
case 'birth_date':
|
2091 |
-
$from_date = date( 'Y/m/d', mktime( 0,0,0, date( 'm', time() ), date( 'd', time() ), date( 'Y', time() - min( $value ) * YEAR_IN_SECONDS ) ) );
|
2092 |
-
$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 ) ) );
|
2093 |
-
|
2094 |
-
$meta_query = array(
|
2095 |
-
array(
|
2096 |
-
'key' => 'birth_date',
|
2097 |
-
'value' => array( $to_date, $from_date ),
|
2098 |
-
'compare' => 'BETWEEN',
|
2099 |
-
'type' => 'DATE',
|
2100 |
-
'inclusive' => true,
|
2101 |
-
)
|
2102 |
-
);
|
2103 |
-
|
2104 |
-
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $meta_query ) );
|
2105 |
-
|
2106 |
-
break;
|
2107 |
-
case 'user_registered':
|
2108 |
-
$offset = 0;
|
2109 |
-
if ( is_numeric( $gmt_offset ) ) {
|
2110 |
-
$offset = $gmt_offset;
|
2111 |
-
}
|
2112 |
-
|
2113 |
-
$from_date = date( 'Y-m-d H:s:i', strtotime( date( 'Y-m-d H:s:i', min( $value ) ) . "+$offset hours" ) );
|
2114 |
-
$to_date = date( 'Y-m-d H:s:i', strtotime( date( 'Y-m-d H:s:i', max( $value ) ) . "+$offset hours" ) );
|
2115 |
-
|
2116 |
-
$date_query = array(
|
2117 |
-
array(
|
2118 |
-
'column' => 'user_registered',
|
2119 |
-
'before' => $to_date,
|
2120 |
-
'after' => $from_date,
|
2121 |
-
'inclusive' => true,
|
2122 |
-
),
|
2123 |
-
);
|
2124 |
-
|
2125 |
-
if ( empty( $this->query_args['date_query'] ) ) {
|
2126 |
-
$this->query_args['date_query'] = $date_query;
|
2127 |
-
} else {
|
2128 |
-
$this->query_args['date_query'] = array_merge( $this->query_args['date_query'], array( $date_query ) );
|
2129 |
-
}
|
2130 |
-
|
2131 |
-
break;
|
2132 |
-
case 'last_login':
|
2133 |
-
$offset = 0;
|
2134 |
-
if ( is_numeric( $gmt_offset ) ) {
|
2135 |
-
$offset = $gmt_offset;
|
2136 |
-
}
|
2137 |
-
|
2138 |
-
$from_date = (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ); // client time zone offset
|
2139 |
-
$to_date = (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1; // time 23:59
|
2140 |
-
$meta_query = array(
|
2141 |
-
array(
|
2142 |
-
'key' => '_um_last_login',
|
2143 |
-
'value' => array( $from_date, $to_date ),
|
2144 |
-
'compare' => 'BETWEEN',
|
2145 |
-
'inclusive' => true,
|
2146 |
-
)
|
2147 |
-
);
|
2148 |
-
|
2149 |
-
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $meta_query ) );
|
2150 |
-
break;
|
2151 |
-
}
|
2152 |
-
}
|
2153 |
-
}
|
2154 |
-
|
2155 |
-
|
2156 |
-
/**
|
2157 |
-
* Get data array for pagination
|
2158 |
-
*
|
2159 |
-
*
|
2160 |
-
* @param array $directory_data
|
2161 |
-
* @param int $total_users
|
2162 |
-
*
|
2163 |
-
* @return array
|
2164 |
-
*/
|
2165 |
-
function calculate_pagination( $directory_data, $total_users ) {
|
2166 |
-
|
2167 |
-
$current_page = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
|
2168 |
-
|
2169 |
-
$total_users = ( ! empty( $directory_data['max_users'] ) && $directory_data['max_users'] <= $total_users ) ? $directory_data['max_users'] : $total_users;
|
2170 |
-
|
2171 |
-
// number of profiles for mobile
|
2172 |
-
$profiles_per_page = $directory_data['profiles_per_page'];
|
2173 |
-
if ( UM()->mobile()->isMobile() && isset( $directory_data['profiles_per_page_mobile'] ) ) {
|
2174 |
-
$profiles_per_page = $directory_data['profiles_per_page_mobile'];
|
2175 |
-
}
|
2176 |
-
|
2177 |
-
$total_pages = 1;
|
2178 |
-
if ( ! empty( $profiles_per_page ) ) {
|
2179 |
-
$total_pages = ceil( $total_users / $profiles_per_page );
|
2180 |
-
}
|
2181 |
-
|
2182 |
-
if ( ! empty( $total_pages ) ) {
|
2183 |
-
$index1 = 0 - ( $current_page - 2 ) + 1;
|
2184 |
-
$to = $current_page + 2;
|
2185 |
-
if ( $index1 > 0 ) {
|
2186 |
-
$to += $index1;
|
2187 |
-
}
|
2188 |
-
|
2189 |
-
$index2 = $total_pages - ( $current_page + 2 );
|
2190 |
-
$from = $current_page - 2;
|
2191 |
-
if ( $index2 < 0 ) {
|
2192 |
-
$from += $index2;
|
2193 |
-
}
|
2194 |
-
|
2195 |
-
$pages_to_show = range(
|
2196 |
-
( $from > 0 ) ? $from : 1,
|
2197 |
-
( $to <= $total_pages ) ? $to : $total_pages
|
2198 |
-
);
|
2199 |
-
}
|
2200 |
-
|
2201 |
-
|
2202 |
-
$pagination_data = array(
|
2203 |
-
'pages_to_show' => ( ! empty( $pages_to_show ) && count( $pages_to_show ) > 1 ) ? array_values( $pages_to_show ) : array(),
|
2204 |
-
'current_page' => $current_page,
|
2205 |
-
'total_pages' => $total_pages,
|
2206 |
-
'total_users' => $total_users,
|
2207 |
-
);
|
2208 |
-
|
2209 |
-
$pagination_data['header'] = $this->convert_tags( $directory_data['header'], $pagination_data );
|
2210 |
-
$pagination_data['header_single'] = $this->convert_tags( $directory_data['header_single'], $pagination_data );
|
2211 |
-
|
2212 |
-
return $pagination_data;
|
2213 |
-
}
|
2214 |
-
|
2215 |
-
|
2216 |
-
/**
|
2217 |
-
* @param int $user_id
|
2218 |
-
*
|
2219 |
-
* @return array
|
2220 |
-
*/
|
2221 |
-
function build_user_actions_list( $user_id ) {
|
2222 |
-
|
2223 |
-
$actions = array();
|
2224 |
-
if ( ! is_user_logged_in() ) {
|
2225 |
-
return $actions;
|
2226 |
-
}
|
2227 |
-
|
2228 |
-
if ( get_current_user_id() != $user_id ) {
|
2229 |
-
|
2230 |
-
if ( UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
|
2231 |
-
$actions['um-editprofile'] = array(
|
2232 |
-
'title' => __( 'Edit Profile', 'ultimate-member' ),
|
2233 |
-
'url' => um_edit_profile_url(),
|
2234 |
-
);
|
2235 |
-
}
|
2236 |
-
|
2237 |
-
/**
|
2238 |
-
* UM hook
|
2239 |
-
*
|
2240 |
-
* @type filter
|
2241 |
-
* @title um_admin_user_actions_hook
|
2242 |
-
* @description Extend admin actions for each user
|
2243 |
-
* @input_vars
|
2244 |
-
* [{"var":"$actions","type":"array","desc":"Actions for user"}]
|
2245 |
-
* @change_log
|
2246 |
-
* ["Since: 2.0"]
|
2247 |
-
* @usage
|
2248 |
-
* <?php add_filter( 'um_admin_user_actions_hook', 'function_name', 10, 1 ); ?>
|
2249 |
-
* @example
|
2250 |
-
* <?php
|
2251 |
-
* add_filter( 'um_admin_user_actions_hook', 'my_admin_user_actions', 10, 1 );
|
2252 |
-
* function my_admin_user_actions( $actions ) {
|
2253 |
-
* // your code here
|
2254 |
-
* return $actions;
|
2255 |
-
* }
|
2256 |
-
* ?>
|
2257 |
-
*/
|
2258 |
-
$admin_actions = apply_filters( 'um_admin_user_actions_hook', array(), $user_id );
|
2259 |
-
if ( ! empty( $admin_actions ) ) {
|
2260 |
-
foreach ( $admin_actions as $id => $arr ) {
|
2261 |
-
$url = add_query_arg( array( 'um_action' => $id, 'uid' => $user_id ), um_get_core_page( 'user' ) );
|
2262 |
-
|
2263 |
-
$actions[ $id ] = array(
|
2264 |
-
'title' => $arr['label'],
|
2265 |
-
'url' => $url,
|
2266 |
-
);
|
2267 |
-
}
|
2268 |
-
}
|
2269 |
-
|
2270 |
-
$actions = apply_filters( 'um_member_directory_users_card_actions', $actions, $user_id );
|
2271 |
-
|
2272 |
-
} else {
|
2273 |
-
|
2274 |
-
if ( empty( UM()->user()->cannot_edit ) ) {
|
2275 |
-
$actions['um-editprofile'] = array(
|
2276 |
-
'title' => __( 'Edit Profile', 'ultimate-member' ),
|
2277 |
-
'url' => um_edit_profile_url(),
|
2278 |
-
);
|
2279 |
-
}
|
2280 |
-
|
2281 |
-
$actions['um-myaccount'] = array(
|
2282 |
-
'title' => __( 'My Account', 'ultimate-member' ),
|
2283 |
-
'url' => um_get_core_page( 'account' ),
|
2284 |
-
);
|
2285 |
-
|
2286 |
-
$actions['um-logout'] = array(
|
2287 |
-
'title' => __( 'Logout', 'ultimate-member' ),
|
2288 |
-
'url' => um_get_core_page( 'logout' ),
|
2289 |
-
);
|
2290 |
-
|
2291 |
-
$actions = apply_filters( 'um_member_directory_my_user_card_actions', $actions, $user_id );
|
2292 |
-
}
|
2293 |
-
|
2294 |
-
|
2295 |
-
return $actions;
|
2296 |
-
}
|
2297 |
-
|
2298 |
-
|
2299 |
-
/**
|
2300 |
-
* @param int $user_id
|
2301 |
-
* @param array $directory_data
|
2302 |
-
*
|
2303 |
-
* @return array
|
2304 |
-
*/
|
2305 |
-
function build_user_card_data( $user_id, $directory_data ) {
|
2306 |
-
|
2307 |
-
um_fetch_user( $user_id );
|
2308 |
-
|
2309 |
-
$dropdown_actions = $this->build_user_actions_list( $user_id );
|
2310 |
-
|
2311 |
-
$actions = array();
|
2312 |
-
$can_edit = UM()->roles()->um_current_user_can( 'edit', $user_id );
|
2313 |
-
|
2314 |
-
// Replace hook 'um_members_just_after_name'
|
2315 |
-
ob_start();
|
2316 |
-
do_action( 'um_members_just_after_name', $user_id, $directory_data );
|
2317 |
-
$hook_just_after_name = ob_get_clean();
|
2318 |
-
|
2319 |
-
// Replace hook 'um_members_after_user_name'
|
2320 |
-
ob_start();
|
2321 |
-
do_action( 'um_members_after_user_name', $user_id, $directory_data );
|
2322 |
-
$hook_after_user_name = ob_get_clean();
|
2323 |
-
|
2324 |
-
$data_array = array(
|
2325 |
-
'card_anchor' => substr( md5( $user_id ), 10, 5 ),
|
2326 |
-
'id' => $user_id,
|
2327 |
-
'role' => um_user( 'role' ),
|
2328 |
-
'account_status' => um_user( 'account_status' ),
|
2329 |
-
'account_status_name' => um_user( 'account_status_name' ),
|
2330 |
-
'cover_photo' => um_user( 'cover_photo', $this->cover_size ),
|
2331 |
-
'display_name' => um_user( 'display_name' ),
|
2332 |
-
'profile_url' => um_user_profile_url(),
|
2333 |
-
'can_edit' => $can_edit,
|
2334 |
-
'edit_profile_url' => um_edit_profile_url(),
|
2335 |
-
'avatar' => get_avatar( $user_id, $this->avatar_size ),
|
2336 |
-
'display_name_html' => um_user( 'display_name', 'html' ),
|
2337 |
-
'dropdown_actions' => $dropdown_actions,
|
2338 |
-
'hook_just_after_name' => preg_replace( '/^\s+/im', '', $hook_just_after_name ),
|
2339 |
-
'hook_after_user_name' => preg_replace( '/^\s+/im', '', $hook_after_user_name ),
|
2340 |
-
);
|
2341 |
-
|
2342 |
-
if ( ! empty( $directory_data['show_tagline'] ) ) {
|
2343 |
-
|
2344 |
-
if ( ! empty( $directory_data['tagline_fields'] ) ) {
|
2345 |
-
$directory_data['tagline_fields'] = maybe_unserialize( $directory_data['tagline_fields'] );
|
2346 |
-
|
2347 |
-
if ( is_array( $directory_data['tagline_fields'] ) ) {
|
2348 |
-
foreach ( $directory_data['tagline_fields'] as $key ) {
|
2349 |
-
if ( ! $key ) {
|
2350 |
-
continue;
|
2351 |
-
}
|
2352 |
-
|
2353 |
-
$value = um_filtered_value( $key );
|
2354 |
-
|
2355 |
-
if ( ! $value ) {
|
2356 |
-
continue;
|
2357 |
-
}
|
2358 |
-
|
2359 |
-
$data_array[ $key ] = $value;
|
2360 |
-
}
|
2361 |
-
}
|
2362 |
-
}
|
2363 |
-
}
|
2364 |
-
|
2365 |
-
if ( ! empty( $directory_data['show_userinfo'] ) ) {
|
2366 |
-
|
2367 |
-
if ( ! empty( $directory_data['reveal_fields'] ) ) {
|
2368 |
-
|
2369 |
-
$directory_data['reveal_fields'] = maybe_unserialize( $directory_data['reveal_fields'] );
|
2370 |
-
|
2371 |
-
if ( is_array( $directory_data['reveal_fields'] ) ) {
|
2372 |
-
foreach ( $directory_data['reveal_fields'] as $key ) {
|
2373 |
-
if ( ! $key ) {
|
2374 |
-
continue;
|
2375 |
-
}
|
2376 |
-
|
2377 |
-
$value = um_filtered_value( $key );
|
2378 |
-
if ( ! $value ) {
|
2379 |
-
continue;
|
2380 |
-
}
|
2381 |
-
|
2382 |
-
$label = UM()->fields()->get_label( $key );
|
2383 |
-
if ( $key == 'role_select' || $key == 'role_radio' ) {
|
2384 |
-
$label = strtr( $label, array(
|
2385 |
-
' (Dropdown)' => '',
|
2386 |
-
' (Radio)' => ''
|
2387 |
-
) );
|
2388 |
-
}
|
2389 |
-
|
2390 |
-
$data_array[ "label_{$key}" ] = __( $label, 'ultimate-member' );
|
2391 |
-
$data_array[ $key ] = $value;
|
2392 |
-
}
|
2393 |
-
}
|
2394 |
-
}
|
2395 |
-
|
2396 |
-
if ( ! empty( $directory_data['show_social'] ) ) {
|
2397 |
-
ob_start();
|
2398 |
-
UM()->fields()->show_social_urls();
|
2399 |
-
$social_urls = ob_get_clean();
|
2400 |
-
|
2401 |
-
$data_array['social_urls'] = $social_urls;
|
2402 |
-
}
|
2403 |
-
}
|
2404 |
-
|
2405 |
-
$data_array = apply_filters( 'um_ajax_get_members_data', $data_array, $user_id, $directory_data );
|
2406 |
-
|
2407 |
-
um_reset_user_clean();
|
2408 |
-
|
2409 |
-
return $data_array;
|
2410 |
-
}
|
2411 |
-
|
2412 |
-
|
2413 |
-
/**
|
2414 |
-
* Update limit query
|
2415 |
-
*
|
2416 |
-
* @param $user_query
|
2417 |
-
*/
|
2418 |
-
function pagination_changes( $user_query ) {
|
2419 |
-
global $wpdb;
|
2420 |
-
|
2421 |
-
$directory_id = $this->get_directory_by_hash( sanitize_key( $_POST['directory_id'] ) );
|
2422 |
-
$directory_data = UM()->query()->post_data( $directory_id );
|
2423 |
-
|
2424 |
-
$qv = $user_query->query_vars;
|
2425 |
-
|
2426 |
-
$number = $qv['number'];
|
2427 |
-
if ( ! empty( $directory_data['max_users'] ) && $qv['paged']*$qv['number'] > $directory_data['max_users'] ) {
|
2428 |
-
$number = ( $qv['paged']*$qv['number'] - ( $qv['paged']*$qv['number'] - $directory_data['max_users'] ) ) % $qv['number'];
|
2429 |
-
}
|
2430 |
-
|
2431 |
-
// limit
|
2432 |
-
if ( isset( $qv['number'] ) && $qv['number'] > 0 ) {
|
2433 |
-
if ( $qv['offset'] ) {
|
2434 |
-
$user_query->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['offset'], $number );
|
2435 |
-
} else {
|
2436 |
-
$user_query->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['number'] * ( $qv['paged'] - 1 ), $number );
|
2437 |
-
}
|
2438 |
-
}
|
2439 |
-
}
|
2440 |
-
|
2441 |
-
|
2442 |
-
function predefined_no_caps( $directory_data ) {
|
2443 |
-
//predefined result for user without capabilities to see other members
|
2444 |
-
if ( is_user_logged_in() && ! UM()->roles()->um_user_can( 'can_view_all' ) ) {
|
2445 |
-
$pagination_data = array(
|
2446 |
-
'pages_to_show' => array(),
|
2447 |
-
'current_page' => 1,
|
2448 |
-
'total_pages' => 0,
|
2449 |
-
'total_users' => 0,
|
2450 |
-
);
|
2451 |
-
|
2452 |
-
$pagination_data['header'] = $this->convert_tags( $directory_data['header'], $pagination_data );
|
2453 |
-
$pagination_data['header_single'] = $this->convert_tags( $directory_data['header_single'], $pagination_data );
|
2454 |
-
|
2455 |
-
wp_send_json_success( array( 'users' => array(), 'pagination' => $pagination_data ) );
|
2456 |
-
}
|
2457 |
-
}
|
2458 |
-
|
2459 |
-
|
2460 |
-
/**
|
2461 |
-
* Main Query function for getting members via AJAX
|
2462 |
-
*/
|
2463 |
-
function ajax_get_members() {
|
2464 |
-
UM()->check_ajax_nonce();
|
2465 |
-
|
2466 |
-
global $wpdb;
|
2467 |
-
|
2468 |
-
|
2469 |
-
|
2470 |
-
|
2471 |
-
|
2472 |
-
$this->
|
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 |
-
// handle
|
2499 |
-
$this->
|
2500 |
-
|
2501 |
-
// handle general
|
2502 |
-
$this->
|
2503 |
-
|
2504 |
-
// handle
|
2505 |
-
$this->
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 $sorting_supported_fields = array();
|
55 |
+
|
56 |
+
|
57 |
+
var $filter_types = array();
|
58 |
+
|
59 |
+
|
60 |
+
var $core_search_fields = array(
|
61 |
+
'user_login',
|
62 |
+
'user_url',
|
63 |
+
'display_name',
|
64 |
+
'user_email',
|
65 |
+
'user_nicename',
|
66 |
+
);
|
67 |
+
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @var
|
71 |
+
*/
|
72 |
+
var $query_args;
|
73 |
+
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @var User Card cover size
|
77 |
+
*/
|
78 |
+
var $cover_size;
|
79 |
+
|
80 |
+
|
81 |
+
/**
|
82 |
+
* @var User Avatar size
|
83 |
+
*/
|
84 |
+
var $avatar_size;
|
85 |
+
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @var bool Searching marker
|
89 |
+
*/
|
90 |
+
var $is_search = false;
|
91 |
+
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Member_Directory constructor.
|
95 |
+
*/
|
96 |
+
function __construct() {
|
97 |
+
add_filter( 'init', array( &$this, 'init_variables' ) );
|
98 |
+
|
99 |
+
add_action( 'template_redirect', array( &$this, 'access_members' ), 555 );
|
100 |
+
}
|
101 |
+
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @return bool
|
105 |
+
*/
|
106 |
+
function get_hide_in_members_default() {
|
107 |
+
$default = false;
|
108 |
+
$option = UM()->options()->get( 'account_hide_in_directory_default' );
|
109 |
+
if ( $option == 'Yes' ) {
|
110 |
+
$default = true;
|
111 |
+
}
|
112 |
+
|
113 |
+
$default = apply_filters( 'um_member_directory_hide_in_members_default', $default );
|
114 |
+
return $default;
|
115 |
+
}
|
116 |
+
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Getting member directory post ID via hash
|
120 |
+
* Hash is unique attr, which we use visible at frontend
|
121 |
+
*
|
122 |
+
* @param string $hash
|
123 |
+
*
|
124 |
+
* @return bool|int
|
125 |
+
*/
|
126 |
+
function get_directory_by_hash( $hash ) {
|
127 |
+
global $wpdb;
|
128 |
+
|
129 |
+
$directory_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE SUBSTRING( MD5( ID ), 11, 5 ) = %s", $hash ) );
|
130 |
+
|
131 |
+
if ( empty( $directory_id ) ) {
|
132 |
+
return false;
|
133 |
+
}
|
134 |
+
|
135 |
+
return (int) $directory_id;
|
136 |
+
}
|
137 |
+
|
138 |
+
|
139 |
+
/**
|
140 |
+
* @param $id
|
141 |
+
*
|
142 |
+
* @return bool|string
|
143 |
+
*/
|
144 |
+
function get_directory_hash( $id ) {
|
145 |
+
$hash = substr( md5( $id ), 10, 5 );
|
146 |
+
return $hash;
|
147 |
+
}
|
148 |
+
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Get view Type template
|
152 |
+
* @param string $type
|
153 |
+
*
|
154 |
+
* @return string
|
155 |
+
*/
|
156 |
+
function get_type_basename( $type ) {
|
157 |
+
return apply_filters( "um_member_directory_{$type}_type_template_basename", '' );
|
158 |
+
}
|
159 |
+
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Tag conversion for member directory
|
163 |
+
*
|
164 |
+
* @param string $string
|
165 |
+
* @param array $array
|
166 |
+
*
|
167 |
+
* @return string
|
168 |
+
*/
|
169 |
+
function convert_tags( $string, $array ) {
|
170 |
+
|
171 |
+
$search = array(
|
172 |
+
'{total_users}',
|
173 |
+
);
|
174 |
+
|
175 |
+
$replace = array(
|
176 |
+
$array['total_users'],
|
177 |
+
);
|
178 |
+
|
179 |
+
$string = str_replace( $search, $replace, $string );
|
180 |
+
return $string;
|
181 |
+
}
|
182 |
+
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Members page allowed?
|
186 |
+
*
|
187 |
+
* can be disabled by "Enable Members Directory" option
|
188 |
+
*
|
189 |
+
*/
|
190 |
+
function access_members() {
|
191 |
+
if ( UM()->options()->get( 'members_page' ) == 0 && um_is_core_page( 'members' ) ) {
|
192 |
+
um_redirect_home();
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
|
197 |
+
/**
|
198 |
+
* @param $value
|
199 |
+
* @param $key
|
200 |
+
* @param $post_id
|
201 |
+
*
|
202 |
+
* @return array
|
203 |
+
*/
|
204 |
+
public function before_save_data( $value, $key, $post_id ) {
|
205 |
+
|
206 |
+
$post = get_post( $post_id );
|
207 |
+
|
208 |
+
if ( 'um_directory' === $post->post_type ) {
|
209 |
+
|
210 |
+
if ( ! empty( $value ) && in_array( $key, array( '_um_view_types', '_um_roles', '_um_roles_can_search', '_um_roles_can_filter' ), true ) ) {
|
211 |
+
$value = array_keys( $value );
|
212 |
+
} elseif ( '_um_search_filters' === $key ) {
|
213 |
+
|
214 |
+
$temp_value = array();
|
215 |
+
|
216 |
+
if ( ! empty( $value ) ) {
|
217 |
+
foreach ( $value as $k ) {
|
218 |
+
$filter_type = $this->filter_types[ $k ];
|
219 |
+
if ( ! empty( $filter_type ) ) {
|
220 |
+
if ( 'slider' === $filter_type ) {
|
221 |
+
if ( ! empty( $_POST[ $k ] ) ) {
|
222 |
+
if ( count( $_POST[ $k ] ) > 1 ) {
|
223 |
+
$temp_value[ $k ] = array_map( 'intval', $_POST[ $k ] );
|
224 |
+
} else {
|
225 |
+
$temp_value[ $k ] = (int) $_POST[ $k ];
|
226 |
+
}
|
227 |
+
}
|
228 |
+
} elseif ( 'timepicker' === $filter_type || 'datepicker' === $filter_type ) {
|
229 |
+
if ( ! empty( $_POST[ $k . '_from' ] ) && ! empty( $_POST[ $k . '_to' ] ) ) {
|
230 |
+
$temp_value[ $k ] = array(
|
231 |
+
sanitize_text_field( $_POST[ $k . '_from' ] ),
|
232 |
+
sanitize_text_field( $_POST[ $k . '_to' ] ),
|
233 |
+
);
|
234 |
+
}
|
235 |
+
} elseif ( 'select' === $filter_type ) {
|
236 |
+
if ( ! empty( $_POST[ $k ] ) ) {
|
237 |
+
if ( is_array( $_POST[ $k ] ) ) {
|
238 |
+
$temp_value[ $k ] = array_map( 'trim', $_POST[ $k ] );
|
239 |
+
} else {
|
240 |
+
$temp_value[ $k ] = array( trim( $_POST[ $k ] ) );
|
241 |
+
}
|
242 |
+
|
243 |
+
$temp_value[ $k ] = array_map( 'sanitize_text_field', $temp_value[ $k ] );
|
244 |
+
}
|
245 |
+
} else {
|
246 |
+
if ( ! empty( $_POST[ $k ] ) ) {
|
247 |
+
$temp_value[ $k ] = trim( sanitize_text_field( $_POST[ $k ] ) );
|
248 |
+
}
|
249 |
+
}
|
250 |
+
}
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
+
$value = $temp_value;
|
255 |
+
} elseif ( '_um_sorting_fields' === $key ) {
|
256 |
+
if ( ! empty( $value['other_data'] ) ) {
|
257 |
+
$other_data = $value['other_data'];
|
258 |
+
unset( $value['other_data'] );
|
259 |
+
|
260 |
+
foreach ( $value as $k => &$row ) {
|
261 |
+
if ( ! empty( $other_data[ $k ]['meta_key'] ) ) {
|
262 |
+
$metakey = sanitize_text_field( $other_data[ $k ]['meta_key'] );
|
263 |
+
if ( ! empty( $metakey ) ) {
|
264 |
+
if ( ! empty( $other_data[ $k ]['label'] ) ) {
|
265 |
+
$metalabel = wp_strip_all_tags( $other_data[ $k ]['label'] );
|
266 |
+
}
|
267 |
+
$row = array(
|
268 |
+
$metakey => ! empty( $metalabel ) ? $metalabel : $metakey,
|
269 |
+
);
|
270 |
+
}
|
271 |
+
}
|
272 |
+
}
|
273 |
+
}
|
274 |
+
} elseif ( '_um_sortby_custom' === $key ) {
|
275 |
+
$value = sanitize_text_field( $value );
|
276 |
+
} elseif ( '_um_sortby_custom_label' === $key ) {
|
277 |
+
$value = wp_strip_all_tags( $value );
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
return $value;
|
282 |
+
}
|
283 |
+
|
284 |
+
|
285 |
+
/**
|
286 |
+
*
|
287 |
+
*/
|
288 |
+
function init_variables() {
|
289 |
+
|
290 |
+
// Types
|
291 |
+
$this->view_types = apply_filters( 'um_member_directory_views', array(
|
292 |
+
'grid' => array( 'title' => __( 'Grid', 'ultimate-member' ), 'icon' => 'um-faicon-th' ),
|
293 |
+
'list' => array( 'title' => __( 'List', 'ultimate-member' ), 'icon' => 'um-faicon-list' ),
|
294 |
+
) );
|
295 |
+
|
296 |
+
// Sort
|
297 |
+
$this->sort_fields = apply_filters( 'um_members_directory_sort_fields', array(
|
298 |
+
'user_registered_desc' => __( 'New users first', 'ultimate-member' ),
|
299 |
+
'user_registered_asc' => __( 'Old users first', 'ultimate-member' ),
|
300 |
+
'username' => __( 'Username', 'ultimate-member' ),
|
301 |
+
'nickname' => __( 'Nickname', 'ultimate-member' ),
|
302 |
+
'first_name' => __( 'First name', 'ultimate-member' ),
|
303 |
+
'last_name' => __( 'Last name', 'ultimate-member' ),
|
304 |
+
'display_name' => __( 'Display name', 'ultimate-member' ),
|
305 |
+
'last_first_name' => __( 'Last & First name', 'ultimate-member' ),
|
306 |
+
'last_login' => __( 'Last login', 'ultimate-member' ),
|
307 |
+
) );
|
308 |
+
|
309 |
+
$this->sorting_supported_fields = apply_filters( 'um_members_directory_custom_field_types_supported_sorting', array( 'number' ) );
|
310 |
+
|
311 |
+
if ( ! empty( UM()->builtin()->saved_fields ) ) {
|
312 |
+
foreach ( UM()->builtin()->saved_fields as $key => $data ) {
|
313 |
+
if ( $key == '_um_last_login' ) {
|
314 |
+
continue;
|
315 |
+
}
|
316 |
+
|
317 |
+
if ( isset( $data['type'] ) && in_array( $data['type'], $this->sorting_supported_fields ) ) {
|
318 |
+
if ( isset( $data['title'] ) && array_search( sprintf( __( '%s DESC', 'ultimate-member' ), $data['title'] ), $this->sort_fields ) !== false ) {
|
319 |
+
$data['title'] = $data['title'] . ' (' . $key . ')';
|
320 |
+
}
|
321 |
+
|
322 |
+
$title = isset( $data['title'] ) ? $data['title'] : ( isset( $data['label'] ) ? $data['label'] : '' );
|
323 |
+
if ( empty( $title ) ) {
|
324 |
+
continue;
|
325 |
+
}
|
326 |
+
|
327 |
+
$this->sort_fields[ $key . '_desc' ] = sprintf( __( '%s DESC', 'ultimate-member' ), $title );
|
328 |
+
$this->sort_fields[ $key . '_asc' ] = sprintf( __( '%s ASC', 'ultimate-member' ), $title );
|
329 |
+
}
|
330 |
+
}
|
331 |
+
}
|
332 |
+
|
333 |
+
asort( $this->sort_fields );
|
334 |
+
|
335 |
+
$this->default_sorting = apply_filters( 'um_members_directory_default_sort', array_merge( $this->sort_fields, array(
|
336 |
+
'random' => __( 'Random', 'ultimate-member' ),
|
337 |
+
'other' => __( 'Other (Custom Field)', 'ultimate-member' ),
|
338 |
+
) ) );
|
339 |
+
|
340 |
+
asort( $this->default_sorting );
|
341 |
+
|
342 |
+
// Filters
|
343 |
+
$this->filter_fields = array(
|
344 |
+
'country' => __( 'Country', 'ultimate-member' ),
|
345 |
+
'gender' => __( 'Gender', 'ultimate-member' ),
|
346 |
+
'languages' => __( 'Languages', 'ultimate-member' ),
|
347 |
+
'role' => __( 'Roles', 'ultimate-member' ),
|
348 |
+
'birth_date' => __( 'Age', 'ultimate-member' ),
|
349 |
+
'last_login' => __( 'Last Login', 'ultimate-member' ),
|
350 |
+
'user_registered' => __( 'User Registered', 'ultimate-member' ),
|
351 |
+
'first_name' => __( 'First Name', 'ultimate-member' ),
|
352 |
+
'last_name' => __( 'Last Name', 'ultimate-member' ),
|
353 |
+
'nickname' => __( 'Nickname', 'ultimate-member' ),
|
354 |
+
'secondary_user_email' => __( 'Secondary E-mail Address', 'ultimate-member' ),
|
355 |
+
'description' => __( 'Biography', 'ultimate-member' ),
|
356 |
+
'phone_number' => __( 'Phone Number', 'ultimate-member' ),
|
357 |
+
'mobile_number' => __( 'Mobile Number', 'ultimate-member' ),
|
358 |
+
);
|
359 |
+
|
360 |
+
$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' ) );
|
361 |
+
|
362 |
+
if ( ! empty( UM()->builtin()->saved_fields ) ) {
|
363 |
+
foreach ( UM()->builtin()->saved_fields as $key => $data ) {
|
364 |
+
|
365 |
+
if ( $key == '_um_last_login' ) {
|
366 |
+
continue;
|
367 |
+
}
|
368 |
+
|
369 |
+
if ( isset( $data['type'] ) && in_array( $data['type'], $this->filter_supported_fields ) ) {
|
370 |
+
if ( isset( $data['title'] ) && array_search( $data['title'], $this->filter_fields ) !== false ) {
|
371 |
+
$data['title'] = $data['title'] . ' (' . $key . ')';
|
372 |
+
}
|
373 |
+
|
374 |
+
$title = isset( $data['title'] ) ? $data['title'] : ( isset( $data['label'] ) ? $data['label'] : '' );
|
375 |
+
if ( empty( $title ) ) {
|
376 |
+
continue;
|
377 |
+
}
|
378 |
+
|
379 |
+
$this->filter_fields[ $key ] = $title;
|
380 |
+
}
|
381 |
+
}
|
382 |
+
}
|
383 |
+
|
384 |
+
$this->filter_fields = apply_filters( 'um_members_directory_filter_fields', $this->filter_fields );
|
385 |
+
|
386 |
+
ksort( $this->filter_fields );
|
387 |
+
|
388 |
+
$this->filter_types = apply_filters( 'um_members_directory_filter_types', array(
|
389 |
+
'country' => 'select',
|
390 |
+
'gender' => 'select',
|
391 |
+
'languages' => 'select',
|
392 |
+
'role' => 'select',
|
393 |
+
'birth_date' => 'slider',
|
394 |
+
'last_login' => 'datepicker',
|
395 |
+
'user_registered' => 'datepicker',
|
396 |
+
'first_name' => 'text',
|
397 |
+
'last_name' => 'text',
|
398 |
+
'nickname' => 'text',
|
399 |
+
'secondary_user_email' => 'text',
|
400 |
+
'description' => 'text',
|
401 |
+
'phone_number' => 'text',
|
402 |
+
'mobile_number' => 'text',
|
403 |
+
) );
|
404 |
+
|
405 |
+
$fields = UM()->builtin()->all_user_fields;
|
406 |
+
|
407 |
+
$custom_fields_types = array_flip( array_keys( $this->filter_fields ) );
|
408 |
+
foreach ( $custom_fields_types as $key => &$value ) {
|
409 |
+
if ( ! isset( $fields[ $key ] ) ) {
|
410 |
+
unset( $custom_fields_types[ $key ] );
|
411 |
+
} else {
|
412 |
+
switch ( $fields[ $key ]['type'] ) {
|
413 |
+
default:
|
414 |
+
$value = apply_filters( 'um_custom_field_filter_type', 'select', $fields[ $key ] );
|
415 |
+
break;
|
416 |
+
case 'text':
|
417 |
+
case 'textarea':
|
418 |
+
$value = 'text';
|
419 |
+
break;
|
420 |
+
case 'date':
|
421 |
+
$value = 'datepicker';
|
422 |
+
break;
|
423 |
+
case 'time':
|
424 |
+
$value = 'timepicker';
|
425 |
+
break;
|
426 |
+
case 'select':
|
427 |
+
case 'multiselect':
|
428 |
+
case 'radio':
|
429 |
+
case 'checkbox':
|
430 |
+
$value = 'select';
|
431 |
+
break;
|
432 |
+
case 'number':
|
433 |
+
case 'rating':
|
434 |
+
$value = 'slider';
|
435 |
+
break;
|
436 |
+
}
|
437 |
+
}
|
438 |
+
}
|
439 |
+
|
440 |
+
$this->filter_types = array_merge( $custom_fields_types, $this->filter_types );
|
441 |
+
}
|
442 |
+
|
443 |
+
|
444 |
+
/**
|
445 |
+
* Render member's directory
|
446 |
+
* filters selectboxes
|
447 |
+
*
|
448 |
+
* @param string $filter
|
449 |
+
* @param array $directory_data
|
450 |
+
* @param mixed $default_value
|
451 |
+
* @param bool $admin
|
452 |
+
*
|
453 |
+
* @return string $filter
|
454 |
+
*/
|
455 |
+
function show_filter( $filter, $directory_data, $default_value = false, $admin = false ) {
|
456 |
+
|
457 |
+
if ( empty( $this->filter_types[ $filter ] ) ) {
|
458 |
+
return '';
|
459 |
+
}
|
460 |
+
|
461 |
+
if ( $default_value === false ) {
|
462 |
+
$default_filters = array();
|
463 |
+
if ( ! empty( $directory_data['search_filters'] ) ) {
|
464 |
+
$default_filters = maybe_unserialize( $directory_data['search_filters'] );
|
465 |
+
}
|
466 |
+
|
467 |
+
if ( ! empty( $default_filters[ $filter ] ) && $this->filter_types[ $filter ] != 'select' ) {
|
468 |
+
return '';
|
469 |
+
}
|
470 |
+
}
|
471 |
+
|
472 |
+
$field_key = $filter;
|
473 |
+
if ( $filter == 'last_login' ) {
|
474 |
+
$field_key = '_um_last_login';
|
475 |
+
}
|
476 |
+
if ( $filter == 'role' ) {
|
477 |
+
$field_key = 'role_select';
|
478 |
+
}
|
479 |
+
|
480 |
+
$fields = UM()->builtin()->all_user_fields;
|
481 |
+
|
482 |
+
if ( isset( $fields[ $field_key ] ) ) {
|
483 |
+
$attrs = $fields[ $field_key ];
|
484 |
+
} else {
|
485 |
+
/**
|
486 |
+
* UM hook
|
487 |
+
*
|
488 |
+
* @type filter
|
489 |
+
* @title um_custom_search_field_{$filter}
|
490 |
+
* @description Custom search settings by $filter
|
491 |
+
* @input_vars
|
492 |
+
* [{"var":"$settings","type":"array","desc":"Search Settings"}]
|
493 |
+
* @change_log
|
494 |
+
* ["Since: 2.0"]
|
495 |
+
* @usage
|
496 |
+
* <?php add_filter( 'um_custom_search_field_{$filter}', 'function_name', 10, 1 ); ?>
|
497 |
+
* @example
|
498 |
+
* <?php
|
499 |
+
* add_filter( 'um_custom_search_field_{$filter}', 'my_custom_search_field', 10, 1 );
|
500 |
+
* function my_change_email_template_file( $settings ) {
|
501 |
+
* // your code here
|
502 |
+
* return $settings;
|
503 |
+
* }
|
504 |
+
* ?>
|
505 |
+
*/
|
506 |
+
$attrs = apply_filters( "um_custom_search_field_{$filter}", array(), $field_key );
|
507 |
+
}
|
508 |
+
|
509 |
+
// skip private invisible fields
|
510 |
+
if ( ! um_can_view_field( $attrs ) ) {
|
511 |
+
return '';
|
512 |
+
}
|
513 |
+
|
514 |
+
/**
|
515 |
+
* UM hook
|
516 |
+
*
|
517 |
+
* @type filter
|
518 |
+
* @title um_search_fields
|
519 |
+
* @description Filter all search fields
|
520 |
+
* @input_vars
|
521 |
+
* [{"var":"$settings","type":"array","desc":"Search Fields"}]
|
522 |
+
* @change_log
|
523 |
+
* ["Since: 2.0"]
|
524 |
+
* @usage
|
525 |
+
* <?php add_filter( 'um_search_fields', 'function_name', 10, 1 ); ?>
|
526 |
+
* @example
|
527 |
+
* <?php
|
528 |
+
* add_filter( 'um_search_fields', 'my_search_fields', 10, 1 );
|
529 |
+
* function my_search_fields( $settings ) {
|
530 |
+
* // your code here
|
531 |
+
* return $settings;
|
532 |
+
* }
|
533 |
+
* ?>
|
534 |
+
*/
|
535 |
+
$attrs = apply_filters( 'um_search_fields', $attrs, $field_key, $directory_data['form_id'] );
|
536 |
+
|
537 |
+
$unique_hash = substr( md5( $directory_data['form_id'] ), 10, 5 );
|
538 |
+
|
539 |
+
ob_start();
|
540 |
+
|
541 |
+
switch ( $this->filter_types[ $filter ] ) {
|
542 |
+
default: {
|
543 |
+
|
544 |
+
do_action( "um_member_directory_filter_type_{$this->filter_types[ $filter ]}", $filter, $directory_data, $unique_hash, $attrs, $default_value );
|
545 |
+
|
546 |
+
break;
|
547 |
+
}
|
548 |
+
case 'text': {
|
549 |
+
$filter_from_url = ! empty( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) ? sanitize_text_field( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) : $default_value; ?>
|
550 |
+
<input type="text" autocomplete="off" id="<?php echo $filter; ?>" name="<?php echo $filter; ?>"
|
551 |
+
placeholder="<?php esc_attr_e( stripslashes( $attrs['label'] ), 'ultimate-member' ); ?>"
|
552 |
+
value="<?php echo esc_attr( $filter_from_url ) ?>" class="um-form-field"
|
553 |
+
aria-label="<?php esc_attr_e( stripslashes( $attrs['label'] ), 'ultimate-member' ); ?>" />
|
554 |
+
<?php
|
555 |
+
break;
|
556 |
+
}
|
557 |
+
case 'select': {
|
558 |
+
|
559 |
+
// getting value from GET line
|
560 |
+
$filter_from_url = ! empty( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) ? explode( '||', sanitize_text_field( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) ) : array();
|
561 |
+
|
562 |
+
// new
|
563 |
+
global $wpdb;
|
564 |
+
|
565 |
+
if ( $attrs['metakey'] != 'role_select' ) {
|
566 |
+
$values_array = $wpdb->get_col(
|
567 |
+
$wpdb->prepare(
|
568 |
+
"SELECT DISTINCT meta_value
|
569 |
+
FROM $wpdb->usermeta
|
570 |
+
WHERE meta_key = %s AND
|
571 |
+
meta_value != ''",
|
572 |
+
$attrs['metakey']
|
573 |
+
)
|
574 |
+
);
|
575 |
+
} else {
|
576 |
+
$users_roles = count_users();
|
577 |
+
$values_array = ( ! empty( $users_roles['avail_roles'] ) && is_array( $users_roles['avail_roles'] ) ) ? array_keys( array_filter( $users_roles['avail_roles'] ) ) : array();
|
578 |
+
}
|
579 |
+
|
580 |
+
if ( ! empty( $values_array ) && in_array( $attrs['type'], array( 'select', 'multiselect', 'checkbox', 'radio' ) ) ) {
|
581 |
+
$values_array = array_map( 'maybe_unserialize', $values_array );
|
582 |
+
$temp_values = array();
|
583 |
+
foreach ( $values_array as $values ) {
|
584 |
+
if ( is_array( $values ) ) {
|
585 |
+
$temp_values = array_merge( $temp_values, $values );
|
586 |
+
} else {
|
587 |
+
$temp_values[] = $values;
|
588 |
+
}
|
589 |
+
}
|
590 |
+
$values_array = array_unique( $temp_values );
|
591 |
+
}
|
592 |
+
|
593 |
+
if ( $attrs['metakey'] != 'online_status' && empty( $values_array ) ) {
|
594 |
+
ob_get_clean();
|
595 |
+
return '';
|
596 |
+
}
|
597 |
+
|
598 |
+
if ( isset( $attrs['metakey'] ) && strstr( $attrs['metakey'], 'role_' ) ) {
|
599 |
+
$shortcode_roles = get_post_meta( $directory_data['form_id'], '_um_roles', true );
|
600 |
+
$um_roles = UM()->roles()->get_roles( false );
|
601 |
+
|
602 |
+
if ( ! empty( $shortcode_roles ) && is_array( $shortcode_roles ) ) {
|
603 |
+
$attrs['options'] = array();
|
604 |
+
|
605 |
+
foreach ( $um_roles as $key => $value ) {
|
606 |
+
if ( in_array( $key, $shortcode_roles ) ) {
|
607 |
+
$attrs['options'][ $key ] = $value;
|
608 |
+
}
|
609 |
+
}
|
610 |
+
} else {
|
611 |
+
$attrs['options'] = array();
|
612 |
+
|
613 |
+
foreach ( $um_roles as $key => $value ) {
|
614 |
+
$attrs['options'][ $key ] = $value;
|
615 |
+
}
|
616 |
+
}
|
617 |
+
}
|
618 |
+
|
619 |
+
$custom_dropdown = '';
|
620 |
+
if ( ! empty( $attrs['custom_dropdown_options_source'] ) ) {
|
621 |
+
$attrs['custom'] = true;
|
622 |
+
|
623 |
+
if ( ! empty( $attrs['parent_dropdown_relationship'] ) ) {
|
624 |
+
|
625 |
+
$custom_dropdown .= ' data-member-directory="yes"';
|
626 |
+
$custom_dropdown .= ' data-um-parent="' . esc_attr( $attrs['parent_dropdown_relationship'] ) . '"';
|
627 |
+
|
628 |
+
if ( isset( $_GET[ 'filter_' . $attrs['parent_dropdown_relationship'] . '_' . $unique_hash ] ) ) {
|
629 |
+
$_POST['parent_option_name'] = $attrs['parent_dropdown_relationship'];
|
630 |
+
$_POST['parent_option'] = explode( '||', filter_input( INPUT_GET, 'filter_' . $attrs['parent_dropdown_relationship'] . '_' . $unique_hash ) );
|
631 |
+
}
|
632 |
+
}
|
633 |
+
|
634 |
+
$attrs['custom_dropdown_options_source'] = wp_unslash( $attrs['custom_dropdown_options_source'] );
|
635 |
+
|
636 |
+
$ajax_source = apply_filters( "um_custom_dropdown_options_source__{$filter}", $attrs['custom_dropdown_options_source'], $attrs );
|
637 |
+
$custom_dropdown .= ' data-um-ajax-source="' . esc_attr( $ajax_source ) . '" ';
|
638 |
+
|
639 |
+
$attrs['options'] = UM()->fields()->get_options_from_callback( $attrs, $attrs['type'] );
|
640 |
+
} else {
|
641 |
+
/**
|
642 |
+
* UM hook
|
643 |
+
*
|
644 |
+
* @type filter
|
645 |
+
* @title um_select_option_value
|
646 |
+
* @description Enable options pair by field $data
|
647 |
+
* @input_vars
|
648 |
+
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
649 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
650 |
+
*/
|
651 |
+
$option_pairs = apply_filters( 'um_select_options_pair', null, $attrs );
|
652 |
+
}
|
653 |
+
|
654 |
+
if ( $attrs['metakey'] != 'online_status' ) {
|
655 |
+
if ( $attrs['metakey'] != 'role_select' && $attrs['metakey'] != 'mycred_rank' && empty( $custom_dropdown ) && empty( $option_pairs ) ) {
|
656 |
+
$attrs['options'] = array_intersect( array_map( 'stripslashes', array_map( 'trim', $attrs['options'] ) ), $values_array );
|
657 |
+
} elseif ( ! empty( $custom_dropdown ) ) {
|
658 |
+
$attrs['options'] = array_intersect_key( array_map( 'trim', $attrs['options'] ), array_flip( $values_array ) );
|
659 |
+
} else {
|
660 |
+
$attrs['options'] = array_intersect_key( array_map( 'trim', $attrs['options'] ), array_flip( $values_array ) );
|
661 |
+
}
|
662 |
+
}
|
663 |
+
|
664 |
+
$attrs['options'] = apply_filters( 'um_member_directory_filter_select_options', $attrs['options'], $values_array, $attrs );
|
665 |
+
|
666 |
+
if ( empty( $attrs['options'] ) || ! is_array( $attrs['options'] ) ) {
|
667 |
+
ob_get_clean();
|
668 |
+
return '';
|
669 |
+
}
|
670 |
+
|
671 |
+
if ( ! empty( $attrs['custom_dropdown_options_source'] ) && ! empty( $attrs['parent_dropdown_relationship'] ) ) {
|
672 |
+
$attrs['options'] = array();
|
673 |
+
}
|
674 |
+
|
675 |
+
if ( isset( $attrs['label'] ) ) {
|
676 |
+
$attrs['label'] = strip_tags( $attrs['label'] );
|
677 |
+
}
|
678 |
+
|
679 |
+
if ( ! empty( $default_filters[ $filter ] ) ) {
|
680 |
+
$attrs['options'] = array_intersect( $attrs['options'], $default_filters[ $filter ] );
|
681 |
+
}
|
682 |
+
|
683 |
+
ksort( $attrs['options'] );
|
684 |
+
|
685 |
+
$attrs['options'] = apply_filters( 'um_member_directory_filter_select_options_sorted', $attrs['options'], $attrs );
|
686 |
+
|
687 |
+
$label = isset( $attrs['label'] ) ? $attrs['label'] : ''; ?>
|
688 |
+
|
689 |
+
<select class="um-s1" id="<?php echo esc_attr( $filter ); ?>" name="<?php echo esc_attr( $filter ); ?><?php if ( $admin && count( $attrs['options'] ) > 1 ) { ?>[]<?php } ?>"
|
690 |
+
data-placeholder="<?php esc_attr_e( stripslashes( $label ), 'ultimate-member' ); ?>"
|
691 |
+
aria-label="<?php esc_attr_e( stripslashes( $label ), 'ultimate-member' ); ?>"
|
692 |
+
<?php if ( $admin && count( $attrs['options'] ) > 1 ) { ?>multiple<?php } ?>
|
693 |
+
<?php echo $custom_dropdown; ?>>
|
694 |
+
|
695 |
+
<option></option>
|
696 |
+
|
697 |
+
<?php if ( ! empty( $attrs['options'] ) ) {
|
698 |
+
foreach ( $attrs['options'] as $k => $v ) {
|
699 |
+
|
700 |
+
$v = stripslashes( $v );
|
701 |
+
|
702 |
+
$opt = $v;
|
703 |
+
|
704 |
+
if ( strstr( $filter, 'role_' ) || $filter == 'role' ) {
|
705 |
+
$opt = $k;
|
706 |
+
}
|
707 |
+
|
708 |
+
if ( isset( $attrs['custom'] ) ) {
|
709 |
+
$opt = $k;
|
710 |
+
}
|
711 |
+
|
712 |
+
if ( ! empty( $option_pairs ) ) {
|
713 |
+
$opt = $k;
|
714 |
+
} ?>
|
715 |
+
|
716 |
+
<option value="<?php echo esc_attr( $opt ); ?>" data-value_label="<?php esc_attr_e( $v, 'ultimate-member' ); ?>"
|
717 |
+
<?php disabled( ! empty( $filter_from_url ) && in_array( $opt, $filter_from_url ) );
|
718 |
+
|
719 |
+
if ( $admin ) {
|
720 |
+
if ( ! is_array( $default_value ) ) {
|
721 |
+
$default_value = array( $default_value );
|
722 |
+
}
|
723 |
+
|
724 |
+
selected( in_array( $opt, $default_value ) );
|
725 |
+
} else {
|
726 |
+
selected( $opt === $default_value );
|
727 |
+
} ?>>
|
728 |
+
<?php _e( $v, 'ultimate-member' ); ?>
|
729 |
+
</option>
|
730 |
+
|
731 |
+
<?php }
|
732 |
+
} ?>
|
733 |
+
|
734 |
+
</select>
|
735 |
+
|
736 |
+
<?php break;
|
737 |
+
}
|
738 |
+
case 'slider': {
|
739 |
+
$range = $this->slider_filters_range( $filter, $directory_data );
|
740 |
+
if ( $range ) {
|
741 |
+
list( $single_placeholder, $plural_placeholder ) = $this->slider_range_placeholder( $filter, $attrs ); ?>
|
742 |
+
|
743 |
+
<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 ) ) : '' ?>" />
|
744 |
+
<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 ) ) : '' ?>" />
|
745 |
+
<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>
|
746 |
+
<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>
|
747 |
+
<?php }
|
748 |
+
|
749 |
+
break;
|
750 |
+
}
|
751 |
+
case 'datepicker': {
|
752 |
+
|
753 |
+
$range = $this->datepicker_filters_range( $filter );
|
754 |
+
|
755 |
+
$label = ! empty( $attrs['label'] ) ? $attrs['label'] : $attrs['title'];
|
756 |
+
|
757 |
+
if ( $range ) { ?>
|
758 |
+
|
759 |
+
<input type="text" id="<?php echo $filter; ?>_from" name="<?php echo $filter; ?>_from" class="um-datepicker-filter"
|
760 |
+
placeholder="<?php esc_attr_e( sprintf( '%s From', stripslashes( $label ) ), 'ultimate-member' ); ?>"
|
761 |
+
data-filter-label="<?php echo esc_attr( stripslashes( $label ) ); ?>"
|
762 |
+
data-date_min="<?php echo $range[0] ?>" data-date_max="<?php echo $range[1] ?>"
|
763 |
+
data-filter_name="<?php echo $filter; ?>" data-range="from" data-value="<?php echo ! empty( $default_value ) ? esc_attr( strtotime( min( $default_value ) ) ) : '' ?>" />
|
764 |
+
<input type="text" id="<?php echo $filter; ?>_to" name="<?php echo $filter; ?>_to" class="um-datepicker-filter"
|
765 |
+
placeholder="<?php esc_attr_e( sprintf( '%s To', stripslashes( $label ) ), 'ultimate-member' ); ?>"
|
766 |
+
data-filter-label="<?php echo esc_attr( stripslashes( $label ) ); ?>"
|
767 |
+
data-date_min="<?php echo $range[0] ?>" data-date_max="<?php echo $range[1] ?>"
|
768 |
+
data-filter_name="<?php echo $filter; ?>" data-range="to" data-value="<?php echo ! empty( $default_value ) ? esc_attr( strtotime( max( $default_value ) ) ) : '' ?>" />
|
769 |
+
|
770 |
+
<?php }
|
771 |
+
|
772 |
+
break;
|
773 |
+
}
|
774 |
+
case 'timepicker': {
|
775 |
+
|
776 |
+
$range = $this->timepicker_filters_range( $filter );
|
777 |
+
|
778 |
+
$label = ! empty( $attrs['label'] ) ? $attrs['label'] : $attrs['title'];
|
779 |
+
|
780 |
+
switch ( $attrs['format'] ) {
|
781 |
+
case 'g:i a':
|
782 |
+
$js_format = 'h:i a';
|
783 |
+
break;
|
784 |
+
case 'g:i A':
|
785 |
+
$js_format = 'h:i A';
|
786 |
+
break;
|
787 |
+
case 'H:i':
|
788 |
+
$js_format = 'HH:i';
|
789 |
+
break;
|
790 |
+
}
|
791 |
+
|
792 |
+
if ( $range ) { ?>
|
793 |
+
|
794 |
+
<input type="text" id="<?php echo $filter; ?>_from" name="<?php echo $filter; ?>_from" class="um-timepicker-filter"
|
795 |
+
placeholder="<?php esc_attr_e( sprintf( '%s From', stripslashes( $label ) ), 'ultimate-member' ); ?>"
|
796 |
+
data-filter-label="<?php echo esc_attr( stripslashes( $label ) ); ?>"
|
797 |
+
data-min="<?php echo $range[0] ?>" data-max="<?php echo $range[1] ?>"
|
798 |
+
data-format="<?php echo esc_attr( $js_format ) ?>" data-intervals="<?php echo esc_attr( $attrs['intervals'] ) ?>"
|
799 |
+
data-filter_name="<?php echo $filter; ?>" data-range="from" />
|
800 |
+
<input type="text" id="<?php echo $filter; ?>_to" name="<?php echo $filter; ?>_to" class="um-timepicker-filter"
|
801 |
+
placeholder="<?php esc_attr_e( sprintf( '%s To', stripslashes( $label ) ), 'ultimate-member' ); ?>"
|
802 |
+
data-filter-label="<?php echo esc_attr( stripslashes( $label ) ); ?>"
|
803 |
+
data-min="<?php echo $range[0] ?>" data-max="<?php echo $range[1] ?>"
|
804 |
+
data-format="<?php echo esc_attr( $js_format ) ?>" data-intervals="<?php echo esc_attr( $attrs['intervals'] ) ?>"
|
805 |
+
data-filter_name="<?php echo $filter; ?>" data-range="to" />
|
806 |
+
|
807 |
+
<?php }
|
808 |
+
|
809 |
+
break;
|
810 |
+
}
|
811 |
+
}
|
812 |
+
|
813 |
+
$filter = ob_get_clean();
|
814 |
+
return $filter;
|
815 |
+
}
|
816 |
+
|
817 |
+
|
818 |
+
/**
|
819 |
+
* @param string $filter
|
820 |
+
* @param array $directory_data
|
821 |
+
*
|
822 |
+
* @return mixed
|
823 |
+
*/
|
824 |
+
function slider_filters_range( $filter, $directory_data ) {
|
825 |
+
global $wpdb;
|
826 |
+
|
827 |
+
$range = false;
|
828 |
+
|
829 |
+
switch ( $filter ) {
|
830 |
+
|
831 |
+
default: {
|
832 |
+
|
833 |
+
$meta = $wpdb->get_row( $wpdb->prepare(
|
834 |
+
"SELECT MIN( CONVERT( meta_value, DECIMAL ) ) as min_meta,
|
835 |
+
MAX( CONVERT( meta_value, DECIMAL ) ) as max_meta,
|
836 |
+
COUNT( DISTINCT meta_value ) as amount
|
837 |
+
FROM {$wpdb->usermeta}
|
838 |
+
WHERE meta_key = %s",
|
839 |
+
$filter
|
840 |
+
), ARRAY_A );
|
841 |
+
|
842 |
+
if ( isset( $meta['min_meta'] ) && isset( $meta['max_meta'] ) && isset( $meta['amount'] ) && $meta['amount'] > 1 ) {
|
843 |
+
$range = array( (float) $meta['min_meta'], (float) $meta['max_meta'] );
|
844 |
+
}
|
845 |
+
|
846 |
+
$range = apply_filters( 'um_member_directory_filter_slider_common', $range, $directory_data, $filter );
|
847 |
+
$range = apply_filters( "um_member_directory_filter_{$filter}_slider", $range, $directory_data );
|
848 |
+
|
849 |
+
break;
|
850 |
+
}
|
851 |
+
case 'birth_date': {
|
852 |
+
|
853 |
+
// $meta = $wpdb->get_col(
|
854 |
+
// "SELECT meta_value
|
855 |
+
// FROM {$wpdb->usermeta}
|
856 |
+
// WHERE meta_key = 'birth_date' AND
|
857 |
+
// meta_value != ''"
|
858 |
+
// );
|
859 |
+
//
|
860 |
+
// if ( empty( $meta ) || count( $meta ) < 2 ) {
|
861 |
+
// $range = false;
|
862 |
+
// } elseif ( is_array( $meta ) ) {
|
863 |
+
// $birth_dates = array_filter( array_map( 'strtotime', $meta ), 'is_numeric' );
|
864 |
+
// sort( $birth_dates );
|
865 |
+
// $min_meta = array_shift( $birth_dates );
|
866 |
+
// $max_meta = array_pop( $birth_dates );
|
867 |
+
// $range = array( $this->borndate( $max_meta ), $this->borndate( $min_meta ) );
|
868 |
+
// }
|
869 |
+
|
870 |
+
$meta = $wpdb->get_row(
|
871 |
+
"SELECT MIN( meta_value ) as min_meta,
|
872 |
+
MAX( meta_value ) as max_meta,
|
873 |
+
COUNT( DISTINCT meta_value ) as amount
|
874 |
+
FROM {$wpdb->usermeta}
|
875 |
+
WHERE meta_key = 'birth_date' AND
|
876 |
+
meta_value != ''",
|
877 |
+
ARRAY_A );
|
878 |
+
|
879 |
+
if ( isset( $meta['min_meta'] ) && isset( $meta['max_meta'] ) && isset( $meta['amount'] ) && $meta['amount'] > 1 ) {
|
880 |
+
$range = array( $this->borndate( strtotime( $meta['max_meta'] ) ), $this->borndate( strtotime( $meta['min_meta'] ) ) );
|
881 |
+
}
|
882 |
+
|
883 |
+
break;
|
884 |
+
}
|
885 |
+
|
886 |
+
}
|
887 |
+
|
888 |
+
return $range;
|
889 |
+
}
|
890 |
+
|
891 |
+
|
892 |
+
/**
|
893 |
+
* @param $filter
|
894 |
+
*
|
895 |
+
* @return mixed
|
896 |
+
*/
|
897 |
+
function slider_range_placeholder( $filter, $attrs ) {
|
898 |
+
switch ( $filter ) {
|
899 |
+
default: {
|
900 |
+
$label = ! empty( $attrs['label'] ) ? $attrs['label'] : $filter;
|
901 |
+
$label = ucwords( str_replace( array( 'um_', '_' ), array( '', ' ' ), $label ) );
|
902 |
+
$placeholders = apply_filters( 'um_member_directory_filter_slider_range_placeholder', false, $filter );
|
903 |
+
|
904 |
+
if ( ! $placeholders ) {
|
905 |
+
switch ( $attrs['type'] ) {
|
906 |
+
default:
|
907 |
+
$placeholders = array(
|
908 |
+
"<strong>$label:</strong> {value}",
|
909 |
+
"<strong>$label:</strong> {min_range} - {max_range}",
|
910 |
+
);
|
911 |
+
break;
|
912 |
+
case 'rating':
|
913 |
+
$placeholders = array(
|
914 |
+
"<strong>$label:</strong> {value}" . __( ' stars', 'ultimate-member' ),
|
915 |
+
"<strong>$label:</strong> {min_range} - {max_range}" . __( ' stars', 'ultimate-member' )
|
916 |
+
);
|
917 |
+
break;
|
918 |
+
}
|
919 |
+
}
|
920 |
+
|
921 |
+
break;
|
922 |
+
}
|
923 |
+
case 'birth_date': {
|
924 |
+
$placeholders = array(
|
925 |
+
__( '<strong>Age:</strong> {value} years old', 'ultimate-member' ),
|
926 |
+
__( '<strong>Age:</strong> {min_range} - {max_range} years old', 'ultimate-member' )
|
927 |
+
);
|
928 |
+
break;
|
929 |
+
}
|
930 |
+
}
|
931 |
+
|
932 |
+
return $placeholders;
|
933 |
+
}
|
934 |
+
|
935 |
+
|
936 |
+
/**
|
937 |
+
* @param $filter
|
938 |
+
*
|
939 |
+
* @return mixed
|
940 |
+
*/
|
941 |
+
function datepicker_filters_range( $filter ) {
|
942 |
+
global $wpdb;
|
943 |
+
|
944 |
+
switch ( $filter ) {
|
945 |
+
|
946 |
+
default: {
|
947 |
+
|
948 |
+
global $wpdb;
|
949 |
+
$meta = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT meta_value
|
950 |
+
FROM {$wpdb->usermeta}
|
951 |
+
WHERE meta_key = %s
|
952 |
+
ORDER BY meta_value DESC", $filter ) );
|
953 |
+
|
954 |
+
if ( empty( $meta ) || count( $meta ) === 1 ) {
|
955 |
+
$range = false;
|
956 |
+
} elseif ( ! empty( $meta ) ) {
|
957 |
+
$range = array( strtotime( min( $meta ) ), strtotime( max( $meta ) ) );
|
958 |
+
}
|
959 |
+
|
960 |
+
$range = apply_filters( "um_member_directory_filter_{$filter}_datepicker", $range );
|
961 |
+
|
962 |
+
break;
|
963 |
+
}
|
964 |
+
case 'last_login': {
|
965 |
+
$meta = $wpdb->get_col( "SELECT DISTINCT meta_value
|
966 |
+
FROM {$wpdb->usermeta}
|
967 |
+
WHERE meta_key='_um_last_login'
|
968 |
+
ORDER BY meta_value DESC" );
|
969 |
+
|
970 |
+
if ( empty( $meta ) || count( $meta ) === 1 ) {
|
971 |
+
$range = false;
|
972 |
+
} elseif ( ! empty( $meta ) ) {
|
973 |
+
$range = array( min( $meta ), max( $meta ) );
|
974 |
+
}
|
975 |
+
|
976 |
+
break;
|
977 |
+
}
|
978 |
+
case 'user_registered': {
|
979 |
+
$meta = $wpdb->get_col(
|
980 |
+
"SELECT DISTINCT user_registered
|
981 |
+
FROM {$wpdb->users}
|
982 |
+
ORDER BY user_registered DESC"
|
983 |
+
);
|
984 |
+
|
985 |
+
if ( empty( $meta ) || count( $meta ) === 1 ) {
|
986 |
+
$range = false;
|
987 |
+
} elseif ( ! empty( $meta ) ) {
|
988 |
+
$range = array( strtotime( min( $meta ) ), strtotime( max( $meta ) ) );
|
989 |
+
}
|
990 |
+
|
991 |
+
break;
|
992 |
+
}
|
993 |
+
|
994 |
+
}
|
995 |
+
|
996 |
+
return $range;
|
997 |
+
}
|
998 |
+
|
999 |
+
|
1000 |
+
/**
|
1001 |
+
* @param $filter
|
1002 |
+
*
|
1003 |
+
* @return mixed
|
1004 |
+
*/
|
1005 |
+
function timepicker_filters_range( $filter ) {
|
1006 |
+
|
1007 |
+
switch ( $filter ) {
|
1008 |
+
|
1009 |
+
default: {
|
1010 |
+
|
1011 |
+
global $wpdb;
|
1012 |
+
$meta = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT meta_value
|
1013 |
+
FROM {$wpdb->usermeta}
|
1014 |
+
WHERE meta_key = %s
|
1015 |
+
ORDER BY meta_value DESC", $filter ) );
|
1016 |
+
|
1017 |
+
$meta = array_filter( $meta );
|
1018 |
+
|
1019 |
+
if ( empty( $meta ) || count( $meta ) === 1 ) {
|
1020 |
+
$range = false;
|
1021 |
+
} elseif ( ! empty( $meta ) ) {
|
1022 |
+
$range = array( min( $meta ), max( $meta ) );
|
1023 |
+
}
|
1024 |
+
|
1025 |
+
|
1026 |
+
$range = apply_filters( "um_member_directory_filter_{$filter}_timepicker", $range );
|
1027 |
+
|
1028 |
+
break;
|
1029 |
+
}
|
1030 |
+
|
1031 |
+
}
|
1032 |
+
|
1033 |
+
return $range;
|
1034 |
+
}
|
1035 |
+
|
1036 |
+
|
1037 |
+
/**
|
1038 |
+
* @param $borndate
|
1039 |
+
*
|
1040 |
+
* @return false|string
|
1041 |
+
*/
|
1042 |
+
function borndate( $borndate ) {
|
1043 |
+
if ( date('m', $borndate) > date('m') || date('m', $borndate) == date('m') && date('d', $borndate ) > date('d')) {
|
1044 |
+
return (date('Y') - date('Y', $borndate ) - 1);
|
1045 |
+
}
|
1046 |
+
return (date('Y') - date('Y', $borndate));
|
1047 |
+
}
|
1048 |
+
|
1049 |
+
|
1050 |
+
/**
|
1051 |
+
* Handle members can view restrictions
|
1052 |
+
*/
|
1053 |
+
function restriction_options() {
|
1054 |
+
$this->hide_not_approved();
|
1055 |
+
$this->hide_by_role();
|
1056 |
+
$this->hide_by_account_settings();
|
1057 |
+
|
1058 |
+
do_action( 'um_member_directory_restrictions_handle_extend' );
|
1059 |
+
}
|
1060 |
+
|
1061 |
+
|
1062 |
+
/**
|
1063 |
+
*
|
1064 |
+
*/
|
1065 |
+
function hide_not_approved() {
|
1066 |
+
if ( UM()->roles()->um_user_can( 'can_edit_everyone' ) ) {
|
1067 |
+
return;
|
1068 |
+
}
|
1069 |
+
|
1070 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( array(
|
1071 |
+
'key' => 'um_member_directory_data',
|
1072 |
+
'value' => 's:14:"account_status";s:8:"approved";',
|
1073 |
+
'compare' => 'LIKE'
|
1074 |
+
) ) );
|
1075 |
+
}
|
1076 |
+
|
1077 |
+
|
1078 |
+
/**
|
1079 |
+
*
|
1080 |
+
*/
|
1081 |
+
function hide_by_role() {
|
1082 |
+
if ( ! is_user_logged_in() ) {
|
1083 |
+
return;
|
1084 |
+
}
|
1085 |
+
|
1086 |
+
$roles = um_user( 'can_view_roles' );
|
1087 |
+
$roles = maybe_unserialize( $roles );
|
1088 |
+
|
1089 |
+
if ( UM()->roles()->um_user_can( 'can_view_all' ) && empty( $roles ) ) {
|
1090 |
+
return;
|
1091 |
+
}
|
1092 |
+
|
1093 |
+
if ( ! empty( $this->query_args['role__in'] ) ) {
|
1094 |
+
$this->query_args['role__in'] = is_array( $this->query_args['role__in'] ) ? $this->query_args['role__in'] : array( $this->query_args['role__in'] );
|
1095 |
+
$this->query_args['role__in'] = array_intersect( $this->query_args['role__in'], $roles );
|
1096 |
+
} else {
|
1097 |
+
$this->query_args['role__in'] = $roles;
|
1098 |
+
}
|
1099 |
+
}
|
1100 |
+
|
1101 |
+
|
1102 |
+
/**
|
1103 |
+
*
|
1104 |
+
*/
|
1105 |
+
function hide_by_account_settings() {
|
1106 |
+
if ( ! UM()->options()->get( 'account_hide_in_directory' ) ) {
|
1107 |
+
return;
|
1108 |
+
}
|
1109 |
+
|
1110 |
+
if ( UM()->roles()->um_user_can( 'can_edit_everyone' ) ) {
|
1111 |
+
return;
|
1112 |
+
}
|
1113 |
+
|
1114 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( array(
|
1115 |
+
'key' => 'um_member_directory_data',
|
1116 |
+
'value' => 's:15:"hide_in_members";b:0;',
|
1117 |
+
'compare' => 'LIKE'
|
1118 |
+
) ) );
|
1119 |
+
}
|
1120 |
+
|
1121 |
+
|
1122 |
+
/**
|
1123 |
+
* Handle "General Options" metabox settings
|
1124 |
+
*
|
1125 |
+
* @param array $directory_data
|
1126 |
+
*/
|
1127 |
+
function general_options( $directory_data ) {
|
1128 |
+
$this->show_selected_roles( $directory_data );
|
1129 |
+
$this->show_only_with_avatar( $directory_data );
|
1130 |
+
$this->show_only_with_cover( $directory_data );
|
1131 |
+
$this->show_only_these_users( $directory_data );
|
1132 |
+
$this->exclude_these_users( $directory_data );
|
1133 |
+
|
1134 |
+
do_action( 'um_member_directory_general_options_handle_extend', $directory_data );
|
1135 |
+
}
|
1136 |
+
|
1137 |
+
|
1138 |
+
/**
|
1139 |
+
* Handle "User Roles to Display" option
|
1140 |
+
*
|
1141 |
+
* @param array $directory_data
|
1142 |
+
*/
|
1143 |
+
function show_selected_roles( $directory_data ) {
|
1144 |
+
// add roles to appear in directory
|
1145 |
+
if ( ! empty( $directory_data['roles'] ) ) {
|
1146 |
+
//since WP4.4 use 'role__in' argument
|
1147 |
+
if ( ! empty( $this->query_args['role__in'] ) ) {
|
1148 |
+
$this->query_args['role__in'] = is_array( $this->query_args['role__in'] ) ? $this->query_args['role__in'] : array( $this->query_args['role__in'] );
|
1149 |
+
$this->query_args['role__in'] = array_intersect( $this->query_args['role__in'], maybe_unserialize( $directory_data['roles'] ) );
|
1150 |
+
} else {
|
1151 |
+
$this->query_args['role__in'] = maybe_unserialize( $directory_data['roles'] );
|
1152 |
+
}
|
1153 |
+
}
|
1154 |
+
}
|
1155 |
+
|
1156 |
+
|
1157 |
+
/**
|
1158 |
+
* Handle "Only show members who have uploaded a profile photo" option
|
1159 |
+
*
|
1160 |
+
* @param array $directory_data
|
1161 |
+
*/
|
1162 |
+
function show_only_with_avatar( $directory_data ) {
|
1163 |
+
if ( $directory_data['has_profile_photo'] == 1 ) {
|
1164 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( array(
|
1165 |
+
'key' => 'um_member_directory_data',
|
1166 |
+
'value' => 's:13:"profile_photo";b:1;',
|
1167 |
+
'compare' => 'LIKE'
|
1168 |
+
) ) );
|
1169 |
+
}
|
1170 |
+
}
|
1171 |
+
|
1172 |
+
|
1173 |
+
/**
|
1174 |
+
* Handle "Only show members who have uploaded a cover photo" option
|
1175 |
+
*
|
1176 |
+
* @param array $directory_data
|
1177 |
+
*/
|
1178 |
+
function show_only_with_cover( $directory_data ) {
|
1179 |
+
if ( $directory_data['has_cover_photo'] == 1 ) {
|
1180 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( array(
|
1181 |
+
'key' => 'um_member_directory_data',
|
1182 |
+
'value' => 's:11:"cover_photo";b:1;',
|
1183 |
+
'compare' => 'LIKE'
|
1184 |
+
) ) );
|
1185 |
+
}
|
1186 |
+
}
|
1187 |
+
|
1188 |
+
|
1189 |
+
/**
|
1190 |
+
* Handle "Only show specific users (Enter one username per line)" option
|
1191 |
+
*
|
1192 |
+
* @param array $directory_data
|
1193 |
+
*/
|
1194 |
+
function show_only_these_users( $directory_data ) {
|
1195 |
+
if ( ! empty( $directory_data['show_these_users'] ) ) {
|
1196 |
+
$show_these_users = maybe_unserialize( $directory_data['show_these_users'] );
|
1197 |
+
|
1198 |
+
if ( is_array( $show_these_users ) && ! empty( $show_these_users ) ) {
|
1199 |
+
|
1200 |
+
$users_array = array();
|
1201 |
+
|
1202 |
+
foreach ( $show_these_users as $username ) {
|
1203 |
+
if ( false !== ( $exists_id = username_exists( $username ) ) ) {
|
1204 |
+
$users_array[] = $exists_id;
|
1205 |
+
}
|
1206 |
+
}
|
1207 |
+
|
1208 |
+
if ( ! empty( $users_array ) ) {
|
1209 |
+
$this->query_args['include'] = $users_array;
|
1210 |
+
}
|
1211 |
+
|
1212 |
+
}
|
1213 |
+
}
|
1214 |
+
}
|
1215 |
+
|
1216 |
+
|
1217 |
+
/**
|
1218 |
+
* Handle "Exclude specific users (Enter one username per line)" option
|
1219 |
+
*
|
1220 |
+
* @param array $directory_data
|
1221 |
+
*/
|
1222 |
+
function exclude_these_users( $directory_data ) {
|
1223 |
+
if ( ! empty( $directory_data['exclude_these_users'] ) ) {
|
1224 |
+
$exclude_these_users = maybe_unserialize( $directory_data['exclude_these_users'] );
|
1225 |
+
|
1226 |
+
if ( is_array( $exclude_these_users ) && ! empty( $exclude_these_users ) ) {
|
1227 |
+
|
1228 |
+
$users_array = array();
|
1229 |
+
|
1230 |
+
foreach ( $exclude_these_users as $username ) {
|
1231 |
+
if ( false !== ( $exists_id = username_exists( $username ) ) ) {
|
1232 |
+
$users_array[] = $exists_id;
|
1233 |
+
}
|
1234 |
+
}
|
1235 |
+
|
1236 |
+
if ( ! empty( $users_array ) ) {
|
1237 |
+
$this->query_args['exclude'] = $users_array;
|
1238 |
+
}
|
1239 |
+
|
1240 |
+
}
|
1241 |
+
}
|
1242 |
+
}
|
1243 |
+
|
1244 |
+
|
1245 |
+
/**
|
1246 |
+
* Handle "Pagination Options" metabox settings
|
1247 |
+
*
|
1248 |
+
* @param array $directory_data
|
1249 |
+
*/
|
1250 |
+
function pagination_options( $directory_data ) {
|
1251 |
+
// number of profiles for mobile
|
1252 |
+
$profiles_per_page = $directory_data['profiles_per_page'];
|
1253 |
+
if ( UM()->mobile()->isMobile() && isset( $directory_data['profiles_per_page_mobile'] ) ) {
|
1254 |
+
$profiles_per_page = $directory_data['profiles_per_page_mobile'];
|
1255 |
+
}
|
1256 |
+
|
1257 |
+
$this->query_args['number'] = ( ! empty( $directory_data['max_users'] ) && $directory_data['max_users'] <= $profiles_per_page ) ? $directory_data['max_users'] : $profiles_per_page;
|
1258 |
+
$this->query_args['paged'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
|
1259 |
+
}
|
1260 |
+
|
1261 |
+
|
1262 |
+
/**
|
1263 |
+
* Add sorting attributes for \WP_Users_Query
|
1264 |
+
*
|
1265 |
+
* @param array $directory_data Member Directory options
|
1266 |
+
*/
|
1267 |
+
function sorting_query( $directory_data ) {
|
1268 |
+
// sort members by
|
1269 |
+
$this->query_args['order'] = 'ASC';
|
1270 |
+
$sortby = ! empty( $_POST['sorting'] ) ? sanitize_text_field( $_POST['sorting'] ) : $directory_data['sortby'];
|
1271 |
+
$sortby = ( $sortby == 'other' ) ? $directory_data['sortby_custom'] : $sortby;
|
1272 |
+
|
1273 |
+
$custom_sort = array();
|
1274 |
+
if ( ! empty( $directory_data['sorting_fields'] ) ) {
|
1275 |
+
$sorting_fields = maybe_unserialize( $directory_data['sorting_fields'] );
|
1276 |
+
foreach ( $sorting_fields as $field ) {
|
1277 |
+
if ( is_array( $field ) ) {
|
1278 |
+
$field_keys = array_keys( $field );
|
1279 |
+
$custom_sort[] = $field_keys[0];
|
1280 |
+
}
|
1281 |
+
}
|
1282 |
+
}
|
1283 |
+
|
1284 |
+
$numeric_sorting_keys = array();
|
1285 |
+
|
1286 |
+
if ( ! empty( UM()->builtin()->saved_fields ) ) {
|
1287 |
+
foreach ( UM()->builtin()->saved_fields as $key => $data ) {
|
1288 |
+
if ( $key == '_um_last_login' ) {
|
1289 |
+
continue;
|
1290 |
+
}
|
1291 |
+
|
1292 |
+
if ( isset( $data['type'] ) && 'number' === $data['type'] ) {
|
1293 |
+
if ( array_key_exists( $key . '_desc', $this->sort_fields ) ) {
|
1294 |
+
$numeric_sorting_keys[] = $key . '_desc';
|
1295 |
+
}
|
1296 |
+
if ( array_key_exists( $key . '_asc', $this->sort_fields ) ) {
|
1297 |
+
$numeric_sorting_keys[] = $key . '_asc';
|
1298 |
+
}
|
1299 |
+
}
|
1300 |
+
}
|
1301 |
+
}
|
1302 |
+
|
1303 |
+
if ( 'username' == $sortby ) {
|
1304 |
+
|
1305 |
+
$this->query_args['orderby'] = 'user_login';
|
1306 |
+
$this->query_args['order'] = 'ASC';
|
1307 |
+
|
1308 |
+
} elseif ( 'display_name' == $sortby ) {
|
1309 |
+
|
1310 |
+
$display_name = UM()->options()->get( 'display_name' );
|
1311 |
+
if ( $display_name == 'username' ) {
|
1312 |
+
$this->query_args['orderby'] = 'user_login';
|
1313 |
+
$this->query_args['order'] = 'ASC';
|
1314 |
+
} else {
|
1315 |
+
$this->query_args['meta_query'][] = array(
|
1316 |
+
'relation' => 'OR',
|
1317 |
+
'full_name' => array(
|
1318 |
+
'key' => 'full_name',
|
1319 |
+
'compare' => 'EXISTS'
|
1320 |
+
),
|
1321 |
+
array(
|
1322 |
+
'key' => 'full_name',
|
1323 |
+
'compare' => 'NOT EXISTS'
|
1324 |
+
)
|
1325 |
+
);
|
1326 |
+
|
1327 |
+
$this->query_args['orderby'] = 'full_name, display_name';
|
1328 |
+
$this->query_args['order'] = 'ASC';
|
1329 |
+
}
|
1330 |
+
|
1331 |
+
} elseif ( in_array( $sortby, array( 'last_name', 'first_name', 'nickname' ) ) ) {
|
1332 |
+
|
1333 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $sortby . '_c' => array(
|
1334 |
+
'key' => $sortby,
|
1335 |
+
'compare' => 'EXISTS',
|
1336 |
+
), ) );
|
1337 |
+
|
1338 |
+
$this->query_args['orderby'] = array( $sortby . '_c' => 'ASC' );
|
1339 |
+
unset( $this->query_args['order'] );
|
1340 |
+
|
1341 |
+
} elseif ( $sortby == 'last_login' ) {
|
1342 |
+
|
1343 |
+
$this->query_args['orderby'] = array( 'um_last_login' => 'DESC' );
|
1344 |
+
$this->query_args['meta_query'][] = array(
|
1345 |
+
'relation' => 'OR',
|
1346 |
+
array(
|
1347 |
+
'key' => '_um_last_login',
|
1348 |
+
'compare' => 'EXISTS',
|
1349 |
+
),
|
1350 |
+
'um_last_login' => array(
|
1351 |
+
'key' => '_um_last_login',
|
1352 |
+
'compare' => 'NOT EXISTS',
|
1353 |
+
),
|
1354 |
+
);
|
1355 |
+
unset( $this->query_args['order'] );
|
1356 |
+
|
1357 |
+
} elseif ( $sortby == 'last_first_name' ) {
|
1358 |
+
|
1359 |
+
$this->query_args['meta_query'][] = array(
|
1360 |
+
'last_name_c' => array(
|
1361 |
+
'key' => 'last_name',
|
1362 |
+
'compare' => 'EXISTS',
|
1363 |
+
),
|
1364 |
+
'first_name_c' => array(
|
1365 |
+
'key' => 'first_name',
|
1366 |
+
'compare' => 'EXISTS',
|
1367 |
+
),
|
1368 |
+
);
|
1369 |
+
|
1370 |
+
$this->query_args['orderby'] = array( 'last_name_c' => 'ASC', 'first_name_c' => 'ASC' );
|
1371 |
+
unset( $this->query_args['order'] );
|
1372 |
+
|
1373 |
+
} elseif ( count( $numeric_sorting_keys ) && in_array( $sortby, $numeric_sorting_keys ) ) {
|
1374 |
+
|
1375 |
+
$order = 'DESC';
|
1376 |
+
if ( strstr( $sortby, '_desc' ) ) {
|
1377 |
+
$sortby = str_replace( '_desc', '', $sortby );
|
1378 |
+
$order = 'DESC';
|
1379 |
+
}
|
1380 |
+
|
1381 |
+
if ( strstr( $sortby, '_asc' ) ) {
|
1382 |
+
$sortby = str_replace( '_asc', '', $sortby );
|
1383 |
+
$order = 'ASC';
|
1384 |
+
}
|
1385 |
+
|
1386 |
+
$this->query_args['meta_query'] = array_merge(
|
1387 |
+
$this->query_args['meta_query'],
|
1388 |
+
array(
|
1389 |
+
array(
|
1390 |
+
'relation' => 'OR',
|
1391 |
+
array(
|
1392 |
+
'key' => $sortby,
|
1393 |
+
'compare' => 'EXISTS',
|
1394 |
+
'type' => 'NUMERIC',
|
1395 |
+
),
|
1396 |
+
$sortby . '_ns' => array(
|
1397 |
+
'key' => $sortby,
|
1398 |
+
'compare' => 'NOT EXISTS',
|
1399 |
+
'type' => 'NUMERIC',
|
1400 |
+
),
|
1401 |
+
),
|
1402 |
+
)
|
1403 |
+
);
|
1404 |
+
|
1405 |
+
$this->query_args['orderby'] = array( $sortby . '_ns' => $order, 'user_registered' => 'DESC' );
|
1406 |
+
unset( $this->query_args['order'] );
|
1407 |
+
|
1408 |
+
} elseif ( ( ! empty( $directory_data['sortby_custom'] ) && $sortby == $directory_data['sortby_custom'] ) || in_array( $sortby, $custom_sort ) ) {
|
1409 |
+
|
1410 |
+
$custom_sort_type = apply_filters( 'um_member_directory_custom_sorting_type', 'CHAR', $sortby, $directory_data );
|
1411 |
+
|
1412 |
+
$this->query_args['meta_query'][] = array(
|
1413 |
+
'relation' => 'OR',
|
1414 |
+
$sortby . '_cs' => array(
|
1415 |
+
'key' => $sortby,
|
1416 |
+
'compare' => 'EXISTS',
|
1417 |
+
'type' => $custom_sort_type,
|
1418 |
+
),
|
1419 |
+
array(
|
1420 |
+
'key' => $sortby,
|
1421 |
+
'compare' => 'NOT EXISTS',
|
1422 |
+
)
|
1423 |
+
);
|
1424 |
+
|
1425 |
+
$this->query_args['orderby'] = array( $sortby . '_cs' => 'ASC', 'user_login' => 'ASC' );
|
1426 |
+
|
1427 |
+
} else {
|
1428 |
+
|
1429 |
+
if ( strstr( $sortby, '_desc' ) ) {
|
1430 |
+
$sortby = str_replace( '_desc', '', $sortby );
|
1431 |
+
$order = 'DESC';
|
1432 |
+
}
|
1433 |
+
|
1434 |
+
if ( strstr( $sortby, '_asc' ) ) {
|
1435 |
+
$sortby = str_replace( '_asc', '', $sortby );
|
1436 |
+
$order = 'ASC';
|
1437 |
+
}
|
1438 |
+
|
1439 |
+
$this->query_args['orderby'] = $sortby;
|
1440 |
+
if ( isset( $order ) ) {
|
1441 |
+
$this->query_args['order'] = $order;
|
1442 |
+
}
|
1443 |
+
|
1444 |
+
add_filter( 'pre_user_query', array( &$this, 'sortby_randomly' ), 10, 1 );
|
1445 |
+
}
|
1446 |
+
|
1447 |
+
|
1448 |
+
/**
|
1449 |
+
* UM hook
|
1450 |
+
*
|
1451 |
+
* @type filter
|
1452 |
+
* @title um_modify_sortby_parameter
|
1453 |
+
* @description Change query sort by attributes for search at Members Directory
|
1454 |
+
* @input_vars
|
1455 |
+
* [{"var":"$query_args","type":"array","desc":"Query Arguments"},
|
1456 |
+
* {"var":"$sortby","type":"string","desc":"Sort by"}]
|
1457 |
+
* @change_log
|
1458 |
+
* ["Since: 2.0"]
|
1459 |
+
* @usage
|
1460 |
+
* <?php add_filter( 'um_modify_sortby_parameter', 'function_name', 10, 2 ); ?>
|
1461 |
+
* @example
|
1462 |
+
* <?php
|
1463 |
+
* add_filter( 'um_modify_sortby_parameter', 'my_modify_sortby_parameter', 10, 2 );
|
1464 |
+
* function my_modify_sortby_parameter( $query_args, $sortby ) {
|
1465 |
+
* // your code here
|
1466 |
+
* return $query_args;
|
1467 |
+
* }
|
1468 |
+
* ?>
|
1469 |
+
*/
|
1470 |
+
$this->query_args = apply_filters( 'um_modify_sortby_parameter', $this->query_args, $sortby );
|
1471 |
+
}
|
1472 |
+
|
1473 |
+
|
1474 |
+
/**
|
1475 |
+
* Sorting random
|
1476 |
+
*
|
1477 |
+
* @param object $query
|
1478 |
+
*
|
1479 |
+
* @return mixed
|
1480 |
+
*/
|
1481 |
+
function sortby_randomly( $query ) {
|
1482 |
+
if ( 'random' == $query->query_vars['orderby'] ) {
|
1483 |
+
|
1484 |
+
if ( um_is_session_started() === false ) {
|
1485 |
+
@session_start();
|
1486 |
+
}
|
1487 |
+
|
1488 |
+
// Reset seed on load of initial
|
1489 |
+
if ( empty( $_REQUEST['directory_id'] ) && isset( $_SESSION['um_member_directory_seed'] ) ) {
|
1490 |
+
unset( $_SESSION['um_member_directory_seed'] );
|
1491 |
+
}
|
1492 |
+
|
1493 |
+
// Get seed from session variable if it exists
|
1494 |
+
$seed = false;
|
1495 |
+
if ( isset( $_SESSION['um_member_directory_seed'] ) ) {
|
1496 |
+
$seed = $_SESSION['um_member_directory_seed'];
|
1497 |
+
}
|
1498 |
+
|
1499 |
+
// Set new seed if none exists
|
1500 |
+
if ( ! $seed ) {
|
1501 |
+
$seed = rand();
|
1502 |
+
$_SESSION['um_member_directory_seed'] = $seed;
|
1503 |
+
}
|
1504 |
+
|
1505 |
+
$query->query_orderby = 'ORDER by RAND(' . $seed . ')';
|
1506 |
+
}
|
1507 |
+
|
1508 |
+
return $query;
|
1509 |
+
}
|
1510 |
+
|
1511 |
+
|
1512 |
+
|
1513 |
+
/**
|
1514 |
+
* Handle general search line request
|
1515 |
+
*/
|
1516 |
+
function general_search() {
|
1517 |
+
//general search
|
1518 |
+
if ( ! empty( $_POST['search'] ) ) {
|
1519 |
+
// complex using with change_meta_sql function
|
1520 |
+
|
1521 |
+
$search = trim( stripslashes( sanitize_text_field( $_POST['search'] ) ) );
|
1522 |
+
|
1523 |
+
$meta_query = array(
|
1524 |
+
'relation' => 'OR',
|
1525 |
+
array(
|
1526 |
+
'value' => $search,
|
1527 |
+
'compare' => '=',
|
1528 |
+
),
|
1529 |
+
array(
|
1530 |
+
'value' => $search,
|
1531 |
+
'compare' => 'LIKE',
|
1532 |
+
),
|
1533 |
+
array(
|
1534 |
+
'value' => serialize( (string) $search ),
|
1535 |
+
'compare' => 'LIKE',
|
1536 |
+
),
|
1537 |
+
);
|
1538 |
+
|
1539 |
+
$meta_query = apply_filters( 'um_member_directory_general_search_meta_query', $meta_query, stripslashes( sanitize_text_field( $_POST['search'] ) ) );
|
1540 |
+
|
1541 |
+
$this->query_args['meta_query'][] = $meta_query;
|
1542 |
+
|
1543 |
+
$this->is_search = true;
|
1544 |
+
}
|
1545 |
+
}
|
1546 |
+
|
1547 |
+
|
1548 |
+
/**
|
1549 |
+
* Change mySQL meta query join attribute
|
1550 |
+
* for search only by UM user meta fields and WP core fields in WP Users table
|
1551 |
+
*
|
1552 |
+
* @param array $sql Array containing the query's JOIN and WHERE clauses.
|
1553 |
+
* @param $queries
|
1554 |
+
* @param $type
|
1555 |
+
* @param $primary_table
|
1556 |
+
* @param $primary_id_column
|
1557 |
+
* @param \WP_User_Query $context
|
1558 |
+
*
|
1559 |
+
* @return mixed
|
1560 |
+
*/
|
1561 |
+
function change_meta_sql( $sql, $queries, $type, $primary_table, $primary_id_column, $context ) {
|
1562 |
+
if ( ! empty( $_POST['search'] ) ) {
|
1563 |
+
global $wpdb;
|
1564 |
+
$search = trim( stripslashes( sanitize_text_field( $_POST['search'] ) ) );
|
1565 |
+
if ( ! empty( $search ) ) {
|
1566 |
+
|
1567 |
+
$meta_value = '%' . $wpdb->esc_like( $search ) . '%';
|
1568 |
+
$search_meta = $wpdb->prepare( '%s', $meta_value );
|
1569 |
+
|
1570 |
+
preg_match(
|
1571 |
+
'/^(.*).meta_value LIKE ' . addslashes( $search_meta ) . '[^\)]/im',
|
1572 |
+
$sql['where'],
|
1573 |
+
$join_matches
|
1574 |
+
);
|
1575 |
+
|
1576 |
+
if ( isset( $join_matches[1] ) ) {
|
1577 |
+
$meta_join_for_search = trim( $join_matches[1] );
|
1578 |
+
|
1579 |
+
// skip private invisible fields
|
1580 |
+
$custom_fields = array();
|
1581 |
+
foreach ( array_keys( UM()->builtin()->all_user_fields ) as $field_key ) {
|
1582 |
+
$data = UM()->fields()->get_field( $field_key );
|
1583 |
+
if ( ! um_can_view_field( $data ) ) {
|
1584 |
+
continue;
|
1585 |
+
}
|
1586 |
+
|
1587 |
+
$custom_fields[] = $field_key;
|
1588 |
+
}
|
1589 |
+
|
1590 |
+
$custom_fields = apply_filters( 'um_general_search_custom_fields', $custom_fields );
|
1591 |
+
|
1592 |
+
if ( ! empty( $custom_fields ) ) {
|
1593 |
+
$sql['join'] = preg_replace(
|
1594 |
+
'/(' . $meta_join_for_search . ' ON \( ' . $wpdb->users . '\.ID = ' . $meta_join_for_search . '\.user_id )(\))/im',
|
1595 |
+
"$1 AND " . $meta_join_for_search . ".meta_key IN( '" . implode( "','", $custom_fields ) . "' ) $2",
|
1596 |
+
$sql['join']
|
1597 |
+
);
|
1598 |
+
}
|
1599 |
+
}
|
1600 |
+
|
1601 |
+
// Add OR instead AND to search in WP core fields user_email, user_login, user_display_name
|
1602 |
+
$search_where = $context->get_search_sql( $search, $this->core_search_fields, 'both' );
|
1603 |
+
|
1604 |
+
$search_where = preg_replace( '/ AND \((.*?)\)/im', "$1 OR", $search_where );
|
1605 |
+
|
1606 |
+
$sql['where'] = preg_replace(
|
1607 |
+
'/(' . $meta_join_for_search . '.meta_value = \'' . esc_attr( $search ) . '\')/im',
|
1608 |
+
trim( $search_where ) . " $1",
|
1609 |
+
$sql['where'],
|
1610 |
+
1
|
1611 |
+
);
|
1612 |
+
}
|
1613 |
+
}
|
1614 |
+
|
1615 |
+
return $sql;
|
1616 |
+
}
|
1617 |
+
|
1618 |
+
|
1619 |
+
/**
|
1620 |
+
* Handle filters request
|
1621 |
+
*/
|
1622 |
+
function filters( $directory_data ) {
|
1623 |
+
//filters
|
1624 |
+
$filter_query = array();
|
1625 |
+
if ( ! empty( $directory_data['search_fields'] ) ) {
|
1626 |
+
$search_filters = maybe_unserialize( $directory_data['search_fields'] );
|
1627 |
+
|
1628 |
+
if ( ! empty( $search_filters ) && is_array( $search_filters ) ) {
|
1629 |
+
$filter_query = array_intersect_key( $_POST, array_flip( $search_filters ) );
|
1630 |
+
}
|
1631 |
+
}
|
1632 |
+
|
1633 |
+
// added for user tags extension integration on individual tag page
|
1634 |
+
$ignore_empty_filters = apply_filters( 'um_member_directory_ignore_empty_filters', false );
|
1635 |
+
|
1636 |
+
if ( empty( $filter_query ) && ! $ignore_empty_filters ) {
|
1637 |
+
return;
|
1638 |
+
}
|
1639 |
+
|
1640 |
+
$this->is_search = true;
|
1641 |
+
foreach ( $filter_query as $field => $value ) {
|
1642 |
+
$field = sanitize_text_field( $field );
|
1643 |
+
if ( is_array( $value ) ) {
|
1644 |
+
$value = array_map( 'sanitize_text_field', $value );
|
1645 |
+
} else {
|
1646 |
+
$value = sanitize_text_field( $value );
|
1647 |
+
}
|
1648 |
+
|
1649 |
+
$attrs = UM()->fields()->get_field( $field );
|
1650 |
+
// skip private invisible fields
|
1651 |
+
if ( ! um_can_view_field( $attrs ) ) {
|
1652 |
+
continue;
|
1653 |
+
}
|
1654 |
+
|
1655 |
+
switch ( $field ) {
|
1656 |
+
default:
|
1657 |
+
|
1658 |
+
$filter_type = $this->filter_types[ $field ];
|
1659 |
+
|
1660 |
+
/**
|
1661 |
+
* UM hook
|
1662 |
+
*
|
1663 |
+
* @type filter
|
1664 |
+
* @title um_query_args_{$field}__filter
|
1665 |
+
* @description Change field's query for search at Members Directory
|
1666 |
+
* @input_vars
|
1667 |
+
* [{"var":"$field_query","type":"array","desc":"Field query"}]
|
1668 |
+
* @change_log
|
1669 |
+
* ["Since: 2.0"]
|
1670 |
+
* @usage
|
1671 |
+
* <?php add_filter( 'um_query_args_{$field}__filter', 'function_name', 10, 1 ); ?>
|
1672 |
+
* @example
|
1673 |
+
* <?php
|
1674 |
+
* add_filter( 'um_query_args_{$field}__filter', 'my_query_args_filter', 10, 1 );
|
1675 |
+
* function my_query_args_filter( $field_query ) {
|
1676 |
+
* // your code here
|
1677 |
+
* return $field_query;
|
1678 |
+
* }
|
1679 |
+
* ?>
|
1680 |
+
*/
|
1681 |
+
$field_query = apply_filters( "um_query_args_{$field}__filter", false, $field, $value, $filter_type );
|
1682 |
+
|
1683 |
+
$field_query = apply_filters( 'um_query_args_filter_global', $field_query, $field, $value, $filter_type );
|
1684 |
+
|
1685 |
+
if ( ! $field_query ) {
|
1686 |
+
|
1687 |
+
switch ( $filter_type ) {
|
1688 |
+
default:
|
1689 |
+
|
1690 |
+
$field_query = apply_filters( "um_query_args_{$field}_{$filter_type}__filter", false, $field, $value, $filter_type );
|
1691 |
+
|
1692 |
+
break;
|
1693 |
+
case 'text':
|
1694 |
+
|
1695 |
+
$value = stripslashes( $value );
|
1696 |
+
$field_query = array(
|
1697 |
+
'relation' => 'OR',
|
1698 |
+
array(
|
1699 |
+
'key' => $field,
|
1700 |
+
'value' => trim( $value ),
|
1701 |
+
'compare' => apply_filters( 'um_members_directory_filter_text', 'LIKE', $field )
|
1702 |
+
),
|
1703 |
+
);
|
1704 |
+
|
1705 |
+
$this->custom_filters_in_query[ $field ] = $value;
|
1706 |
+
|
1707 |
+
break;
|
1708 |
+
|
1709 |
+
case 'select':
|
1710 |
+
if ( is_array( $value ) ) {
|
1711 |
+
$field_query = array( 'relation' => 'OR' );
|
1712 |
+
|
1713 |
+
foreach ( $value as $single_val ) {
|
1714 |
+
$single_val = trim( stripslashes( $single_val ) );
|
1715 |
+
|
1716 |
+
$arr_meta_query = array(
|
1717 |
+
array(
|
1718 |
+
'key' => $field,
|
1719 |
+
'value' => $single_val,
|
1720 |
+
'compare' => '=',
|
1721 |
+
),
|
1722 |
+
array(
|
1723 |
+
'key' => $field,
|
1724 |
+
'value' => serialize( (string) $single_val ),
|
1725 |
+
'compare' => 'LIKE',
|
1726 |
+
),
|
1727 |
+
array(
|
1728 |
+
'key' => $field,
|
1729 |
+
'value' => '"' . $single_val . '"',
|
1730 |
+
'compare' => 'LIKE',
|
1731 |
+
)
|
1732 |
+
);
|
1733 |
+
|
1734 |
+
if ( is_numeric( $single_val ) ) {
|
1735 |
+
|
1736 |
+
$arr_meta_query[] = array(
|
1737 |
+
'key' => $field,
|
1738 |
+
'value' => serialize( (int) $single_val ),
|
1739 |
+
'compare' => 'LIKE',
|
1740 |
+
);
|
1741 |
+
|
1742 |
+
}
|
1743 |
+
|
1744 |
+
$field_query = array_merge( $field_query, $arr_meta_query );
|
1745 |
+
}
|
1746 |
+
}
|
1747 |
+
|
1748 |
+
$this->custom_filters_in_query[ $field ] = $value;
|
1749 |
+
|
1750 |
+
break;
|
1751 |
+
case 'slider':
|
1752 |
+
|
1753 |
+
$this->custom_filters_in_query[ $field ] = $value;
|
1754 |
+
|
1755 |
+
$field_query = array(
|
1756 |
+
'key' => $field,
|
1757 |
+
'value' => $value,
|
1758 |
+
'compare' => 'BETWEEN',
|
1759 |
+
'inclusive' => true,
|
1760 |
+
'type' => 'NUMERIC',
|
1761 |
+
);
|
1762 |
+
|
1763 |
+
break;
|
1764 |
+
case 'datepicker':
|
1765 |
+
|
1766 |
+
$offset = 0;
|
1767 |
+
if ( isset( $_POST['gmt_offset'] ) && is_numeric( $_POST['gmt_offset'] ) ) {
|
1768 |
+
$offset = (int) $_POST['gmt_offset'];
|
1769 |
+
}
|
1770 |
+
|
1771 |
+
$from_date = (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ); // client time zone offset
|
1772 |
+
$to_date = (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1; // time 23:59
|
1773 |
+
$from_date = date( 'Y/m/d', $from_date );
|
1774 |
+
$to_date = date( 'Y/m/d', $to_date );
|
1775 |
+
|
1776 |
+
$field_query = array(
|
1777 |
+
'key' => $field,
|
1778 |
+
'value' => array( $from_date, $to_date ),
|
1779 |
+
'compare' => 'BETWEEN',
|
1780 |
+
'inclusive' => true,
|
1781 |
+
);
|
1782 |
+
|
1783 |
+
$this->custom_filters_in_query[ $field ] = array( $from_date, $to_date );
|
1784 |
+
|
1785 |
+
break;
|
1786 |
+
case 'timepicker':
|
1787 |
+
|
1788 |
+
if ( $value[0] == $value[1] ) {
|
1789 |
+
$field_query = array(
|
1790 |
+
'key' => $field,
|
1791 |
+
'value' => $value[0],
|
1792 |
+
);
|
1793 |
+
} else {
|
1794 |
+
$field_query = array(
|
1795 |
+
'key' => $field,
|
1796 |
+
'value' => $value,
|
1797 |
+
'compare' => 'BETWEEN',
|
1798 |
+
'type' => 'TIME',
|
1799 |
+
'inclusive' => true,
|
1800 |
+
);
|
1801 |
+
}
|
1802 |
+
|
1803 |
+
$this->custom_filters_in_query[ $field ] = $value;
|
1804 |
+
|
1805 |
+
break;
|
1806 |
+
}
|
1807 |
+
|
1808 |
+
}
|
1809 |
+
|
1810 |
+
if ( ! empty( $field_query ) && $field_query !== true ) {
|
1811 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $field_query ) );
|
1812 |
+
}
|
1813 |
+
|
1814 |
+
break;
|
1815 |
+
case 'role':
|
1816 |
+
$value = array_map( 'strtolower', $value );
|
1817 |
+
|
1818 |
+
if ( ! empty( $this->query_args['role__in'] ) ) {
|
1819 |
+
$this->query_args['role__in'] = is_array( $this->query_args['role__in'] ) ? $this->query_args['role__in'] : array( $this->query_args['role__in'] );
|
1820 |
+
$default_role = array_intersect( $this->query_args['role__in'], $value );
|
1821 |
+
$um_role = array_diff( $value, $default_role );
|
1822 |
+
|
1823 |
+
foreach ( $um_role as $key => &$val ) {
|
1824 |
+
$val = 'um_' . str_replace( ' ', '-', $val );
|
1825 |
+
}
|
1826 |
+
$this->query_args['role__in'] = array_merge( $default_role, $um_role );
|
1827 |
+
} else {
|
1828 |
+
$this->query_args['role__in'] = $value;
|
1829 |
+
};
|
1830 |
+
|
1831 |
+
$this->custom_filters_in_query[ $field ] = $this->query_args['role__in'];
|
1832 |
+
|
1833 |
+
break;
|
1834 |
+
case 'birth_date':
|
1835 |
+
|
1836 |
+
$from_date = date( 'Y/m/d', mktime( 0,0,0, date( 'm', time() ), date( 'd', time() ), date( 'Y', time() - min( $value ) * YEAR_IN_SECONDS ) ) );
|
1837 |
+
$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 ) ) );
|
1838 |
+
|
1839 |
+
$meta_query = array(
|
1840 |
+
array(
|
1841 |
+
'key' => 'birth_date',
|
1842 |
+
'value' => array( $to_date, $from_date ),
|
1843 |
+
'compare' => 'BETWEEN',
|
1844 |
+
'type' => 'DATE',
|
1845 |
+
'inclusive' => true,
|
1846 |
+
)
|
1847 |
+
);
|
1848 |
+
|
1849 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $meta_query ) );
|
1850 |
+
|
1851 |
+
$this->custom_filters_in_query[ $field ] = array( $to_date, $from_date );
|
1852 |
+
|
1853 |
+
break;
|
1854 |
+
case 'user_registered':
|
1855 |
+
|
1856 |
+
$offset = 0;
|
1857 |
+
if ( isset( $_POST['gmt_offset'] ) && is_numeric( $_POST['gmt_offset'] ) ) {
|
1858 |
+
$offset = (int) $_POST['gmt_offset'];
|
1859 |
+
}
|
1860 |
+
|
1861 |
+
$from_date = date( 'Y-m-d H:s:i', strtotime( date( 'Y-m-d H:s:i', min( $value ) ) . "+$offset hours" ) );
|
1862 |
+
$to_date = date( 'Y-m-d H:s:i', strtotime( date( 'Y-m-d H:s:i', max( $value ) ) . "+$offset hours" ) );
|
1863 |
+
|
1864 |
+
$date_query = array(
|
1865 |
+
array(
|
1866 |
+
'column' => 'user_registered',
|
1867 |
+
'before' => $to_date,
|
1868 |
+
'after' => $from_date,
|
1869 |
+
'inclusive' => true,
|
1870 |
+
),
|
1871 |
+
);
|
1872 |
+
|
1873 |
+
if ( empty( $this->query_args['date_query'] ) ) {
|
1874 |
+
$this->query_args['date_query'] = $date_query;
|
1875 |
+
} else {
|
1876 |
+
$this->query_args['date_query'] = array_merge( $this->query_args['date_query'], array( $date_query ) );
|
1877 |
+
}
|
1878 |
+
|
1879 |
+
$this->custom_filters_in_query[ $field ] = $value;
|
1880 |
+
|
1881 |
+
break;
|
1882 |
+
case 'last_login':
|
1883 |
+
|
1884 |
+
$offset = 0;
|
1885 |
+
if ( isset( $_POST['gmt_offset'] ) && is_numeric( $_POST['gmt_offset'] ) ) {
|
1886 |
+
$offset = (int) $_POST['gmt_offset'];
|
1887 |
+
}
|
1888 |
+
|
1889 |
+
$from_date = (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ); // client time zone offset
|
1890 |
+
$to_date = (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1; // time 23:59
|
1891 |
+
$meta_query = array(
|
1892 |
+
array(
|
1893 |
+
'key' => '_um_last_login',
|
1894 |
+
'value' => array( $from_date, $to_date ),
|
1895 |
+
'compare' => 'BETWEEN',
|
1896 |
+
'inclusive' => true,
|
1897 |
+
)
|
1898 |
+
);
|
1899 |
+
|
1900 |
+
$this->custom_filters_in_query[ $field ] = $value;
|
1901 |
+
|
1902 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $meta_query ) );
|
1903 |
+
break;
|
1904 |
+
}
|
1905 |
+
|
1906 |
+
}
|
1907 |
+
}
|
1908 |
+
|
1909 |
+
|
1910 |
+
/**
|
1911 |
+
* Set default filters
|
1912 |
+
*
|
1913 |
+
* @param $directory_data
|
1914 |
+
*/
|
1915 |
+
function default_filters( $directory_data ) {
|
1916 |
+
$default_filters = array();
|
1917 |
+
if ( ! empty( $directory_data['search_filters'] ) ) {
|
1918 |
+
$default_filters = maybe_unserialize( $directory_data['search_filters'] );
|
1919 |
+
}
|
1920 |
+
|
1921 |
+
$gmt_offset = get_post_meta( $directory_data['form_id'], '_um_search_filters_gmt', true );
|
1922 |
+
|
1923 |
+
if ( empty( $default_filters ) ) {
|
1924 |
+
return;
|
1925 |
+
}
|
1926 |
+
|
1927 |
+
foreach ( $default_filters as $field => $value ) {
|
1928 |
+
|
1929 |
+
switch ( $field ) {
|
1930 |
+
default:
|
1931 |
+
|
1932 |
+
$filter_type = $this->filter_types[ $field ];
|
1933 |
+
|
1934 |
+
/**
|
1935 |
+
* UM hook
|
1936 |
+
*
|
1937 |
+
* @type filter
|
1938 |
+
* @title um_query_args_{$field}__filter
|
1939 |
+
* @description Change field's query for search at Members Directory
|
1940 |
+
* @input_vars
|
1941 |
+
* [{"var":"$field_query","type":"array","desc":"Field query"}]
|
1942 |
+
* @change_log
|
1943 |
+
* ["Since: 2.0"]
|
1944 |
+
* @usage
|
1945 |
+
* <?php add_filter( 'um_query_args_{$field}__filter', 'function_name', 10, 1 ); ?>
|
1946 |
+
* @example
|
1947 |
+
* <?php
|
1948 |
+
* add_filter( 'um_query_args_{$field}__filter', 'my_query_args_filter', 10, 1 );
|
1949 |
+
* function my_query_args_filter( $field_query ) {
|
1950 |
+
* // your code here
|
1951 |
+
* return $field_query;
|
1952 |
+
* }
|
1953 |
+
* ?>
|
1954 |
+
*/
|
1955 |
+
$field_query = apply_filters( "um_query_args_{$field}__filter", false, $field, $value, $filter_type );
|
1956 |
+
|
1957 |
+
if ( ! $field_query ) {
|
1958 |
+
|
1959 |
+
switch ( $filter_type ) {
|
1960 |
+
default:
|
1961 |
+
|
1962 |
+
$field_query = apply_filters( "um_query_args_{$field}_{$filter_type}__filter", false, $field, $value, $filter_type );
|
1963 |
+
|
1964 |
+
break;
|
1965 |
+
|
1966 |
+
case 'text':
|
1967 |
+
|
1968 |
+
$field_query = array(
|
1969 |
+
'key' => $field,
|
1970 |
+
'value' => $value,
|
1971 |
+
'compare' => apply_filters( 'um_members_directory_filter_text', '=', $field ),
|
1972 |
+
);
|
1973 |
+
|
1974 |
+
break;
|
1975 |
+
|
1976 |
+
case 'select':
|
1977 |
+
if ( ! is_array( $value ) ) {
|
1978 |
+
$value = array( $value );
|
1979 |
+
}
|
1980 |
+
|
1981 |
+
$field_query = array( 'relation' => 'OR' );
|
1982 |
+
|
1983 |
+
foreach ( $value as $single_val ) {
|
1984 |
+
$single_val = trim( $single_val );
|
1985 |
+
|
1986 |
+
$arr_meta_query = array(
|
1987 |
+
array(
|
1988 |
+
'key' => $field,
|
1989 |
+
'value' => $single_val,
|
1990 |
+
'compare' => '=',
|
1991 |
+
),
|
1992 |
+
array(
|
1993 |
+
'key' => $field,
|
1994 |
+
'value' => serialize( (string) $single_val ),
|
1995 |
+
'compare' => 'LIKE',
|
1996 |
+
),
|
1997 |
+
array(
|
1998 |
+
'key' => $field,
|
1999 |
+
'value' => '"' . $single_val . '"',
|
2000 |
+
'compare' => 'LIKE',
|
2001 |
+
)
|
2002 |
+
);
|
2003 |
+
|
2004 |
+
if ( is_numeric( $single_val ) ) {
|
2005 |
+
|
2006 |
+
$arr_meta_query[] = array(
|
2007 |
+
'key' => $field,
|
2008 |
+
'value' => serialize( (int) $single_val ),
|
2009 |
+
'compare' => 'LIKE',
|
2010 |
+
);
|
2011 |
+
|
2012 |
+
}
|
2013 |
+
|
2014 |
+
$field_query = array_merge( $field_query, $arr_meta_query );
|
2015 |
+
}
|
2016 |
+
|
2017 |
+
break;
|
2018 |
+
case 'slider':
|
2019 |
+
|
2020 |
+
$field_query = array(
|
2021 |
+
'key' => $field,
|
2022 |
+
'value' => $value,
|
2023 |
+
'compare' => 'BETWEEN',
|
2024 |
+
'inclusive' => true,
|
2025 |
+
);
|
2026 |
+
|
2027 |
+
break;
|
2028 |
+
case 'datepicker':
|
2029 |
+
|
2030 |
+
$offset = 0;
|
2031 |
+
if ( is_numeric( $gmt_offset ) ) {
|
2032 |
+
$offset = $gmt_offset;
|
2033 |
+
}
|
2034 |
+
|
2035 |
+
$from_date = (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ); // client time zone offset
|
2036 |
+
$to_date = (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1; // time 23:59
|
2037 |
+
$field_query = array(
|
2038 |
+
'key' => $field,
|
2039 |
+
'value' => array( $from_date, $to_date ),
|
2040 |
+
'compare' => 'BETWEEN',
|
2041 |
+
'inclusive' => true,
|
2042 |
+
);
|
2043 |
+
|
2044 |
+
break;
|
2045 |
+
case 'timepicker':
|
2046 |
+
|
2047 |
+
if ( $value[0] == $value[1] ) {
|
2048 |
+
$field_query = array(
|
2049 |
+
'key' => $field,
|
2050 |
+
'value' => $value[0],
|
2051 |
+
);
|
2052 |
+
} else {
|
2053 |
+
$field_query = array(
|
2054 |
+
'key' => $field,
|
2055 |
+
'value' => $value,
|
2056 |
+
'compare' => 'BETWEEN',
|
2057 |
+
'type' => 'TIME',
|
2058 |
+
'inclusive' => true,
|
2059 |
+
);
|
2060 |
+
}
|
2061 |
+
|
2062 |
+
break;
|
2063 |
+
}
|
2064 |
+
|
2065 |
+
}
|
2066 |
+
|
2067 |
+
if ( ! empty( $field_query ) && $field_query !== true ) {
|
2068 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $field_query ) );
|
2069 |
+
}
|
2070 |
+
|
2071 |
+
break;
|
2072 |
+
case 'role':
|
2073 |
+
$value = is_array( $value ) ? $value : explode( '||', $value );
|
2074 |
+
$value = array_map( 'strtolower', $value );
|
2075 |
+
|
2076 |
+
if ( ! empty( $this->query_args['role__in'] ) ) {
|
2077 |
+
$this->query_args['role__in'] = is_array( $this->query_args['role__in'] ) ? $this->query_args['role__in'] : array( $this->query_args['role__in'] );
|
2078 |
+
$default_role = array_intersect( $this->query_args['role__in'], $value );
|
2079 |
+
$um_role = array_diff( $value, $default_role );
|
2080 |
+
|
2081 |
+
foreach ( $um_role as $key => &$val ) {
|
2082 |
+
$val = 'um_' . str_replace( ' ', '-', $val );
|
2083 |
+
}
|
2084 |
+
$this->query_args['role__in'] = array_merge( $default_role, $um_role );
|
2085 |
+
} else {
|
2086 |
+
$this->query_args['role__in'] = $value;
|
2087 |
+
};
|
2088 |
+
|
2089 |
+
break;
|
2090 |
+
case 'birth_date':
|
2091 |
+
$from_date = date( 'Y/m/d', mktime( 0,0,0, date( 'm', time() ), date( 'd', time() ), date( 'Y', time() - min( $value ) * YEAR_IN_SECONDS ) ) );
|
2092 |
+
$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 ) ) );
|
2093 |
+
|
2094 |
+
$meta_query = array(
|
2095 |
+
array(
|
2096 |
+
'key' => 'birth_date',
|
2097 |
+
'value' => array( $to_date, $from_date ),
|
2098 |
+
'compare' => 'BETWEEN',
|
2099 |
+
'type' => 'DATE',
|
2100 |
+
'inclusive' => true,
|
2101 |
+
)
|
2102 |
+
);
|
2103 |
+
|
2104 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $meta_query ) );
|
2105 |
+
|
2106 |
+
break;
|
2107 |
+
case 'user_registered':
|
2108 |
+
$offset = 0;
|
2109 |
+
if ( is_numeric( $gmt_offset ) ) {
|
2110 |
+
$offset = $gmt_offset;
|
2111 |
+
}
|
2112 |
+
|
2113 |
+
$from_date = date( 'Y-m-d H:s:i', strtotime( date( 'Y-m-d H:s:i', min( $value ) ) . "+$offset hours" ) );
|
2114 |
+
$to_date = date( 'Y-m-d H:s:i', strtotime( date( 'Y-m-d H:s:i', max( $value ) ) . "+$offset hours" ) );
|
2115 |
+
|
2116 |
+
$date_query = array(
|
2117 |
+
array(
|
2118 |
+
'column' => 'user_registered',
|
2119 |
+
'before' => $to_date,
|
2120 |
+
'after' => $from_date,
|
2121 |
+
'inclusive' => true,
|
2122 |
+
),
|
2123 |
+
);
|
2124 |
+
|
2125 |
+
if ( empty( $this->query_args['date_query'] ) ) {
|
2126 |
+
$this->query_args['date_query'] = $date_query;
|
2127 |
+
} else {
|
2128 |
+
$this->query_args['date_query'] = array_merge( $this->query_args['date_query'], array( $date_query ) );
|
2129 |
+
}
|
2130 |
+
|
2131 |
+
break;
|
2132 |
+
case 'last_login':
|
2133 |
+
$offset = 0;
|
2134 |
+
if ( is_numeric( $gmt_offset ) ) {
|
2135 |
+
$offset = $gmt_offset;
|
2136 |
+
}
|
2137 |
+
|
2138 |
+
$from_date = (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ); // client time zone offset
|
2139 |
+
$to_date = (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1; // time 23:59
|
2140 |
+
$meta_query = array(
|
2141 |
+
array(
|
2142 |
+
'key' => '_um_last_login',
|
2143 |
+
'value' => array( $from_date, $to_date ),
|
2144 |
+
'compare' => 'BETWEEN',
|
2145 |
+
'inclusive' => true,
|
2146 |
+
)
|
2147 |
+
);
|
2148 |
+
|
2149 |
+
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $meta_query ) );
|
2150 |
+
break;
|
2151 |
+
}
|
2152 |
+
}
|
2153 |
+
}
|
2154 |
+
|
2155 |
+
|
2156 |
+
/**
|
2157 |
+
* Get data array for pagination
|
2158 |
+
*
|
2159 |
+
*
|
2160 |
+
* @param array $directory_data
|
2161 |
+
* @param int $total_users
|
2162 |
+
*
|
2163 |
+
* @return array
|
2164 |
+
*/
|
2165 |
+
function calculate_pagination( $directory_data, $total_users ) {
|
2166 |
+
|
2167 |
+
$current_page = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
|
2168 |
+
|
2169 |
+
$total_users = ( ! empty( $directory_data['max_users'] ) && $directory_data['max_users'] <= $total_users ) ? $directory_data['max_users'] : $total_users;
|
2170 |
+
|
2171 |
+
// number of profiles for mobile
|
2172 |
+
$profiles_per_page = $directory_data['profiles_per_page'];
|
2173 |
+
if ( UM()->mobile()->isMobile() && isset( $directory_data['profiles_per_page_mobile'] ) ) {
|
2174 |
+
$profiles_per_page = $directory_data['profiles_per_page_mobile'];
|
2175 |
+
}
|
2176 |
+
|
2177 |
+
$total_pages = 1;
|
2178 |
+
if ( ! empty( $profiles_per_page ) ) {
|
2179 |
+
$total_pages = ceil( $total_users / $profiles_per_page );
|
2180 |
+
}
|
2181 |
+
|
2182 |
+
if ( ! empty( $total_pages ) ) {
|
2183 |
+
$index1 = 0 - ( $current_page - 2 ) + 1;
|
2184 |
+
$to = $current_page + 2;
|
2185 |
+
if ( $index1 > 0 ) {
|
2186 |
+
$to += $index1;
|
2187 |
+
}
|
2188 |
+
|
2189 |
+
$index2 = $total_pages - ( $current_page + 2 );
|
2190 |
+
$from = $current_page - 2;
|
2191 |
+
if ( $index2 < 0 ) {
|
2192 |
+
$from += $index2;
|
2193 |
+
}
|
2194 |
+
|
2195 |
+
$pages_to_show = range(
|
2196 |
+
( $from > 0 ) ? $from : 1,
|
2197 |
+
( $to <= $total_pages ) ? $to : $total_pages
|
2198 |
+
);
|
2199 |
+
}
|
2200 |
+
|
2201 |
+
|
2202 |
+
$pagination_data = array(
|
2203 |
+
'pages_to_show' => ( ! empty( $pages_to_show ) && count( $pages_to_show ) > 1 ) ? array_values( $pages_to_show ) : array(),
|
2204 |
+
'current_page' => $current_page,
|
2205 |
+
'total_pages' => $total_pages,
|
2206 |
+
'total_users' => $total_users,
|
2207 |
+
);
|
2208 |
+
|
2209 |
+
$pagination_data['header'] = $this->convert_tags( $directory_data['header'], $pagination_data );
|
2210 |
+
$pagination_data['header_single'] = $this->convert_tags( $directory_data['header_single'], $pagination_data );
|
2211 |
+
|
2212 |
+
return $pagination_data;
|
2213 |
+
}
|
2214 |
+
|
2215 |
+
|
2216 |
+
/**
|
2217 |
+
* @param int $user_id
|
2218 |
+
*
|
2219 |
+
* @return array
|
2220 |
+
*/
|
2221 |
+
function build_user_actions_list( $user_id ) {
|
2222 |
+
|
2223 |
+
$actions = array();
|
2224 |
+
if ( ! is_user_logged_in() ) {
|
2225 |
+
return $actions;
|
2226 |
+
}
|
2227 |
+
|
2228 |
+
if ( get_current_user_id() != $user_id ) {
|
2229 |
+
|
2230 |
+
if ( UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
|
2231 |
+
$actions['um-editprofile'] = array(
|
2232 |
+
'title' => __( 'Edit Profile', 'ultimate-member' ),
|
2233 |
+
'url' => um_edit_profile_url(),
|
2234 |
+
);
|
2235 |
+
}
|
2236 |
+
|
2237 |
+
/**
|
2238 |
+
* UM hook
|
2239 |
+
*
|
2240 |
+
* @type filter
|
2241 |
+
* @title um_admin_user_actions_hook
|
2242 |
+
* @description Extend admin actions for each user
|
2243 |
+
* @input_vars
|
2244 |
+
* [{"var":"$actions","type":"array","desc":"Actions for user"}]
|
2245 |
+
* @change_log
|
2246 |
+
* ["Since: 2.0"]
|
2247 |
+
* @usage
|
2248 |
+
* <?php add_filter( 'um_admin_user_actions_hook', 'function_name', 10, 1 ); ?>
|
2249 |
+
* @example
|
2250 |
+
* <?php
|
2251 |
+
* add_filter( 'um_admin_user_actions_hook', 'my_admin_user_actions', 10, 1 );
|
2252 |
+
* function my_admin_user_actions( $actions ) {
|
2253 |
+
* // your code here
|
2254 |
+
* return $actions;
|
2255 |
+
* }
|
2256 |
+
* ?>
|
2257 |
+
*/
|
2258 |
+
$admin_actions = apply_filters( 'um_admin_user_actions_hook', array(), $user_id );
|
2259 |
+
if ( ! empty( $admin_actions ) ) {
|
2260 |
+
foreach ( $admin_actions as $id => $arr ) {
|
2261 |
+
$url = add_query_arg( array( 'um_action' => $id, 'uid' => $user_id ), um_get_core_page( 'user' ) );
|
2262 |
+
|
2263 |
+
$actions[ $id ] = array(
|
2264 |
+
'title' => $arr['label'],
|
2265 |
+
'url' => $url,
|
2266 |
+
);
|
2267 |
+
}
|
2268 |
+
}
|
2269 |
+
|
2270 |
+
$actions = apply_filters( 'um_member_directory_users_card_actions', $actions, $user_id );
|
2271 |
+
|
2272 |
+
} else {
|
2273 |
+
|
2274 |
+
if ( empty( UM()->user()->cannot_edit ) ) {
|
2275 |
+
$actions['um-editprofile'] = array(
|
2276 |
+
'title' => __( 'Edit Profile', 'ultimate-member' ),
|
2277 |
+
'url' => um_edit_profile_url(),
|
2278 |
+
);
|
2279 |
+
}
|
2280 |
+
|
2281 |
+
$actions['um-myaccount'] = array(
|
2282 |
+
'title' => __( 'My Account', 'ultimate-member' ),
|
2283 |
+
'url' => um_get_core_page( 'account' ),
|
2284 |
+
);
|
2285 |
+
|
2286 |
+
$actions['um-logout'] = array(
|
2287 |
+
'title' => __( 'Logout', 'ultimate-member' ),
|
2288 |
+
'url' => um_get_core_page( 'logout' ),
|
2289 |
+
);
|
2290 |
+
|
2291 |
+
$actions = apply_filters( 'um_member_directory_my_user_card_actions', $actions, $user_id );
|
2292 |
+
}
|
2293 |
+
|
2294 |
+
|
2295 |
+
return $actions;
|
2296 |
+
}
|
2297 |
+
|
2298 |
+
|
2299 |
+
/**
|
2300 |
+
* @param int $user_id
|
2301 |
+
* @param array $directory_data
|
2302 |
+
*
|
2303 |
+
* @return array
|
2304 |
+
*/
|
2305 |
+
function build_user_card_data( $user_id, $directory_data ) {
|
2306 |
+
|
2307 |
+
um_fetch_user( $user_id );
|
2308 |
+
|
2309 |
+
$dropdown_actions = $this->build_user_actions_list( $user_id );
|
2310 |
+
|
2311 |
+
$actions = array();
|
2312 |
+
$can_edit = UM()->roles()->um_current_user_can( 'edit', $user_id );
|
2313 |
+
|
2314 |
+
// Replace hook 'um_members_just_after_name'
|
2315 |
+
ob_start();
|
2316 |
+
do_action( 'um_members_just_after_name', $user_id, $directory_data );
|
2317 |
+
$hook_just_after_name = ob_get_clean();
|
2318 |
+
|
2319 |
+
// Replace hook 'um_members_after_user_name'
|
2320 |
+
ob_start();
|
2321 |
+
do_action( 'um_members_after_user_name', $user_id, $directory_data );
|
2322 |
+
$hook_after_user_name = ob_get_clean();
|
2323 |
+
|
2324 |
+
$data_array = array(
|
2325 |
+
'card_anchor' => substr( md5( $user_id ), 10, 5 ),
|
2326 |
+
'id' => $user_id,
|
2327 |
+
'role' => um_user( 'role' ),
|
2328 |
+
'account_status' => um_user( 'account_status' ),
|
2329 |
+
'account_status_name' => um_user( 'account_status_name' ),
|
2330 |
+
'cover_photo' => um_user( 'cover_photo', $this->cover_size ),
|
2331 |
+
'display_name' => um_user( 'display_name' ),
|
2332 |
+
'profile_url' => um_user_profile_url(),
|
2333 |
+
'can_edit' => $can_edit,
|
2334 |
+
'edit_profile_url' => um_edit_profile_url(),
|
2335 |
+
'avatar' => get_avatar( $user_id, $this->avatar_size ),
|
2336 |
+
'display_name_html' => um_user( 'display_name', 'html' ),
|
2337 |
+
'dropdown_actions' => $dropdown_actions,
|
2338 |
+
'hook_just_after_name' => preg_replace( '/^\s+/im', '', $hook_just_after_name ),
|
2339 |
+
'hook_after_user_name' => preg_replace( '/^\s+/im', '', $hook_after_user_name ),
|
2340 |
+
);
|
2341 |
+
|
2342 |
+
if ( ! empty( $directory_data['show_tagline'] ) ) {
|
2343 |
+
|
2344 |
+
if ( ! empty( $directory_data['tagline_fields'] ) ) {
|
2345 |
+
$directory_data['tagline_fields'] = maybe_unserialize( $directory_data['tagline_fields'] );
|
2346 |
+
|
2347 |
+
if ( is_array( $directory_data['tagline_fields'] ) ) {
|
2348 |
+
foreach ( $directory_data['tagline_fields'] as $key ) {
|
2349 |
+
if ( ! $key ) {
|
2350 |
+
continue;
|
2351 |
+
}
|
2352 |
+
|
2353 |
+
$value = um_filtered_value( $key );
|
2354 |
+
|
2355 |
+
if ( ! $value ) {
|
2356 |
+
continue;
|
2357 |
+
}
|
2358 |
+
|
2359 |
+
$data_array[ $key ] = $value;
|
2360 |
+
}
|
2361 |
+
}
|
2362 |
+
}
|
2363 |
+
}
|
2364 |
+
|
2365 |
+
if ( ! empty( $directory_data['show_userinfo'] ) ) {
|
2366 |
+
|
2367 |
+
if ( ! empty( $directory_data['reveal_fields'] ) ) {
|
2368 |
+
|
2369 |
+
$directory_data['reveal_fields'] = maybe_unserialize( $directory_data['reveal_fields'] );
|
2370 |
+
|
2371 |
+
if ( is_array( $directory_data['reveal_fields'] ) ) {
|
2372 |
+
foreach ( $directory_data['reveal_fields'] as $key ) {
|
2373 |
+
if ( ! $key ) {
|
2374 |
+
continue;
|
2375 |
+
}
|
2376 |
+
|
2377 |
+
$value = um_filtered_value( $key );
|
2378 |
+
if ( ! $value ) {
|
2379 |
+
continue;
|
2380 |
+
}
|
2381 |
+
|
2382 |
+
$label = UM()->fields()->get_label( $key );
|
2383 |
+
if ( $key == 'role_select' || $key == 'role_radio' ) {
|
2384 |
+
$label = strtr( $label, array(
|
2385 |
+
' (Dropdown)' => '',
|
2386 |
+
' (Radio)' => ''
|
2387 |
+
) );
|
2388 |
+
}
|
2389 |
+
|
2390 |
+
$data_array[ "label_{$key}" ] = __( $label, 'ultimate-member' );
|
2391 |
+
$data_array[ $key ] = $value;
|
2392 |
+
}
|
2393 |
+
}
|
2394 |
+
}
|
2395 |
+
|
2396 |
+
if ( ! empty( $directory_data['show_social'] ) ) {
|
2397 |
+
ob_start();
|
2398 |
+
UM()->fields()->show_social_urls();
|
2399 |
+
$social_urls = ob_get_clean();
|
2400 |
+
|
2401 |
+
$data_array['social_urls'] = $social_urls;
|
2402 |
+
}
|
2403 |
+
}
|
2404 |
+
|
2405 |
+
$data_array = apply_filters( 'um_ajax_get_members_data', $data_array, $user_id, $directory_data );
|
2406 |
+
|
2407 |
+
um_reset_user_clean();
|
2408 |
+
|
2409 |
+
return $data_array;
|
2410 |
+
}
|
2411 |
+
|
2412 |
+
|
2413 |
+
/**
|
2414 |
+
* Update limit query
|
2415 |
+
*
|
2416 |
+
* @param $user_query
|
2417 |
+
*/
|
2418 |
+
function pagination_changes( $user_query ) {
|
2419 |
+
global $wpdb;
|
2420 |
+
|
2421 |
+
$directory_id = $this->get_directory_by_hash( sanitize_key( $_POST['directory_id'] ) );
|
2422 |
+
$directory_data = UM()->query()->post_data( $directory_id );
|
2423 |
+
|
2424 |
+
$qv = $user_query->query_vars;
|
2425 |
+
|
2426 |
+
$number = $qv['number'];
|
2427 |
+
if ( ! empty( $directory_data['max_users'] ) && $qv['paged']*$qv['number'] > $directory_data['max_users'] ) {
|
2428 |
+
$number = ( $qv['paged']*$qv['number'] - ( $qv['paged']*$qv['number'] - $directory_data['max_users'] ) ) % $qv['number'];
|
2429 |
+
}
|
2430 |
+
|
2431 |
+
// limit
|
2432 |
+
if ( isset( $qv['number'] ) && $qv['number'] > 0 ) {
|
2433 |
+
if ( $qv['offset'] ) {
|
2434 |
+
$user_query->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['offset'], $number );
|
2435 |
+
} else {
|
2436 |
+
$user_query->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['number'] * ( $qv['paged'] - 1 ), $number );
|
2437 |
+
}
|
2438 |
+
}
|
2439 |
+
}
|
2440 |
+
|
2441 |
+
|
2442 |
+
function predefined_no_caps( $directory_data ) {
|
2443 |
+
//predefined result for user without capabilities to see other members
|
2444 |
+
if ( is_user_logged_in() && ! UM()->roles()->um_user_can( 'can_view_all' ) ) {
|
2445 |
+
$pagination_data = array(
|
2446 |
+
'pages_to_show' => array(),
|
2447 |
+
'current_page' => 1,
|
2448 |
+
'total_pages' => 0,
|
2449 |
+
'total_users' => 0,
|
2450 |
+
);
|
2451 |
+
|
2452 |
+
$pagination_data['header'] = $this->convert_tags( $directory_data['header'], $pagination_data );
|
2453 |
+
$pagination_data['header_single'] = $this->convert_tags( $directory_data['header_single'], $pagination_data );
|
2454 |
+
|
2455 |
+
wp_send_json_success( array( 'users' => array(), 'pagination' => $pagination_data ) );
|
2456 |
+
}
|
2457 |
+
}
|
2458 |
+
|
2459 |
+
|
2460 |
+
/**
|
2461 |
+
* Main Query function for getting members via AJAX
|
2462 |
+
*/
|
2463 |
+
function ajax_get_members() {
|
2464 |
+
UM()->check_ajax_nonce();
|
2465 |
+
|
2466 |
+
global $wpdb;
|
2467 |
+
|
2468 |
+
if ( empty( $_POST['directory_id'] ) ) {
|
2469 |
+
wp_send_json_error( __( 'Wrong member directory data', 'ultimate-member' ) );
|
2470 |
+
}
|
2471 |
+
|
2472 |
+
$directory_id = $this->get_directory_by_hash( sanitize_key( $_POST['directory_id'] ) );
|
2473 |
+
|
2474 |
+
if ( empty( $directory_id ) ) {
|
2475 |
+
wp_send_json_error( __( 'Wrong member directory data', 'ultimate-member' ) );
|
2476 |
+
}
|
2477 |
+
|
2478 |
+
$directory_data = UM()->query()->post_data( $directory_id );
|
2479 |
+
|
2480 |
+
//predefined result for user without capabilities to see other members
|
2481 |
+
$this->predefined_no_caps( $directory_data );
|
2482 |
+
|
2483 |
+
do_action( 'um_member_directory_before_query' );
|
2484 |
+
|
2485 |
+
// Prepare for BIG SELECT query
|
2486 |
+
$wpdb->query( 'SET SQL_BIG_SELECTS=1' );
|
2487 |
+
|
2488 |
+
// Prepare default user query values
|
2489 |
+
$this->query_args = array(
|
2490 |
+
'fields' => 'ids',
|
2491 |
+
'number' => 0,
|
2492 |
+
'meta_query' => array(
|
2493 |
+
'relation' => 'AND'
|
2494 |
+
),
|
2495 |
+
);
|
2496 |
+
|
2497 |
+
|
2498 |
+
// handle different restrictions
|
2499 |
+
$this->restriction_options();
|
2500 |
+
|
2501 |
+
// handle general options
|
2502 |
+
$this->general_options( $directory_data );
|
2503 |
+
|
2504 |
+
// handle pagination options
|
2505 |
+
$this->pagination_options( $directory_data );
|
2506 |
+
|
2507 |
+
// handle sorting options
|
2508 |
+
$this->sorting_query( $directory_data );
|
2509 |
+
|
2510 |
+
// handle general search line
|
2511 |
+
$this->general_search();
|
2512 |
+
|
2513 |
+
// handle filters
|
2514 |
+
$this->filters( $directory_data );
|
2515 |
+
|
2516 |
+
$this->default_filters( $directory_data );
|
2517 |
+
|
2518 |
+
/**
|
2519 |
+
* UM hook
|
2520 |
+
*
|
2521 |
+
* @type filter
|
2522 |
+
* @title um_prepare_user_query_args
|
2523 |
+
* @description Extend member directory query arguments
|
2524 |
+
* @input_vars
|
2525 |
+
* [{"var":"$query_args","type":"array","desc":"Members Query Arguments"},
|
2526 |
+
* {"var":"$directory_settings","type":"array","desc":"Member Directory Settings"}]
|
2527 |
+
* @change_log
|
2528 |
+
* ["Since: 2.0"]
|
2529 |
+
* @usage
|
2530 |
+
* <?php add_filter( 'um_prepare_user_query_args', 'function_name', 10, 2 ); ?>
|
2531 |
+
* @example
|
2532 |
+
* <?php
|
2533 |
+
* add_filter( 'um_prepare_user_query_args', 'my_prepare_user_query_args', 10, 2 );
|
2534 |
+
* function my_prepare_user_query_args( $query_args, $directory_settings ) {
|
2535 |
+
* // your code here
|
2536 |
+
* return $query_args;
|
2537 |
+
* }
|
2538 |
+
* ?>
|
2539 |
+
*/
|
2540 |
+
$this->query_args = apply_filters( 'um_prepare_user_query_args', $this->query_args, $directory_data );
|
2541 |
+
|
2542 |
+
//unset empty meta_query attribute
|
2543 |
+
if ( isset( $this->query_args['meta_query']['relation'] ) && count( $this->query_args['meta_query'] ) == 1 ) {
|
2544 |
+
unset( $this->query_args['meta_query'] );
|
2545 |
+
}
|
2546 |
+
|
2547 |
+
if ( isset( $this->query_args['role__in'] ) && empty( $this->query_args['role__in'] ) ) {
|
2548 |
+
$member_directory_response = apply_filters( 'um_ajax_get_members_response', array(
|
2549 |
+
'pagination' => $this->calculate_pagination( $directory_data, 0 ),
|
2550 |
+
'users' => array(),
|
2551 |
+
'is_search' => $this->is_search,
|
2552 |
+
), $directory_data );
|
2553 |
+
|
2554 |
+
wp_send_json_success( $member_directory_response );
|
2555 |
+
}
|
2556 |
+
|
2557 |
+
/**
|
2558 |
+
* UM hook
|
2559 |
+
*
|
2560 |
+
* @type action
|
2561 |
+
* @title um_user_before_query
|
2562 |
+
* @description Action before users query on member directory
|
2563 |
+
* @input_vars
|
2564 |
+
* [{"var":"$query_args","type":"array","desc":"Query arguments"},
|
2565 |
+
* {"var":"$md_class","type":"um\core\Member_Directory","desc":"Member Directory class"}]
|
2566 |
+
* @change_log
|
2567 |
+
* ["Since: 2.0"]
|
2568 |
+
* @usage add_action( 'um_user_before_query', 'function_name', 10, 1 );
|
2569 |
+
* @example
|
2570 |
+
* <?php
|
2571 |
+
* add_action( 'um_user_before_query', 'my_user_before_query', 10, 1 );
|
2572 |
+
* function my_user_before_query( $query_args ) {
|
2573 |
+
* // your code here
|
2574 |
+
* }
|
2575 |
+
* ?>
|
2576 |
+
*/
|
2577 |
+
do_action( 'um_user_before_query', $this->query_args, $this );
|
2578 |
+
|
2579 |
+
add_filter( 'get_meta_sql', array( &$this, 'change_meta_sql' ), 10, 6 );
|
2580 |
+
|
2581 |
+
add_filter( 'pre_user_query', array( &$this, 'pagination_changes' ), 10, 1 );
|
2582 |
+
|
2583 |
+
$user_query = new \WP_User_Query( $this->query_args );
|
2584 |
+
|
2585 |
+
remove_filter( 'pre_user_query', array( &$this, 'pagination_changes' ), 10 );
|
2586 |
+
|
2587 |
+
remove_filter( 'get_meta_sql', array( &$this, 'change_meta_sql' ), 10 );
|
2588 |
+
|
2589 |
+
/**
|
2590 |
+
* UM hook
|
2591 |
+
*
|
2592 |
+
* @type action
|
2593 |
+
* @title um_user_after_query
|
2594 |
+
* @description Action before users query on member directory
|
2595 |
+
* @input_vars
|
2596 |
+
* [{"var":"$query_args","type":"array","desc":"Query arguments"},
|
2597 |
+
* {"var":"$user_query","type":"array","desc":"User Query"}]
|
2598 |
+
* @change_log
|
2599 |
+
* ["Since: 2.0"]
|
2600 |
+
* @usage add_action( 'um_user_after_query', 'function_name', 10, 2 );
|
2601 |
+
* @example
|
2602 |
+
* <?php
|
2603 |
+
* add_action( 'um_user_after_query', 'my_user_after_query', 10, 2 );
|
2604 |
+
* function my_user_after_query( $query_args, $user_query ) {
|
2605 |
+
* // your code here
|
2606 |
+
* }
|
2607 |
+
* ?>
|
2608 |
+
*/
|
2609 |
+
do_action( 'um_user_after_query', $this->query_args, $user_query );
|
2610 |
+
|
2611 |
+
$pagination_data = $this->calculate_pagination( $directory_data, $user_query->total_users );
|
2612 |
+
|
2613 |
+
$user_ids = ! empty( $user_query->results ) ? array_unique( $user_query->results ) : array();
|
2614 |
+
|
2615 |
+
/**
|
2616 |
+
* UM hook
|
2617 |
+
*
|
2618 |
+
* @type filter
|
2619 |
+
* @title um_prepare_user_results_array
|
2620 |
+
* @description Extend member directory query result
|
2621 |
+
* @input_vars
|
2622 |
+
* [{"var":"$result","type":"array","desc":"Members Query Result"}]
|
2623 |
+
* @change_log
|
2624 |
+
* ["Since: 2.0"]
|
2625 |
+
* @usage
|
2626 |
+
* <?php add_filter( 'um_prepare_user_results_array', 'function_name', 10, 2 ); ?>
|
2627 |
+
* @example
|
2628 |
+
* <?php
|
2629 |
+
* add_filter( 'um_prepare_user_results_array', 'my_prepare_user_results', 10, 2 );
|
2630 |
+
* function my_prepare_user_results( $user_ids, $query ) {
|
2631 |
+
* // your code here
|
2632 |
+
* return $user_ids;
|
2633 |
+
* }
|
2634 |
+
* ?>
|
2635 |
+
*/
|
2636 |
+
$user_ids = apply_filters( 'um_prepare_user_results_array', $user_ids, $this->query_args );
|
2637 |
+
|
2638 |
+
|
2639 |
+
$sizes = UM()->options()->get( 'cover_thumb_sizes' );
|
2640 |
+
|
2641 |
+
$this->cover_size = UM()->mobile()->isTablet() ? $sizes[1] : end( $sizes );
|
2642 |
+
|
2643 |
+
$this->cover_size = apply_filters( 'um_member_directory_cover_image_size', $this->cover_size, $directory_data );
|
2644 |
+
|
2645 |
+
$avatar_size = UM()->options()->get( 'profile_photosize' );
|
2646 |
+
$this->avatar_size = str_replace( 'px', '', $avatar_size );
|
2647 |
+
$this->avatar_size = apply_filters( 'um_member_directory_avatar_image_size', $this->avatar_size, $directory_data );
|
2648 |
+
|
2649 |
+
$users = array();
|
2650 |
+
foreach ( $user_ids as $user_id ) {
|
2651 |
+
$users[] = $this->build_user_card_data( $user_id, $directory_data );
|
2652 |
+
}
|
2653 |
+
|
2654 |
+
um_reset_user();
|
2655 |
+
// end of user card
|
2656 |
+
|
2657 |
+
$member_directory_response = apply_filters( 'um_ajax_get_members_response', array(
|
2658 |
+
'pagination' => $pagination_data,
|
2659 |
+
'users' => $users,
|
2660 |
+
'is_search' => $this->is_search,
|
2661 |
+
), $directory_data );
|
2662 |
+
|
2663 |
+
wp_send_json_success( $member_directory_response );
|
2664 |
+
}
|
2665 |
+
|
2666 |
+
|
2667 |
+
/**
|
2668 |
+
* New menu
|
2669 |
+
*
|
2670 |
+
* @param string $element
|
2671 |
+
* @param string $trigger
|
2672 |
+
* @param array $items
|
2673 |
+
* @param string $parent
|
2674 |
+
*/
|
2675 |
+
function dropdown_menu( $element, $trigger, $items = array(), $parent = '' ) {
|
2676 |
+
// !!!!Important: all links in the dropdown items must have "class" attribute
|
2677 |
+
?>
|
2678 |
+
|
2679 |
+
<div class="um-new-dropdown" data-element="<?php echo $element; ?>" data-trigger="<?php echo $trigger; ?>" data-parent="<?php echo $parent; ?>">
|
2680 |
+
<ul>
|
2681 |
+
<?php foreach ( $items as $k => $v ) { ?>
|
2682 |
+
<li><?php echo $v; ?></li>
|
2683 |
+
<?php } ?>
|
2684 |
+
</ul>
|
2685 |
+
</div>
|
2686 |
+
|
2687 |
+
<?php
|
2688 |
+
}
|
2689 |
+
|
2690 |
+
|
2691 |
+
/**
|
2692 |
+
* New menu JS
|
2693 |
+
*
|
2694 |
+
* @param string $element
|
2695 |
+
* @param string $trigger
|
2696 |
+
* @param string $item
|
2697 |
+
* @param string $additional_attributes
|
2698 |
+
* @param string $parent
|
2699 |
+
*/
|
2700 |
+
function dropdown_menu_js( $element, $trigger, $item, $additional_attributes = '', $parent = '' ) {
|
2701 |
+
?>
|
2702 |
+
|
2703 |
+
<div class="um-new-dropdown" data-element="<?php echo $element; ?>" data-trigger="<?php echo $trigger; ?>" data-parent="<?php echo $parent; ?>">
|
2704 |
+
<ul>
|
2705 |
+
<# _.each( <?php echo $item; ?>.dropdown_actions, function( action, key, list ) { #>
|
2706 |
+
<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>
|
2707 |
+
<# }); #>
|
2708 |
+
</ul>
|
2709 |
+
</div>
|
2710 |
+
|
2711 |
+
<?php
|
2712 |
+
}
|
2713 |
+
|
2714 |
+
|
2715 |
+
/**
|
2716 |
+
* AJAX handler - Get options for the member directory "Admin filtering"
|
2717 |
+
* @version 2.1.12
|
2718 |
+
*/
|
2719 |
+
function default_filter_settings() {
|
2720 |
+
UM()->admin()->check_ajax_nonce();
|
2721 |
+
|
2722 |
+
// we can't use function "sanitize_key" because it changes uppercase to lowercase
|
2723 |
+
$filter_key = sanitize_text_field( $_REQUEST['key'] );
|
2724 |
+
$directory_id = absint( $_REQUEST['directory_id'] );
|
2725 |
+
|
2726 |
+
$html = $this->show_filter( $filter_key, array( 'form_id' => $directory_id ), false, true );
|
2727 |
+
|
2728 |
+
wp_send_json_success( array( 'field_html' => $html ) );
|
2729 |
+
}
|
2730 |
+
}
|
2731 |
+
}
|
includes/core/class-query.php
CHANGED
@@ -1,460 +1,460 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\core;
|
3 |
-
|
4 |
-
// Exit if accessed directly.
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
if ( ! class_exists( 'um\core\Query' ) ) {
|
8 |
-
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class Query
|
12 |
-
* @package um\core
|
13 |
-
*/
|
14 |
-
class Query {
|
15 |
-
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @var array
|
19 |
-
*/
|
20 |
-
public $wp_pages = array();
|
21 |
-
|
22 |
-
|
23 |
-
/**
|
24 |
-
* @var array
|
25 |
-
*/
|
26 |
-
public $roles = array();
|
27 |
-
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Query constructor.
|
31 |
-
*/
|
32 |
-
public function __construct() {
|
33 |
-
|
34 |
-
|
35 |
-
}
|
36 |
-
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Ajax pagination for posts
|
40 |
-
*/
|
41 |
-
public function ajax_paginate() {
|
42 |
-
UM()->check_ajax_nonce();
|
43 |
-
|
44 |
-
/**
|
45 |
-
* @var $hook
|
46 |
-
* @var $args
|
47 |
-
*/
|
48 |
-
extract( $_REQUEST );
|
49 |
-
|
50 |
-
ob_start();
|
51 |
-
|
52 |
-
/**
|
53 |
-
* UM hook
|
54 |
-
*
|
55 |
-
* @type action
|
56 |
-
* @title um_ajax_load_posts__{$hook}
|
57 |
-
* @description Action on posts loading by AJAX
|
58 |
-
* @input_vars
|
59 |
-
* [{"var":"$args","type":"array","desc":"Query arguments"}]
|
60 |
-
* @change_log
|
61 |
-
* ["Since: 2.0"]
|
62 |
-
* @usage add_action( 'um_ajax_load_posts__{$hook}', 'function_name', 10, 1 );
|
63 |
-
* @example
|
64 |
-
* <?php
|
65 |
-
* add_action( 'um_ajax_load_posts__{$hook}', 'my_ajax_load_posts', 10, 1 );
|
66 |
-
* function my_ajax_load_posts( $args ) {
|
67 |
-
* // your code here
|
68 |
-
* }
|
69 |
-
* ?>
|
70 |
-
*/
|
71 |
-
do_action( "um_ajax_load_posts__{$hook}", $args );
|
72 |
-
|
73 |
-
$output = ob_get_clean();
|
74 |
-
|
75 |
-
die( $output );
|
76 |
-
}
|
77 |
-
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Get wp pages
|
81 |
-
*
|
82 |
-
* @return array|string
|
83 |
-
*/
|
84 |
-
function wp_pages() {
|
85 |
-
global $wpdb;
|
86 |
-
|
87 |
-
if( isset( $this->wp_pages ) && ! empty( $this->wp_pages ) ){
|
88 |
-
return $this->wp_pages;
|
89 |
-
}
|
90 |
-
|
91 |
-
$count_pages = wp_count_posts('page');
|
92 |
-
|
93 |
-
if ( $count_pages->publish > 300 ){
|
94 |
-
return 'reached_maximum_limit';
|
95 |
-
}
|
96 |
-
|
97 |
-
$pages = $wpdb->get_results(
|
98 |
-
"SELECT *
|
99 |
-
FROM {$wpdb->posts}
|
100 |
-
WHERE post_type = 'page' AND
|
101 |
-
post_status = 'publish'",
|
102 |
-
OBJECT
|
103 |
-
);
|
104 |
-
|
105 |
-
$array = array();
|
106 |
-
if( $wpdb->num_rows > 0 ){
|
107 |
-
foreach ($pages as $page_data) {
|
108 |
-
$array[ $page_data->ID ] = $page_data->post_title;
|
109 |
-
}
|
110 |
-
}
|
111 |
-
|
112 |
-
$this->wp_pages = $array;
|
113 |
-
|
114 |
-
return $array;
|
115 |
-
}
|
116 |
-
|
117 |
-
|
118 |
-
/**
|
119 |
-
* Get all forms
|
120 |
-
*
|
121 |
-
* @return mixed
|
122 |
-
*/
|
123 |
-
function forms() {
|
124 |
-
$results = array();
|
125 |
-
|
126 |
-
$args = array(
|
127 |
-
'post_type' => 'um_form',
|
128 |
-
'posts_per_page' => 200,
|
129 |
-
'post_status' => array('publish')
|
130 |
-
);
|
131 |
-
$query = new \WP_Query( $args );
|
132 |
-
|
133 |
-
foreach ( $query->posts as $post ) {
|
134 |
-
setup_postdata( $post );
|
135 |
-
$results[ $post->ID ] = $post->post_title;
|
136 |
-
}
|
137 |
-
return $results;
|
138 |
-
}
|
139 |
-
|
140 |
-
|
141 |
-
/**
|
142 |
-
* Do custom queries
|
143 |
-
*
|
144 |
-
* @param $args
|
145 |
-
*
|
146 |
-
* @return array|bool|int|\WP_Query
|
147 |
-
*/
|
148 |
-
function make( $args ) {
|
149 |
-
|
150 |
-
$defaults = array(
|
151 |
-
'post_type' => 'post',
|
152 |
-
'post_status' => array('publish')
|
153 |
-
);
|
154 |
-
$args = wp_parse_args( $args, $defaults );
|
155 |
-
|
156 |
-
if ( isset( $args['post__in'] ) && empty( $args['post__in'] ) )
|
157 |
-
return false;
|
158 |
-
|
159 |
-
extract( $args );
|
160 |
-
|
161 |
-
if ( $post_type == 'comment' ) { // comments
|
162 |
-
|
163 |
-
unset( $args['post_type'] );
|
164 |
-
|
165 |
-
/**
|
166 |
-
* UM hook
|
167 |
-
*
|
168 |
-
* @type filter
|
169 |
-
* @title um_excluded_comment_types
|
170 |
-
* @description Extend excluded comment types
|
171 |
-
* @input_vars
|
172 |
-
* [{"var":"$types","type":"array","desc":"Comment Types"}]
|
173 |
-
* @change_log
|
174 |
-
* ["Since: 2.0"]
|
175 |
-
* @usage
|
176 |
-
* <?php add_filter( 'um_excluded_comment_types', 'function_name', 10, 1 ); ?>
|
177 |
-
* @example
|
178 |
-
* <?php
|
179 |
-
* add_filter( 'um_excluded_comment_types', 'my_excluded_comment_types', 10, 1 );
|
180 |
-
* function my_profile_active_tab( $types ) {
|
181 |
-
* // your code here
|
182 |
-
* return $types;
|
183 |
-
* }
|
184 |
-
* ?>
|
185 |
-
*/
|
186 |
-
$args['type__not_in'] = apply_filters( 'um_excluded_comment_types', array('') );
|
187 |
-
|
188 |
-
$comments = get_comments($args);
|
189 |
-
return $comments;
|
190 |
-
|
191 |
-
} else {
|
192 |
-
$custom_posts = new \WP_Query();
|
193 |
-
$args['post_status'] = is_array( $args['post_status'] ) ? $args['post_status'] : explode( ',', $args['post_status'] );
|
194 |
-
|
195 |
-
$custom_posts->query( $args );
|
196 |
-
|
197 |
-
return $custom_posts;
|
198 |
-
}
|
199 |
-
}
|
200 |
-
|
201 |
-
|
202 |
-
/**
|
203 |
-
* Get last users
|
204 |
-
*
|
205 |
-
* @param int $number
|
206 |
-
*
|
207 |
-
* @return array
|
208 |
-
*/
|
209 |
-
function get_recent_users($number = 5){
|
210 |
-
$args = array( 'fields' => 'ID', 'number' => $number, 'orderby' => 'user_registered', 'order' => 'desc' );
|
211 |
-
|
212 |
-
$users = new \WP_User_Query( $args );
|
213 |
-
return $users->results;
|
214 |
-
}
|
215 |
-
|
216 |
-
|
217 |
-
/**
|
218 |
-
* Count users by status
|
219 |
-
*
|
220 |
-
* @param $status
|
221 |
-
*
|
222 |
-
* @return int
|
223 |
-
*/
|
224 |
-
function count_users_by_status( $status ) {
|
225 |
-
$args = array( 'fields' => 'ID', 'number' => 0, 'um_custom_user_query' => true );
|
226 |
-
if ( $status == 'unassigned' ) {
|
227 |
-
$args['meta_query'][] = array(array('key' => 'account_status','compare' => 'NOT EXISTS'));
|
228 |
-
$users = new \WP_User_Query( $args );
|
229 |
-
foreach ( $users->results as $user ) {
|
230 |
-
update_user_meta( $user, 'account_status', 'approved' );
|
231 |
-
}
|
232 |
-
return 0;
|
233 |
-
} else {
|
234 |
-
$args['meta_query'][] = array(array('key' => 'account_status','value' => $status,'compare' => '='));
|
235 |
-
}
|
236 |
-
$users = new \WP_User_Query( $args );
|
237 |
-
return count( $users->results );
|
238 |
-
}
|
239 |
-
|
240 |
-
|
241 |
-
/**
|
242 |
-
* Get users by status
|
243 |
-
*
|
244 |
-
* @param $status
|
245 |
-
* @param int $number
|
246 |
-
*
|
247 |
-
* @return array
|
248 |
-
*/
|
249 |
-
function get_users_by_status($status, $number = 5){
|
250 |
-
$args = array( 'fields' => 'ID', 'number' => $number, 'orderby' => 'user_registered', 'order' => 'desc' );
|
251 |
-
|
252 |
-
$args['meta_query'][] = array(
|
253 |
-
array(
|
254 |
-
'key' => 'account_status',
|
255 |
-
'value' => $status,
|
256 |
-
'compare' => '='
|
257 |
-
)
|
258 |
-
);
|
259 |
-
|
260 |
-
$users = new \WP_User_Query( $args );
|
261 |
-
return $users->results;
|
262 |
-
}
|
263 |
-
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Count all users
|
267 |
-
*
|
268 |
-
* @return mixed
|
269 |
-
*/
|
270 |
-
function count_users() {
|
271 |
-
$result = count_users();
|
272 |
-
return $result['total_users'];
|
273 |
-
}
|
274 |
-
|
275 |
-
|
276 |
-
/**
|
277 |
-
* Using wpdb instead of update_post_meta
|
278 |
-
*
|
279 |
-
* @param $key
|
280 |
-
* @param $post_id
|
281 |
-
* @param $new_value
|
282 |
-
*/
|
283 |
-
function update_attr( $key, $post_id, $new_value ) {
|
284 |
-
/**
|
285 |
-
* Post meta values are passed through the stripslashes() function upon being stored.
|
286 |
-
* Function wp_slash() is added to compensate for the call to stripslashes().
|
287 |
-
* @see https://developer.wordpress.org/reference/functions/update_post_meta/
|
288 |
-
*/
|
289 |
-
if ( is_array( $new_value ) ) {
|
290 |
-
foreach ( $new_value as $k => $val ) {
|
291 |
-
if ( is_array( $val ) && array_key_exists( 'custom_dropdown_options_source', $val ) ) {
|
292 |
-
$new_value[ $k ]['custom_dropdown_options_source'] = wp_slash( $val['custom_dropdown_options_source'] );
|
293 |
-
}
|
294 |
-
}
|
295 |
-
}
|
296 |
-
|
297 |
-
update_post_meta( $post_id, '_um_' . $key, $new_value );
|
298 |
-
}
|
299 |
-
|
300 |
-
|
301 |
-
/**
|
302 |
-
* Get data
|
303 |
-
*
|
304 |
-
* @param $key
|
305 |
-
* @param $post_id
|
306 |
-
*
|
307 |
-
* @return mixed
|
308 |
-
*/
|
309 |
-
function get_attr( $key, $post_id ) {
|
310 |
-
$meta = get_post_meta( $post_id, '_um_' . $key, true );
|
311 |
-
return $meta;
|
312 |
-
}
|
313 |
-
|
314 |
-
|
315 |
-
/**
|
316 |
-
* Delete data
|
317 |
-
*
|
318 |
-
* @param $key
|
319 |
-
* @param $post_id
|
320 |
-
*
|
321 |
-
* @return bool
|
322 |
-
*/
|
323 |
-
function delete_attr( $key, $post_id ) {
|
324 |
-
$meta = delete_post_meta( $post_id, '_um_' . $key );
|
325 |
-
return $meta;
|
326 |
-
}
|
327 |
-
|
328 |
-
|
329 |
-
/**
|
330 |
-
* Checks if post has a specific meta key
|
331 |
-
*
|
332 |
-
* @param $key
|
333 |
-
* @param null $value
|
334 |
-
* @param null $post_id
|
335 |
-
*
|
336 |
-
* @return bool
|
337 |
-
*/
|
338 |
-
function has_post_meta( $key, $value = null, $post_id = null ) {
|
339 |
-
if ( ! $post_id ) {
|
340 |
-
global $post;
|
341 |
-
$post_id = $post->ID;
|
342 |
-
}
|
343 |
-
if ( $value ) {
|
344 |
-
if ( get_post_meta( $post_id, $key, true ) == $value ) {
|
345 |
-
return true;
|
346 |
-
}
|
347 |
-
} else {
|
348 |
-
if ( get_post_meta( $post_id, $key, true ) ) {
|
349 |
-
return true;
|
350 |
-
}
|
351 |
-
}
|
352 |
-
return false;
|
353 |
-
}
|
354 |
-
|
355 |
-
|
356 |
-
/**
|
357 |
-
* Get posts with specific meta key/value
|
358 |
-
*
|
359 |
-
* @param $post_type
|
360 |
-
* @param $key
|
361 |
-
* @param $value
|
362 |
-
*
|
363 |
-
* @return bool
|
364 |
-
*/
|
365 |
-
function find_post_id( $post_type, $key, $value ) {
|
366 |
-
$posts = get_posts( array( 'post_type' => $post_type, 'meta_key' => $key, 'meta_value' => $value ) );
|
367 |
-
if ( isset( $posts[0] ) && ! empty( $posts ) )
|
368 |
-
return $posts[0]->ID;
|
369 |
-
return false;
|
370 |
-
}
|
371 |
-
|
372 |
-
|
373 |
-
/**
|
374 |
-
* Get post data
|
375 |
-
*
|
376 |
-
* @param $post_id
|
377 |
-
*
|
378 |
-
* @return mixed
|
379 |
-
*/
|
380 |
-
function post_data( $post_id ) {
|
381 |
-
$array['form_id'] = $post_id;
|
382 |
-
$mode = $this->get_attr('mode', $post_id);
|
383 |
-
$meta = get_post_custom( $post_id );
|
384 |
-
foreach ($meta as $k => $v){
|
385 |
-
if ( strstr($k, '_um_'.$mode.'_' ) ) {
|
386 |
-
$k = str_replace('_um_'.$mode.'_', '', $k);
|
387 |
-
$array[$k] = $v[0];
|
388 |
-
} elseif ($k == '_um_mode'){
|
389 |
-
$k = str_replace('_um_', '', $k);
|
390 |
-
$array[$k] = $v[0];
|
391 |
-
} elseif ( strstr($k, '_um_') ) {
|
392 |
-
$k = str_replace('_um_', '', $k);
|
393 |
-
$array[$k] = $v[0];
|
394 |
-
}
|
395 |
-
|
396 |
-
}
|
397 |
-
|
398 |
-
foreach( $array as $k => $v ) {
|
399 |
-
if ( strstr( $k, 'login_') || strstr( $k, 'register_' ) || strstr( $k, 'profile_' ) ){
|
400 |
-
if ( $mode != 'directory' ) {
|
401 |
-
unset($array[$k]);
|
402 |
-
}
|
403 |
-
}
|
404 |
-
}
|
405 |
-
return $array;
|
406 |
-
}
|
407 |
-
|
408 |
-
|
409 |
-
/**
|
410 |
-
* Capture selected value
|
411 |
-
*
|
412 |
-
* @param string $key
|
413 |
-
* @param string|null $array_key
|
414 |
-
* @param bool $fallback
|
415 |
-
* @return int|mixed|null|string
|
416 |
-
*/
|
417 |
-
function get_meta_value( $key, $array_key = null, $fallback = false ) {
|
418 |
-
$post_id = get_the_ID();
|
419 |
-
$try = get_post_meta( $post_id, $key, true );
|
420 |
-
|
421 |
-
//old-old version if ( ! empty( $try ) )
|
422 |
-
//old version if ( $try !== false )
|
423 |
-
if ( $try != '' ) {
|
424 |
-
if ( is_array( $try ) && in_array( $array_key, $try ) ) {
|
425 |
-
return $array_key;
|
426 |
-
} else if ( is_array( $try ) ) {
|
427 |
-
return '';
|
428 |
-
} else {
|
429 |
-
return $try;
|
430 |
-
}
|
431 |
-
}
|
432 |
-
|
433 |
-
if ( $fallback == 'na' ) {
|
434 |
-
$fallback = 0;
|
435 |
-
$none = '';
|
436 |
-
} else {
|
437 |
-
$none = 0;
|
438 |
-
}
|
439 |
-
return ! empty( $fallback ) ? $fallback : $none;
|
440 |
-
}
|
441 |
-
|
442 |
-
|
443 |
-
/**
|
444 |
-
* Checks if its a core page of UM
|
445 |
-
*
|
446 |
-
* @param $post_id
|
447 |
-
*
|
448 |
-
* @return bool|mixed
|
449 |
-
*/
|
450 |
-
function is_core( $post_id ){
|
451 |
-
$is_core = get_post_meta($post_id, '_um_core', true);
|
452 |
-
if ( $is_core != '' ) {
|
453 |
-
return $is_core;
|
454 |
-
} else {
|
455 |
-
return false;
|
456 |
-
}
|
457 |
-
}
|
458 |
-
|
459 |
-
}
|
460 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\core;
|
3 |
+
|
4 |
+
// Exit if accessed directly.
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
if ( ! class_exists( 'um\core\Query' ) ) {
|
8 |
+
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Query
|
12 |
+
* @package um\core
|
13 |
+
*/
|
14 |
+
class Query {
|
15 |
+
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var array
|
19 |
+
*/
|
20 |
+
public $wp_pages = array();
|
21 |
+
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var array
|
25 |
+
*/
|
26 |
+
public $roles = array();
|
27 |
+
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Query constructor.
|
31 |
+
*/
|
32 |
+
public function __construct() {
|
33 |
+
|
34 |
+
|
35 |
+
}
|
36 |
+
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Ajax pagination for posts
|
40 |
+
*/
|
41 |
+
public function ajax_paginate() {
|
42 |
+
UM()->check_ajax_nonce();
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @var $hook
|
46 |
+
* @var $args
|
47 |
+
*/
|
48 |
+
extract( $_REQUEST );
|
49 |
+
|
50 |
+
ob_start();
|
51 |
+
|
52 |
+
/**
|
53 |
+
* UM hook
|
54 |
+
*
|
55 |
+
* @type action
|
56 |
+
* @title um_ajax_load_posts__{$hook}
|
57 |
+
* @description Action on posts loading by AJAX
|
58 |
+
* @input_vars
|
59 |
+
* [{"var":"$args","type":"array","desc":"Query arguments"}]
|
60 |
+
* @change_log
|
61 |
+
* ["Since: 2.0"]
|
62 |
+
* @usage add_action( 'um_ajax_load_posts__{$hook}', 'function_name', 10, 1 );
|
63 |
+
* @example
|
64 |
+
* <?php
|
65 |
+
* add_action( 'um_ajax_load_posts__{$hook}', 'my_ajax_load_posts', 10, 1 );
|
66 |
+
* function my_ajax_load_posts( $args ) {
|
67 |
+
* // your code here
|
68 |
+
* }
|
69 |
+
* ?>
|
70 |
+
*/
|
71 |
+
do_action( "um_ajax_load_posts__{$hook}", $args );
|
72 |
+
|
73 |
+
$output = ob_get_clean();
|
74 |
+
|
75 |
+
die( $output );
|
76 |
+
}
|
77 |
+
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Get wp pages
|
81 |
+
*
|
82 |
+
* @return array|string
|
83 |
+
*/
|
84 |
+
function wp_pages() {
|
85 |
+
global $wpdb;
|
86 |
+
|
87 |
+
if( isset( $this->wp_pages ) && ! empty( $this->wp_pages ) ){
|
88 |
+
return $this->wp_pages;
|
89 |
+
}
|
90 |
+
|
91 |
+
$count_pages = wp_count_posts('page');
|
92 |
+
|
93 |
+
if ( $count_pages->publish > 300 ){
|
94 |
+
return 'reached_maximum_limit';
|
95 |
+
}
|
96 |
+
|
97 |
+
$pages = $wpdb->get_results(
|
98 |
+
"SELECT *
|
99 |
+
FROM {$wpdb->posts}
|
100 |
+
WHERE post_type = 'page' AND
|
101 |
+
post_status = 'publish'",
|
102 |
+
OBJECT
|
103 |
+
);
|
104 |
+
|
105 |
+
$array = array();
|
106 |
+
if( $wpdb->num_rows > 0 ){
|
107 |
+
foreach ($pages as $page_data) {
|
108 |
+
$array[ $page_data->ID ] = $page_data->post_title;
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
$this->wp_pages = $array;
|
113 |
+
|
114 |
+
return $array;
|
115 |
+
}
|
116 |
+
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Get all forms
|
120 |
+
*
|
121 |
+
* @return mixed
|
122 |
+
*/
|
123 |
+
function forms() {
|
124 |
+
$results = array();
|
125 |
+
|
126 |
+
$args = array(
|
127 |
+
'post_type' => 'um_form',
|
128 |
+
'posts_per_page' => 200,
|
129 |
+
'post_status' => array('publish')
|
130 |
+
);
|
131 |
+
$query = new \WP_Query( $args );
|
132 |
+
|
133 |
+
foreach ( $query->posts as $post ) {
|
134 |
+
setup_postdata( $post );
|
135 |
+
$results[ $post->ID ] = $post->post_title;
|
136 |
+
}
|
137 |
+
return $results;
|
138 |
+
}
|
139 |
+
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Do custom queries
|
143 |
+
*
|
144 |
+
* @param $args
|
145 |
+
*
|
146 |
+
* @return array|bool|int|\WP_Query
|
147 |
+
*/
|
148 |
+
function make( $args ) {
|
149 |
+
|
150 |
+
$defaults = array(
|
151 |
+
'post_type' => 'post',
|
152 |
+
'post_status' => array('publish')
|
153 |
+
);
|
154 |
+
$args = wp_parse_args( $args, $defaults );
|
155 |
+
|
156 |
+
if ( isset( $args['post__in'] ) && empty( $args['post__in'] ) )
|
157 |
+
return false;
|
158 |
+
|
159 |
+
extract( $args );
|
160 |
+
|
161 |
+
if ( $post_type == 'comment' ) { // comments
|
162 |
+
|
163 |
+
unset( $args['post_type'] );
|
164 |
+
|
165 |
+
/**
|
166 |
+
* UM hook
|
167 |
+
*
|
168 |
+
* @type filter
|
169 |
+
* @title um_excluded_comment_types
|
170 |
+
* @description Extend excluded comment types
|
171 |
+
* @input_vars
|
172 |
+
* [{"var":"$types","type":"array","desc":"Comment Types"}]
|
173 |
+
* @change_log
|
174 |
+
* ["Since: 2.0"]
|
175 |
+
* @usage
|
176 |
+
* <?php add_filter( 'um_excluded_comment_types', 'function_name', 10, 1 ); ?>
|
177 |
+
* @example
|
178 |
+
* <?php
|
179 |
+
* add_filter( 'um_excluded_comment_types', 'my_excluded_comment_types', 10, 1 );
|
180 |
+
* function my_profile_active_tab( $types ) {
|
181 |
+
* // your code here
|
182 |
+
* return $types;
|
183 |
+
* }
|
184 |
+
* ?>
|
185 |
+
*/
|
186 |
+
$args['type__not_in'] = apply_filters( 'um_excluded_comment_types', array('') );
|
187 |
+
|
188 |
+
$comments = get_comments($args);
|
189 |
+
return $comments;
|
190 |
+
|
191 |
+
} else {
|
192 |
+
$custom_posts = new \WP_Query();
|
193 |
+
$args['post_status'] = is_array( $args['post_status'] ) ? $args['post_status'] : explode( ',', $args['post_status'] );
|
194 |
+
|
195 |
+
$custom_posts->query( $args );
|
196 |
+
|
197 |
+
return $custom_posts;
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Get last users
|
204 |
+
*
|
205 |
+
* @param int $number
|
206 |
+
*
|
207 |
+
* @return array
|
208 |
+
*/
|
209 |
+
function get_recent_users($number = 5){
|
210 |
+
$args = array( 'fields' => 'ID', 'number' => $number, 'orderby' => 'user_registered', 'order' => 'desc' );
|
211 |
+
|
212 |
+
$users = new \WP_User_Query( $args );
|
213 |
+
return $users->results;
|
214 |
+
}
|
215 |
+
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Count users by status
|
219 |
+
*
|
220 |
+
* @param $status
|
221 |
+
*
|
222 |
+
* @return int
|
223 |
+
*/
|
224 |
+
function count_users_by_status( $status ) {
|
225 |
+
$args = array( 'fields' => 'ID', 'number' => 0, 'um_custom_user_query' => true );
|
226 |
+
if ( $status == 'unassigned' ) {
|
227 |
+
$args['meta_query'][] = array(array('key' => 'account_status','compare' => 'NOT EXISTS'));
|
228 |
+
$users = new \WP_User_Query( $args );
|
229 |
+
foreach ( $users->results as $user ) {
|
230 |
+
update_user_meta( $user, 'account_status', 'approved' );
|
231 |
+
}
|
232 |
+
return 0;
|
233 |
+
} else {
|
234 |
+
$args['meta_query'][] = array(array('key' => 'account_status','value' => $status,'compare' => '='));
|
235 |
+
}
|
236 |
+
$users = new \WP_User_Query( $args );
|
237 |
+
return count( $users->results );
|
238 |
+
}
|
239 |
+
|
240 |
+
|
241 |
+
/**
|
242 |
+
* Get users by status
|
243 |
+
*
|
244 |
+
* @param $status
|
245 |
+
* @param int $number
|
246 |
+
*
|
247 |
+
* @return array
|
248 |
+
*/
|
249 |
+
function get_users_by_status($status, $number = 5){
|
250 |
+
$args = array( 'fields' => 'ID', 'number' => $number, 'orderby' => 'user_registered', 'order' => 'desc' );
|
251 |
+
|
252 |
+
$args['meta_query'][] = array(
|
253 |
+
array(
|
254 |
+
'key' => 'account_status',
|
255 |
+
'value' => $status,
|
256 |
+
'compare' => '='
|
257 |
+
)
|
258 |
+
);
|
259 |
+
|
260 |
+
$users = new \WP_User_Query( $args );
|
261 |
+
return $users->results;
|
262 |
+
}
|
263 |
+
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Count all users
|
267 |
+
*
|
268 |
+
* @return mixed
|
269 |
+
*/
|
270 |
+
function count_users() {
|
271 |
+
$result = count_users();
|
272 |
+
return $result['total_users'];
|
273 |
+
}
|
274 |
+
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Using wpdb instead of update_post_meta
|
278 |
+
*
|
279 |
+
* @param $key
|
280 |
+
* @param $post_id
|
281 |
+
* @param $new_value
|
282 |
+
*/
|
283 |
+
function update_attr( $key, $post_id, $new_value ) {
|
284 |
+
/**
|
285 |
+
* Post meta values are passed through the stripslashes() function upon being stored.
|
286 |
+
* Function wp_slash() is added to compensate for the call to stripslashes().
|
287 |
+
* @see https://developer.wordpress.org/reference/functions/update_post_meta/
|
288 |
+
*/
|
289 |
+
if ( is_array( $new_value ) ) {
|
290 |
+
foreach ( $new_value as $k => $val ) {
|
291 |
+
if ( is_array( $val ) && array_key_exists( 'custom_dropdown_options_source', $val ) ) {
|
292 |
+
$new_value[ $k ]['custom_dropdown_options_source'] = wp_slash( $val['custom_dropdown_options_source'] );
|
293 |
+
}
|
294 |
+
}
|
295 |
+
}
|
296 |
+
|
297 |
+
update_post_meta( $post_id, '_um_' . $key, $new_value );
|
298 |
+
}
|
299 |
+
|
300 |
+
|
301 |
+
/**
|
302 |
+
* Get data
|
303 |
+
*
|
304 |
+
* @param $key
|
305 |
+
* @param $post_id
|
306 |
+
*
|
307 |
+
* @return mixed
|
308 |
+
*/
|
309 |
+
function get_attr( $key, $post_id ) {
|
310 |
+
$meta = get_post_meta( $post_id, '_um_' . $key, true );
|
311 |
+
return $meta;
|
312 |
+
}
|
313 |
+
|
314 |
+
|
315 |
+
/**
|
316 |
+
* Delete data
|
317 |
+
*
|
318 |
+
* @param $key
|
319 |
+
* @param $post_id
|
320 |
+
*
|
321 |
+
* @return bool
|
322 |
+
*/
|
323 |
+
function delete_attr( $key, $post_id ) {
|
324 |
+
$meta = delete_post_meta( $post_id, '_um_' . $key );
|
325 |
+
return $meta;
|
326 |
+
}
|
327 |
+
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Checks if post has a specific meta key
|
331 |
+
*
|
332 |
+
* @param $key
|
333 |
+
* @param null $value
|
334 |
+
* @param null $post_id
|
335 |
+
*
|
336 |
+
* @return bool
|
337 |
+
*/
|
338 |
+
function has_post_meta( $key, $value = null, $post_id = null ) {
|
339 |
+
if ( ! $post_id ) {
|
340 |
+
global $post;
|
341 |
+
$post_id = $post->ID;
|
342 |
+
}
|
343 |
+
if ( $value ) {
|
344 |
+
if ( get_post_meta( $post_id, $key, true ) == $value ) {
|
345 |
+
return true;
|
346 |
+
}
|
347 |
+
} else {
|
348 |
+
if ( get_post_meta( $post_id, $key, true ) ) {
|
349 |
+
return true;
|
350 |
+
}
|
351 |
+
}
|
352 |
+
return false;
|
353 |
+
}
|
354 |
+
|
355 |
+
|
356 |
+
/**
|
357 |
+
* Get posts with specific meta key/value
|
358 |
+
*
|
359 |
+
* @param $post_type
|
360 |
+
* @param $key
|
361 |
+
* @param $value
|
362 |
+
*
|
363 |
+
* @return bool
|
364 |
+
*/
|
365 |
+
function find_post_id( $post_type, $key, $value ) {
|
366 |
+
$posts = get_posts( array( 'post_type' => $post_type, 'meta_key' => $key, 'meta_value' => $value ) );
|
367 |
+
if ( isset( $posts[0] ) && ! empty( $posts ) )
|
368 |
+
return $posts[0]->ID;
|
369 |
+
return false;
|
370 |
+
}
|
371 |
+
|
372 |
+
|
373 |
+
/**
|
374 |
+
* Get post data
|
375 |
+
*
|
376 |
+
* @param $post_id
|
377 |
+
*
|
378 |
+
* @return mixed
|
379 |
+
*/
|
380 |
+
function post_data( $post_id ) {
|
381 |
+
$array['form_id'] = $post_id;
|
382 |
+
$mode = $this->get_attr('mode', $post_id);
|
383 |
+
$meta = get_post_custom( $post_id );
|
384 |
+
foreach ($meta as $k => $v){
|
385 |
+
if ( strstr($k, '_um_'.$mode.'_' ) ) {
|
386 |
+
$k = str_replace('_um_'.$mode.'_', '', $k);
|
387 |
+
$array[$k] = $v[0];
|
388 |
+
} elseif ($k == '_um_mode'){
|
389 |
+
$k = str_replace('_um_', '', $k);
|
390 |
+
$array[$k] = $v[0];
|
391 |
+
} elseif ( strstr($k, '_um_') ) {
|
392 |
+
$k = str_replace('_um_', '', $k);
|
393 |
+
$array[$k] = $v[0];
|
394 |
+
}
|
395 |
+
|
396 |
+
}
|
397 |
+
|
398 |
+
foreach( $array as $k => $v ) {
|
399 |
+
if ( strstr( $k, 'login_') || strstr( $k, 'register_' ) || strstr( $k, 'profile_' ) ){
|
400 |
+
if ( $mode != 'directory' ) {
|
401 |
+
unset($array[$k]);
|
402 |
+
}
|
403 |
+
}
|
404 |
+
}
|
405 |
+
return $array;
|
406 |
+
}
|
407 |
+
|
408 |
+
|
409 |
+
/**
|
410 |
+
* Capture selected value
|
411 |
+
*
|
412 |
+
* @param string $key
|
413 |
+
* @param string|null $array_key
|
414 |
+
* @param bool $fallback
|
415 |
+
* @return int|mixed|null|string
|
416 |
+
*/
|
417 |
+
function get_meta_value( $key, $array_key = null, $fallback = false ) {
|
418 |
+
$post_id = get_the_ID();
|
419 |
+
$try = get_post_meta( $post_id, $key, true );
|
420 |
+
|
421 |
+
//old-old version if ( ! empty( $try ) )
|
422 |
+
//old version if ( $try !== false )
|
423 |
+
if ( $try != '' ) {
|
424 |
+
if ( is_array( $try ) && in_array( $array_key, $try ) ) {
|
425 |
+
return $array_key;
|
426 |
+
} else if ( is_array( $try ) ) {
|
427 |
+
return '';
|
428 |
+
} else {
|
429 |
+
return $try;
|
430 |
+
}
|
431 |
+
}
|
432 |
+
|
433 |
+
if ( $fallback == 'na' ) {
|
434 |
+
$fallback = 0;
|
435 |
+
$none = '';
|
436 |
+
} else {
|
437 |
+
$none = 0;
|
438 |
+
}
|
439 |
+
return ! empty( $fallback ) ? $fallback : $none;
|
440 |
+
}
|
441 |
+
|
442 |
+
|
443 |
+
/**
|
444 |
+
* Checks if its a core page of UM
|
445 |
+
*
|
446 |
+
* @param $post_id
|
447 |
+
*
|
448 |
+
* @return bool|mixed
|
449 |
+
*/
|
450 |
+
function is_core( $post_id ){
|
451 |
+
$is_core = get_post_meta($post_id, '_um_core', true);
|
452 |
+
if ( $is_core != '' ) {
|
453 |
+
return $is_core;
|
454 |
+
} else {
|
455 |
+
return false;
|
456 |
+
}
|
457 |
+
}
|
458 |
+
|
459 |
+
}
|
460 |
+
}
|
includes/core/um-actions-register.php
CHANGED
@@ -1,753 +1,753 @@
|
|
1 |
-
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
2 |
-
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Account automatically approved
|
6 |
-
*
|
7 |
-
* @param $user_id
|
8 |
-
* @param $args
|
9 |
-
*/
|
10 |
-
function um_post_registration_approved_hook( $user_id, $args ) {
|
11 |
-
um_fetch_user( $user_id );
|
12 |
-
|
13 |
-
UM()->user()->approve();
|
14 |
-
}
|
15 |
-
add_action( 'um_post_registration_approved_hook', 'um_post_registration_approved_hook', 10, 2 );
|
16 |
-
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Account needs email validation
|
20 |
-
*
|
21 |
-
* @param $user_id
|
22 |
-
* @param $args
|
23 |
-
*/
|
24 |
-
function um_post_registration_checkmail_hook( $user_id, $args ) {
|
25 |
-
um_fetch_user( $user_id );
|
26 |
-
|
27 |
-
UM()->user()->email_pending();
|
28 |
-
}
|
29 |
-
add_action( 'um_post_registration_checkmail_hook', 'um_post_registration_checkmail_hook', 10, 2 );
|
30 |
-
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Account needs admin review
|
34 |
-
*
|
35 |
-
* @param $user_id
|
36 |
-
* @param $args
|
37 |
-
*/
|
38 |
-
function um_post_registration_pending_hook( $user_id, $args ) {
|
39 |
-
um_fetch_user( $user_id );
|
40 |
-
|
41 |
-
UM()->user()->pending();
|
42 |
-
}
|
43 |
-
add_action('um_post_registration_pending_hook', 'um_post_registration_pending_hook', 10, 2);
|
44 |
-
|
45 |
-
|
46 |
-
/**
|
47 |
-
* After insert a new user
|
48 |
-
* run at frontend and backend
|
49 |
-
*
|
50 |
-
* @param $user_id
|
51 |
-
* @param $args
|
52 |
-
*/
|
53 |
-
function um_after_insert_user( $user_id, $args ) {
|
54 |
-
|
55 |
-
if ( empty( $user_id ) || ( is_object( $user_id ) && is_a( $user_id, 'WP_Error' ) ) ) {
|
56 |
-
return;
|
57 |
-
}
|
58 |
-
|
59 |
-
//clear Users cached queue
|
60 |
-
UM()->user()->remove_cached_queue();
|
61 |
-
|
62 |
-
um_fetch_user( $user_id );
|
63 |
-
if ( ! empty( $args['submitted'] ) ) {
|
64 |
-
UM()->user()->set_registration_details( $args['submitted'], $args );
|
65 |
-
}
|
66 |
-
|
67 |
-
$status = um_user( 'status' );
|
68 |
-
if ( empty( $status ) ) {
|
69 |
-
um_fetch_user( $user_id );
|
70 |
-
$status = um_user( 'status' );
|
71 |
-
}
|
72 |
-
|
73 |
-
/* save user status */
|
74 |
-
UM()->user()->set_status( $status );
|
75 |
-
|
76 |
-
/* create user uploads directory */
|
77 |
-
UM()->uploader()->get_upload_user_base_dir( $user_id, true );
|
78 |
-
|
79 |
-
/**
|
80 |
-
* UM hook
|
81 |
-
*
|
82 |
-
* @type action
|
83 |
-
* @title um_registration_set_extra_data
|
84 |
-
* @description Hook that runs after insert user to DB and there you can set any extra details
|
85 |
-
* @input_vars
|
86 |
-
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
87 |
-
* {"var":"$args","type":"array","desc":"Form data"}]
|
88 |
-
* @change_log
|
89 |
-
* ["Since: 2.0"]
|
90 |
-
* @usage add_action( 'um_registration_set_extra_data', 'function_name', 10, 2 );
|
91 |
-
* @example
|
92 |
-
* <?php
|
93 |
-
* add_action( 'um_registration_set_extra_data', 'my_registration_set_extra_data', 10, 2 );
|
94 |
-
* function my_registration_set_extra_data( $user_id, $args ) {
|
95 |
-
* // your code here
|
96 |
-
* }
|
97 |
-
* ?>
|
98 |
-
*/
|
99 |
-
do_action( 'um_registration_set_extra_data', $user_id, $args );
|
100 |
-
|
101 |
-
/**
|
102 |
-
* UM hook
|
103 |
-
*
|
104 |
-
* @type action
|
105 |
-
* @title um_registration_complete
|
106 |
-
* @description After complete UM user registration. Redirects handlers at 100 priority, you can add some info before redirects
|
107 |
-
* @input_vars
|
108 |
-
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
109 |
-
* {"var":"$args","type":"array","desc":"Form data"}]
|
110 |
-
* @change_log
|
111 |
-
* ["Since: 2.0"]
|
112 |
-
* @usage add_action( 'um_registration_complete', 'function_name', 10, 2 );
|
113 |
-
* @example
|
114 |
-
* <?php
|
115 |
-
* add_action( 'um_registration_complete', 'my_registration_complete', 10, 2 );
|
116 |
-
* function my_registration_complete( $user_id, $args ) {
|
117 |
-
* // your code here
|
118 |
-
* }
|
119 |
-
* ?>
|
120 |
-
*/
|
121 |
-
do_action( 'um_registration_complete', $user_id, $args );
|
122 |
-
}
|
123 |
-
add_action( 'um_user_register', 'um_after_insert_user', 1, 2 );
|
124 |
-
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Send notification about registration
|
128 |
-
*
|
129 |
-
* @param $user_id
|
130 |
-
* @param $args
|
131 |
-
*/
|
132 |
-
function um_send_registration_notification( $user_id, $args ) {
|
133 |
-
um_fetch_user( $user_id );
|
134 |
-
|
135 |
-
$emails = um_multi_admin_email();
|
136 |
-
if ( ! empty( $emails ) ) {
|
137 |
-
foreach ( $emails as $email ) {
|
138 |
-
if ( um_user( 'account_status' ) != 'pending' ) {
|
139 |
-
UM()->mail()->send( $email, 'notification_new_user', array( 'admin' => true ) );
|
140 |
-
} else {
|
141 |
-
UM()->mail()->send( $email, 'notification_review', array( 'admin' => true ) );
|
142 |
-
}
|
143 |
-
}
|
144 |
-
}
|
145 |
-
}
|
146 |
-
add_action( 'um_registration_complete', 'um_send_registration_notification', 10, 2 );
|
147 |
-
|
148 |
-
|
149 |
-
/**
|
150 |
-
* Check user status and redirect it after registration
|
151 |
-
*
|
152 |
-
* @param $user_id
|
153 |
-
* @param $args
|
154 |
-
*/
|
155 |
-
function um_check_user_status( $user_id, $args ) {
|
156 |
-
$status = um_user( 'account_status' );
|
157 |
-
|
158 |
-
/**
|
159 |
-
* UM hook
|
160 |
-
*
|
161 |
-
* @type action
|
162 |
-
* @title um_post_registration_{$status}_hook
|
163 |
-
* @description After complete UM user registration.
|
164 |
-
* @input_vars
|
165 |
-
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
166 |
-
* {"var":"$args","type":"array","desc":"Form data"}]
|
167 |
-
* @change_log
|
168 |
-
* ["Since: 2.0"]
|
169 |
-
* @usage add_action( 'um_post_registration_{$status}_hook', 'function_name', 10, 2 );
|
170 |
-
* @example
|
171 |
-
* <?php
|
172 |
-
* add_action( 'um_post_registration_{$status}_hook', 'my_post_registration', 10, 2 );
|
173 |
-
* function my_post_registration( $user_id, $args ) {
|
174 |
-
* // your code here
|
175 |
-
* }
|
176 |
-
* ?>
|
177 |
-
*/
|
178 |
-
do_action( "um_post_registration_{$status}_hook", $user_id, $args );
|
179 |
-
|
180 |
-
if ( ! is_admin() ) {
|
181 |
-
|
182 |
-
do_action( "track_{$status}_user_registration" );
|
183 |
-
|
184 |
-
if ( $status == 'approved' ) {
|
185 |
-
|
186 |
-
UM()->user()->auto_login( $user_id );
|
187 |
-
UM()->user()->generate_profile_slug( $user_id );
|
188 |
-
|
189 |
-
/**
|
190 |
-
* UM hook
|
191 |
-
*
|
192 |
-
* @type action
|
193 |
-
* @title um_registration_after_auto_login
|
194 |
-
* @description After complete UM user registration and autologin.
|
195 |
-
* @input_vars
|
196 |
-
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
197 |
-
* @change_log
|
198 |
-
* ["Since: 2.0"]
|
199 |
-
* @usage add_action( 'um_registration_after_auto_login', 'function_name', 10, 1 );
|
200 |
-
* @example
|
201 |
-
* <?php
|
202 |
-
* add_action( 'um_registration_after_auto_login', 'my_registration_after_auto_login', 10, 1 );
|
203 |
-
* function my_registration_after_auto_login( $user_id ) {
|
204 |
-
* // your code here
|
205 |
-
* }
|
206 |
-
* ?>
|
207 |
-
*/
|
208 |
-
do_action( 'um_registration_after_auto_login', $user_id );
|
209 |
-
|
210 |
-
// Priority redirect
|
211 |
-
if ( isset( $args['redirect_to'] ) ) {
|
212 |
-
exit( wp_safe_redirect( urldecode( $args['redirect_to'] ) ) );
|
213 |
-
}
|
214 |
-
|
215 |
-
um_fetch_user( $user_id );
|
216 |
-
|
217 |
-
if ( um_user( 'auto_approve_act' ) == 'redirect_url' && um_user( 'auto_approve_url' ) !== '' ) {
|
218 |
-
exit( wp_redirect( um_user( 'auto_approve_url' ) ) );
|
219 |
-
}
|
220 |
-
|
221 |
-
if ( um_user( 'auto_approve_act' ) == 'redirect_profile' ) {
|
222 |
-
exit( wp_redirect( um_user_profile_url() ) );
|
223 |
-
}
|
224 |
-
|
225 |
-
} else {
|
226 |
-
|
227 |
-
if ( um_user( $status . '_action' ) == 'redirect_url' && um_user( $status . '_url' ) != '' ) {
|
228 |
-
/**
|
229 |
-
* UM hook
|
230 |
-
*
|
231 |
-
* @type filter
|
232 |
-
* @title um_registration_pending_user_redirect
|
233 |
-
* @description Change redirect URL for pending user after registration
|
234 |
-
* @input_vars
|
235 |
-
* [{"var":"$url","type":"string","desc":"Redirect URL"},
|
236 |
-
* {"var":"$status","type":"string","desc":"User status"},
|
237 |
-
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
238 |
-
* @change_log
|
239 |
-
* ["Since: 2.0"]
|
240 |
-
* @usage
|
241 |
-
* <?php add_filter( 'um_registration_pending_user_redirect', 'function_name', 10, 3 ); ?>
|
242 |
-
* @example
|
243 |
-
* <?php
|
244 |
-
* add_filter( 'um_registration_pending_user_redirect', 'my_registration_pending_user_redirect', 10, 3 );
|
245 |
-
* function my_registration_pending_user_redirect( $url, $status, $user_id ) {
|
246 |
-
* // your code here
|
247 |
-
* return $url;
|
248 |
-
* }
|
249 |
-
* ?>
|
250 |
-
*/
|
251 |
-
$redirect_url = apply_filters( 'um_registration_pending_user_redirect', um_user( $status . '_url' ), $status, um_user( 'ID' ) );
|
252 |
-
|
253 |
-
exit( wp_redirect( $redirect_url ) );
|
254 |
-
}
|
255 |
-
|
256 |
-
if ( um_user( $status . '_action' ) == 'show_message' && um_user( $status . '_message' ) != '' ) {
|
257 |
-
|
258 |
-
$url = UM()->permalinks()->get_current_url();
|
259 |
-
$url = add_query_arg( 'message', esc_attr( $status ), $url );
|
260 |
-
//add only priority role to URL
|
261 |
-
$url = add_query_arg( 'um_role', esc_attr( um_user( 'role' ) ), $url );
|
262 |
-
$url = add_query_arg( 'um_form_id', esc_attr( $args['form_id'] ), $url );
|
263 |
-
|
264 |
-
exit( wp_redirect( $url ) );
|
265 |
-
}
|
266 |
-
|
267 |
-
}
|
268 |
-
|
269 |
-
}
|
270 |
-
|
271 |
-
}
|
272 |
-
add_action( 'um_registration_complete', 'um_check_user_status', 100, 2 );
|
273 |
-
|
274 |
-
|
275 |
-
function um_submit_form_errors_hook__registration( $args ) {
|
276 |
-
// Check for "\" in password.
|
277 |
-
if ( false !== strpos( wp_unslash( trim( $args['user_password'] ) ), '\\' ) ) {
|
278 |
-
UM()->form()->add_error( 'user_password', __( 'Passwords may not contain the character "\\".', 'ultimate-member' ) );
|
279 |
-
}
|
280 |
-
}
|
281 |
-
add_action( 'um_submit_form_errors_hook__registration', 'um_submit_form_errors_hook__registration', 10, 1 );
|
282 |
-
|
283 |
-
/**
|
284 |
-
* Registration form submit handler
|
285 |
-
*
|
286 |
-
* @param $args
|
287 |
-
* @return bool|int|WP_Error
|
288 |
-
*/
|
289 |
-
function um_submit_form_register( $args ) {
|
290 |
-
if ( isset( UM()->form()->errors ) ) {
|
291 |
-
return false;
|
292 |
-
}
|
293 |
-
|
294 |
-
/**
|
295 |
-
* UM hook
|
296 |
-
*
|
297 |
-
* @type filter
|
298 |
-
* @title um_add_user_frontend_submitted
|
299 |
-
* @description Extend user data on registration form submit
|
300 |
-
* @input_vars
|
301 |
-
* [{"var":"$submitted","type":"array","desc":"Registration data"}]
|
302 |
-
* @change_log
|
303 |
-
* ["Since: 2.0"]
|
304 |
-
* @usage
|
305 |
-
* <?php add_filter( 'um_add_user_frontend_submitted', 'function_name', 10, 1 ); ?>
|
306 |
-
* @example
|
307 |
-
* <?php
|
308 |
-
* add_filter( 'um_add_user_frontend_submitted', 'my_add_user_frontend_submitted', 10, 1 );
|
309 |
-
* function my_add_user_frontend_submitted( $submitted ) {
|
310 |
-
* // your code here
|
311 |
-
* return $submitted;
|
312 |
-
* }
|
313 |
-
* ?>
|
314 |
-
*/
|
315 |
-
$args = apply_filters( 'um_add_user_frontend_submitted', $args );
|
316 |
-
|
317 |
-
extract( $args );
|
318 |
-
|
319 |
-
if ( ! empty( $username ) && empty( $user_login ) ) {
|
320 |
-
$user_login = $username;
|
321 |
-
}
|
322 |
-
|
323 |
-
if ( ! empty( $first_name ) && ! empty( $last_name ) && empty( $user_login ) ) {
|
324 |
-
|
325 |
-
switch ( UM()->options()->get( 'permalink_base' ) ) {
|
326 |
-
case 'name':
|
327 |
-
$user_login = str_replace( " ", ".", $first_name . " " . $last_name );
|
328 |
-
break;
|
329 |
-
|
330 |
-
case 'name_dash':
|
331 |
-
$user_login = str_replace( " ", "-", $first_name . " " . $last_name );
|
332 |
-
break;
|
333 |
-
|
334 |
-
case 'name_plus':
|
335 |
-
$user_login = str_replace( " ", "+", $first_name . " " . $last_name );
|
336 |
-
break;
|
337 |
-
|
338 |
-
default:
|
339 |
-
$user_login = str_replace( " ", "", $first_name . " " . $last_name );
|
340 |
-
break;
|
341 |
-
}
|
342 |
-
$user_login = sanitize_user( strtolower( remove_accents( $user_login ) ), true );
|
343 |
-
|
344 |
-
if ( ! empty( $user_login ) ) {
|
345 |
-
$count = 1;
|
346 |
-
$temp_user_login = $user_login;
|
347 |
-
while ( username_exists( $temp_user_login ) ) {
|
348 |
-
$temp_user_login = $user_login . $count;
|
349 |
-
$count++;
|
350 |
-
}
|
351 |
-
$user_login = $temp_user_login;
|
352 |
-
}
|
353 |
-
}
|
354 |
-
|
355 |
-
if ( empty( $user_login ) && ! empty( $user_email ) ) {
|
356 |
-
$user_login = $user_email;
|
357 |
-
}
|
358 |
-
|
359 |
-
$unique_userID = uniqid();
|
360 |
-
|
361 |
-
// see dbDelta and WP native DB structure user_login varchar(60)
|
362 |
-
if ( empty( $user_login ) || mb_strlen( $user_login ) > 60 && ! is_email( $user_login ) ) {
|
363 |
-
$user_login = 'user' . $unique_userID;
|
364 |
-
while ( username_exists( $user_login ) ) {
|
365 |
-
$unique_userID = uniqid();
|
366 |
-
$user_login = 'user' . $unique_userID;
|
367 |
-
}
|
368 |
-
}
|
369 |
-
|
370 |
-
if ( isset( $username ) && is_email( $username ) ) {
|
371 |
-
$user_email = $username;
|
372 |
-
}
|
373 |
-
|
374 |
-
if ( ! isset( $user_password ) ) {
|
375 |
-
$user_password = UM()->validation()->generate( 8 );
|
376 |
-
}
|
377 |
-
|
378 |
-
if ( empty( $user_email ) ) {
|
379 |
-
$site_url = @$_SERVER['SERVER_NAME'];
|
380 |
-
$user_email = 'nobody' . $unique_userID . '@' . $site_url;
|
381 |
-
while ( email_exists( $user_email ) ) {
|
382 |
-
$unique_userID = uniqid();
|
383 |
-
$user_email = 'nobody' . $unique_userID . '@' . $site_url;
|
384 |
-
}
|
385 |
-
/**
|
386 |
-
* UM hook
|
387 |
-
*
|
388 |
-
* @type filter
|
389 |
-
* @title um_user_register_submitted__email
|
390 |
-
* @description Change user default email if it's empty on registration
|
391 |
-
* @input_vars
|
392 |
-
* [{"var":"$user_email","type":"string","desc":"Default email"}]
|
393 |
-
* @change_log
|
394 |
-
* ["Since: 2.0"]
|
395 |
-
* @usage
|
396 |
-
* <?php add_filter( 'um_user_register_submitted__email', 'function_name', 10, 1 ); ?>
|
397 |
-
* @example
|
398 |
-
* <?php
|
399 |
-
* add_filter( 'um_user_register_submitted__email', 'my_user_register_submitted__email', 10, 1 );
|
400 |
-
* function my_user_register_submitted__email( $user_email ) {
|
401 |
-
* // your code here
|
402 |
-
* return $user_email;
|
403 |
-
* }
|
404 |
-
* ?>
|
405 |
-
*/
|
406 |
-
$user_email = apply_filters( 'um_user_register_submitted__email', $user_email );
|
407 |
-
}
|
408 |
-
|
409 |
-
$credentials = array(
|
410 |
-
'user_login' => $user_login,
|
411 |
-
'user_password' => $user_password,
|
412 |
-
'user_email' => trim( $user_email ),
|
413 |
-
);
|
414 |
-
|
415 |
-
if ( ! empty( $args['submitted'] ) ) {
|
416 |
-
$args['submitted'] = array_diff_key( $args['submitted'], array_flip( UM()->user()->banned_keys ) );
|
417 |
-
}
|
418 |
-
|
419 |
-
$args['submitted'] = array_merge( $args['submitted'], $credentials );
|
420 |
-
|
421 |
-
// set timestamp
|
422 |
-
$timestamp = current_time( 'timestamp' );
|
423 |
-
$args['submitted']['timestamp'] = $timestamp;
|
424 |
-
$args['timestamp'] = $timestamp;
|
425 |
-
|
426 |
-
$args = array_merge( $args, $credentials );
|
427 |
-
|
428 |
-
//get user role from global or form's settings
|
429 |
-
$user_role = UM()->form()->assigned_role( UM()->form()->form_id );
|
430 |
-
|
431 |
-
//get user role from field Role dropdown or radio
|
432 |
-
if ( isset( $args['role'] ) ) {
|
433 |
-
global $wp_roles;
|
434 |
-
$um_roles = get_option( 'um_roles', array() );
|
435 |
-
|
436 |
-
if ( ! empty( $um_roles ) ) {
|
437 |
-
$role_keys = array_map( function( $item ) {
|
438 |
-
return 'um_' . $item;
|
439 |
-
}, $um_roles );
|
440 |
-
} else {
|
441 |
-
$role_keys = array();
|
442 |
-
}
|
443 |
-
|
444 |
-
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
445 |
-
|
446 |
-
//if role is properly set it
|
447 |
-
if ( ! in_array( $args['role'], $exclude_roles ) ) {
|
448 |
-
$user_role = $args['role'];
|
449 |
-
}
|
450 |
-
}
|
451 |
-
|
452 |
-
/**
|
453 |
-
* UM hook
|
454 |
-
*
|
455 |
-
* @type filter
|
456 |
-
* @title um_registration_user_role
|
457 |
-
* @description Change user role on registration process
|
458 |
-
* @input_vars
|
459 |
-
* [{"var":"$role","type":"string","desc":"User role"},
|
460 |
-
* {"var":"$submitted","type":"array","desc":"Registration data"}]
|
461 |
-
* @change_log
|
462 |
-
* ["Since: 2.0"]
|
463 |
-
* @usage
|
464 |
-
* <?php add_filter( 'um_registration_user_role', 'function_name', 10, 2 ); ?>
|
465 |
-
* @example
|
466 |
-
* <?php
|
467 |
-
* add_filter( 'um_registration_user_role', 'my_registration_user_role', 10, 2 );
|
468 |
-
* function my_user_register_submitted__email( $role, $submitted ) {
|
469 |
-
* // your code here
|
470 |
-
* return $role;
|
471 |
-
* }
|
472 |
-
* ?>
|
473 |
-
*/
|
474 |
-
$user_role = apply_filters( 'um_registration_user_role', $user_role, $args );
|
475 |
-
|
476 |
-
$userdata = array(
|
477 |
-
'user_login' => $user_login,
|
478 |
-
'user_pass' => $user_password,
|
479 |
-
'user_email' => $user_email,
|
480 |
-
'role' => $user_role,
|
481 |
-
);
|
482 |
-
|
483 |
-
$user_id = wp_insert_user( $userdata );
|
484 |
-
|
485 |
-
/**
|
486 |
-
* UM hook
|
487 |
-
*
|
488 |
-
* @type action
|
489 |
-
* @title um_user_register
|
490 |
-
* @description After complete UM user registration.
|
491 |
-
* @input_vars
|
492 |
-
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
493 |
-
* {"var":"$args","type":"array","desc":"Form data"}]
|
494 |
-
* @change_log
|
495 |
-
* ["Since: 2.0"]
|
496 |
-
* @usage add_action( 'um_user_register', 'function_name', 10, 2 );
|
497 |
-
* @example
|
498 |
-
* <?php
|
499 |
-
* add_action( 'um_user_register', 'my_user_register', 10, 2 );
|
500 |
-
* function my_user_register( $user_id, $args ) {
|
501 |
-
* // your code here
|
502 |
-
* }
|
503 |
-
* ?>
|
504 |
-
*/
|
505 |
-
do_action( 'um_user_register', $user_id, $args );
|
506 |
-
|
507 |
-
return $user_id;
|
508 |
-
}
|
509 |
-
add_action( 'um_submit_form_register', 'um_submit_form_register', 10 );
|
510 |
-
|
511 |
-
|
512 |
-
/**
|
513 |
-
* Show the submit button
|
514 |
-
*
|
515 |
-
* @param $args
|
516 |
-
*/
|
517 |
-
function um_add_submit_button_to_register( $args ) {
|
518 |
-
$primary_btn_word = $args['primary_btn_word'];
|
519 |
-
/**
|
520 |
-
* UM hook
|
521 |
-
*
|
522 |
-
* @type filter
|
523 |
-
* @title um_register_form_button_one
|
524 |
-
* @description Change Register Form Primary button
|
525 |
-
* @input_vars
|
526 |
-
* [{"var":"$primary_btn_word","type":"string","desc":"Button text"},
|
527 |
-
* {"var":"$args","type":"array","desc":"Registration Form arguments"}]
|
528 |
-
* @change_log
|
529 |
-
* ["Since: 2.0"]
|
530 |
-
* @usage
|
531 |
-
* <?php add_filter( 'um_register_form_button_one', 'function_name', 10, 2 ); ?>
|
532 |
-
* @example
|
533 |
-
* <?php
|
534 |
-
* add_filter( 'um_register_form_button_one', 'my_register_form_button_one', 10, 2 );
|
535 |
-
* function my_register_form_button_one( $primary_btn_word, $args ) {
|
536 |
-
* // your code here
|
537 |
-
* return $primary_btn_word;
|
538 |
-
* }
|
539 |
-
* ?>
|
540 |
-
*/
|
541 |
-
$primary_btn_word = apply_filters('um_register_form_button_one', $primary_btn_word, $args );
|
542 |
-
|
543 |
-
if ( ! isset( $primary_btn_word ) || $primary_btn_word == '' ){
|
544 |
-
$primary_btn_word = UM()->options()->get( 'register_primary_btn_word' );
|
545 |
-
}
|
546 |
-
|
547 |
-
$secondary_btn_word = $args['secondary_btn_word'];
|
548 |
-
/**
|
549 |
-
* UM hook
|
550 |
-
*
|
551 |
-
* @type filter
|
552 |
-
* @title um_register_form_button_two
|
553 |
-
* @description Change Registration Form Secondary button
|
554 |
-
* @input_vars
|
555 |
-
* [{"var":"$secondary_btn_word","type":"string","desc":"Button text"},
|
556 |
-
* {"var":"$args","type":"array","desc":"Registration Form arguments"}]
|
557 |
-
* @change_log
|
558 |
-
* ["Since: 2.0"]
|
559 |
-
* @usage
|
560 |
-
* <?php add_filter( 'um_register_form_button_two', 'function_name', 10, 2 ); ?>
|
561 |
-
* @example
|
562 |
-
* <?php
|
563 |
-
* add_filter( 'um_register_form_button_two', 'my_register_form_button_two', 10, 2 );
|
564 |
-
* function my_register_form_button_two( $secondary_btn_word, $args ) {
|
565 |
-
* // your code here
|
566 |
-
* return $secondary_btn_word;
|
567 |
-
* }
|
568 |
-
* ?>
|
569 |
-
*/
|
570 |
-
$secondary_btn_word = apply_filters( 'um_register_form_button_two', $secondary_btn_word, $args );
|
571 |
-
|
572 |
-
if ( ! isset( $secondary_btn_word ) || $secondary_btn_word == '' ){
|
573 |
-
$secondary_btn_word = UM()->options()->get( 'register_secondary_btn_word' );
|
574 |
-
}
|
575 |
-
|
576 |
-
$secondary_btn_url = ( isset( $args['secondary_btn_url'] ) && $args['secondary_btn_url'] ) ? $args['secondary_btn_url'] : um_get_core_page('login');
|
577 |
-
/**
|
578 |
-
* UM hook
|
579 |
-
*
|
580 |
-
* @type filter
|
581 |
-
* @title um_register_form_button_two_url
|
582 |
-
* @description Change Registration Form Secondary button URL
|
583 |
-
* @input_vars
|
584 |
-
* [{"var":"$secondary_btn_url","type":"string","desc":"Button URL"},
|
585 |
-
* {"var":"$args","type":"array","desc":"Registration Form arguments"}]
|
586 |
-
* @change_log
|
587 |
-
* ["Since: 2.0"]
|
588 |
-
* @usage
|
589 |
-
* <?php add_filter( 'um_register_form_button_two_url', 'function_name', 10, 2 ); ?>
|
590 |
-
* @example
|
591 |
-
* <?php
|
592 |
-
* add_filter( 'um_register_form_button_two_url', 'my_register_form_button_two_url', 10, 2 );
|
593 |
-
* function my_register_form_button_two_url( $secondary_btn_url, $args ) {
|
594 |
-
* // your code here
|
595 |
-
* return $secondary_btn_url;
|
596 |
-
* }
|
597 |
-
* ?>
|
598 |
-
*/
|
599 |
-
$secondary_btn_url = apply_filters('um_register_form_button_two_url', $secondary_btn_url, $args ); ?>
|
600 |
-
|
601 |
-
<div class="um-col-alt">
|
602 |
-
|
603 |
-
<?php if ( ! empty( $args['secondary_btn'] ) ) { ?>
|
604 |
-
|
605 |
-
<div class="um-left um-half">
|
606 |
-
<input type="submit" value="<?php esc_attr_e( wp_unslash( $primary_btn_word ), 'ultimate-member' ) ?>" class="um-button" id="um-submit-btn" />
|
607 |
-
</div>
|
608 |
-
<div class="um-right um-half">
|
609 |
-
<a href="<?php echo esc_url( $secondary_btn_url ); ?>" class="um-button um-alt">
|
610 |
-
<?php _e( wp_unslash( $secondary_btn_word ),'ultimate-member' ); ?>
|
611 |
-
</a>
|
612 |
-
</div>
|
613 |
-
|
614 |
-
<?php } else { ?>
|
615 |
-
|
616 |
-
<div class="um-center">
|
617 |
-
<input type="submit" value="<?php esc_attr_e( wp_unslash( $primary_btn_word ), 'ultimate-member' ) ?>" class="um-button" id="um-submit-btn" />
|
618 |
-
</div>
|
619 |
-
|
620 |
-
<?php } ?>
|
621 |
-
|
622 |
-
<div class="um-clear"></div>
|
623 |
-
|
624 |
-
</div>
|
625 |
-
|
626 |
-
<?php
|
627 |
-
}
|
628 |
-
add_action( 'um_after_register_fields', 'um_add_submit_button_to_register', 1000 );
|
629 |
-
|
630 |
-
|
631 |
-
/**
|
632 |
-
* Show Fields
|
633 |
-
*
|
634 |
-
* @param $args
|
635 |
-
*/
|
636 |
-
function um_add_register_fields( $args ){
|
637 |
-
echo UM()->fields()->display( 'register', $args );
|
638 |
-
}
|
639 |
-
add_action( 'um_main_register_fields', 'um_add_register_fields', 100 );
|
640 |
-
|
641 |
-
|
642 |
-
/**
|
643 |
-
* Saving files to register a new user, if there are fields with files
|
644 |
-
*
|
645 |
-
* @param $user_id
|
646 |
-
* @param $args
|
647 |
-
*/
|
648 |
-
function um_registration_save_files( $user_id, $args ) {
|
649 |
-
|
650 |
-
if ( empty( $args['custom_fields'] ) ) {
|
651 |
-
return;
|
652 |
-
}
|
653 |
-
|
654 |
-
$files = array();
|
655 |
-
|
656 |
-
$fields = unserialize( $args['custom_fields'] );
|
657 |
-
|
658 |
-
// loop through fields
|
659 |
-
if ( isset( $fields ) && is_array( $fields ) ) {
|
660 |
-
|
661 |
-
foreach ( $fields as $key => $array ) {
|
662 |
-
|
663 |
-
if ( isset( $args['submitted'][ $key ] ) ) {
|
664 |
-
|
665 |
-
if ( isset( $fields[ $key ]['type'] ) && in_array( $fields[ $key ]['type'], array( 'image', 'file' ) ) &&
|
666 |
-
( um_is_temp_file( $args['submitted'][ $key ] ) || $args['submitted'][ $key ] == 'empty_file' )
|
667 |
-
) {
|
668 |
-
|
669 |
-
$files[ $key ] = $args['submitted'][ $key ];
|
670 |
-
|
671 |
-
}
|
672 |
-
}
|
673 |
-
}
|
674 |
-
}
|
675 |
-
|
676 |
-
/**
|
677 |
-
* UM hook
|
678 |
-
*
|
679 |
-
* @type filter
|
680 |
-
* @title um_user_pre_updating_files_array
|
681 |
-
* @description Change submitted files before register new user
|
682 |
-
* @input_vars
|
683 |
-
* [{"var":"$files","type":"array","desc":"Profile data files"}]
|
684 |
-
* @change_log
|
685 |
-
* ["Since: 2.0"]
|
686 |
-
* @usage
|
687 |
-
* <?php add_filter( 'um_user_pre_updating_files_array', 'function_name', 10, 1 ); ?>
|
688 |
-
* @example
|
689 |
-
* <?php
|
690 |
-
* add_filter( 'um_user_pre_updating_files_array', 'my_user_pre_updating_files', 10, 1 );
|
691 |
-
* function my_user_pre_updating_files( $files ) {
|
692 |
-
* // your code here
|
693 |
-
* return $files;
|
694 |
-
* }
|
695 |
-
* ?>
|
696 |
-
*/
|
697 |
-
$files = apply_filters( 'um_user_pre_updating_files_array', $files );
|
698 |
-
|
699 |
-
if ( ! empty( $files ) ) {
|
700 |
-
UM()->uploader()->replace_upload_dir = true;
|
701 |
-
UM()->uploader()->move_temporary_files( $user_id, $files );
|
702 |
-
UM()->uploader()->replace_upload_dir = false;
|
703 |
-
}
|
704 |
-
}
|
705 |
-
add_action( 'um_registration_set_extra_data', 'um_registration_save_files', 10, 2 );
|
706 |
-
|
707 |
-
|
708 |
-
/**
|
709 |
-
* Update user Full Name
|
710 |
-
*
|
711 |
-
* @profile name update
|
712 |
-
*
|
713 |
-
* @param $user_id
|
714 |
-
* @param $args
|
715 |
-
*/
|
716 |
-
function um_registration_set_profile_full_name( $user_id, $args ) {
|
717 |
-
/**
|
718 |
-
* UM hook
|
719 |
-
*
|
720 |
-
* @type action
|
721 |
-
* @title um_update_profile_full_name
|
722 |
-
* @description On update user profile change full name
|
723 |
-
* @input_vars
|
724 |
-
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
725 |
-
* {"var":"$args","type":"array","desc":"Form data"}]
|
726 |
-
* @change_log
|
727 |
-
* ["Since: 2.0"]
|
728 |
-
* @usage add_action( 'um_update_profile_full_name', 'function_name', 10, 2 );
|
729 |
-
* @example
|
730 |
-
* <?php
|
731 |
-
* add_action( 'um_update_profile_full_name', 'my_update_profile_full_name', 10, 2 );
|
732 |
-
* function my_update_profile_full_name( $user_id, $args ) {
|
733 |
-
* // your code here
|
734 |
-
* }
|
735 |
-
* ?>
|
736 |
-
*/
|
737 |
-
do_action( 'um_update_profile_full_name', $user_id, $args );
|
738 |
-
}
|
739 |
-
add_action( 'um_registration_set_extra_data', 'um_registration_set_profile_full_name', 10, 2 );
|
740 |
-
|
741 |
-
|
742 |
-
/**
|
743 |
-
* Redirect from default registration to UM registration page
|
744 |
-
*/
|
745 |
-
function um_form_register_redirect() {
|
746 |
-
$page_id = UM()->options()->get( UM()->options()->get_core_page_id( 'register' ) );
|
747 |
-
$register_post = get_post( $page_id );
|
748 |
-
if ( ! empty( $register_post ) ) {
|
749 |
-
wp_safe_redirect( get_permalink( $page_id ) );
|
750 |
-
exit();
|
751 |
-
}
|
752 |
-
}
|
753 |
-
add_action( 'login_form_register', 'um_form_register_redirect', 10 );
|
1 |
+
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
2 |
+
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Account automatically approved
|
6 |
+
*
|
7 |
+
* @param $user_id
|
8 |
+
* @param $args
|
9 |
+
*/
|
10 |
+
function um_post_registration_approved_hook( $user_id, $args ) {
|
11 |
+
um_fetch_user( $user_id );
|
12 |
+
|
13 |
+
UM()->user()->approve();
|
14 |
+
}
|
15 |
+
add_action( 'um_post_registration_approved_hook', 'um_post_registration_approved_hook', 10, 2 );
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Account needs email validation
|
20 |
+
*
|
21 |
+
* @param $user_id
|
22 |
+
* @param $args
|
23 |
+
*/
|
24 |
+
function um_post_registration_checkmail_hook( $user_id, $args ) {
|
25 |
+
um_fetch_user( $user_id );
|
26 |
+
|
27 |
+
UM()->user()->email_pending();
|
28 |
+
}
|
29 |
+
add_action( 'um_post_registration_checkmail_hook', 'um_post_registration_checkmail_hook', 10, 2 );
|
30 |
+
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Account needs admin review
|
34 |
+
*
|
35 |
+
* @param $user_id
|
36 |
+
* @param $args
|
37 |
+
*/
|
38 |
+
function um_post_registration_pending_hook( $user_id, $args ) {
|
39 |
+
um_fetch_user( $user_id );
|
40 |
+
|
41 |
+
UM()->user()->pending();
|
42 |
+
}
|
43 |
+
add_action('um_post_registration_pending_hook', 'um_post_registration_pending_hook', 10, 2);
|
44 |
+
|
45 |
+
|
46 |
+
/**
|
47 |
+
* After insert a new user
|
48 |
+
* run at frontend and backend
|
49 |
+
*
|
50 |
+
* @param $user_id
|
51 |
+
* @param $args
|
52 |
+
*/
|
53 |
+
function um_after_insert_user( $user_id, $args ) {
|
54 |
+
|
55 |
+
if ( empty( $user_id ) || ( is_object( $user_id ) && is_a( $user_id, 'WP_Error' ) ) ) {
|
56 |
+
return;
|
57 |
+
}
|
58 |
+
|
59 |
+
//clear Users cached queue
|
60 |
+
UM()->user()->remove_cached_queue();
|
61 |
+
|
62 |
+
um_fetch_user( $user_id );
|
63 |
+
if ( ! empty( $args['submitted'] ) ) {
|
64 |
+
UM()->user()->set_registration_details( $args['submitted'], $args );
|
65 |
+
}
|
66 |
+
|
67 |
+
$status = um_user( 'status' );
|
68 |
+
if ( empty( $status ) ) {
|
69 |
+
um_fetch_user( $user_id );
|
70 |
+
$status = um_user( 'status' );
|
71 |
+
}
|
72 |
+
|
73 |
+
/* save user status */
|
74 |
+
UM()->user()->set_status( $status );
|
75 |
+
|
76 |
+
/* create user uploads directory */
|
77 |
+
UM()->uploader()->get_upload_user_base_dir( $user_id, true );
|
78 |
+
|
79 |
+
/**
|
80 |
+
* UM hook
|
81 |
+
*
|
82 |
+
* @type action
|
83 |
+
* @title um_registration_set_extra_data
|
84 |
+
* @description Hook that runs after insert user to DB and there you can set any extra details
|
85 |
+
* @input_vars
|
86 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
87 |
+
* {"var":"$args","type":"array","desc":"Form data"}]
|
88 |
+
* @change_log
|
89 |
+
* ["Since: 2.0"]
|
90 |
+
* @usage add_action( 'um_registration_set_extra_data', 'function_name', 10, 2 );
|
91 |
+
* @example
|
92 |
+
* <?php
|
93 |
+
* add_action( 'um_registration_set_extra_data', 'my_registration_set_extra_data', 10, 2 );
|
94 |
+
* function my_registration_set_extra_data( $user_id, $args ) {
|
95 |
+
* // your code here
|
96 |
+
* }
|
97 |
+
* ?>
|
98 |
+
*/
|
99 |
+
do_action( 'um_registration_set_extra_data', $user_id, $args );
|
100 |
+
|
101 |
+
/**
|
102 |
+
* UM hook
|
103 |
+
*
|
104 |
+
* @type action
|
105 |
+
* @title um_registration_complete
|
106 |
+
* @description After complete UM user registration. Redirects handlers at 100 priority, you can add some info before redirects
|
107 |
+
* @input_vars
|
108 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
109 |
+
* {"var":"$args","type":"array","desc":"Form data"}]
|
110 |
+
* @change_log
|
111 |
+
* ["Since: 2.0"]
|
112 |
+
* @usage add_action( 'um_registration_complete', 'function_name', 10, 2 );
|
113 |
+
* @example
|
114 |
+
* <?php
|
115 |
+
* add_action( 'um_registration_complete', 'my_registration_complete', 10, 2 );
|
116 |
+
* function my_registration_complete( $user_id, $args ) {
|
117 |
+
* // your code here
|
118 |
+
* }
|
119 |
+
* ?>
|
120 |
+
*/
|
121 |
+
do_action( 'um_registration_complete', $user_id, $args );
|
122 |
+
}
|
123 |
+
add_action( 'um_user_register', 'um_after_insert_user', 1, 2 );
|
124 |
+
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Send notification about registration
|
128 |
+
*
|
129 |
+
* @param $user_id
|
130 |
+
* @param $args
|
131 |
+
*/
|
132 |
+
function um_send_registration_notification( $user_id, $args ) {
|
133 |
+
um_fetch_user( $user_id );
|
134 |
+
|
135 |
+
$emails = um_multi_admin_email();
|
136 |
+
if ( ! empty( $emails ) ) {
|
137 |
+
foreach ( $emails as $email ) {
|
138 |
+
if ( um_user( 'account_status' ) != 'pending' ) {
|
139 |
+
UM()->mail()->send( $email, 'notification_new_user', array( 'admin' => true ) );
|
140 |
+
} else {
|
141 |
+
UM()->mail()->send( $email, 'notification_review', array( 'admin' => true ) );
|
142 |
+
}
|
143 |
+
}
|
144 |
+
}
|
145 |
+
}
|
146 |
+
add_action( 'um_registration_complete', 'um_send_registration_notification', 10, 2 );
|
147 |
+
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Check user status and redirect it after registration
|
151 |
+
*
|
152 |
+
* @param $user_id
|
153 |
+
* @param $args
|
154 |
+
*/
|
155 |
+
function um_check_user_status( $user_id, $args ) {
|
156 |
+
$status = um_user( 'account_status' );
|
157 |
+
|
158 |
+
/**
|
159 |
+
* UM hook
|
160 |
+
*
|
161 |
+
* @type action
|
162 |
+
* @title um_post_registration_{$status}_hook
|
163 |
+
* @description After complete UM user registration.
|
164 |
+
* @input_vars
|
165 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
166 |
+
* {"var":"$args","type":"array","desc":"Form data"}]
|
167 |
+
* @change_log
|
168 |
+
* ["Since: 2.0"]
|
169 |
+
* @usage add_action( 'um_post_registration_{$status}_hook', 'function_name', 10, 2 );
|
170 |
+
* @example
|
171 |
+
* <?php
|
172 |
+
* add_action( 'um_post_registration_{$status}_hook', 'my_post_registration', 10, 2 );
|
173 |
+
* function my_post_registration( $user_id, $args ) {
|
174 |
+
* // your code here
|
175 |
+
* }
|
176 |
+
* ?>
|
177 |
+
*/
|
178 |
+
do_action( "um_post_registration_{$status}_hook", $user_id, $args );
|
179 |
+
|
180 |
+
if ( ! is_admin() ) {
|
181 |
+
|
182 |
+
do_action( "track_{$status}_user_registration" );
|
183 |
+
|
184 |
+
if ( $status == 'approved' ) {
|
185 |
+
|
186 |
+
UM()->user()->auto_login( $user_id );
|
187 |
+
UM()->user()->generate_profile_slug( $user_id );
|
188 |
+
|
189 |
+
/**
|
190 |
+
* UM hook
|
191 |
+
*
|
192 |
+
* @type action
|
193 |
+
* @title um_registration_after_auto_login
|
194 |
+
* @description After complete UM user registration and autologin.
|
195 |
+
* @input_vars
|
196 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
197 |
+
* @change_log
|
198 |
+
* ["Since: 2.0"]
|
199 |
+
* @usage add_action( 'um_registration_after_auto_login', 'function_name', 10, 1 );
|
200 |
+
* @example
|
201 |
+
* <?php
|
202 |
+
* add_action( 'um_registration_after_auto_login', 'my_registration_after_auto_login', 10, 1 );
|
203 |
+
* function my_registration_after_auto_login( $user_id ) {
|
204 |
+
* // your code here
|
205 |
+
* }
|
206 |
+
* ?>
|
207 |
+
*/
|
208 |
+
do_action( 'um_registration_after_auto_login', $user_id );
|
209 |
+
|
210 |
+
// Priority redirect
|
211 |
+
if ( isset( $args['redirect_to'] ) ) {
|
212 |
+
exit( wp_safe_redirect( urldecode( $args['redirect_to'] ) ) );
|
213 |
+
}
|
214 |
+
|
215 |
+
um_fetch_user( $user_id );
|
216 |
+
|
217 |
+
if ( um_user( 'auto_approve_act' ) == 'redirect_url' && um_user( 'auto_approve_url' ) !== '' ) {
|
218 |
+
exit( wp_redirect( um_user( 'auto_approve_url' ) ) );
|
219 |
+
}
|
220 |
+
|
221 |
+
if ( um_user( 'auto_approve_act' ) == 'redirect_profile' ) {
|
222 |
+
exit( wp_redirect( um_user_profile_url() ) );
|
223 |
+
}
|
224 |
+
|
225 |
+
} else {
|
226 |
+
|
227 |
+
if ( um_user( $status . '_action' ) == 'redirect_url' && um_user( $status . '_url' ) != '' ) {
|
228 |
+
/**
|
229 |
+
* UM hook
|
230 |
+
*
|
231 |
+
* @type filter
|
232 |
+
* @title um_registration_pending_user_redirect
|
233 |
+
* @description Change redirect URL for pending user after registration
|
234 |
+
* @input_vars
|
235 |
+
* [{"var":"$url","type":"string","desc":"Redirect URL"},
|
236 |
+
* {"var":"$status","type":"string","desc":"User status"},
|
237 |
+
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
238 |
+
* @change_log
|
239 |
+
* ["Since: 2.0"]
|
240 |
+
* @usage
|
241 |
+
* <?php add_filter( 'um_registration_pending_user_redirect', 'function_name', 10, 3 ); ?>
|
242 |
+
* @example
|
243 |
+
* <?php
|
244 |
+
* add_filter( 'um_registration_pending_user_redirect', 'my_registration_pending_user_redirect', 10, 3 );
|
245 |
+
* function my_registration_pending_user_redirect( $url, $status, $user_id ) {
|
246 |
+
* // your code here
|
247 |
+
* return $url;
|
248 |
+
* }
|
249 |
+
* ?>
|
250 |
+
*/
|
251 |
+
$redirect_url = apply_filters( 'um_registration_pending_user_redirect', um_user( $status . '_url' ), $status, um_user( 'ID' ) );
|
252 |
+
|
253 |
+
exit( wp_redirect( $redirect_url ) );
|
254 |
+
}
|
255 |
+
|
256 |
+
if ( um_user( $status . '_action' ) == 'show_message' && um_user( $status . '_message' ) != '' ) {
|
257 |
+
|
258 |
+
$url = UM()->permalinks()->get_current_url();
|
259 |
+
$url = add_query_arg( 'message', esc_attr( $status ), $url );
|
260 |
+
//add only priority role to URL
|
261 |
+
$url = add_query_arg( 'um_role', esc_attr( um_user( 'role' ) ), $url );
|
262 |
+
$url = add_query_arg( 'um_form_id', esc_attr( $args['form_id'] ), $url );
|
263 |
+
|
264 |
+
exit( wp_redirect( $url ) );
|
265 |
+
}
|
266 |
+
|
267 |
+
}
|
268 |
+
|
269 |
+
}
|
270 |
+
|
271 |
+
}
|
272 |
+
add_action( 'um_registration_complete', 'um_check_user_status', 100, 2 );
|
273 |
+
|
274 |
+
|
275 |
+
function um_submit_form_errors_hook__registration( $args ) {
|
276 |
+
// Check for "\" in password.
|
277 |
+
if ( false !== strpos( wp_unslash( trim( $args['user_password'] ) ), '\\' ) ) {
|
278 |
+
UM()->form()->add_error( 'user_password', __( 'Passwords may not contain the character "\\".', 'ultimate-member' ) );
|
279 |
+
}
|
280 |
+
}
|
281 |
+
add_action( 'um_submit_form_errors_hook__registration', 'um_submit_form_errors_hook__registration', 10, 1 );
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Registration form submit handler
|
285 |
+
*
|
286 |
+
* @param $args
|
287 |
+
* @return bool|int|WP_Error
|
288 |
+
*/
|
289 |
+
function um_submit_form_register( $args ) {
|
290 |
+
if ( isset( UM()->form()->errors ) ) {
|
291 |
+
return false;
|
292 |
+
}
|
293 |
+
|
294 |
+
/**
|
295 |
+
* UM hook
|
296 |
+
*
|
297 |
+
* @type filter
|
298 |
+
* @title um_add_user_frontend_submitted
|
299 |
+
* @description Extend user data on registration form submit
|
300 |
+
* @input_vars
|
301 |
+
* [{"var":"$submitted","type":"array","desc":"Registration data"}]
|
302 |
+
* @change_log
|
303 |
+
* ["Since: 2.0"]
|
304 |
+
* @usage
|
305 |
+
* <?php add_filter( 'um_add_user_frontend_submitted', 'function_name', 10, 1 ); ?>
|
306 |
+
* @example
|
307 |
+
* <?php
|
308 |
+
* add_filter( 'um_add_user_frontend_submitted', 'my_add_user_frontend_submitted', 10, 1 );
|
309 |
+
* function my_add_user_frontend_submitted( $submitted ) {
|
310 |
+
* // your code here
|
311 |
+
* return $submitted;
|
312 |
+
* }
|
313 |
+
* ?>
|
314 |
+
*/
|
315 |
+
$args = apply_filters( 'um_add_user_frontend_submitted', $args );
|
316 |
+
|
317 |
+
extract( $args );
|
318 |
+
|
319 |
+
if ( ! empty( $username ) && empty( $user_login ) ) {
|
320 |
+
$user_login = $username;
|
321 |
+
}
|
322 |
+
|
323 |
+
if ( ! empty( $first_name ) && ! empty( $last_name ) && empty( $user_login ) ) {
|
324 |
+
|
325 |
+
switch ( UM()->options()->get( 'permalink_base' ) ) {
|
326 |
+
case 'name':
|
327 |
+
$user_login = str_replace( " ", ".", $first_name . " " . $last_name );
|
328 |
+
break;
|
329 |
+
|
330 |
+
case 'name_dash':
|
331 |
+
$user_login = str_replace( " ", "-", $first_name . " " . $last_name );
|
332 |
+
break;
|
333 |
+
|
334 |
+
case 'name_plus':
|
335 |
+
$user_login = str_replace( " ", "+", $first_name . " " . $last_name );
|
336 |
+
break;
|
337 |
+
|
338 |
+
default:
|
339 |
+
$user_login = str_replace( " ", "", $first_name . " " . $last_name );
|
340 |
+
break;
|
341 |
+
}
|
342 |
+
$user_login = sanitize_user( strtolower( remove_accents( $user_login ) ), true );
|
343 |
+
|
344 |
+
if ( ! empty( $user_login ) ) {
|
345 |
+
$count = 1;
|
346 |
+
$temp_user_login = $user_login;
|
347 |
+
while ( username_exists( $temp_user_login ) ) {
|
348 |
+
$temp_user_login = $user_login . $count;
|
349 |
+
$count++;
|
350 |
+
}
|
351 |
+
$user_login = $temp_user_login;
|
352 |
+
}
|
353 |
+
}
|
354 |
+
|
355 |
+
if ( empty( $user_login ) && ! empty( $user_email ) ) {
|
356 |
+
$user_login = $user_email;
|
357 |
+
}
|
358 |
+
|
359 |
+
$unique_userID = uniqid();
|
360 |
+
|
361 |
+
// see dbDelta and WP native DB structure user_login varchar(60)
|
362 |
+
if ( empty( $user_login ) || mb_strlen( $user_login ) > 60 && ! is_email( $user_login ) ) {
|
363 |
+
$user_login = 'user' . $unique_userID;
|
364 |
+
while ( username_exists( $user_login ) ) {
|
365 |
+
$unique_userID = uniqid();
|
366 |
+
$user_login = 'user' . $unique_userID;
|
367 |
+
}
|
368 |
+
}
|
369 |
+
|
370 |
+
if ( isset( $username ) && is_email( $username ) ) {
|
371 |
+
$user_email = $username;
|
372 |
+
}
|
373 |
+
|
374 |
+
if ( ! isset( $user_password ) ) {
|
375 |
+
$user_password = UM()->validation()->generate( 8 );
|
376 |
+
}
|
377 |
+
|
378 |
+
if ( empty( $user_email ) ) {
|
379 |
+
$site_url = @$_SERVER['SERVER_NAME'];
|
380 |
+
$user_email = 'nobody' . $unique_userID . '@' . $site_url;
|
381 |
+
while ( email_exists( $user_email ) ) {
|
382 |
+
$unique_userID = uniqid();
|
383 |
+
$user_email = 'nobody' . $unique_userID . '@' . $site_url;
|
384 |
+
}
|
385 |
+
/**
|
386 |
+
* UM hook
|
387 |
+
*
|
388 |
+
* @type filter
|
389 |
+
* @title um_user_register_submitted__email
|
390 |
+
* @description Change user default email if it's empty on registration
|
391 |
+
* @input_vars
|
392 |
+
* [{"var":"$user_email","type":"string","desc":"Default email"}]
|
393 |
+
* @change_log
|
394 |
+
* ["Since: 2.0"]
|
395 |
+
* @usage
|
396 |
+
* <?php add_filter( 'um_user_register_submitted__email', 'function_name', 10, 1 ); ?>
|
397 |
+
* @example
|
398 |
+
* <?php
|
399 |
+
* add_filter( 'um_user_register_submitted__email', 'my_user_register_submitted__email', 10, 1 );
|
400 |
+
* function my_user_register_submitted__email( $user_email ) {
|
401 |
+
* // your code here
|
402 |
+
* return $user_email;
|
403 |
+
* }
|
404 |
+
* ?>
|
405 |
+
*/
|
406 |
+
$user_email = apply_filters( 'um_user_register_submitted__email', $user_email );
|
407 |
+
}
|
408 |
+
|
409 |
+
$credentials = array(
|
410 |
+
'user_login' => $user_login,
|
411 |
+
'user_password' => $user_password,
|
412 |
+
'user_email' => trim( $user_email ),
|
413 |
+
);
|
414 |
+
|
415 |
+
if ( ! empty( $args['submitted'] ) ) {
|
416 |
+
$args['submitted'] = array_diff_key( $args['submitted'], array_flip( UM()->user()->banned_keys ) );
|
417 |
+
}
|
418 |
+
|
419 |
+
$args['submitted'] = array_merge( $args['submitted'], $credentials );
|
420 |
+
|
421 |
+
// set timestamp
|
422 |
+
$timestamp = current_time( 'timestamp' );
|
423 |
+
$args['submitted']['timestamp'] = $timestamp;
|
424 |
+
$args['timestamp'] = $timestamp;
|
425 |
+
|
426 |
+
$args = array_merge( $args, $credentials );
|
427 |
+
|
428 |
+
//get user role from global or form's settings
|
429 |
+
$user_role = UM()->form()->assigned_role( UM()->form()->form_id );
|
430 |
+
|
431 |
+
//get user role from field Role dropdown or radio
|
432 |
+
if ( isset( $args['role'] ) ) {
|
433 |
+
global $wp_roles;
|
434 |
+
$um_roles = get_option( 'um_roles', array() );
|
435 |
+
|
436 |
+
if ( ! empty( $um_roles ) ) {
|
437 |
+
$role_keys = array_map( function( $item ) {
|
438 |
+
return 'um_' . $item;
|
439 |
+
}, $um_roles );
|
440 |
+
} else {
|
441 |
+
$role_keys = array();
|
442 |
+
}
|
443 |
+
|
444 |
+
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
445 |
+
|
446 |
+
//if role is properly set it
|
447 |
+
if ( ! in_array( $args['role'], $exclude_roles ) ) {
|
448 |
+
$user_role = $args['role'];
|
449 |
+
}
|
450 |
+
}
|
451 |
+
|
452 |
+
/**
|
453 |
+
* UM hook
|
454 |
+
*
|
455 |
+
* @type filter
|
456 |
+
* @title um_registration_user_role
|
457 |
+
* @description Change user role on registration process
|
458 |
+
* @input_vars
|
459 |
+
* [{"var":"$role","type":"string","desc":"User role"},
|
460 |
+
* {"var":"$submitted","type":"array","desc":"Registration data"}]
|
461 |
+
* @change_log
|
462 |
+
* ["Since: 2.0"]
|
463 |
+
* @usage
|
464 |
+
* <?php add_filter( 'um_registration_user_role', 'function_name', 10, 2 ); ?>
|
465 |
+
* @example
|
466 |
+
* <?php
|
467 |
+
* add_filter( 'um_registration_user_role', 'my_registration_user_role', 10, 2 );
|
468 |
+
* function my_user_register_submitted__email( $role, $submitted ) {
|
469 |
+
* // your code here
|
470 |
+
* return $role;
|
471 |
+
* }
|
472 |
+
* ?>
|
473 |
+
*/
|
474 |
+
$user_role = apply_filters( 'um_registration_user_role', $user_role, $args );
|
475 |
+
|
476 |
+
$userdata = array(
|
477 |
+
'user_login' => $user_login,
|
478 |
+
'user_pass' => $user_password,
|
479 |
+
'user_email' => $user_email,
|
480 |
+
'role' => $user_role,
|
481 |
+
);
|
482 |
+
|
483 |
+
$user_id = wp_insert_user( $userdata );
|
484 |
+
|
485 |
+
/**
|
486 |
+
* UM hook
|
487 |
+
*
|
488 |
+
* @type action
|
489 |
+
* @title um_user_register
|
490 |
+
* @description After complete UM user registration.
|
491 |
+
* @input_vars
|
492 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
493 |
+
* {"var":"$args","type":"array","desc":"Form data"}]
|
494 |
+
* @change_log
|
495 |
+
* ["Since: 2.0"]
|
496 |
+
* @usage add_action( 'um_user_register', 'function_name', 10, 2 );
|
497 |
+
* @example
|
498 |
+
* <?php
|
499 |
+
* add_action( 'um_user_register', 'my_user_register', 10, 2 );
|
500 |
+
* function my_user_register( $user_id, $args ) {
|
501 |
+
* // your code here
|
502 |
+
* }
|
503 |
+
* ?>
|
504 |
+
*/
|
505 |
+
do_action( 'um_user_register', $user_id, $args );
|
506 |
+
|
507 |
+
return $user_id;
|
508 |
+
}
|
509 |
+
add_action( 'um_submit_form_register', 'um_submit_form_register', 10 );
|
510 |
+
|
511 |
+
|
512 |
+
/**
|
513 |
+
* Show the submit button
|
514 |
+
*
|
515 |
+
* @param $args
|
516 |
+
*/
|
517 |
+
function um_add_submit_button_to_register( $args ) {
|
518 |
+
$primary_btn_word = $args['primary_btn_word'];
|
519 |
+
/**
|
520 |
+
* UM hook
|
521 |
+
*
|
522 |
+
* @type filter
|
523 |
+
* @title um_register_form_button_one
|
524 |
+
* @description Change Register Form Primary button
|
525 |
+
* @input_vars
|
526 |
+
* [{"var":"$primary_btn_word","type":"string","desc":"Button text"},
|
527 |
+
* {"var":"$args","type":"array","desc":"Registration Form arguments"}]
|
528 |
+
* @change_log
|
529 |
+
* ["Since: 2.0"]
|
530 |
+
* @usage
|
531 |
+
* <?php add_filter( 'um_register_form_button_one', 'function_name', 10, 2 ); ?>
|
532 |
+
* @example
|
533 |
+
* <?php
|
534 |
+
* add_filter( 'um_register_form_button_one', 'my_register_form_button_one', 10, 2 );
|
535 |
+
* function my_register_form_button_one( $primary_btn_word, $args ) {
|
536 |
+
* // your code here
|
537 |
+
* return $primary_btn_word;
|
538 |
+
* }
|
539 |
+
* ?>
|
540 |
+
*/
|
541 |
+
$primary_btn_word = apply_filters('um_register_form_button_one', $primary_btn_word, $args );
|
542 |
+
|
543 |
+
if ( ! isset( $primary_btn_word ) || $primary_btn_word == '' ){
|
544 |
+
$primary_btn_word = UM()->options()->get( 'register_primary_btn_word' );
|
545 |
+
}
|
546 |
+
|
547 |
+
$secondary_btn_word = $args['secondary_btn_word'];
|
548 |
+
/**
|
549 |
+
* UM hook
|
550 |
+
*
|
551 |
+
* @type filter
|
552 |
+
* @title um_register_form_button_two
|
553 |
+
* @description Change Registration Form Secondary button
|
554 |
+
* @input_vars
|
555 |
+
* [{"var":"$secondary_btn_word","type":"string","desc":"Button text"},
|
556 |
+
* {"var":"$args","type":"array","desc":"Registration Form arguments"}]
|
557 |
+
* @change_log
|
558 |
+
* ["Since: 2.0"]
|
559 |
+
* @usage
|
560 |
+
* <?php add_filter( 'um_register_form_button_two', 'function_name', 10, 2 ); ?>
|
561 |
+
* @example
|
562 |
+
* <?php
|
563 |
+
* add_filter( 'um_register_form_button_two', 'my_register_form_button_two', 10, 2 );
|
564 |
+
* function my_register_form_button_two( $secondary_btn_word, $args ) {
|
565 |
+
* // your code here
|
566 |
+
* return $secondary_btn_word;
|
567 |
+
* }
|
568 |
+
* ?>
|
569 |
+
*/
|
570 |
+
$secondary_btn_word = apply_filters( 'um_register_form_button_two', $secondary_btn_word, $args );
|
571 |
+
|
572 |
+
if ( ! isset( $secondary_btn_word ) || $secondary_btn_word == '' ){
|
573 |
+
$secondary_btn_word = UM()->options()->get( 'register_secondary_btn_word' );
|
574 |
+
}
|
575 |
+
|
576 |
+
$secondary_btn_url = ( isset( $args['secondary_btn_url'] ) && $args['secondary_btn_url'] ) ? $args['secondary_btn_url'] : um_get_core_page('login');
|
577 |
+
/**
|
578 |
+
* UM hook
|
579 |
+
*
|
580 |
+
* @type filter
|
581 |
+
* @title um_register_form_button_two_url
|
582 |
+
* @description Change Registration Form Secondary button URL
|
583 |
+
* @input_vars
|
584 |
+
* [{"var":"$secondary_btn_url","type":"string","desc":"Button URL"},
|
585 |
+
* {"var":"$args","type":"array","desc":"Registration Form arguments"}]
|
586 |
+
* @change_log
|
587 |
+
* ["Since: 2.0"]
|
588 |
+
* @usage
|
589 |
+
* <?php add_filter( 'um_register_form_button_two_url', 'function_name', 10, 2 ); ?>
|
590 |
+
* @example
|
591 |
+
* <?php
|
592 |
+
* add_filter( 'um_register_form_button_two_url', 'my_register_form_button_two_url', 10, 2 );
|
593 |
+
* function my_register_form_button_two_url( $secondary_btn_url, $args ) {
|
594 |
+
* // your code here
|
595 |
+
* return $secondary_btn_url;
|
596 |
+
* }
|
597 |
+
* ?>
|
598 |
+
*/
|
599 |
+
$secondary_btn_url = apply_filters('um_register_form_button_two_url', $secondary_btn_url, $args ); ?>
|
600 |
+
|
601 |
+
<div class="um-col-alt">
|
602 |
+
|
603 |
+
<?php if ( ! empty( $args['secondary_btn'] ) ) { ?>
|
604 |
+
|
605 |
+
<div class="um-left um-half">
|
606 |
+
<input type="submit" value="<?php esc_attr_e( wp_unslash( $primary_btn_word ), 'ultimate-member' ) ?>" class="um-button" id="um-submit-btn" />
|
607 |
+
</div>
|
608 |
+
<div class="um-right um-half">
|
609 |
+
<a href="<?php echo esc_url( $secondary_btn_url ); ?>" class="um-button um-alt">
|
610 |
+
<?php _e( wp_unslash( $secondary_btn_word ),'ultimate-member' ); ?>
|
611 |
+
</a>
|
612 |
+
</div>
|
613 |
+
|
614 |
+
<?php } else { ?>
|
615 |
+
|
616 |
+
<div class="um-center">
|
617 |
+
<input type="submit" value="<?php esc_attr_e( wp_unslash( $primary_btn_word ), 'ultimate-member' ) ?>" class="um-button" id="um-submit-btn" />
|
618 |
+
</div>
|
619 |
+
|
620 |
+
<?php } ?>
|
621 |
+
|
622 |
+
<div class="um-clear"></div>
|
623 |
+
|
624 |
+
</div>
|
625 |
+
|
626 |
+
<?php
|
627 |
+
}
|
628 |
+
add_action( 'um_after_register_fields', 'um_add_submit_button_to_register', 1000 );
|
629 |
+
|
630 |
+
|
631 |
+
/**
|
632 |
+
* Show Fields
|
633 |
+
*
|
634 |
+
* @param $args
|
635 |
+
*/
|
636 |
+
function um_add_register_fields( $args ){
|
637 |
+
echo UM()->fields()->display( 'register', $args );
|
638 |
+
}
|
639 |
+
add_action( 'um_main_register_fields', 'um_add_register_fields', 100 );
|
640 |
+
|
641 |
+
|
642 |
+
/**
|
643 |
+
* Saving files to register a new user, if there are fields with files
|
644 |
+
*
|
645 |
+
* @param $user_id
|
646 |
+
* @param $args
|
647 |
+
*/
|
648 |
+
function um_registration_save_files( $user_id, $args ) {
|
649 |
+
|
650 |
+
if ( empty( $args['custom_fields'] ) ) {
|
651 |
+
return;
|
652 |
+
}
|
653 |
+
|
654 |
+
$files = array();
|
655 |
+
|
656 |
+
$fields = unserialize( $args['custom_fields'] );
|
657 |
+
|
658 |
+
// loop through fields
|
659 |
+
if ( isset( $fields ) && is_array( $fields ) ) {
|
660 |
+
|
661 |
+
foreach ( $fields as $key => $array ) {
|
662 |
+
|
663 |
+
if ( isset( $args['submitted'][ $key ] ) ) {
|
664 |
+
|
665 |
+
if ( isset( $fields[ $key ]['type'] ) && in_array( $fields[ $key ]['type'], array( 'image', 'file' ) ) &&
|
666 |
+
( um_is_temp_file( $args['submitted'][ $key ] ) || $args['submitted'][ $key ] == 'empty_file' )
|
667 |
+
) {
|
668 |
+
|
669 |
+
$files[ $key ] = $args['submitted'][ $key ];
|
670 |
+
|
671 |
+
}
|
672 |
+
}
|
673 |
+
}
|
674 |
+
}
|
675 |
+
|
676 |
+
/**
|
677 |
+
* UM hook
|
678 |
+
*
|
679 |
+
* @type filter
|
680 |
+
* @title um_user_pre_updating_files_array
|
681 |
+
* @description Change submitted files before register new user
|
682 |
+
* @input_vars
|
683 |
+
* [{"var":"$files","type":"array","desc":"Profile data files"}]
|
684 |
+
* @change_log
|
685 |
+
* ["Since: 2.0"]
|
686 |
+
* @usage
|
687 |
+
* <?php add_filter( 'um_user_pre_updating_files_array', 'function_name', 10, 1 ); ?>
|
688 |
+
* @example
|
689 |
+
* <?php
|
690 |
+
* add_filter( 'um_user_pre_updating_files_array', 'my_user_pre_updating_files', 10, 1 );
|
691 |
+
* function my_user_pre_updating_files( $files ) {
|
692 |
+
* // your code here
|
693 |
+
* return $files;
|
694 |
+
* }
|
695 |
+
* ?>
|
696 |
+
*/
|
697 |
+
$files = apply_filters( 'um_user_pre_updating_files_array', $files );
|
698 |
+
|
699 |
+
if ( ! empty( $files ) ) {
|
700 |
+
UM()->uploader()->replace_upload_dir = true;
|
701 |
+
UM()->uploader()->move_temporary_files( $user_id, $files );
|
702 |
+
UM()->uploader()->replace_upload_dir = false;
|
703 |
+
}
|
704 |
+
}
|
705 |
+
add_action( 'um_registration_set_extra_data', 'um_registration_save_files', 10, 2 );
|
706 |
+
|
707 |
+
|
708 |
+
/**
|
709 |
+
* Update user Full Name
|
710 |
+
*
|
711 |
+
* @profile name update
|
712 |
+
*
|
713 |
+
* @param $user_id
|
714 |
+
* @param $args
|
715 |
+
*/
|
716 |
+
function um_registration_set_profile_full_name( $user_id, $args ) {
|
717 |
+
/**
|
718 |
+
* UM hook
|
719 |
+
*
|
720 |
+
* @type action
|
721 |
+
* @title um_update_profile_full_name
|
722 |
+
* @description On update user profile change full name
|
723 |
+
* @input_vars
|
724 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"},
|
725 |
+
* {"var":"$args","type":"array","desc":"Form data"}]
|
726 |
+
* @change_log
|
727 |
+
* ["Since: 2.0"]
|
728 |
+
* @usage add_action( 'um_update_profile_full_name', 'function_name', 10, 2 );
|
729 |
+
* @example
|
730 |
+
* <?php
|
731 |
+
* add_action( 'um_update_profile_full_name', 'my_update_profile_full_name', 10, 2 );
|
732 |
+
* function my_update_profile_full_name( $user_id, $args ) {
|
733 |
+
* // your code here
|
734 |
+
* }
|
735 |
+
* ?>
|
736 |
+
*/
|
737 |
+
do_action( 'um_update_profile_full_name', $user_id, $args );
|
738 |
+
}
|
739 |
+
add_action( 'um_registration_set_extra_data', 'um_registration_set_profile_full_name', 10, 2 );
|
740 |
+
|
741 |
+
|
742 |
+
/**
|
743 |
+
* Redirect from default registration to UM registration page
|
744 |
+
*/
|
745 |
+
function um_form_register_redirect() {
|
746 |
+
$page_id = UM()->options()->get( UM()->options()->get_core_page_id( 'register' ) );
|
747 |
+
$register_post = get_post( $page_id );
|
748 |
+
if ( ! empty( $register_post ) ) {
|
749 |
+
wp_safe_redirect( get_permalink( $page_id ) );
|
750 |
+
exit();
|
751 |
+
}
|
752 |
+
}
|
753 |
+
add_action( 'login_form_register', 'um_form_register_redirect', 10 );
|
readme.txt
CHANGED
@@ -7,7 +7,7 @@ Tags: community, member, membership, user-profile, user-registration
|
|
7 |
Requires PHP: 5.6
|
8 |
Requires at least: 5.0
|
9 |
Tested up to: 6.0
|
10 |
-
Stable tag: 2.4.
|
11 |
License: GNU Version 2 or Any Later Version
|
12 |
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
|
13 |
|
@@ -163,6 +163,15 @@ No, you do not need to use our plugin’s login or registration pages and can us
|
|
163 |
* To learn more about version 2.1 please see this [docs](https://docs.ultimatemember.com/article/1512-upgrade-2-1-0)
|
164 |
* UM2.1+ is a significant update to the Member Directories' code base from 2.0.x. Please make sure you take a full-site backup with restore point before updating the plugin
|
165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
= 2.4.1: June 13, 2022 =
|
167 |
|
168 |
* Enhancements:
|
7 |
Requires PHP: 5.6
|
8 |
Requires at least: 5.0
|
9 |
Tested up to: 6.0
|
10 |
+
Stable tag: 2.4.2
|
11 |
License: GNU Version 2 or Any Later Version
|
12 |
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
|
13 |
|
163 |
* To learn more about version 2.1 please see this [docs](https://docs.ultimatemember.com/article/1512-upgrade-2-1-0)
|
164 |
* UM2.1+ is a significant update to the Member Directories' code base from 2.0.x. Please make sure you take a full-site backup with restore point before updating the plugin
|
165 |
|
166 |
+
= 2.4.2: July 14, 2022 =
|
167 |
+
|
168 |
+
* Bugfixes:
|
169 |
+
|
170 |
+
- Fixed: Member Directory vulnerabilities
|
171 |
+
- Fixed: 3rd-party integration with profile tabs and ability to show edit profile form on the 3rd-party profile tab
|
172 |
+
- Fixed: PHP fatal error on unset
|
173 |
+
- Fixed: select2 style conflicts with 3rd-party plugins
|
174 |
+
|
175 |
= 2.4.1: June 13, 2022 =
|
176 |
|
177 |
* Enhancements:
|
ultimate-member.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Ultimate Member
|
4 |
Plugin URI: http://ultimatemember.com/
|
5 |
Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress
|
6 |
-
Version: 2.4.
|
7 |
Author: Ultimate Member
|
8 |
Author URI: http://ultimatemember.com/
|
9 |
Text Domain: ultimate-member
|
3 |
Plugin Name: Ultimate Member
|
4 |
Plugin URI: http://ultimatemember.com/
|
5 |
Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress
|
6 |
+
Version: 2.4.2
|
7 |
Author: Ultimate Member
|
8 |
Author URI: http://ultimatemember.com/
|
9 |
Text Domain: ultimate-member
|