Version Description
Download this release
Release Info
Developer | nsinelnikov |
Plugin | Ultimate Member – User Profile & Membership Plugin |
Version | 2.4.1 |
Comparing to | |
See all releases |
Code changes from version 2.4.0 to 2.4.1
- assets/css/um-styles.css +100 -56
- includes/admin/class-admin.php +1980 -1980
- includes/admin/core/class-admin-builder.php +1232 -1228
- includes/admin/core/class-admin-metabox.php +2426 -2427
- includes/admin/core/packages/2.4.0/functions.php +50 -50
- includes/admin/templates/form/builder.php +35 -35
- includes/core/class-access.php +2136 -2133
- includes/core/class-builtin.php +1976 -1976
- includes/core/class-fields.php +4902 -4896
- includes/core/class-form.php +837 -831
- includes/core/class-member-directory-meta.php +794 -864
assets/css/um-styles.css
CHANGED
@@ -877,34 +877,40 @@ small.um-max-filesize span{
|
|
877 |
right: 10px;
|
878 |
}
|
879 |
|
880 |
-
/*
|
|
|
|
|
|
|
881 |
.select2-container.select2-container--open {
|
882 |
-
|
883 |
-
|
884 |
.select2.select2-container .select2-selection {
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
|
|
|
|
|
|
908 |
}
|
909 |
|
910 |
.select2.select2-container .select2-selection .select2-selection__arrow {
|
@@ -922,51 +928,64 @@ small.um-max-filesize span{
|
|
922 |
background: transparent !important;
|
923 |
border-left: 0 !important;
|
924 |
}
|
|
|
|
|
|
|
|
|
925 |
|
926 |
.select2.select2-container .select2-selection .select2-selection__arrow:before {
|
927 |
content: "\f3d0" !important;
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
|
|
|
|
935 |
}
|
936 |
|
937 |
.select2.select2-container .select2-selection .select2-selection__arrow b[role="presentation"] {
|
938 |
-
display:none;
|
939 |
}
|
940 |
|
941 |
.select2-container.select2-container--open .select2-dropdown {
|
942 |
-
|
943 |
border-radius: 0;
|
944 |
}
|
945 |
|
946 |
.select2-container.select2-container--open .select2-dropdown .select2-results li {
|
947 |
list-style: none;
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
|
958 |
.select2.select2-container .select2-selection.select2-selection--multiple {
|
959 |
height: auto !important;
|
960 |
line-height: 0.8 !important;
|
|
|
|
|
961 |
}
|
962 |
|
963 |
.select2-container--default .select2-selection--single .select2-selection__rendered {
|
964 |
-
padding-left: 0 !important;
|
965 |
line-height: 37px;
|
|
|
|
|
|
|
|
|
|
|
|
|
966 |
}
|
967 |
|
968 |
.select2-container--default .select2-selection--multiple .select2-selection__rendered {
|
969 |
-
|
970 |
box-sizing: border-box;
|
971 |
list-style: none;
|
972 |
margin: 0;
|
@@ -975,23 +994,36 @@ small.um-max-filesize span{
|
|
975 |
width: 100%;
|
976 |
font-size: 13px;
|
977 |
}
|
|
|
|
|
|
|
|
|
978 |
|
979 |
.select2-results li.select2-results__option.select2-results__option--highlighted {
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
}
|
984 |
.select2-container--default .select2-results__option[aria-selected="true"] {
|
985 |
-
|
986 |
}
|
987 |
|
988 |
|
989 |
.select2-container--default .select2-selection--single .select2-selection__clear,
|
990 |
.select2-container--default .select2-selection--multiple .select2-selection__clear {
|
991 |
-
right: 10px;
|
992 |
-
font-size: 30px;
|
993 |
color: #aaaaaa !important;
|
|
|
|
|
|
|
994 |
margin: 0 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
995 |
}
|
996 |
|
997 |
.select2-container--default .select2-selection--multiple .select2-selection__clear {
|
@@ -999,13 +1031,28 @@ small.um-max-filesize span{
|
|
999 |
}
|
1000 |
|
1001 |
.select2-container--default .select2-selection--multiple .select2-selection__choice {
|
|
|
1002 |
padding: 3px 3px 3px 5px;
|
1003 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1004 |
|
1005 |
.um .um-form .select2-container .select2-search.select2-search--inline > input {
|
1006 |
border: none !important;
|
1007 |
padding: 0 !important;
|
1008 |
border-radius: 0 !important;
|
|
|
1009 |
}
|
1010 |
|
1011 |
.um .um-form .select2-container--default .select2-selection--multiple .select2-selection__rendered li {
|
@@ -1013,6 +1060,7 @@ small.um-max-filesize span{
|
|
1013 |
text-overflow: ellipsis;
|
1014 |
max-width: 100%;
|
1015 |
box-sizing: border-box;
|
|
|
1016 |
}
|
1017 |
|
1018 |
/*
|
@@ -1042,10 +1090,6 @@ small.um-max-filesize span{
|
|
1042 |
/*width: 100% !important;*/
|
1043 |
/*}*/
|
1044 |
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
/* @todo maybe deprecated and used only for select and multiselect */
|
1050 |
.um-field-select .um-field-area .um-field-icon,
|
1051 |
.um-field-multiselect .um-field-area .um-field-icon {
|
877 |
right: 10px;
|
878 |
}
|
879 |
|
880 |
+
/*
|
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;
|
891 |
+
overflow: hidden !important;
|
892 |
+
position: relative !important;
|
893 |
+
white-space: nowrap !important;
|
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;
|
902 |
+
background-clip: padding-box !important;
|
903 |
+
-webkit-touch-callout: none;
|
904 |
+
-webkit-user-select: none;
|
905 |
+
-moz-user-select: none;
|
906 |
+
-ms-user-select: none;
|
907 |
+
user-select: none;
|
908 |
+
background: none !important;
|
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 {
|
928 |
background: transparent !important;
|
929 |
border-left: 0 !important;
|
930 |
}
|
931 |
+
.rtl .select2.select2-container .select2-selection .select2-selection__arrow {
|
932 |
+
right: initial !important;
|
933 |
+
left: 0 !important;
|
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;
|
944 |
+
min-width: 1em;
|
945 |
+
text-align: center;
|
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-image: none;
|
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 !important;
|
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: 0 !important;
|
980 |
+
padding-right: 24px !important;
|
981 |
+
}
|
982 |
+
.rtl .select2-container--default .select2-selection--single .select2-selection__rendered {
|
983 |
+
padding-left: 24px !important;
|
984 |
+
padding-right: 0 !important;
|
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;
|
994 |
width: 100%;
|
995 |
font-size: 13px;
|
996 |
}
|
997 |
+
.rtl .select2-container--default .select2-selection--multiple .select2-selection__rendered {
|
998 |
+
padding-left: 30px !important;
|
999 |
+
padding-right: 0 !important;
|
1000 |
+
}
|
1001 |
|
1002 |
.select2-results li.select2-results__option.select2-results__option--highlighted {
|
1003 |
+
background: none !important;
|
1004 |
+
background: #f4f4f4 !important;
|
1005 |
+
color: #666 !important;
|
1006 |
}
|
1007 |
.select2-container--default .select2-results__option[aria-selected="true"] {
|
1008 |
+
background-color: #ddd;
|
1009 |
}
|
1010 |
|
1011 |
|
1012 |
.select2-container--default .select2-selection--single .select2-selection__clear,
|
1013 |
.select2-container--default .select2-selection--multiple .select2-selection__clear {
|
|
|
|
|
1014 |
color: #aaaaaa !important;
|
1015 |
+
font-size: 28px;
|
1016 |
+
font-weight: normal;
|
1017 |
+
line-height: 34px;
|
1018 |
margin: 0 !important;
|
1019 |
+
right: 0;
|
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 {
|
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 .um-form .select2-container .select2-search.select2-search--inline{
|
1044 |
+
margin: 5px 5px 0 0;
|
1045 |
+
padding: 0px;
|
1046 |
+
}
|
1047 |
+
.rtl .um .um-form .select2-container .select2-search.select2-search--inline{
|
1048 |
+
margin: 5px 0 0 5px;
|
1049 |
+
}
|
1050 |
|
1051 |
.um .um-form .select2-container .select2-search.select2-search--inline > input {
|
1052 |
border: none !important;
|
1053 |
padding: 0 !important;
|
1054 |
border-radius: 0 !important;
|
1055 |
+
max-height: 28px;
|
1056 |
}
|
1057 |
|
1058 |
.um .um-form .select2-container--default .select2-selection--multiple .select2-selection__rendered li {
|
1060 |
text-overflow: ellipsis;
|
1061 |
max-width: 100%;
|
1062 |
box-sizing: border-box;
|
1063 |
+
line-height: 20px;
|
1064 |
}
|
1065 |
|
1066 |
/*
|
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 {
|
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/admin/core/class-admin-builder.php
CHANGED
@@ -1,1228 +1,1232 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\admin\core;
|
3 |
-
|
4 |
-
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
|
8 |
-
if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Admin_Builder
|
13 |
-
* @package um\admin\core
|
14 |
-
*/
|
15 |
-
class Admin_Builder {
|
16 |
-
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @var
|
20 |
-
*/
|
21 |
-
var $form_id;
|
22 |
-
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Admin_Builder constructor.
|
26 |
-
*/
|
27 |
-
function __construct() {
|
28 |
-
add_action( 'um_admin_field_modal_header', array( &$this, 'add_message_handlers' ) );
|
29 |
-
add_action( 'um_admin_field_modal_footer', array( &$this, 'add_conditional_support' ), 10, 4 );
|
30 |
-
add_filter( 'um_admin_builder_skip_field_validation', array( &$this, 'skip_field_validation' ), 10, 3 );
|
31 |
-
add_filter( 'um_admin_pre_save_field_to_form', array( &$this, 'um_admin_pre_save_field_to_form' ), 1 );
|
32 |
-
add_filter( 'um_admin_pre_save_fields_hook', array( &$this, 'um_admin_pre_save_fields_hook' ), 1 );
|
33 |
-
add_filter( 'um_admin_field_update_error_handling', array( &$this, 'um_admin_field_update_error_handling' ), 1, 2 );
|
34 |
-
}
|
35 |
-
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Apply a filter to handle errors for field updating in backend
|
39 |
-
*
|
40 |
-
* @param $errors
|
41 |
-
* @param $array
|
42 |
-
*
|
43 |
-
* @return mixed
|
44 |
-
*/
|
45 |
-
function um_admin_field_update_error_handling( $errors, $array ) {
|
46 |
-
/**
|
47 |
-
* @var $field_type
|
48 |
-
*/
|
49 |
-
extract( $array );
|
50 |
-
|
51 |
-
$field_attr = UM()->builtin()->get_core_field_attrs( $field_type );
|
52 |
-
|
53 |
-
if ( isset( $field_attr['validate'] ) ) {
|
54 |
-
|
55 |
-
$validate = $field_attr['validate'];
|
56 |
-
foreach ( $validate as $post_input => $arr ) {
|
57 |
-
|
58 |
-
$skip = apply_filters( 'um_admin_builder_skip_field_validation', false, $post_input, $array );
|
59 |
-
if ( $skip ) {
|
60 |
-
continue;
|
61 |
-
}
|
62 |
-
|
63 |
-
$mode = $arr['mode'];
|
64 |
-
|
65 |
-
switch ( $mode ) {
|
66 |
-
|
67 |
-
case 'numeric':
|
68 |
-
if ( ! empty( $array['post'][ $post_input ] ) && ! is_numeric( $array['post'][ $post_input ] ) ){
|
69 |
-
$errors[ $post_input ] = $validate[ $post_input ]['error'];
|
70 |
-
}
|
71 |
-
break;
|
72 |
-
|
73 |
-
case 'unique':
|
74 |
-
if ( ! isset( $array['post']['edit_mode'] ) ) {
|
75 |
-
if ( UM()->builtin()->unique_field_err( $array['post'][ $post_input ] ) ) {
|
76 |
-
$errors[ $post_input ] = UM()->builtin()->unique_field_err( $array['post'][ $post_input ] );
|
77 |
-
}
|
78 |
-
}
|
79 |
-
break;
|
80 |
-
|
81 |
-
case 'required':
|
82 |
-
if ( $array['post'][ $post_input ] == '' ) {
|
83 |
-
$errors[ $post_input ] = $validate[ $post_input ]['error'];
|
84 |
-
}
|
85 |
-
break;
|
86 |
-
|
87 |
-
case 'range-start':
|
88 |
-
if ( UM()->builtin()->date_range_start_err( $array['post'][ $post_input ] ) && $array['post']['_range'] == 'date_range' ) {
|
89 |
-
$errors[ $post_input ] = UM()->builtin()->date_range_start_err( $array['post'][ $post_input ] );
|
90 |
-
}
|
91 |
-
break;
|
92 |
-
|
93 |
-
case 'range-end':
|
94 |
-
if ( UM()->builtin()->date_range_end_err( $array['post'][ $post_input ], $array['post']['_range_start'] ) && $array['post']['_range'] == 'date_range' ) {
|
95 |
-
$errors[ $post_input ] = UM()->builtin()->date_range_end_err( $array['post'][ $post_input ], $array['post']['_range_start'] );
|
96 |
-
}
|
97 |
-
break;
|
98 |
-
|
99 |
-
}
|
100 |
-
|
101 |
-
}
|
102 |
-
|
103 |
-
}
|
104 |
-
|
105 |
-
return $errors;
|
106 |
-
|
107 |
-
}
|
108 |
-
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Some fields may require extra fields before saving
|
112 |
-
*
|
113 |
-
* @param $array
|
114 |
-
*
|
115 |
-
* @return mixed
|
116 |
-
*/
|
117 |
-
function um_admin_pre_save_fields_hook( $array ) {
|
118 |
-
/**
|
119 |
-
* @var $form_id
|
120 |
-
* @var $field_type
|
121 |
-
*/
|
122 |
-
extract( $array );
|
123 |
-
|
124 |
-
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
125 |
-
|
126 |
-
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
127 |
-
$count = 1;
|
128 |
-
if ( ! empty( $fields ) ) {
|
129 |
-
$count = count( $fields ) + 1;
|
130 |
-
}
|
131 |
-
|
132 |
-
// set unique meta key
|
133 |
-
if ( in_array( $field_type, $fields_without_metakey ) && ! isset( $array['post']['_metakey'] ) ) {
|
134 |
-
$array['post']['_metakey'] = "um_{$field_type}_{$form_id}_{$count}";
|
135 |
-
}
|
136 |
-
|
137 |
-
// set position
|
138 |
-
if ( ! isset( $array['post']['_position'] ) ) {
|
139 |
-
$array['post']['_position'] = $count;
|
140 |
-
}
|
141 |
-
|
142 |
-
return $array;
|
143 |
-
}
|
144 |
-
|
145 |
-
|
146 |
-
/**
|
147 |
-
* Modify field args just before it is saved into form
|
148 |
-
*
|
149 |
-
* @param $array
|
150 |
-
*
|
151 |
-
* @return mixed
|
152 |
-
*/
|
153 |
-
function um_admin_pre_save_field_to_form( $array ){
|
154 |
-
unset( $array['conditions'] );
|
155 |
-
if ( isset($array['conditional_field']) && ! empty( $array['conditional_action'] ) && ! empty( $array['conditional_operator'] ) ) {
|
156 |
-
$array['conditional_value'] = isset( $array['conditional_value'] ) ? $array['conditional_value'] : '';
|
157 |
-
$array['conditions'][] = array( $array['conditional_action'], $array['conditional_field'], $array['conditional_operator'], $array['conditional_value'] );
|
158 |
-
}
|
159 |
-
|
160 |
-
if ( isset( $array['conditional_field1'] ) && ! empty( $array['conditional_action1'] ) && ! empty( $array['conditional_operator1'] ) ) {
|
161 |
-
$array['conditional_value1'] = isset( $array['conditional_value1'] ) ? $array['conditional_value1'] : '';
|
162 |
-
$array['conditions'][] = array( $array['conditional_action1'], $array['conditional_field1'], $array['conditional_operator1'], $array['conditional_value1'] );
|
163 |
-
}
|
164 |
-
|
165 |
-
if ( isset( $array['conditional_field2'] ) && ! empty( $array['conditional_action2'] ) && ! empty( $array['conditional_operator2'] ) ) {
|
166 |
-
$array['conditional_value2'] = isset( $array['conditional_value2'] ) ? $array['conditional_value2'] : '';
|
167 |
-
$array['conditions'][] = array( $array['conditional_action2'], $array['conditional_field2'], $array['conditional_operator2'], $array['conditional_value2'] );
|
168 |
-
}
|
169 |
-
|
170 |
-
if ( isset( $array['conditional_field3'] ) && ! empty( $array['conditional_action3'] ) && ! empty( $array['conditional_operator3'] ) ) {
|
171 |
-
$array['conditional_value3'] = isset( $array['conditional_value3'] ) ? $array['conditional_value3'] : '';
|
172 |
-
$array['conditions'][] = array( $array['conditional_action3'], $array['conditional_field3'], $array['conditional_operator3'], $array['conditional_value3'] );
|
173 |
-
}
|
174 |
-
|
175 |
-
if ( isset( $array['conditional_field4'] ) && ! empty( $array['conditional_action4'] ) && ! empty( $array['conditional_operator4'] ) ) {
|
176 |
-
$array['conditional_value4'] = isset( $array['conditional_value4'] ) ? $array['conditional_value4'] : '';
|
177 |
-
$array['conditions'][] = array( $array['conditional_action4'], $array['conditional_field4'], $array['conditional_operator4'], $array['conditional_value4'] );
|
178 |
-
}
|
179 |
-
|
180 |
-
return $array;
|
181 |
-
}
|
182 |
-
|
183 |
-
|
184 |
-
/**
|
185 |
-
* Put status handler in modal
|
186 |
-
*/
|
187 |
-
function add_message_handlers() {
|
188 |
-
?>
|
189 |
-
<div class="um-admin-error-block"></div>
|
190 |
-
<div class="um-admin-success-block"></div>
|
191 |
-
<?php
|
192 |
-
}
|
193 |
-
|
194 |
-
|
195 |
-
/**
|
196 |
-
* Footer of modal
|
197 |
-
*
|
198 |
-
* @param $form_id
|
199 |
-
* @param $field_args
|
200 |
-
* @param $in_edit
|
201 |
-
* @param $edit_array
|
202 |
-
*/
|
203 |
-
function add_conditional_support( $form_id, $field_args, $in_edit, $edit_array ) {
|
204 |
-
$metabox = UM()->metabox();
|
205 |
-
|
206 |
-
if ( isset( $field_args['conditional_support'] ) && $field_args['conditional_support'] == 0 ) {
|
207 |
-
return;
|
208 |
-
} ?>
|
209 |
-
|
210 |
-
<div class="um-admin-btn-toggle">
|
211 |
-
|
212 |
-
<?php if ( $in_edit ) { $metabox->in_edit = true; $metabox->edit_array = $edit_array; ?>
|
213 |
-
<a href="javascript:void(0);"><i class="um-icon-plus"></i><?php _e( 'Manage conditional fields support' ); ?></a> <?php UM()->tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
|
214 |
-
<?php } else { ?>
|
215 |
-
<a href="javascript:void(0);"><i class="um-icon-plus"></i><?php _e( 'Add conditional fields support' ); ?></a> <?php UM()->tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
|
216 |
-
<?php } ?>
|
217 |
-
|
218 |
-
<div class="um-admin-btn-content">
|
219 |
-
<div class="um-admin-cur-condition-template">
|
220 |
-
|
221 |
-
<?php $metabox->field_input( '_conditional_action', $form_id ); ?>
|
222 |
-
<?php $metabox->field_input( '_conditional_field', $form_id ); ?>
|
223 |
-
<?php $metabox->field_input( '_conditional_operator', $form_id ); ?>
|
224 |
-
<?php $metabox->field_input( '_conditional_value', $form_id ); ?>
|
225 |
-
|
226 |
-
<p><a href="javascript:void(0);" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
|
227 |
-
|
228 |
-
<div class="um-admin-clear"></div>
|
229 |
-
</div>
|
230 |
-
<p class="um-admin-conditions-notice">
|
231 |
-
<small>
|
232 |
-
<?php _e( 'Use the condition operator `equals to` or `not equals` if the parent field has a single option.', 'ultimate-member' ); ?>
|
233 |
-
<br><?php _e( 'Use the condition operator `greater than` or `less than` if the parent field is a number.', 'ultimate-member' ); ?>
|
234 |
-
<br><?php _e( 'Use the condition operator `contains` if the parent field has multiple options.', 'ultimate-member' ); ?>
|
235 |
-
</small>
|
236 |
-
</p>
|
237 |
-
<p><a href="javascript:void(0);" class="um-admin-new-condition button button-primary um-admin-tipsy-n" title="Add new condition"><?php _e( 'Add new rule', 'ultimate-member' ); ?></a></p>
|
238 |
-
<p class="um-admin-reset-conditions"><a href="javascript:void(0);" class="button"><?php _e( 'Reset all rules', 'ultimate-member' ); ?></a></p>
|
239 |
-
|
240 |
-
<div class="um-admin-clear"></div>
|
241 |
-
|
242 |
-
<?php if ( isset( $edit_array['conditions'] ) && count( $edit_array['conditions'] ) != 0 ) {
|
243 |
-
|
244 |
-
foreach ( $edit_array['conditions'] as $k => $arr ) {
|
245 |
-
|
246 |
-
if ( $k == 0 ) $k = ''; ?>
|
247 |
-
|
248 |
-
<div class="um-admin-cur-condition">
|
249 |
-
|
250 |
-
<?php $metabox->field_input( '_conditional_action' . $k, $form_id ); ?>
|
251 |
-
<?php $metabox->field_input( '_conditional_field' . $k , $form_id ); ?>
|
252 |
-
<?php $metabox->field_input( '_conditional_operator' . $k, $form_id ); ?>
|
253 |
-
<?php $metabox->field_input( '_conditional_value' . $k, $form_id ); ?>
|
254 |
-
|
255 |
-
<p><a href="#" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
|
256 |
-
|
257 |
-
<div class="um-admin-clear"></div>
|
258 |
-
</div>
|
259 |
-
|
260 |
-
<?php
|
261 |
-
}
|
262 |
-
|
263 |
-
} else { ?>
|
264 |
-
|
265 |
-
<div class="um-admin-cur-condition">
|
266 |
-
|
267 |
-
<?php $metabox->field_input( '_conditional_action', $form_id ); ?>
|
268 |
-
<?php $metabox->field_input( '_conditional_field', $form_id ); ?>
|
269 |
-
<?php $metabox->field_input( '_conditional_operator', $form_id ); ?>
|
270 |
-
<?php $metabox->field_input( '_conditional_value', $form_id ); ?>
|
271 |
-
|
272 |
-
<p><a href="#" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
|
273 |
-
|
274 |
-
<div class="um-admin-clear"></div>
|
275 |
-
</div>
|
276 |
-
|
277 |
-
<?php } ?>
|
278 |
-
</div>
|
279 |
-
</div>
|
280 |
-
|
281 |
-
<?php
|
282 |
-
}
|
283 |
-
|
284 |
-
|
285 |
-
/**
|
286 |
-
* Update the builder area
|
287 |
-
*/
|
288 |
-
function update_builder() {
|
289 |
-
UM()->admin()->check_ajax_nonce();
|
290 |
-
|
291 |
-
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
|
292 |
-
wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
|
293 |
-
}
|
294 |
-
|
295 |
-
ob_start();
|
296 |
-
|
297 |
-
$this->form_id = absint( $_POST['form_id'] );
|
298 |
-
|
299 |
-
$this->show_builder();
|
300 |
-
|
301 |
-
$output = ob_get_clean();
|
302 |
-
|
303 |
-
if ( is_array( $output ) ) {
|
304 |
-
print_r( $output );
|
305 |
-
} else {
|
306 |
-
echo $output;
|
307 |
-
}
|
308 |
-
die;
|
309 |
-
}
|
310 |
-
|
311 |
-
|
312 |
-
/**
|
313 |
-
* Sort array function
|
314 |
-
*
|
315 |
-
* @param array $arr
|
316 |
-
* @param string $col
|
317 |
-
* @param int $dir
|
318 |
-
*
|
319 |
-
* @return array
|
320 |
-
*/
|
321 |
-
function array_sort_by_column( $arr, $col, $dir = SORT_ASC ) {
|
322 |
-
$sort_col = array();
|
323 |
-
|
324 |
-
foreach ( $arr as $key => $row ) {
|
325 |
-
if ( ! empty( $row[ $col ] ) ) {
|
326 |
-
$sort_col[ $key ] = $row[ $col ];
|
327 |
-
}
|
328 |
-
}
|
329 |
-
|
330 |
-
if ( ! empty( $sort_col ) ) {
|
331 |
-
array_multisort( $sort_col, $dir, $arr );
|
332 |
-
}
|
333 |
-
|
334 |
-
return $arr;
|
335 |
-
}
|
336 |
-
|
337 |
-
|
338 |
-
/**
|
339 |
-
* Get fields in row
|
340 |
-
*
|
341 |
-
* @param $row_id
|
342 |
-
*
|
343 |
-
* @return string
|
344 |
-
*/
|
345 |
-
function get_fields_by_row( $row_id ) {
|
346 |
-
|
347 |
-
if ( empty( $this->global_fields ) || ! is_array( $this->global_fields ) ) {
|
348 |
-
$this->global_fields = array();
|
349 |
-
}
|
350 |
-
|
351 |
-
foreach ( $this->global_fields as $key => $array ) {
|
352 |
-
if ( ! isset( $array['in_row'] ) || ( isset( $array['in_row'] ) && $array['in_row'] == $row_id ) ) {
|
353 |
-
$results[ $key ] = $array;
|
354 |
-
unset( $this->global_fields[ $key ] );
|
355 |
-
}
|
356 |
-
}
|
357 |
-
|
358 |
-
return ( isset ( $results ) ) ? $results : '';
|
359 |
-
}
|
360 |
-
|
361 |
-
|
362 |
-
/**
|
363 |
-
* Get fields by sub row
|
364 |
-
*
|
365 |
-
* @param $row_fields
|
366 |
-
* @param $subrow_id
|
367 |
-
*
|
368 |
-
* @return string
|
369 |
-
*/
|
370 |
-
function get_fields_in_subrow( $row_fields, $subrow_id ) {
|
371 |
-
if ( ! is_array( $row_fields ) ) {
|
372 |
-
return '';
|
373 |
-
}
|
374 |
-
|
375 |
-
foreach( $row_fields as $key => $array ) {
|
376 |
-
if ( ! isset( $array['in_sub_row'] ) || ( isset( $array['in_sub_row'] ) && $array['in_sub_row'] == $subrow_id ) ) {
|
377 |
-
$results[ $key ] = $array;
|
378 |
-
unset( $this->global_fields[ $key ] );
|
379 |
-
}
|
380 |
-
}
|
381 |
-
|
382 |
-
return ( isset ( $results ) ) ? $results : '';
|
383 |
-
}
|
384 |
-
|
385 |
-
|
386 |
-
/**
|
387 |
-
* Display the builder
|
388 |
-
*/
|
389 |
-
function show_builder() {
|
390 |
-
|
391 |
-
$fields = UM()->query()->get_attr( 'custom_fields', $this->form_id );
|
392 |
-
|
393 |
-
if ( !isset( $fields ) || empty( $fields ) ) { ?>
|
394 |
-
|
395 |
-
<div class="um-admin-drag-row">
|
396 |
-
|
397 |
-
<!-- Master Row Actions -->
|
398 |
-
<div class="um-admin-drag-row-icons">
|
399 |
-
<a href="javascript:void(0);" class="um-admin-drag-rowsub-add um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Row', 'ultimate-member' ); ?>" data-row_action="add_subrow"><i class="um-icon-plus"></i></a>
|
400 |
-
<a href="javascript:void(0);" class="um-admin-drag-row-edit um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit Row', 'ultimate-member' ); ?>" data-modal="UM_edit_row" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="row" data-arg2="<?php echo esc_attr( $this->form_id ); ?>" data-arg3="_um_row_1"><i class="um-faicon-pencil"></i></a>
|
401 |
-
<span class="um-admin-drag-row-start"><i class="um-icon-arrow-move"></i></span>
|
402 |
-
</div>
|
403 |
-
<div class="um-admin-clear"></div>
|
404 |
-
|
405 |
-
<div class="um-admin-drag-rowsubs">
|
406 |
-
<div class="um-admin-drag-rowsub">
|
407 |
-
|
408 |
-
<!-- Column Layout -->
|
409 |
-
<div class="um-admin-drag-ctrls columns">
|
410 |
-
<a href="javascript:void(0);" class="active" data-cols="1"></a>
|
411 |
-
<a href="javascript:void(0);" data-cols="2"></a>
|
412 |
-
<a href="javascript:void(0);" data-cols="3"></a>
|
413 |
-
</div>
|
414 |
-
|
415 |
-
<!-- Sub Row Actions -->
|
416 |
-
<div class="um-admin-drag-rowsub-icons">
|
417 |
-
<span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
|
418 |
-
</div><div class="um-admin-clear"></div>
|
419 |
-
|
420 |
-
<!-- Columns -->
|
421 |
-
<div class="um-admin-drag-col">
|
422 |
-
|
423 |
-
</div>
|
424 |
-
|
425 |
-
<div class="um-admin-drag-col-dynamic"></div>
|
426 |
-
|
427 |
-
<div class="um-admin-clear"></div>
|
428 |
-
|
429 |
-
</div>
|
430 |
-
</div>
|
431 |
-
|
432 |
-
</div>
|
433 |
-
|
434 |
-
<?php
|
435 |
-
|
436 |
-
} else {
|
437 |
-
|
438 |
-
if ( empty( $fields ) || ! is_array( $fields ) ) {
|
439 |
-
$this->global_fields = array();
|
440 |
-
} else {
|
441 |
-
$this->global_fields = $fields;
|
442 |
-
}
|
443 |
-
|
444 |
-
foreach ( $this->global_fields as $key => $array ) {
|
445 |
-
if ( $array['type'] == 'row' ) {
|
446 |
-
$rows[ $key ] = $array;
|
447 |
-
unset( $this->global_fields[ $key ] ); // not needed now
|
448 |
-
}
|
449 |
-
|
450 |
-
}
|
451 |
-
|
452 |
-
if ( ! isset( $rows ) ) {
|
453 |
-
$rows = array(
|
454 |
-
'_um_row_1' => array(
|
455 |
-
'type' => 'row',
|
456 |
-
'id' => '_um_row_1',
|
457 |
-
'sub_rows' => 1,
|
458 |
-
'cols' => 1
|
459 |
-
),
|
460 |
-
);
|
461 |
-
}
|
462 |
-
|
463 |
-
foreach ( $rows as $row_id => $array ) { ?>
|
464 |
-
|
465 |
-
<div class="um-admin-drag-row" data-original="<?php echo esc_attr( $row_id ); ?>">
|
466 |
-
|
467 |
-
<!-- Master Row Actions -->
|
468 |
-
<div class="um-admin-drag-row-icons">
|
469 |
-
<a href="javascript:void(0);" class="um-admin-drag-rowsub-add um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Row', 'ultimate-member' ); ?>" data-row_action="add_subrow"><i class="um-icon-plus"></i></a>
|
470 |
-
<a href="javascript:void(0);" class="um-admin-drag-row-edit um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit Row', 'ultimate-member'); ?>" data-modal="UM_edit_row" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="row" data-arg2="<?php echo esc_attr( $this->form_id ); ?>" data-arg3="<?php echo esc_attr( $row_id ); ?>"><i class="um-faicon-pencil"></i></a>
|
471 |
-
<span class="um-admin-drag-row-start"><i class="um-icon-arrow-move"></i></span>
|
472 |
-
<?php if ( $row_id != '_um_row_1' ) {?>
|
473 |
-
<a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Row', 'ultimate-member' ); ?>" data-remove_element="um-admin-drag-row"><i class="um-faicon-trash-o"></i></a>
|
474 |
-
<?php } ?>
|
475 |
-
</div><div class="um-admin-clear"></div>
|
476 |
-
|
477 |
-
<div class="um-admin-drag-rowsubs">
|
478 |
-
|
479 |
-
<?php $row_fields = $this->get_fields_by_row( $row_id );
|
480 |
-
|
481 |
-
$sub_rows = ( isset( $array['sub_rows'] ) ) ? $array['sub_rows'] : 1;
|
482 |
-
for ( $c = 0; $c < $sub_rows; $c++ ) {
|
483 |
-
|
484 |
-
$subrow_fields = $this->get_fields_in_subrow( $row_fields, $c );
|
485 |
-
|
486 |
-
?>
|
487 |
-
|
488 |
-
<div class="um-admin-drag-rowsub">
|
489 |
-
|
490 |
-
<!-- Column Layout -->
|
491 |
-
<div class="um-admin-drag-ctrls columns">
|
492 |
-
|
493 |
-
<?php
|
494 |
-
|
495 |
-
if ( ! isset( $array['cols'] ) ) {
|
496 |
-
$col_num = 1;
|
497 |
-
} elseif ( is_numeric( $array['cols'] ) ) {
|
498 |
-
$col_num = (int) $array['cols'];
|
499 |
-
} else {
|
500 |
-
$col_split = explode( ':', $array['cols'] );
|
501 |
-
$col_num = $col_split[ $c ];
|
502 |
-
}
|
503 |
-
|
504 |
-
for ( $i = 1; $i <= 3; $i++ ) {
|
505 |
-
echo '<a href="javascript:void(0);" data-cols="'.$i.'" ';
|
506 |
-
if ( $col_num == $i ) echo 'class="active"';
|
507 |
-
echo '></a>';
|
508 |
-
}
|
509 |
-
|
510 |
-
?>
|
511 |
-
|
512 |
-
</div>
|
513 |
-
|
514 |
-
<!-- Sub Row Actions -->
|
515 |
-
<div class="um-admin-drag-rowsub-icons">
|
516 |
-
<span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
|
517 |
-
<?php if ( $c > 0 ) { ?><a href="javascript:void(0);" class="um-admin-tipsy-n" title="Delete Row" data-remove_element="um-admin-drag-rowsub"><i class="um-faicon-trash-o"></i></a><?php } ?>
|
518 |
-
</div>
|
519 |
-
<div class="um-admin-clear"></div>
|
520 |
-
|
521 |
-
<!-- Columns -->
|
522 |
-
<div class="um-admin-drag-col">
|
523 |
-
|
524 |
-
<?php
|
525 |
-
|
526 |
-
if ( is_array( $subrow_fields ) ) {
|
527 |
-
|
528 |
-
$subrow_fields = $this->array_sort_by_column( $subrow_fields, 'position');
|
529 |
-
|
530 |
-
foreach( $subrow_fields as $key => $keyarray ) {
|
531 |
-
/**
|
532 |
-
* @var $type
|
533 |
-
* @var $title
|
534 |
-
*/
|
535 |
-
extract( $keyarray );
|
536 |
-
|
537 |
-
?>
|
538 |
-
|
539 |
-
<div class="um-admin-drag-fld um-admin-delete-area um-field-type-<?php echo $type; ?> <?php echo $key; ?>" data-group="<?php echo (isset($keyarray['in_group'])) ? $keyarray['in_group'] : ''; ?>" data-key="<?php echo $key; ?>" data-column="<?php echo ( isset($keyarray['in_column']) ) ? $keyarray['in_column'] : 1; ?>">
|
540 |
-
|
541 |
-
<div class="um-admin-drag-fld-title um-field-type-<?php echo $type; ?>">
|
542 |
-
<?php if ( $type == 'group' ) { ?>
|
543 |
-
<i class="um-icon-plus"></i>
|
544 |
-
<?php } else if ( isset($keyarray['icon']) && !empty( $keyarray['icon'] ) ) { ?>
|
545 |
-
<i class="<?php echo $keyarray['icon']; ?>"></i>
|
546 |
-
<?php } ?><?php echo ! empty( $keyarray['title'] ) ? $keyarray['title'] : __( '(no title)', 'ultimate-member' ); ?></div>
|
547 |
-
<?php $field_name = isset( UM()->builtin()->core_fields[$type]['name'] ) ? UM()->builtin()->core_fields[$type]['name'] : ''; ?>
|
548 |
-
<div class="um-admin-drag-fld-type um-field-type-<?php echo $type; ?>"><?php echo $field_name; ?></div>
|
549 |
-
<div class="um-admin-drag-fld-icons um-field-type-<?php echo $type; ?>">
|
550 |
-
|
551 |
-
<a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit', 'ultimate-member' ) ?>" data-modal="UM_edit_field" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="<?php echo $type; ?>" data-arg2="<?php echo $this->form_id; ?>" data-arg3="<?php echo $key; ?>"><i class="um-faicon-pencil"></i></a>
|
552 |
-
|
553 |
-
<a href="javascript:void(0);" class="um-admin-tipsy-n um_admin_duplicate_field" title="<?php esc_attr_e( 'Duplicate', 'ultimate-member' ) ?>" data-silent_action="um_admin_duplicate_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-files-o"></i></a>
|
554 |
-
|
555 |
-
<?php if ( $type == 'group' ) { ?>
|
556 |
-
|
557 |
-
<a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Group', 'ultimate-member' ) ?>" data-remove_element="um-admin-drag-fld.um-field-type-group" data-silent_action="um_admin_remove_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-trash-o"></i></a>
|
558 |
-
<?php } else { ?>
|
559 |
-
|
560 |
-
<a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete', 'ultimate-member' ) ?>" data-silent_action="um_admin_remove_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-trash-o"></i></a>
|
561 |
-
|
562 |
-
<?php } ?>
|
563 |
-
|
564 |
-
</div><div class="um-admin-clear"></div>
|
565 |
-
|
566 |
-
<?php if ( $type == 'group' ) { ?>
|
567 |
-
<div class="um-admin-drag-group">
|
568 |
-
|
569 |
-
</div>
|
570 |
-
<?php } ?>
|
571 |
-
|
572 |
-
</div>
|
573 |
-
|
574 |
-
<?php
|
575 |
-
|
576 |
-
} // end foreach
|
577 |
-
|
578 |
-
} // end if
|
579 |
-
|
580 |
-
?>
|
581 |
-
|
582 |
-
</div>
|
583 |
-
|
584 |
-
<div class="um-admin-drag-col-dynamic"></div>
|
585 |
-
|
586 |
-
<div class="um-admin-clear"></div>
|
587 |
-
|
588 |
-
</div>
|
589 |
-
|
590 |
-
<?php } ?>
|
591 |
-
|
592 |
-
</div>
|
593 |
-
|
594 |
-
</div>
|
595 |
-
|
596 |
-
<?php
|
597 |
-
|
598 |
-
} // rows loop
|
599 |
-
|
600 |
-
} // if fields exist
|
601 |
-
|
602 |
-
}
|
603 |
-
|
604 |
-
|
605 |
-
/**
|
606 |
-
*
|
607 |
-
*/
|
608 |
-
function update_field() {
|
609 |
-
UM()->admin()->check_ajax_nonce();
|
610 |
-
|
611 |
-
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
|
612 |
-
wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
|
613 |
-
}
|
614 |
-
|
615 |
-
$output['error'] = null;
|
616 |
-
|
617 |
-
$array = array(
|
618 |
-
'field_type' => sanitize_key( $_POST['_type'] ),
|
619 |
-
'form_id' => absint( $_POST['post_id'] ),
|
620 |
-
'args' => UM()->builtin()->get_core_field_attrs( sanitize_key( $_POST['_type'] ) ),
|
621 |
-
'post' => UM()->admin()->sanitize_builder_field_meta( $_POST ),
|
622 |
-
);
|
623 |
-
|
624 |
-
/**
|
625 |
-
* UM hook
|
626 |
-
*
|
627 |
-
* @type filter
|
628 |
-
* @title um_admin_pre_save_fields_hook
|
629 |
-
* @description Filter field data before save
|
630 |
-
* @input_vars
|
631 |
-
* [{"var":"$array","type":"array","desc":"Save Field data"}]
|
632 |
-
* @change_log
|
633 |
-
* ["Since: 2.0"]
|
634 |
-
* @usage add_filter( 'um_admin_pre_save_fields_hook', 'function_name', 10, 1 );
|
635 |
-
* @example
|
636 |
-
* <?php
|
637 |
-
* add_filter( 'um_admin_pre_save_fields_hook', 'my_admin_pre_save_fields', 10, 1 );
|
638 |
-
* function my_admin_pre_save_fields( $array ) {
|
639 |
-
* // your code here
|
640 |
-
* return $array;
|
641 |
-
* }
|
642 |
-
* ?>
|
643 |
-
*/
|
644 |
-
$array = apply_filters( 'um_admin_pre_save_fields_hook', $array );
|
645 |
-
|
646 |
-
/**
|
647 |
-
* UM hook
|
648 |
-
*
|
649 |
-
* @type filter
|
650 |
-
* @title um_admin_field_update_error_handling
|
651 |
-
* @description Change error string on save field
|
652 |
-
* @input_vars
|
653 |
-
* [{"var":"$error","type":"string","desc":"Error String"},
|
654 |
-
* {"var":"$array","type":"array","desc":"Save Field data"}]
|
655 |
-
* @change_log
|
656 |
-
* ["Since: 2.0"]
|
657 |
-
* @usage add_filter( 'um_admin_field_update_error_handling', 'function_name', 10, 2 );
|
658 |
-
* @example
|
659 |
-
* <?php
|
660 |
-
* add_filter( 'um_admin_field_update_error_handling', 'my_admin_field_update_error', 10, 2 );
|
661 |
-
* function my_admin_field_update_error( $error, $array ) {
|
662 |
-
* // your code here
|
663 |
-
* return $error;
|
664 |
-
* }
|
665 |
-
* ?>
|
666 |
-
*/
|
667 |
-
$output['error'] = apply_filters( 'um_admin_field_update_error_handling', $output['error'], $array );
|
668 |
-
|
669 |
-
/**
|
670 |
-
* @var $_metakey
|
671 |
-
* @var $post_id
|
672 |
-
*/
|
673 |
-
extract( $array['post'] );
|
674 |
-
|
675 |
-
if ( empty( $output['error'] ) ) {
|
676 |
-
|
677 |
-
$save = array();
|
678 |
-
$save[ $_metakey ] = null;
|
679 |
-
foreach ( $array['post'] as $key => $val ) {
|
680 |
-
|
681 |
-
if ( substr( $key, 0, 1 ) === '_' && $val !== '' ) { // field attribute
|
682 |
-
$new_key = ltrim ( $key, '_' );
|
683 |
-
|
684 |
-
if ( $new_key == 'options' ) {
|
685 |
-
//$save[ $_metakey ][$new_key] = explode(PHP_EOL, $val);
|
686 |
-
$save[ $_metakey ][ $new_key ] = preg_split( '/[\r\n]+/', $val, -1, PREG_SPLIT_NO_EMPTY );
|
687 |
-
} else {
|
688 |
-
$save[ $_metakey ][ $new_key ] = $val;
|
689 |
-
}
|
690 |
-
|
691 |
-
} elseif ( strstr( $key, 'um_editor' ) ) {
|
692 |
-
|
693 |
-
if ( 'block' === $array['post']['_type'] ) {
|
694 |
-
$save[ $_metakey ]['content'] = wp_kses_post( $val );
|
695 |
-
} else {
|
696 |
-
$save[ $_metakey ]['content'] = sanitize_textarea_field( $val );
|
697 |
-
}
|
698 |
-
}
|
699 |
-
|
700 |
-
}
|
701 |
-
|
702 |
-
$field_ID = $_metakey;
|
703 |
-
$field_args = $save[ $_metakey ];
|
704 |
-
|
705 |
-
/**
|
706 |
-
* UM hook
|
707 |
-
*
|
708 |
-
* @type filter
|
709 |
-
* @title um_admin_pre_save_field_to_form
|
710 |
-
* @description Change field options before save to form
|
711 |
-
* @input_vars
|
712 |
-
* [{"var":"$field_args","type":"array","desc":"Field Options"}]
|
713 |
-
* @change_log
|
714 |
-
* ["Since: 2.0"]
|
715 |
-
* @usage add_filter( 'um_admin_pre_save_field_to_form', 'function_name', 10, 1 );
|
716 |
-
* @example
|
717 |
-
* <?php
|
718 |
-
* add_filter( 'um_admin_pre_save_field_to_form', 'my_admin_pre_save_field_to_form', 10, 1 );
|
719 |
-
* function my_admin_pre_save_field_to_form( $field_args ) {
|
720 |
-
* // your code here
|
721 |
-
* return $field_args;
|
722 |
-
* }
|
723 |
-
* ?>
|
724 |
-
*/
|
725 |
-
$field_args = apply_filters( 'um_admin_pre_save_field_to_form', $field_args );
|
726 |
-
|
727 |
-
UM()->fields()->update_field( $field_ID, $field_args, $post_id );
|
728 |
-
|
729 |
-
/**
|
730 |
-
* UM hook
|
731 |
-
*
|
732 |
-
* @type filter
|
733 |
-
* @title um_admin_pre_save_field_to_db
|
734 |
-
* @description Change field options before save to DB
|
735 |
-
* @input_vars
|
736 |
-
* [{"var":"$field_args","type":"array","desc":"Field Options"}]
|
737 |
-
* @change_log
|
738 |
-
* ["Since: 2.0"]
|
739 |
-
* @usage add_filter( 'um_admin_pre_save_field_to_db', 'function_name', 10, 1 );
|
740 |
-
* @example
|
741 |
-
* <?php
|
742 |
-
* add_filter( 'um_admin_pre_save_field_to_db', 'my_admin_pre_save_field_to_db', 10, 1 );
|
743 |
-
* function my_admin_pre_save_field_to_form( $field_args ) {
|
744 |
-
* // your code here
|
745 |
-
* return $field_args;
|
746 |
-
* }
|
747 |
-
* ?>
|
748 |
-
*/
|
749 |
-
$field_args = apply_filters( 'um_admin_pre_save_field_to_db', $field_args );
|
750 |
-
|
751 |
-
if ( ! isset( $array['args']['form_only'] ) ) {
|
752 |
-
if ( ! isset( UM()->builtin()->predefined_fields[ $field_ID ] ) ) {
|
753 |
-
UM()->fields()->globally_update_field( $field_ID, $field_args );
|
754 |
-
}
|
755 |
-
}
|
756 |
-
|
757 |
-
}
|
758 |
-
|
759 |
-
$output = json_encode( $output );
|
760 |
-
if ( is_array( $output ) ) {
|
761 |
-
print_r( $output );
|
762 |
-
} else {
|
763 |
-
echo $output;
|
764 |
-
}
|
765 |
-
die;
|
766 |
-
}
|
767 |
-
|
768 |
-
|
769 |
-
/**
|
770 |
-
*
|
771 |
-
*/
|
772 |
-
function dynamic_modal_content() {
|
773 |
-
UM()->admin()->check_ajax_nonce();
|
774 |
-
|
775 |
-
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
|
776 |
-
wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
|
777 |
-
}
|
778 |
-
|
779 |
-
$metabox = UM()->metabox();
|
780 |
-
|
781 |
-
/**
|
782 |
-
* @var $act_id
|
783 |
-
* @var $arg1
|
784 |
-
* @var $arg2
|
785 |
-
* @var $arg3
|
786 |
-
*/
|
787 |
-
extract( $_POST );
|
788 |
-
|
789 |
-
if ( isset( $arg1 ) ) {
|
790 |
-
$arg1 = sanitize_text_field( $arg1 );
|
791 |
-
}
|
792 |
-
|
793 |
-
if ( isset( $arg2 ) ) {
|
794 |
-
$arg2 = sanitize_text_field( $arg2 );
|
795 |
-
}
|
796 |
-
|
797 |
-
if ( isset( $arg3 ) ) {
|
798 |
-
$arg3 = sanitize_text_field( $arg3 );
|
799 |
-
}
|
800 |
-
|
801 |
-
switch ( sanitize_key( $act_id ) ) {
|
802 |
-
|
803 |
-
default:
|
804 |
-
|
805 |
-
ob_start();
|
806 |
-
|
807 |
-
/**
|
808 |
-
* UM hook
|
809 |
-
*
|
810 |
-
* @type action
|
811 |
-
* @title um_admin_ajax_modal_content__hook
|
812 |
-
* @description Integration hook on ajax popup admin builder modal content
|
813 |
-
* @input_vars
|
814 |
-
* [{"var":"$act_id","type":"string","desc":"Ajax Action"}]
|
815 |
-
* @change_log
|
816 |
-
* ["Since: 2.0"]
|
817 |
-
* @usage add_action( 'um_admin_ajax_modal_content__hook', 'function_name', 10, 1 );
|
818 |
-
* @example
|
819 |
-
* <?php
|
820 |
-
* add_action( 'um_admin_ajax_modal_content__hook', 'my_admin_custom_hook', 10, 1 );
|
821 |
-
* function um_admin_ajax_modal_content__hook( $act_id ) {
|
822 |
-
* // your code here
|
823 |
-
* }
|
824 |
-
* ?>
|
825 |
-
*/
|
826 |
-
do_action( 'um_admin_ajax_modal_content__hook', sanitize_key( $act_id ) );
|
827 |
-
/**
|
828 |
-
* UM hook
|
829 |
-
*
|
830 |
-
* @type action
|
831 |
-
* @title um_admin_ajax_modal_content__hook_{$act_id}
|
832 |
-
* @description Integration hook on ajax popup admin builder modal content
|
833 |
-
* @change_log
|
834 |
-
* ["Since: 2.0"]
|
835 |
-
* @usage add_action( 'um_admin_ajax_modal_content__hook_{$act_id}', 'function_name', 10 );
|
836 |
-
* @example
|
837 |
-
* <?php
|
838 |
-
* add_action( 'um_admin_ajax_modal_content__hook_{$act_id}', 'my_admin_ajax_modal_content', 10 );
|
839 |
-
* function my_admin_ajax_modal_content() {
|
840 |
-
* // your code here
|
841 |
-
* }
|
842 |
-
* ?>
|
843 |
-
*/
|
844 |
-
do_action( "um_admin_ajax_modal_content__hook_" . sanitize_key( $act_id ) );
|
845 |
-
|
846 |
-
$output = ob_get_clean();
|
847 |
-
break;
|
848 |
-
|
849 |
-
case 'um_admin_fonticon_selector':
|
850 |
-
|
851 |
-
ob_start(); ?>
|
852 |
-
|
853 |
-
<div class="um-admin-metabox">
|
854 |
-
<p class="_icon_search"><input type="text" name="_icon_search" id="_icon_search" value="" placeholder="<?php esc_attr_e('Search Icons...', 'ultimate-member' ); ?>" /></p>
|
855 |
-
</div>
|
856 |
-
|
857 |
-
<div class="um-admin-icons">
|
858 |
-
<?php foreach( UM()->fonticons()->all as $icon ) { ?>
|
859 |
-
<span data-code="<?php echo esc_attr( $icon ); ?>" title="<?php echo esc_attr( $icon ); ?>" class="um-admin-tipsy-n"><i class="<?php echo $icon; ?>"></i></span>
|
860 |
-
<?php } ?>
|
861 |
-
</div><div class="um-admin-clear"></div>
|
862 |
-
|
863 |
-
<?php $output = ob_get_clean();
|
864 |
-
break;
|
865 |
-
|
866 |
-
case 'um_admin_show_fields':
|
867 |
-
|
868 |
-
ob_start();
|
869 |
-
$form_fields = UM()->query()->get_attr( 'custom_fields', $arg2 );
|
870 |
-
$form_fields = array_values( array_filter( array_keys( $form_fields ) ) );
|
871 |
-
//$form_fields = array_keys( $form_fields );
|
872 |
-
?>
|
873 |
-
|
874 |
-
<h4><?php _e('Setup New Field','ultimate-member'); ?></h4>
|
875 |
-
<div class="um-admin-btns">
|
876 |
-
|
877 |
-
<?php if ( UM()->builtin()->core_fields ) {
|
878 |
-
foreach ( UM()->builtin()->core_fields as $field_type => $array ) {
|
879 |
-
|
880 |
-
if ( isset( $array['in_fields'] ) && $array['in_fields'] == false ) {
|
881 |
-
continue;
|
882 |
-
} ?>
|
883 |
-
|
884 |
-
<a href="javascript:void(0);" class="button" data-modal="UM_add_field" data-modal-size="normal" data-dynamic-content="um_admin_new_field_popup" data-arg1="<?php echo esc_attr( $field_type ); ?>" data-arg2="<?php echo esc_attr( $arg2 ) ?>"><?php echo esc_html( $array['name'] ); ?></a>
|
885 |
-
|
886 |
-
<?php }
|
887 |
-
} ?>
|
888 |
-
|
889 |
-
</div>
|
890 |
-
|
891 |
-
<h4><?php _e('Predefined Fields','ultimate-member'); ?></h4>
|
892 |
-
<div class="um-admin-btns">
|
893 |
-
|
894 |
-
<?php if ( UM()->builtin()->predefined_fields ) {
|
895 |
-
foreach ( UM()->builtin()->predefined_fields as $field_key => $array ) {
|
896 |
-
if ( ! isset( $array['account_only'] ) && ! isset( $array['private_use'] ) ) { ?>
|
897 |
-
|
898 |
-
<a href="javascript:void(0);" class="button" <?php disabled( in_array( $field_key, $form_fields, true ) ) ?> data-silent_action="um_admin_add_field_from_predefined" data-arg1="<?php echo esc_attr( $field_key ); ?>" data-arg2="<?php echo esc_attr( $arg2 ); ?>"><?php echo um_trim_string( stripslashes( $array['title'] ), 20 ); ?></a>
|
899 |
-
|
900 |
-
<?php }
|
901 |
-
}
|
902 |
-
} else {
|
903 |
-
echo '<p>' . __( 'None', 'ultimate-member' ) . '</p>';
|
904 |
-
} ?>
|
905 |
-
|
906 |
-
</div>
|
907 |
-
|
908 |
-
<h4><?php _e( 'Custom Fields', 'ultimate-member' ); ?></h4>
|
909 |
-
<div class="um-admin-btns">
|
910 |
-
|
911 |
-
<?php
|
912 |
-
if ( UM()->builtin()->custom_fields ) {
|
913 |
-
foreach ( UM()->builtin()->custom_fields as $field_key => $array ) {
|
914 |
-
if ( empty( $array['title'] ) || empty( $array['type'] ) ) {
|
915 |
-
continue;
|
916 |
-
} ?>
|
917 |
-
|
918 |
-
<a href="javascript:void(0);" class="button with-icon" <?php disabled( in_array( $field_key, $form_fields, true ) ) ?> data-silent_action="um_admin_add_field_from_list" data-arg1="<?php echo esc_attr( $field_key ); ?>" data-arg2="<?php echo esc_attr( $arg2 ); ?>" title="<?php echo __( 'Meta Key', 'ultimate-member' ) . ' - ' . esc_attr( $field_key ); ?>"><?php echo um_trim_string( stripslashes( $array['title'] ), 20 ); ?> <small>(<?php echo ucfirst( $array['type'] ); ?>)</small><span class="remove"></span></a>
|
919 |
-
|
920 |
-
<?php }
|
921 |
-
} else {
|
922 |
-
echo '<p>' . __( 'You did not create any custom fields', 'ultimate-member' ) . '</p>';
|
923 |
-
} ?>
|
924 |
-
|
925 |
-
</div>
|
926 |
-
|
927 |
-
<?php $output = ob_get_clean();
|
928 |
-
break;
|
929 |
-
|
930 |
-
case 'um_admin_edit_field_popup':
|
931 |
-
|
932 |
-
ob_start();
|
933 |
-
|
934 |
-
$args = UM()->builtin()->get_core_field_attrs( $arg1 );
|
935 |
-
|
936 |
-
$form_fields = UM()->query()->get_attr( 'custom_fields', $arg2 );
|
937 |
-
|
938 |
-
$metabox->set_field_type = $arg1;
|
939 |
-
$metabox->in_edit = true;
|
940 |
-
$metabox->edit_array = $form_fields[ $arg3 ];
|
941 |
-
|
942 |
-
if ( !isset( $metabox->edit_array['metakey'] ) ){
|
943 |
-
$metabox->edit_array['metakey'] = $metabox->edit_array['id'];
|
944 |
-
}
|
945 |
-
|
946 |
-
if ( !isset( $metabox->edit_array['position'] ) ){
|
947 |
-
$metabox->edit_array['position'] = $metabox->edit_array['id'];
|
948 |
-
}
|
949 |
-
|
950 |
-
extract( $args );
|
951 |
-
|
952 |
-
if ( ! isset( $col1 ) ) {
|
953 |
-
|
954 |
-
echo '<p>'. __( 'This field type is not setup correcty.', 'ultimate-member' ) . '</p>';
|
955 |
-
|
956 |
-
} else {
|
957 |
-
|
958 |
-
?>
|
959 |
-
|
960 |
-
<?php if ( isset( $metabox->edit_array['in_group'] ) ) { ?>
|
961 |
-
<input type="hidden" name="_in_row" id="_in_row" value="<?php echo $metabox->edit_array['in_row']; ?>" />
|
962 |
-
<input type="hidden" name="_in_sub_row" id="_in_sub_row" value="<?php echo $metabox->edit_array['in_sub_row']; ?>" />
|
963 |
-
<input type="hidden" name="_in_column" id="_in_column" value="<?php echo $metabox->edit_array['in_column']; ?>" />
|
964 |
-
<input type="hidden" name="_in_group" id="_in_group" value="<?php echo $metabox->edit_array['in_group']; ?>" />
|
965 |
-
<?php } ?>
|
966 |
-
|
967 |
-
<input type="hidden" name="_type" id="_type" value="<?php echo $arg1; ?>" />
|
968 |
-
|
969 |
-
<input type="hidden" name="post_id" id="post_id" value="<?php echo $arg2; ?>" />
|
970 |
-
|
971 |
-
<input type="hidden" name="edit_mode" id="edit_mode" value="true" />
|
972 |
-
|
973 |
-
<input type="hidden" name="_metakey" id="_metakey" value="<?php echo $metabox->edit_array['metakey']; ?>" />
|
974 |
-
|
975 |
-
<input type="hidden" name="_position" id="_position" value="<?php echo $metabox->edit_array['position']; ?>" />
|
976 |
-
|
977 |
-
<?php if ( isset( $args['mce_content'] ) ) { ?>
|
978 |
-
<div class="dynamic-mce-content"><?php echo ! empty( $metabox->edit_array['content'] ) ? $metabox->edit_array['content'] : ''; ?></div>
|
979 |
-
<?php } ?>
|
980 |
-
|
981 |
-
<?php $this->modal_header(); ?>
|
982 |
-
|
983 |
-
<div class="um-admin-half">
|
984 |
-
|
985 |
-
<?php if ( isset( $col1 ) ) { foreach( $col1 as $opt ) $metabox->field_input ( $opt,
|
986 |
-
|
987 |
-
</div>
|
988 |
-
|
989 |
-
<div class="um-admin-half um-admin-right">
|
990 |
-
|
991 |
-
<?php if ( isset( $col2 ) ) { foreach( $col2 as $opt ) $metabox->field_input ( $opt,
|
992 |
-
|
993 |
-
</div><div class="um-admin-clear"></div>
|
994 |
-
|
995 |
-
<?php if ( isset( $col3 ) ) { foreach( $col3 as $opt ) $metabox->field_input ( $opt,
|
996 |
-
|
997 |
-
<div class="um-admin-clear"></div>
|
998 |
-
|
999 |
-
<?php if ( isset( $col_full ) ) {foreach( $col_full as $opt ) $metabox->field_input ( $opt,
|
1000 |
-
|
1001 |
-
<?php $this->modal_footer( $arg2, $args, $metabox ); ?>
|
1002 |
-
|
1003 |
-
<?php
|
1004 |
-
|
1005 |
-
}
|
1006 |
-
|
1007 |
-
$output = ob_get_clean();
|
1008 |
-
break;
|
1009 |
-
|
1010 |
-
case 'um_admin_new_field_popup':
|
1011 |
-
|
1012 |
-
ob_start();
|
1013 |
-
|
1014 |
-
$args = UM()->builtin()->get_core_field_attrs( $arg1 );
|
1015 |
-
|
1016 |
-
$metabox->set_field_type = $arg1;
|
1017 |
-
|
1018 |
-
/**
|
1019 |
-
* @var $in_row
|
1020 |
-
* @var $in_sub_row
|
1021 |
-
* @var $in_column
|
1022 |
-
* @var $in_group
|
1023 |
-
*/
|
1024 |
-
extract( $args );
|
1025 |
-
|
1026 |
-
if ( ! isset( $col1 ) ) {
|
1027 |
-
|
1028 |
-
echo '<p>'. __( 'This field type is not setup correcty.', 'ultimate-member' ) . '</p>';
|
1029 |
-
|
1030 |
-
} else {
|
1031 |
-
|
1032 |
-
if ( $in_column ) { ?>
|
1033 |
-
<input type="hidden" name="_in_row" id="_in_row" value="_um_row_<?php echo $in_row + 1; ?>" />
|
1034 |
-
<input type="hidden" name="_in_sub_row" id="_in_sub_row" value="<?php echo $in_sub_row; ?>" />
|
1035 |
-
<input type="hidden" name="_in_column" id="_in_column" value="<?php echo $in_column; ?>" />
|
1036 |
-
<input type="hidden" name="_in_group" id="_in_group" value="<?php echo $in_group; ?>" />
|
1037 |
-
<?php } ?>
|
1038 |
-
|
1039 |
-
<input type="hidden" name="_type" id="_type" value="<?php echo $arg1; ?>" />
|
1040 |
-
|
1041 |
-
<input type="hidden" name="post_id" id="post_id" value="<?php echo $arg2; ?>" />
|
1042 |
-
|
1043 |
-
<?php $this->modal_header(); ?>
|
1044 |
-
|
1045 |
-
<div class="um-admin-half">
|
1046 |
-
|
1047 |
-
<?php if ( isset( $col1 ) ) { foreach( $col1 as $opt ) $metabox->field_input ( $opt ); } ?>
|
1048 |
-
|
1049 |
-
</div>
|
1050 |
-
|
1051 |
-
<div class="um-admin-half um-admin-right">
|
1052 |
-
|
1053 |
-
<?php if ( isset( $col2 ) ) { foreach( $col2 as $opt ) $metabox->field_input ( $opt ); } ?>
|
1054 |
-
|
1055 |
-
</div><div class="um-admin-clear"></div>
|
1056 |
-
|
1057 |
-
<?php if ( isset( $col3 ) ) { foreach( $col3 as $opt ) $metabox->field_input ( $opt ); } ?>
|
1058 |
-
|
1059 |
-
<div class="um-admin-clear"></div>
|
1060 |
-
|
1061 |
-
<?php if ( isset( $col_full ) ) { foreach( $col_full as $opt ) $metabox->field_input ( $opt ); } ?>
|
1062 |
-
|
1063 |
-
<?php $this->modal_footer( $arg2, $args, $metabox ); ?>
|
1064 |
-
|
1065 |
-
<?php
|
1066 |
-
|
1067 |
-
}
|
1068 |
-
|
1069 |
-
$output = ob_get_clean();
|
1070 |
-
break;
|
1071 |
-
|
1072 |
-
case 'um_admin_preview_form':
|
1073 |
-
|
1074 |
-
UM()->user()->preview = true;
|
1075 |
-
|
1076 |
-
$mode = UM()->query()->get_attr('mode', $arg1 );
|
1077 |
-
|
1078 |
-
if ( $mode == 'profile' ) {
|
1079 |
-
UM()->fields()->editing = true;
|
1080 |
-
}
|
1081 |
-
|
1082 |
-
$output = '<div class="um-admin-preview-overlay"></div>';
|
1083 |
-
|
1084 |
-
if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
|
1085 |
-
$output .= do_shortcode('[ultimatemember form_id="' . $arg1 . '" /]');
|
1086 |
-
} else {
|
1087 |
-
$output .= apply_shortcodes('[ultimatemember form_id="' . $arg1 . '" /]');
|
1088 |
-
}
|
1089 |
-
|
1090 |
-
break;
|
1091 |
-
|
1092 |
-
case 'um_admin_review_registration':
|
1093 |
-
//$user_id = $arg1;
|
1094 |
-
|
1095 |
-
if ( ! current_user_can( 'administrator' ) ) {
|
1096 |
-
if ( ! um_can_view_profile( $arg1 ) ) {
|
1097 |
-
$output = '';
|
1098 |
-
break;
|
1099 |
-
}
|
1100 |
-
}
|
1101 |
-
|
1102 |
-
um_fetch_user( $arg1 );
|
1103 |
-
|
1104 |
-
UM()->user()->preview = true;
|
1105 |
-
|
1106 |
-
$output = um_user_submitted_registration_formatted( true );
|
1107 |
-
|
1108 |
-
um_reset_user();
|
1109 |
-
|
1110 |
-
break;
|
1111 |
-
|
1112 |
-
}
|
1113 |
-
|
1114 |
-
if ( is_array( $output ) ) {
|
1115 |
-
print_r( $output );
|
1116 |
-
} else {
|
1117 |
-
echo $output;
|
1118 |
-
}
|
1119 |
-
die;
|
1120 |
-
}
|
1121 |
-
|
1122 |
-
|
1123 |
-
/**
|
1124 |
-
*
|
1125 |
-
*/
|
1126 |
-
function modal_header() {
|
1127 |
-
/**
|
1128 |
-
* UM hook
|
1129 |
-
*
|
1130 |
-
* @type action
|
1131 |
-
* @title um_admin_field_modal_header
|
1132 |
-
* @description Modal Window Header
|
1133 |
-
* @change_log
|
1134 |
-
* ["Since: 2.0"]
|
1135 |
-
* @usage add_action( 'um_admin_field_modal_header', 'function_name', 10 );
|
1136 |
-
* @example
|
1137 |
-
* <?php
|
1138 |
-
* add_action( 'um_admin_field_modal_header', 'my_admin_field_modal_header', 10 );
|
1139 |
-
* function my_admin_field_modal_header() {
|
1140 |
-
* // your code here
|
1141 |
-
* }
|
1142 |
-
* ?>
|
1143 |
-
*/
|
1144 |
-
do_action( 'um_admin_field_modal_header' );
|
1145 |
-
}
|
1146 |
-
|
1147 |
-
|
1148 |
-
/**
|
1149 |
-
* Modal Footer loading
|
1150 |
-
*
|
1151 |
-
* @param $arg2
|
1152 |
-
* @param $args
|
1153 |
-
* @param $metabox
|
1154 |
-
*/
|
1155 |
-
function modal_footer( $arg2, $args, $metabox ) {
|
1156 |
-
/**
|
1157 |
-
* UM hook
|
1158 |
-
*
|
1159 |
-
* @type action
|
1160 |
-
* @title um_admin_field_modal_footer
|
1161 |
-
* @description Modal Window Footer
|
1162 |
-
* @input_vars
|
1163 |
-
* [{"var":"$arg2","type":"string","desc":"Ajax Action"},
|
1164 |
-
* {"var":"$args","type":"array","desc":"Modal window arguments"},
|
1165 |
-
* {"var":"$in_edit","type":"bool","desc":"Is edit mode?"},
|
1166 |
-
* {"var":"$edit_array","type":"array","desc":"Edit Array"}]
|
1167 |
-
* @change_log
|
1168 |
-
* ["Since: 2.0"]
|
1169 |
-
* @usage add_action( 'um_admin_field_modal_footer', 'function_name', 10, 4 );
|
1170 |
-
* @example
|
1171 |
-
* <?php
|
1172 |
-
* add_action( 'um_admin_field_modal_footer', 'my_admin_field_modal_footer', 10, 4 );
|
1173 |
-
* function my_admin_field_modal_footer( $arg2, $args, $in_edit, $edit_array ) {
|
1174 |
-
* // your code here
|
1175 |
-
* }
|
1176 |
-
* ?>
|
1177 |
-
*/
|
1178 |
-
do_action( 'um_admin_field_modal_footer', $arg2, $args, $metabox->in_edit, ( isset( $metabox->edit_array ) ) ? $metabox->edit_array : '' );
|
1179 |
-
}
|
1180 |
-
|
1181 |
-
|
1182 |
-
/**
|
1183 |
-
* Skip field validation for:
|
1184 |
-
* - '_options' if Choices Callback specified
|
1185 |
-
*
|
1186 |
-
* @param boolean $skip
|
1187 |
-
* @param string $post_input
|
1188 |
-
* @param array $array
|
1189 |
-
* @return boolean
|
1190 |
-
*/
|
1191 |
-
public function skip_field_validation( $skip, $post_input, $array ) {
|
1192 |
-
if ( $post_input === '_options' && isset( $array['post']['_custom_dropdown_options_source'] ) ) {
|
1193 |
-
$skip = function_exists( $array['post']['_custom_dropdown_options_source'] );
|
1194 |
-
}
|
1195 |
-
|
1196 |
-
return $skip;
|
1197 |
-
}
|
1198 |
-
|
1199 |
-
|
1200 |
-
/**
|
1201 |
-
* Retrieves dropdown/multi-select options from a callback function
|
1202 |
-
*/
|
1203 |
-
function populate_dropdown_options() {
|
1204 |
-
UM()->admin()->check_ajax_nonce();
|
1205 |
-
|
1206 |
-
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
|
1207 |
-
wp_send_json_error( __( 'This is not possible for security reasons.', 'ultimate-member' ) );
|
1208 |
-
}
|
1209 |
-
|
1210 |
-
$arr_options = array();
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace um\admin\core;
|
3 |
+
|
4 |
+
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Admin_Builder
|
13 |
+
* @package um\admin\core
|
14 |
+
*/
|
15 |
+
class Admin_Builder {
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var
|
20 |
+
*/
|
21 |
+
var $form_id;
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Admin_Builder constructor.
|
26 |
+
*/
|
27 |
+
function __construct() {
|
28 |
+
add_action( 'um_admin_field_modal_header', array( &$this, 'add_message_handlers' ) );
|
29 |
+
add_action( 'um_admin_field_modal_footer', array( &$this, 'add_conditional_support' ), 10, 4 );
|
30 |
+
add_filter( 'um_admin_builder_skip_field_validation', array( &$this, 'skip_field_validation' ), 10, 3 );
|
31 |
+
add_filter( 'um_admin_pre_save_field_to_form', array( &$this, 'um_admin_pre_save_field_to_form' ), 1 );
|
32 |
+
add_filter( 'um_admin_pre_save_fields_hook', array( &$this, 'um_admin_pre_save_fields_hook' ), 1 );
|
33 |
+
add_filter( 'um_admin_field_update_error_handling', array( &$this, 'um_admin_field_update_error_handling' ), 1, 2 );
|
34 |
+
}
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Apply a filter to handle errors for field updating in backend
|
39 |
+
*
|
40 |
+
* @param $errors
|
41 |
+
* @param $array
|
42 |
+
*
|
43 |
+
* @return mixed
|
44 |
+
*/
|
45 |
+
function um_admin_field_update_error_handling( $errors, $array ) {
|
46 |
+
/**
|
47 |
+
* @var $field_type
|
48 |
+
*/
|
49 |
+
extract( $array );
|
50 |
+
|
51 |
+
$field_attr = UM()->builtin()->get_core_field_attrs( $field_type );
|
52 |
+
|
53 |
+
if ( isset( $field_attr['validate'] ) ) {
|
54 |
+
|
55 |
+
$validate = $field_attr['validate'];
|
56 |
+
foreach ( $validate as $post_input => $arr ) {
|
57 |
+
|
58 |
+
$skip = apply_filters( 'um_admin_builder_skip_field_validation', false, $post_input, $array );
|
59 |
+
if ( $skip ) {
|
60 |
+
continue;
|
61 |
+
}
|
62 |
+
|
63 |
+
$mode = $arr['mode'];
|
64 |
+
|
65 |
+
switch ( $mode ) {
|
66 |
+
|
67 |
+
case 'numeric':
|
68 |
+
if ( ! empty( $array['post'][ $post_input ] ) && ! is_numeric( $array['post'][ $post_input ] ) ){
|
69 |
+
$errors[ $post_input ] = $validate[ $post_input ]['error'];
|
70 |
+
}
|
71 |
+
break;
|
72 |
+
|
73 |
+
case 'unique':
|
74 |
+
if ( ! isset( $array['post']['edit_mode'] ) ) {
|
75 |
+
if ( UM()->builtin()->unique_field_err( $array['post'][ $post_input ] ) ) {
|
76 |
+
$errors[ $post_input ] = UM()->builtin()->unique_field_err( $array['post'][ $post_input ] );
|
77 |
+
}
|
78 |
+
}
|
79 |
+
break;
|
80 |
+
|
81 |
+
case 'required':
|
82 |
+
if ( $array['post'][ $post_input ] == '' ) {
|
83 |
+
$errors[ $post_input ] = $validate[ $post_input ]['error'];
|
84 |
+
}
|
85 |
+
break;
|
86 |
+
|
87 |
+
case 'range-start':
|
88 |
+
if ( UM()->builtin()->date_range_start_err( $array['post'][ $post_input ] ) && $array['post']['_range'] == 'date_range' ) {
|
89 |
+
$errors[ $post_input ] = UM()->builtin()->date_range_start_err( $array['post'][ $post_input ] );
|
90 |
+
}
|
91 |
+
break;
|
92 |
+
|
93 |
+
case 'range-end':
|
94 |
+
if ( UM()->builtin()->date_range_end_err( $array['post'][ $post_input ], $array['post']['_range_start'] ) && $array['post']['_range'] == 'date_range' ) {
|
95 |
+
$errors[ $post_input ] = UM()->builtin()->date_range_end_err( $array['post'][ $post_input ], $array['post']['_range_start'] );
|
96 |
+
}
|
97 |
+
break;
|
98 |
+
|
99 |
+
}
|
100 |
+
|
101 |
+
}
|
102 |
+
|
103 |
+
}
|
104 |
+
|
105 |
+
return $errors;
|
106 |
+
|
107 |
+
}
|
108 |
+
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Some fields may require extra fields before saving
|
112 |
+
*
|
113 |
+
* @param $array
|
114 |
+
*
|
115 |
+
* @return mixed
|
116 |
+
*/
|
117 |
+
function um_admin_pre_save_fields_hook( $array ) {
|
118 |
+
/**
|
119 |
+
* @var $form_id
|
120 |
+
* @var $field_type
|
121 |
+
*/
|
122 |
+
extract( $array );
|
123 |
+
|
124 |
+
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
125 |
+
|
126 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
127 |
+
$count = 1;
|
128 |
+
if ( ! empty( $fields ) ) {
|
129 |
+
$count = count( $fields ) + 1;
|
130 |
+
}
|
131 |
+
|
132 |
+
// set unique meta key
|
133 |
+
if ( in_array( $field_type, $fields_without_metakey ) && ! isset( $array['post']['_metakey'] ) ) {
|
134 |
+
$array['post']['_metakey'] = "um_{$field_type}_{$form_id}_{$count}";
|
135 |
+
}
|
136 |
+
|
137 |
+
// set position
|
138 |
+
if ( ! isset( $array['post']['_position'] ) ) {
|
139 |
+
$array['post']['_position'] = $count;
|
140 |
+
}
|
141 |
+
|
142 |
+
return $array;
|
143 |
+
}
|
144 |
+
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Modify field args just before it is saved into form
|
148 |
+
*
|
149 |
+
* @param $array
|
150 |
+
*
|
151 |
+
* @return mixed
|
152 |
+
*/
|
153 |
+
function um_admin_pre_save_field_to_form( $array ){
|
154 |
+
unset( $array['conditions'] );
|
155 |
+
if ( isset($array['conditional_field']) && ! empty( $array['conditional_action'] ) && ! empty( $array['conditional_operator'] ) ) {
|
156 |
+
$array['conditional_value'] = isset( $array['conditional_value'] ) ? $array['conditional_value'] : '';
|
157 |
+
$array['conditions'][] = array( $array['conditional_action'], $array['conditional_field'], $array['conditional_operator'], $array['conditional_value'] );
|
158 |
+
}
|
159 |
+
|
160 |
+
if ( isset( $array['conditional_field1'] ) && ! empty( $array['conditional_action1'] ) && ! empty( $array['conditional_operator1'] ) ) {
|
161 |
+
$array['conditional_value1'] = isset( $array['conditional_value1'] ) ? $array['conditional_value1'] : '';
|
162 |
+
$array['conditions'][] = array( $array['conditional_action1'], $array['conditional_field1'], $array['conditional_operator1'], $array['conditional_value1'] );
|
163 |
+
}
|
164 |
+
|
165 |
+
if ( isset( $array['conditional_field2'] ) && ! empty( $array['conditional_action2'] ) && ! empty( $array['conditional_operator2'] ) ) {
|
166 |
+
$array['conditional_value2'] = isset( $array['conditional_value2'] ) ? $array['conditional_value2'] : '';
|
167 |
+
$array['conditions'][] = array( $array['conditional_action2'], $array['conditional_field2'], $array['conditional_operator2'], $array['conditional_value2'] );
|
168 |
+
}
|
169 |
+
|
170 |
+
if ( isset( $array['conditional_field3'] ) && ! empty( $array['conditional_action3'] ) && ! empty( $array['conditional_operator3'] ) ) {
|
171 |
+
$array['conditional_value3'] = isset( $array['conditional_value3'] ) ? $array['conditional_value3'] : '';
|
172 |
+
$array['conditions'][] = array( $array['conditional_action3'], $array['conditional_field3'], $array['conditional_operator3'], $array['conditional_value3'] );
|
173 |
+
}
|
174 |
+
|
175 |
+
if ( isset( $array['conditional_field4'] ) && ! empty( $array['conditional_action4'] ) && ! empty( $array['conditional_operator4'] ) ) {
|
176 |
+
$array['conditional_value4'] = isset( $array['conditional_value4'] ) ? $array['conditional_value4'] : '';
|
177 |
+
$array['conditions'][] = array( $array['conditional_action4'], $array['conditional_field4'], $array['conditional_operator4'], $array['conditional_value4'] );
|
178 |
+
}
|
179 |
+
|
180 |
+
return $array;
|
181 |
+
}
|
182 |
+
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Put status handler in modal
|
186 |
+
*/
|
187 |
+
function add_message_handlers() {
|
188 |
+
?>
|
189 |
+
<div class="um-admin-error-block"></div>
|
190 |
+
<div class="um-admin-success-block"></div>
|
191 |
+
<?php
|
192 |
+
}
|
193 |
+
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Footer of modal
|
197 |
+
*
|
198 |
+
* @param $form_id
|
199 |
+
* @param $field_args
|
200 |
+
* @param $in_edit
|
201 |
+
* @param $edit_array
|
202 |
+
*/
|
203 |
+
function add_conditional_support( $form_id, $field_args, $in_edit, $edit_array ) {
|
204 |
+
$metabox = UM()->metabox();
|
205 |
+
|
206 |
+
if ( isset( $field_args['conditional_support'] ) && $field_args['conditional_support'] == 0 ) {
|
207 |
+
return;
|
208 |
+
} ?>
|
209 |
+
|
210 |
+
<div class="um-admin-btn-toggle">
|
211 |
+
|
212 |
+
<?php if ( $in_edit ) { $metabox->in_edit = true; $metabox->edit_array = $edit_array; ?>
|
213 |
+
<a href="javascript:void(0);"><i class="um-icon-plus"></i><?php _e( 'Manage conditional fields support' ); ?></a> <?php UM()->tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
|
214 |
+
<?php } else { ?>
|
215 |
+
<a href="javascript:void(0);"><i class="um-icon-plus"></i><?php _e( 'Add conditional fields support' ); ?></a> <?php UM()->tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
|
216 |
+
<?php } ?>
|
217 |
+
|
218 |
+
<div class="um-admin-btn-content">
|
219 |
+
<div class="um-admin-cur-condition-template">
|
220 |
+
|
221 |
+
<?php $metabox->field_input( '_conditional_action', $form_id ); ?>
|
222 |
+
<?php $metabox->field_input( '_conditional_field', $form_id ); ?>
|
223 |
+
<?php $metabox->field_input( '_conditional_operator', $form_id ); ?>
|
224 |
+
<?php $metabox->field_input( '_conditional_value', $form_id ); ?>
|
225 |
+
|
226 |
+
<p><a href="javascript:void(0);" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
|
227 |
+
|
228 |
+
<div class="um-admin-clear"></div>
|
229 |
+
</div>
|
230 |
+
<p class="um-admin-conditions-notice">
|
231 |
+
<small>
|
232 |
+
<?php _e( 'Use the condition operator `equals to` or `not equals` if the parent field has a single option.', 'ultimate-member' ); ?>
|
233 |
+
<br><?php _e( 'Use the condition operator `greater than` or `less than` if the parent field is a number.', 'ultimate-member' ); ?>
|
234 |
+
<br><?php _e( 'Use the condition operator `contains` if the parent field has multiple options.', 'ultimate-member' ); ?>
|
235 |
+
</small>
|
236 |
+
</p>
|
237 |
+
<p><a href="javascript:void(0);" class="um-admin-new-condition button button-primary um-admin-tipsy-n" title="Add new condition"><?php _e( 'Add new rule', 'ultimate-member' ); ?></a></p>
|
238 |
+
<p class="um-admin-reset-conditions"><a href="javascript:void(0);" class="button"><?php _e( 'Reset all rules', 'ultimate-member' ); ?></a></p>
|
239 |
+
|
240 |
+
<div class="um-admin-clear"></div>
|
241 |
+
|
242 |
+
<?php if ( isset( $edit_array['conditions'] ) && count( $edit_array['conditions'] ) != 0 ) {
|
243 |
+
|
244 |
+
foreach ( $edit_array['conditions'] as $k => $arr ) {
|
245 |
+
|
246 |
+
if ( $k == 0 ) $k = ''; ?>
|
247 |
+
|
248 |
+
<div class="um-admin-cur-condition">
|
249 |
+
|
250 |
+
<?php $metabox->field_input( '_conditional_action' . $k, $form_id ); ?>
|
251 |
+
<?php $metabox->field_input( '_conditional_field' . $k , $form_id ); ?>
|
252 |
+
<?php $metabox->field_input( '_conditional_operator' . $k, $form_id ); ?>
|
253 |
+
<?php $metabox->field_input( '_conditional_value' . $k, $form_id ); ?>
|
254 |
+
|
255 |
+
<p><a href="#" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
|
256 |
+
|
257 |
+
<div class="um-admin-clear"></div>
|
258 |
+
</div>
|
259 |
+
|
260 |
+
<?php
|
261 |
+
}
|
262 |
+
|
263 |
+
} else { ?>
|
264 |
+
|
265 |
+
<div class="um-admin-cur-condition">
|
266 |
+
|
267 |
+
<?php $metabox->field_input( '_conditional_action', $form_id ); ?>
|
268 |
+
<?php $metabox->field_input( '_conditional_field', $form_id ); ?>
|
269 |
+
<?php $metabox->field_input( '_conditional_operator', $form_id ); ?>
|
270 |
+
<?php $metabox->field_input( '_conditional_value', $form_id ); ?>
|
271 |
+
|
272 |
+
<p><a href="#" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
|
273 |
+
|
274 |
+
<div class="um-admin-clear"></div>
|
275 |
+
</div>
|
276 |
+
|
277 |
+
<?php } ?>
|
278 |
+
</div>
|
279 |
+
</div>
|
280 |
+
|
281 |
+
<?php
|
282 |
+
}
|
283 |
+
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Update the builder area
|
287 |
+
*/
|
288 |
+
function update_builder() {
|
289 |
+
UM()->admin()->check_ajax_nonce();
|
290 |
+
|
291 |
+
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
|
292 |
+
wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
|
293 |
+
}
|
294 |
+
|
295 |
+
ob_start();
|
296 |
+
|
297 |
+
$this->form_id = absint( $_POST['form_id'] );
|
298 |
+
|
299 |
+
$this->show_builder();
|
300 |
+
|
301 |
+
$output = ob_get_clean();
|
302 |
+
|
303 |
+
if ( is_array( $output ) ) {
|
304 |
+
print_r( $output );
|
305 |
+
} else {
|
306 |
+
echo $output;
|
307 |
+
}
|
308 |
+
die;
|
309 |
+
}
|
310 |
+
|
311 |
+
|
312 |
+
/**
|
313 |
+
* Sort array function
|
314 |
+
*
|
315 |
+
* @param array $arr
|
316 |
+
* @param string $col
|
317 |
+
* @param int $dir
|
318 |
+
*
|
319 |
+
* @return array
|
320 |
+
*/
|
321 |
+
function array_sort_by_column( $arr, $col, $dir = SORT_ASC ) {
|
322 |
+
$sort_col = array();
|
323 |
+
|
324 |
+
foreach ( $arr as $key => $row ) {
|
325 |
+
if ( ! empty( $row[ $col ] ) ) {
|
326 |
+
$sort_col[ $key ] = $row[ $col ];
|
327 |
+
}
|
328 |
+
}
|
329 |
+
|
330 |
+
if ( ! empty( $sort_col ) ) {
|
331 |
+
array_multisort( $sort_col, $dir, $arr );
|
332 |
+
}
|
333 |
+
|
334 |
+
return $arr;
|
335 |
+
}
|
336 |
+
|
337 |
+
|
338 |
+
/**
|
339 |
+
* Get fields in row
|
340 |
+
*
|
341 |
+
* @param $row_id
|
342 |
+
*
|
343 |
+
* @return string
|
344 |
+
*/
|
345 |
+
function get_fields_by_row( $row_id ) {
|
346 |
+
|
347 |
+
if ( empty( $this->global_fields ) || ! is_array( $this->global_fields ) ) {
|
348 |
+
$this->global_fields = array();
|
349 |
+
}
|
350 |
+
|
351 |
+
foreach ( $this->global_fields as $key => $array ) {
|
352 |
+
if ( ! isset( $array['in_row'] ) || ( isset( $array['in_row'] ) && $array['in_row'] == $row_id ) ) {
|
353 |
+
$results[ $key ] = $array;
|
354 |
+
unset( $this->global_fields[ $key ] );
|
355 |
+
}
|
356 |
+
}
|
357 |
+
|
358 |
+
return ( isset ( $results ) ) ? $results : '';
|
359 |
+
}
|
360 |
+
|
361 |
+
|
362 |
+
/**
|
363 |
+
* Get fields by sub row
|
364 |
+
*
|
365 |
+
* @param $row_fields
|
366 |
+
* @param $subrow_id
|
367 |
+
*
|
368 |
+
* @return string
|
369 |
+
*/
|
370 |
+
function get_fields_in_subrow( $row_fields, $subrow_id ) {
|
371 |
+
if ( ! is_array( $row_fields ) ) {
|
372 |
+
return '';
|
373 |
+
}
|
374 |
+
|
375 |
+
foreach( $row_fields as $key => $array ) {
|
376 |
+
if ( ! isset( $array['in_sub_row'] ) || ( isset( $array['in_sub_row'] ) && $array['in_sub_row'] == $subrow_id ) ) {
|
377 |
+
$results[ $key ] = $array;
|
378 |
+
unset( $this->global_fields[ $key ] );
|
379 |
+
}
|
380 |
+
}
|
381 |
+
|
382 |
+
return ( isset ( $results ) ) ? $results : '';
|
383 |
+
}
|
384 |
+
|
385 |
+
|
386 |
+
/**
|
387 |
+
* Display the builder
|
388 |
+
*/
|
389 |
+
function show_builder() {
|
390 |
+
|
391 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $this->form_id );
|
392 |
+
|
393 |
+
if ( !isset( $fields ) || empty( $fields ) ) { ?>
|
394 |
+
|
395 |
+
<div class="um-admin-drag-row">
|
396 |
+
|
397 |
+
<!-- Master Row Actions -->
|
398 |
+
<div class="um-admin-drag-row-icons">
|
399 |
+
<a href="javascript:void(0);" class="um-admin-drag-rowsub-add um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Row', 'ultimate-member' ); ?>" data-row_action="add_subrow"><i class="um-icon-plus"></i></a>
|
400 |
+
<a href="javascript:void(0);" class="um-admin-drag-row-edit um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit Row', 'ultimate-member' ); ?>" data-modal="UM_edit_row" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="row" data-arg2="<?php echo esc_attr( $this->form_id ); ?>" data-arg3="_um_row_1"><i class="um-faicon-pencil"></i></a>
|
401 |
+
<span class="um-admin-drag-row-start"><i class="um-icon-arrow-move"></i></span>
|
402 |
+
</div>
|
403 |
+
<div class="um-admin-clear"></div>
|
404 |
+
|
405 |
+
<div class="um-admin-drag-rowsubs">
|
406 |
+
<div class="um-admin-drag-rowsub">
|
407 |
+
|
408 |
+
<!-- Column Layout -->
|
409 |
+
<div class="um-admin-drag-ctrls columns">
|
410 |
+
<a href="javascript:void(0);" class="active" data-cols="1"></a>
|
411 |
+
<a href="javascript:void(0);" data-cols="2"></a>
|
412 |
+
<a href="javascript:void(0);" data-cols="3"></a>
|
413 |
+
</div>
|
414 |
+
|
415 |
+
<!-- Sub Row Actions -->
|
416 |
+
<div class="um-admin-drag-rowsub-icons">
|
417 |
+
<span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
|
418 |
+
</div><div class="um-admin-clear"></div>
|
419 |
+
|
420 |
+
<!-- Columns -->
|
421 |
+
<div class="um-admin-drag-col">
|
422 |
+
|
423 |
+
</div>
|
424 |
+
|
425 |
+
<div class="um-admin-drag-col-dynamic"></div>
|
426 |
+
|
427 |
+
<div class="um-admin-clear"></div>
|
428 |
+
|
429 |
+
</div>
|
430 |
+
</div>
|
431 |
+
|
432 |
+
</div>
|
433 |
+
|
434 |
+
<?php
|
435 |
+
|
436 |
+
} else {
|
437 |
+
|
438 |
+
if ( empty( $fields ) || ! is_array( $fields ) ) {
|
439 |
+
$this->global_fields = array();
|
440 |
+
} else {
|
441 |
+
$this->global_fields = $fields;
|
442 |
+
}
|
443 |
+
|
444 |
+
foreach ( $this->global_fields as $key => $array ) {
|
445 |
+
if ( $array['type'] == 'row' ) {
|
446 |
+
$rows[ $key ] = $array;
|
447 |
+
unset( $this->global_fields[ $key ] ); // not needed now
|
448 |
+
}
|
449 |
+
|
450 |
+
}
|
451 |
+
|
452 |
+
if ( ! isset( $rows ) ) {
|
453 |
+
$rows = array(
|
454 |
+
'_um_row_1' => array(
|
455 |
+
'type' => 'row',
|
456 |
+
'id' => '_um_row_1',
|
457 |
+
'sub_rows' => 1,
|
458 |
+
'cols' => 1
|
459 |
+
),
|
460 |
+
);
|
461 |
+
}
|
462 |
+
|
463 |
+
foreach ( $rows as $row_id => $array ) { ?>
|
464 |
+
|
465 |
+
<div class="um-admin-drag-row" data-original="<?php echo esc_attr( $row_id ); ?>">
|
466 |
+
|
467 |
+
<!-- Master Row Actions -->
|
468 |
+
<div class="um-admin-drag-row-icons">
|
469 |
+
<a href="javascript:void(0);" class="um-admin-drag-rowsub-add um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Row', 'ultimate-member' ); ?>" data-row_action="add_subrow"><i class="um-icon-plus"></i></a>
|
470 |
+
<a href="javascript:void(0);" class="um-admin-drag-row-edit um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit Row', 'ultimate-member'); ?>" data-modal="UM_edit_row" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="row" data-arg2="<?php echo esc_attr( $this->form_id ); ?>" data-arg3="<?php echo esc_attr( $row_id ); ?>"><i class="um-faicon-pencil"></i></a>
|
471 |
+
<span class="um-admin-drag-row-start"><i class="um-icon-arrow-move"></i></span>
|
472 |
+
<?php if ( $row_id != '_um_row_1' ) {?>
|
473 |
+
<a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Row', 'ultimate-member' ); ?>" data-remove_element="um-admin-drag-row"><i class="um-faicon-trash-o"></i></a>
|
474 |
+
<?php } ?>
|
475 |
+
</div><div class="um-admin-clear"></div>
|
476 |
+
|
477 |
+
<div class="um-admin-drag-rowsubs">
|
478 |
+
|
479 |
+
<?php $row_fields = $this->get_fields_by_row( $row_id );
|
480 |
+
|
481 |
+
$sub_rows = ( isset( $array['sub_rows'] ) ) ? $array['sub_rows'] : 1;
|
482 |
+
for ( $c = 0; $c < $sub_rows; $c++ ) {
|
483 |
+
|
484 |
+
$subrow_fields = $this->get_fields_in_subrow( $row_fields, $c );
|
485 |
+
|
486 |
+
?>
|
487 |
+
|
488 |
+
<div class="um-admin-drag-rowsub">
|
489 |
+
|
490 |
+
<!-- Column Layout -->
|
491 |
+
<div class="um-admin-drag-ctrls columns">
|
492 |
+
|
493 |
+
<?php
|
494 |
+
|
495 |
+
if ( ! isset( $array['cols'] ) ) {
|
496 |
+
$col_num = 1;
|
497 |
+
} elseif ( is_numeric( $array['cols'] ) ) {
|
498 |
+
$col_num = (int) $array['cols'];
|
499 |
+
} else {
|
500 |
+
$col_split = explode( ':', $array['cols'] );
|
501 |
+
$col_num = $col_split[ $c ];
|
502 |
+
}
|
503 |
+
|
504 |
+
for ( $i = 1; $i <= 3; $i++ ) {
|
505 |
+
echo '<a href="javascript:void(0);" data-cols="'.$i.'" ';
|
506 |
+
if ( $col_num == $i ) echo 'class="active"';
|
507 |
+
echo '></a>';
|
508 |
+
}
|
509 |
+
|
510 |
+
?>
|
511 |
+
|
512 |
+
</div>
|
513 |
+
|
514 |
+
<!-- Sub Row Actions -->
|
515 |
+
<div class="um-admin-drag-rowsub-icons">
|
516 |
+
<span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
|
517 |
+
<?php if ( $c > 0 ) { ?><a href="javascript:void(0);" class="um-admin-tipsy-n" title="Delete Row" data-remove_element="um-admin-drag-rowsub"><i class="um-faicon-trash-o"></i></a><?php } ?>
|
518 |
+
</div>
|
519 |
+
<div class="um-admin-clear"></div>
|
520 |
+
|
521 |
+
<!-- Columns -->
|
522 |
+
<div class="um-admin-drag-col">
|
523 |
+
|
524 |
+
<?php
|
525 |
+
|
526 |
+
if ( is_array( $subrow_fields ) ) {
|
527 |
+
|
528 |
+
$subrow_fields = $this->array_sort_by_column( $subrow_fields, 'position');
|
529 |
+
|
530 |
+
foreach( $subrow_fields as $key => $keyarray ) {
|
531 |
+
/**
|
532 |
+
* @var $type
|
533 |
+
* @var $title
|
534 |
+
*/
|
535 |
+
extract( $keyarray );
|
536 |
+
|
537 |
+
?>
|
538 |
+
|
539 |
+
<div class="um-admin-drag-fld um-admin-delete-area um-field-type-<?php echo $type; ?> <?php echo $key; ?>" data-group="<?php echo (isset($keyarray['in_group'])) ? $keyarray['in_group'] : ''; ?>" data-key="<?php echo $key; ?>" data-column="<?php echo ( isset($keyarray['in_column']) ) ? $keyarray['in_column'] : 1; ?>">
|
540 |
+
|
541 |
+
<div class="um-admin-drag-fld-title um-field-type-<?php echo $type; ?>">
|
542 |
+
<?php if ( $type == 'group' ) { ?>
|
543 |
+
<i class="um-icon-plus"></i>
|
544 |
+
<?php } else if ( isset($keyarray['icon']) && !empty( $keyarray['icon'] ) ) { ?>
|
545 |
+
<i class="<?php echo $keyarray['icon']; ?>"></i>
|
546 |
+
<?php } ?><?php echo ! empty( $keyarray['title'] ) ? $keyarray['title'] : __( '(no title)', 'ultimate-member' ); ?></div>
|
547 |
+
<?php $field_name = isset( UM()->builtin()->core_fields[$type]['name'] ) ? UM()->builtin()->core_fields[$type]['name'] : ''; ?>
|
548 |
+
<div class="um-admin-drag-fld-type um-field-type-<?php echo $type; ?>"><?php echo $field_name; ?></div>
|
549 |
+
<div class="um-admin-drag-fld-icons um-field-type-<?php echo $type; ?>">
|
550 |
+
|
551 |
+
<a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit', 'ultimate-member' ) ?>" data-modal="UM_edit_field" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="<?php echo $type; ?>" data-arg2="<?php echo $this->form_id; ?>" data-arg3="<?php echo $key; ?>"><i class="um-faicon-pencil"></i></a>
|
552 |
+
|
553 |
+
<a href="javascript:void(0);" class="um-admin-tipsy-n um_admin_duplicate_field" title="<?php esc_attr_e( 'Duplicate', 'ultimate-member' ) ?>" data-silent_action="um_admin_duplicate_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-files-o"></i></a>
|
554 |
+
|
555 |
+
<?php if ( $type == 'group' ) { ?>
|
556 |
+
|
557 |
+
<a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Group', 'ultimate-member' ) ?>" data-remove_element="um-admin-drag-fld.um-field-type-group" data-silent_action="um_admin_remove_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-trash-o"></i></a>
|
558 |
+
<?php } else { ?>
|
559 |
+
|
560 |
+
<a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete', 'ultimate-member' ) ?>" data-silent_action="um_admin_remove_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-trash-o"></i></a>
|
561 |
+
|
562 |
+
<?php } ?>
|
563 |
+
|
564 |
+
</div><div class="um-admin-clear"></div>
|
565 |
+
|
566 |
+
<?php if ( $type == 'group' ) { ?>
|
567 |
+
<div class="um-admin-drag-group">
|
568 |
+
|
569 |
+
</div>
|
570 |
+
<?php } ?>
|
571 |
+
|
572 |
+
</div>
|
573 |
+
|
574 |
+
<?php
|
575 |
+
|
576 |
+
} // end foreach
|
577 |
+
|
578 |
+
} // end if
|
579 |
+
|
580 |
+
?>
|
581 |
+
|
582 |
+
</div>
|
583 |
+
|
584 |
+
<div class="um-admin-drag-col-dynamic"></div>
|
585 |
+
|
586 |
+
<div class="um-admin-clear"></div>
|
587 |
+
|
588 |
+
</div>
|
589 |
+
|
590 |
+
<?php } ?>
|
591 |
+
|
592 |
+
</div>
|
593 |
+
|
594 |
+
</div>
|
595 |
+
|
596 |
+
<?php
|
597 |
+
|
598 |
+
} // rows loop
|
599 |
+
|
600 |
+
} // if fields exist
|
601 |
+
|
602 |
+
}
|
603 |
+
|
604 |
+
|
605 |
+
/**
|
606 |
+
*
|
607 |
+
*/
|
608 |
+
function update_field() {
|
609 |
+
UM()->admin()->check_ajax_nonce();
|
610 |
+
|
611 |
+
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
|
612 |
+
wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
|
613 |
+
}
|
614 |
+
|
615 |
+
$output['error'] = null;
|
616 |
+
|
617 |
+
$array = array(
|
618 |
+
'field_type' => sanitize_key( $_POST['_type'] ),
|
619 |
+
'form_id' => absint( $_POST['post_id'] ),
|
620 |
+
'args' => UM()->builtin()->get_core_field_attrs( sanitize_key( $_POST['_type'] ) ),
|
621 |
+
'post' => UM()->admin()->sanitize_builder_field_meta( $_POST ),
|
622 |
+
);
|
623 |
+
|
624 |
+
/**
|
625 |
+
* UM hook
|
626 |
+
*
|
627 |
+
* @type filter
|
628 |
+
* @title um_admin_pre_save_fields_hook
|
629 |
+
* @description Filter field data before save
|
630 |
+
* @input_vars
|
631 |
+
* [{"var":"$array","type":"array","desc":"Save Field data"}]
|
632 |
+
* @change_log
|
633 |
+
* ["Since: 2.0"]
|
634 |
+
* @usage add_filter( 'um_admin_pre_save_fields_hook', 'function_name', 10, 1 );
|
635 |
+
* @example
|
636 |
+
* <?php
|
637 |
+
* add_filter( 'um_admin_pre_save_fields_hook', 'my_admin_pre_save_fields', 10, 1 );
|
638 |
+
* function my_admin_pre_save_fields( $array ) {
|
639 |
+
* // your code here
|
640 |
+
* return $array;
|
641 |
+
* }
|
642 |
+
* ?>
|
643 |
+
*/
|
644 |
+
$array = apply_filters( 'um_admin_pre_save_fields_hook', $array );
|
645 |
+
|
646 |
+
/**
|
647 |
+
* UM hook
|
648 |
+
*
|
649 |
+
* @type filter
|
650 |
+
* @title um_admin_field_update_error_handling
|
651 |
+
* @description Change error string on save field
|
652 |
+
* @input_vars
|
653 |
+
* [{"var":"$error","type":"string","desc":"Error String"},
|
654 |
+
* {"var":"$array","type":"array","desc":"Save Field data"}]
|
655 |
+
* @change_log
|
656 |
+
* ["Since: 2.0"]
|
657 |
+
* @usage add_filter( 'um_admin_field_update_error_handling', 'function_name', 10, 2 );
|
658 |
+
* @example
|
659 |
+
* <?php
|
660 |
+
* add_filter( 'um_admin_field_update_error_handling', 'my_admin_field_update_error', 10, 2 );
|
661 |
+
* function my_admin_field_update_error( $error, $array ) {
|
662 |
+
* // your code here
|
663 |
+
* return $error;
|
664 |
+
* }
|
665 |
+
* ?>
|
666 |
+
*/
|
667 |
+
$output['error'] = apply_filters( 'um_admin_field_update_error_handling', $output['error'], $array );
|
668 |
+
|
669 |
+
/**
|
670 |
+
* @var $_metakey
|
671 |
+
* @var $post_id
|
672 |
+
*/
|
673 |
+
extract( $array['post'] );
|
674 |
+
|
675 |
+
if ( empty( $output['error'] ) ) {
|
676 |
+
|
677 |
+
$save = array();
|
678 |
+
$save[ $_metakey ] = null;
|
679 |
+
foreach ( $array['post'] as $key => $val ) {
|
680 |
+
|
681 |
+
if ( substr( $key, 0, 1 ) === '_' && $val !== '' ) { // field attribute
|
682 |
+
$new_key = ltrim ( $key, '_' );
|
683 |
+
|
684 |
+
if ( $new_key == 'options' ) {
|
685 |
+
//$save[ $_metakey ][$new_key] = explode(PHP_EOL, $val);
|
686 |
+
$save[ $_metakey ][ $new_key ] = preg_split( '/[\r\n]+/', $val, -1, PREG_SPLIT_NO_EMPTY );
|
687 |
+
} else {
|
688 |
+
$save[ $_metakey ][ $new_key ] = $val;
|
689 |
+
}
|
690 |
+
|
691 |
+
} elseif ( strstr( $key, 'um_editor' ) ) {
|
692 |
+
|
693 |
+
if ( 'block' === $array['post']['_type'] ) {
|
694 |
+
$save[ $_metakey ]['content'] = wp_kses_post( $val );
|
695 |
+
} else {
|
696 |
+
$save[ $_metakey ]['content'] = sanitize_textarea_field( $val );
|
697 |
+
}
|
698 |
+
}
|
699 |
+
|
700 |
+
}
|
701 |
+
|
702 |
+
$field_ID = $_metakey;
|
703 |
+
$field_args = $save[ $_metakey ];
|
704 |
+
|
705 |
+
/**
|
706 |
+
* UM hook
|
707 |
+
*
|
708 |
+
* @type filter
|
709 |
+
* @title um_admin_pre_save_field_to_form
|
710 |
+
* @description Change field options before save to form
|
711 |
+
* @input_vars
|
712 |
+
* [{"var":"$field_args","type":"array","desc":"Field Options"}]
|
713 |
+
* @change_log
|
714 |
+
* ["Since: 2.0"]
|
715 |
+
* @usage add_filter( 'um_admin_pre_save_field_to_form', 'function_name', 10, 1 );
|
716 |
+
* @example
|
717 |
+
* <?php
|
718 |
+
* add_filter( 'um_admin_pre_save_field_to_form', 'my_admin_pre_save_field_to_form', 10, 1 );
|
719 |
+
* function my_admin_pre_save_field_to_form( $field_args ) {
|
720 |
+
* // your code here
|
721 |
+
* return $field_args;
|
722 |
+
* }
|
723 |
+
* ?>
|
724 |
+
*/
|
725 |
+
$field_args = apply_filters( 'um_admin_pre_save_field_to_form', $field_args );
|
726 |
+
|
727 |
+
UM()->fields()->update_field( $field_ID, $field_args, $post_id );
|
728 |
+
|
729 |
+
/**
|
730 |
+
* UM hook
|
731 |
+
*
|
732 |
+
* @type filter
|
733 |
+
* @title um_admin_pre_save_field_to_db
|
734 |
+
* @description Change field options before save to DB
|
735 |
+
* @input_vars
|
736 |
+
* [{"var":"$field_args","type":"array","desc":"Field Options"}]
|
737 |
+
* @change_log
|
738 |
+
* ["Since: 2.0"]
|
739 |
+
* @usage add_filter( 'um_admin_pre_save_field_to_db', 'function_name', 10, 1 );
|
740 |
+
* @example
|
741 |
+
* <?php
|
742 |
+
* add_filter( 'um_admin_pre_save_field_to_db', 'my_admin_pre_save_field_to_db', 10, 1 );
|
743 |
+
* function my_admin_pre_save_field_to_form( $field_args ) {
|
744 |
+
* // your code here
|
745 |
+
* return $field_args;
|
746 |
+
* }
|
747 |
+
* ?>
|
748 |
+
*/
|
749 |
+
$field_args = apply_filters( 'um_admin_pre_save_field_to_db', $field_args );
|
750 |
+
|
751 |
+
if ( ! isset( $array['args']['form_only'] ) ) {
|
752 |
+
if ( ! isset( UM()->builtin()->predefined_fields[ $field_ID ] ) ) {
|
753 |
+
UM()->fields()->globally_update_field( $field_ID, $field_args );
|
754 |
+
}
|
755 |
+
}
|
756 |
+
|
757 |
+
}
|
758 |
+
|
759 |
+
$output = json_encode( $output );
|
760 |
+
if ( is_array( $output ) ) {
|
761 |
+
print_r( $output );
|
762 |
+
} else {
|
763 |
+
echo $output;
|
764 |
+
}
|
765 |
+
die;
|
766 |
+
}
|
767 |
+
|
768 |
+
|
769 |
+
/**
|
770 |
+
*
|
771 |
+
*/
|
772 |
+
function dynamic_modal_content() {
|
773 |
+
UM()->admin()->check_ajax_nonce();
|
774 |
+
|
775 |
+
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
|
776 |
+
wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
|
777 |
+
}
|
778 |
+
|
779 |
+
$metabox = UM()->metabox();
|
780 |
+
|
781 |
+
/**
|
782 |
+
* @var $act_id
|
783 |
+
* @var $arg1
|
784 |
+
* @var $arg2
|
785 |
+
* @var $arg3
|
786 |
+
*/
|
787 |
+
extract( $_POST );
|
788 |
+
|
789 |
+
if ( isset( $arg1 ) ) {
|
790 |
+
$arg1 = sanitize_text_field( $arg1 );
|
791 |
+
}
|
792 |
+
|
793 |
+
if ( isset( $arg2 ) ) {
|
794 |
+
$arg2 = sanitize_text_field( $arg2 );
|
795 |
+
}
|
796 |
+
|
797 |
+
if ( isset( $arg3 ) ) {
|
798 |
+
$arg3 = sanitize_text_field( $arg3 );
|
799 |
+
}
|
800 |
+
|
801 |
+
switch ( sanitize_key( $act_id ) ) {
|
802 |
+
|
803 |
+
default:
|
804 |
+
|
805 |
+
ob_start();
|
806 |
+
|
807 |
+
/**
|
808 |
+
* UM hook
|
809 |
+
*
|
810 |
+
* @type action
|
811 |
+
* @title um_admin_ajax_modal_content__hook
|
812 |
+
* @description Integration hook on ajax popup admin builder modal content
|
813 |
+
* @input_vars
|
814 |
+
* [{"var":"$act_id","type":"string","desc":"Ajax Action"}]
|
815 |
+
* @change_log
|
816 |
+
* ["Since: 2.0"]
|
817 |
+
* @usage add_action( 'um_admin_ajax_modal_content__hook', 'function_name', 10, 1 );
|
818 |
+
* @example
|
819 |
+
* <?php
|
820 |
+
* add_action( 'um_admin_ajax_modal_content__hook', 'my_admin_custom_hook', 10, 1 );
|
821 |
+
* function um_admin_ajax_modal_content__hook( $act_id ) {
|
822 |
+
* // your code here
|
823 |
+
* }
|
824 |
+
* ?>
|
825 |
+
*/
|
826 |
+
do_action( 'um_admin_ajax_modal_content__hook', sanitize_key( $act_id ) );
|
827 |
+
/**
|
828 |
+
* UM hook
|
829 |
+
*
|
830 |
+
* @type action
|
831 |
+
* @title um_admin_ajax_modal_content__hook_{$act_id}
|
832 |
+
* @description Integration hook on ajax popup admin builder modal content
|
833 |
+
* @change_log
|
834 |
+
* ["Since: 2.0"]
|
835 |
+
* @usage add_action( 'um_admin_ajax_modal_content__hook_{$act_id}', 'function_name', 10 );
|
836 |
+
* @example
|
837 |
+
* <?php
|
838 |
+
* add_action( 'um_admin_ajax_modal_content__hook_{$act_id}', 'my_admin_ajax_modal_content', 10 );
|
839 |
+
* function my_admin_ajax_modal_content() {
|
840 |
+
* // your code here
|
841 |
+
* }
|
842 |
+
* ?>
|
843 |
+
*/
|
844 |
+
do_action( "um_admin_ajax_modal_content__hook_" . sanitize_key( $act_id ) );
|
845 |
+
|
846 |
+
$output = ob_get_clean();
|
847 |
+
break;
|
848 |
+
|
849 |
+
case 'um_admin_fonticon_selector':
|
850 |
+
|
851 |
+
ob_start(); ?>
|
852 |
+
|
853 |
+
<div class="um-admin-metabox">
|
854 |
+
<p class="_icon_search"><input type="text" name="_icon_search" id="_icon_search" value="" placeholder="<?php esc_attr_e('Search Icons...', 'ultimate-member' ); ?>" /></p>
|
855 |
+
</div>
|
856 |
+
|
857 |
+
<div class="um-admin-icons">
|
858 |
+
<?php foreach( UM()->fonticons()->all as $icon ) { ?>
|
859 |
+
<span data-code="<?php echo esc_attr( $icon ); ?>" title="<?php echo esc_attr( $icon ); ?>" class="um-admin-tipsy-n"><i class="<?php echo $icon; ?>"></i></span>
|
860 |
+
<?php } ?>
|
861 |
+
</div><div class="um-admin-clear"></div>
|
862 |
+
|
863 |
+
<?php $output = ob_get_clean();
|
864 |
+
break;
|
865 |
+
|
866 |
+
case 'um_admin_show_fields':
|
867 |
+
|
868 |
+
ob_start();
|
869 |
+
$form_fields = UM()->query()->get_attr( 'custom_fields', $arg2 );
|
870 |
+
$form_fields = array_values( array_filter( array_keys( $form_fields ) ) );
|
871 |
+
//$form_fields = array_keys( $form_fields );
|
872 |
+
?>
|
873 |
+
|
874 |
+
<h4><?php _e('Setup New Field','ultimate-member'); ?></h4>
|
875 |
+
<div class="um-admin-btns">
|
876 |
+
|
877 |
+
<?php if ( UM()->builtin()->core_fields ) {
|
878 |
+
foreach ( UM()->builtin()->core_fields as $field_type => $array ) {
|
879 |
+
|
880 |
+
if ( isset( $array['in_fields'] ) && $array['in_fields'] == false ) {
|
881 |
+
continue;
|
882 |
+
} ?>
|
883 |
+
|
884 |
+
<a href="javascript:void(0);" class="button" data-modal="UM_add_field" data-modal-size="normal" data-dynamic-content="um_admin_new_field_popup" data-arg1="<?php echo esc_attr( $field_type ); ?>" data-arg2="<?php echo esc_attr( $arg2 ) ?>"><?php echo esc_html( $array['name'] ); ?></a>
|
885 |
+
|
886 |
+
<?php }
|
887 |
+
} ?>
|
888 |
+
|
889 |
+
</div>
|
890 |
+
|
891 |
+
<h4><?php _e('Predefined Fields','ultimate-member'); ?></h4>
|
892 |
+
<div class="um-admin-btns">
|
893 |
+
|
894 |
+
<?php if ( UM()->builtin()->predefined_fields ) {
|
895 |
+
foreach ( UM()->builtin()->predefined_fields as $field_key => $array ) {
|
896 |
+
if ( ! isset( $array['account_only'] ) && ! isset( $array['private_use'] ) ) { ?>
|
897 |
+
|
898 |
+
<a href="javascript:void(0);" class="button" <?php disabled( in_array( $field_key, $form_fields, true ) ) ?> data-silent_action="um_admin_add_field_from_predefined" data-arg1="<?php echo esc_attr( $field_key ); ?>" data-arg2="<?php echo esc_attr( $arg2 ); ?>"><?php echo um_trim_string( stripslashes( $array['title'] ), 20 ); ?></a>
|
899 |
+
|
900 |
+
<?php }
|
901 |
+
}
|
902 |
+
} else {
|
903 |
+
echo '<p>' . __( 'None', 'ultimate-member' ) . '</p>';
|
904 |
+
} ?>
|
905 |
+
|
906 |
+
</div>
|
907 |
+
|
908 |
+
<h4><?php _e( 'Custom Fields', 'ultimate-member' ); ?></h4>
|
909 |
+
<div class="um-admin-btns">
|
910 |
+
|
911 |
+
<?php
|
912 |
+
if ( UM()->builtin()->custom_fields ) {
|
913 |
+
foreach ( UM()->builtin()->custom_fields as $field_key => $array ) {
|
914 |
+
if ( empty( $array['title'] ) || empty( $array['type'] ) ) {
|
915 |
+
continue;
|
916 |
+
} ?>
|
917 |
+
|
918 |
+
<a href="javascript:void(0);" class="button with-icon" <?php disabled( in_array( $field_key, $form_fields, true ) ) ?> data-silent_action="um_admin_add_field_from_list" data-arg1="<?php echo esc_attr( $field_key ); ?>" data-arg2="<?php echo esc_attr( $arg2 ); ?>" title="<?php echo __( 'Meta Key', 'ultimate-member' ) . ' - ' . esc_attr( $field_key ); ?>"><?php echo um_trim_string( stripslashes( $array['title'] ), 20 ); ?> <small>(<?php echo ucfirst( $array['type'] ); ?>)</small><span class="remove"></span></a>
|
919 |
+
|
920 |
+
<?php }
|
921 |
+
} else {
|
922 |
+
echo '<p>' . __( 'You did not create any custom fields', 'ultimate-member' ) . '</p>';
|
923 |
+
} ?>
|
924 |
+
|
925 |
+
</div>
|
926 |
+
|
927 |
+
<?php $output = ob_get_clean();
|
928 |
+
break;
|
929 |
+
|
930 |
+
case 'um_admin_edit_field_popup':
|
931 |
+
|
932 |
+
ob_start();
|
933 |
+
|
934 |
+
$args = UM()->builtin()->get_core_field_attrs( $arg1 );
|
935 |
+
|
936 |
+
$form_fields = UM()->query()->get_attr( 'custom_fields', $arg2 );
|
937 |
+
|
938 |
+
$metabox->set_field_type = $arg1;
|
939 |
+
$metabox->in_edit = true;
|
940 |
+
$metabox->edit_array = $form_fields[ $arg3 ];
|
941 |
+
|
942 |
+
if ( !isset( $metabox->edit_array['metakey'] ) ){
|
943 |
+
$metabox->edit_array['metakey'] = $metabox->edit_array['id'];
|
944 |
+
}
|
945 |
+
|
946 |
+
if ( !isset( $metabox->edit_array['position'] ) ){
|
947 |
+
$metabox->edit_array['position'] = $metabox->edit_array['id'];
|
948 |
+
}
|
949 |
+
|
950 |
+
extract( $args );
|
951 |
+
|
952 |
+
if ( ! isset( $col1 ) ) {
|
953 |
+
|
954 |
+
echo '<p>'. __( 'This field type is not setup correcty.', 'ultimate-member' ) . '</p>';
|
955 |
+
|
956 |
+
} else {
|
957 |
+
|
958 |
+
?>
|
959 |
+
|
960 |
+
<?php if ( isset( $metabox->edit_array['in_group'] ) ) { ?>
|
961 |
+
<input type="hidden" name="_in_row" id="_in_row" value="<?php echo $metabox->edit_array['in_row']; ?>" />
|
962 |
+
<input type="hidden" name="_in_sub_row" id="_in_sub_row" value="<?php echo $metabox->edit_array['in_sub_row']; ?>" />
|
963 |
+
<input type="hidden" name="_in_column" id="_in_column" value="<?php echo $metabox->edit_array['in_column']; ?>" />
|
964 |
+
<input type="hidden" name="_in_group" id="_in_group" value="<?php echo $metabox->edit_array['in_group']; ?>" />
|
965 |
+
<?php } ?>
|
966 |
+
|
967 |
+
<input type="hidden" name="_type" id="_type" value="<?php echo $arg1; ?>" />
|
968 |
+
|
969 |
+
<input type="hidden" name="post_id" id="post_id" value="<?php echo $arg2; ?>" />
|
970 |
+
|
971 |
+
<input type="hidden" name="edit_mode" id="edit_mode" value="true" />
|
972 |
+
|
973 |
+
<input type="hidden" name="_metakey" id="_metakey" value="<?php echo $metabox->edit_array['metakey']; ?>" />
|
974 |
+
|
975 |
+
<input type="hidden" name="_position" id="_position" value="<?php echo $metabox->edit_array['position']; ?>" />
|
976 |
+
|
977 |
+
<?php if ( isset( $args['mce_content'] ) ) { ?>
|
978 |
+
<div class="dynamic-mce-content"><?php echo ! empty( $metabox->edit_array['content'] ) ? $metabox->edit_array['content'] : ''; ?></div>
|
979 |
+
<?php } ?>
|
980 |
+
|
981 |
+
<?php $this->modal_header(); ?>
|
982 |
+
|
983 |
+
<div class="um-admin-half">
|
984 |
+
|
985 |
+
<?php if ( isset( $col1 ) ) { foreach( $col1 as $opt ) $metabox->field_input ( $opt, $arg2, $metabox->edit_array ); } ?>
|
986 |
+
|
987 |
+
</div>
|
988 |
+
|
989 |
+
<div class="um-admin-half um-admin-right">
|
990 |
+
|
991 |
+
<?php if ( isset( $col2 ) ) { foreach( $col2 as $opt ) $metabox->field_input ( $opt, $arg2, $metabox->edit_array ); } ?>
|
992 |
+
|
993 |
+
</div><div class="um-admin-clear"></div>
|
994 |
+
|
995 |
+
<?php if ( isset( $col3 ) ) { foreach( $col3 as $opt ) $metabox->field_input ( $opt, $arg2, $metabox->edit_array ); } ?>
|
996 |
+
|
997 |
+
<div class="um-admin-clear"></div>
|
998 |
+
|
999 |
+
<?php if ( isset( $col_full ) ) {foreach( $col_full as $opt ) $metabox->field_input ( $opt, $arg2, $metabox->edit_array ); } ?>
|
1000 |
+
|
1001 |
+
<?php $this->modal_footer( $arg2, $args, $metabox ); ?>
|
1002 |
+
|
1003 |
+
<?php
|
1004 |
+
|
1005 |
+
}
|
1006 |
+
|
1007 |
+
$output = ob_get_clean();
|
1008 |
+
break;
|
1009 |
+
|
1010 |
+
case 'um_admin_new_field_popup':
|
1011 |
+
|
1012 |
+
ob_start();
|
1013 |
+
|
1014 |
+
$args = UM()->builtin()->get_core_field_attrs( $arg1 );
|
1015 |
+
|
1016 |
+
$metabox->set_field_type = $arg1;
|
1017 |
+
|
1018 |
+
/**
|
1019 |
+
* @var $in_row
|
1020 |
+
* @var $in_sub_row
|
1021 |
+
* @var $in_column
|
1022 |
+
* @var $in_group
|
1023 |
+
*/
|
1024 |
+
extract( $args );
|
1025 |
+
|
1026 |
+
if ( ! isset( $col1 ) ) {
|
1027 |
+
|
1028 |
+
echo '<p>'. __( 'This field type is not setup correcty.', 'ultimate-member' ) . '</p>';
|
1029 |
+
|
1030 |
+
} else {
|
1031 |
+
|
1032 |
+
if ( $in_column ) { ?>
|
1033 |
+
<input type="hidden" name="_in_row" id="_in_row" value="_um_row_<?php echo $in_row + 1; ?>" />
|
1034 |
+
<input type="hidden" name="_in_sub_row" id="_in_sub_row" value="<?php echo $in_sub_row; ?>" />
|
1035 |
+
<input type="hidden" name="_in_column" id="_in_column" value="<?php echo $in_column; ?>" />
|
1036 |
+
<input type="hidden" name="_in_group" id="_in_group" value="<?php echo $in_group; ?>" />
|
1037 |
+
<?php } ?>
|
1038 |
+
|
1039 |
+
<input type="hidden" name="_type" id="_type" value="<?php echo $arg1; ?>" />
|
1040 |
+
|
1041 |
+
<input type="hidden" name="post_id" id="post_id" value="<?php echo $arg2; ?>" />
|
1042 |
+
|
1043 |
+
<?php $this->modal_header(); ?>
|
1044 |
+
|
1045 |
+
<div class="um-admin-half">
|
1046 |
+
|
1047 |
+
<?php if ( isset( $col1 ) ) { foreach( $col1 as $opt ) $metabox->field_input ( $opt ); } ?>
|
1048 |
+
|
1049 |
+
</div>
|
1050 |
+
|
1051 |
+
<div class="um-admin-half um-admin-right">
|
1052 |
+
|
1053 |
+
<?php if ( isset( $col2 ) ) { foreach( $col2 as $opt ) $metabox->field_input ( $opt ); } ?>
|
1054 |
+
|
1055 |
+
</div><div class="um-admin-clear"></div>
|
1056 |
+
|
1057 |
+
<?php if ( isset( $col3 ) ) { foreach( $col3 as $opt ) $metabox->field_input ( $opt ); } ?>
|
1058 |
+
|
1059 |
+
<div class="um-admin-clear"></div>
|
1060 |
+
|
1061 |
+
<?php if ( isset( $col_full ) ) { foreach( $col_full as $opt ) $metabox->field_input ( $opt ); } ?>
|
1062 |
+
|
1063 |
+
<?php $this->modal_footer( $arg2, $args, $metabox ); ?>
|
1064 |
+
|
1065 |
+
<?php
|
1066 |
+
|
1067 |
+
}
|
1068 |
+
|
1069 |
+
$output = ob_get_clean();
|
1070 |
+
break;
|
1071 |
+
|
1072 |
+
case 'um_admin_preview_form':
|
1073 |
+
|
1074 |
+
UM()->user()->preview = true;
|
1075 |
+
|
1076 |
+
$mode = UM()->query()->get_attr('mode', $arg1 );
|
1077 |
+
|
1078 |
+
if ( $mode == 'profile' ) {
|
1079 |
+
UM()->fields()->editing = true;
|
1080 |
+
}
|
1081 |
+
|
1082 |
+
$output = '<div class="um-admin-preview-overlay"></div>';
|
1083 |
+
|
1084 |
+
if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
|
1085 |
+
$output .= do_shortcode('[ultimatemember form_id="' . $arg1 . '" /]');
|
1086 |
+
} else {
|
1087 |
+
$output .= apply_shortcodes('[ultimatemember form_id="' . $arg1 . '" /]');
|
1088 |
+
}
|
1089 |
+
|
1090 |
+
break;
|
1091 |
+
|
1092 |
+
case 'um_admin_review_registration':
|
1093 |
+
//$user_id = $arg1;
|
1094 |
+
|
1095 |
+
if ( ! current_user_can( 'administrator' ) ) {
|
1096 |
+
if ( ! um_can_view_profile( $arg1 ) ) {
|
1097 |
+
$output = '';
|
1098 |
+
break;
|
1099 |
+
}
|
1100 |
+
}
|
1101 |
+
|
1102 |
+
um_fetch_user( $arg1 );
|
1103 |
+
|
1104 |
+
UM()->user()->preview = true;
|
1105 |
+
|
1106 |
+
$output = um_user_submitted_registration_formatted( true );
|
1107 |
+
|
1108 |
+
um_reset_user();
|
1109 |
+
|
1110 |
+
break;
|
1111 |
+
|
1112 |
+
}
|
1113 |
+
|
1114 |
+
if ( is_array( $output ) ) {
|
1115 |
+
print_r( $output );
|
1116 |
+
} else {
|
1117 |
+
echo $output;
|
1118 |
+
}
|
1119 |
+
die;
|
1120 |
+
}
|
1121 |
+
|
1122 |
+
|
1123 |
+
/**
|
1124 |
+
*
|
1125 |
+
*/
|
1126 |
+
function modal_header() {
|
1127 |
+
/**
|
1128 |
+
* UM hook
|
1129 |
+
*
|
1130 |
+
* @type action
|
1131 |
+
* @title um_admin_field_modal_header
|
1132 |
+
* @description Modal Window Header
|
1133 |
+
* @change_log
|
1134 |
+
* ["Since: 2.0"]
|
1135 |
+
* @usage add_action( 'um_admin_field_modal_header', 'function_name', 10 );
|
1136 |
+
* @example
|
1137 |
+
* <?php
|
1138 |
+
* add_action( 'um_admin_field_modal_header', 'my_admin_field_modal_header', 10 );
|
1139 |
+
* function my_admin_field_modal_header() {
|
1140 |
+
* // your code here
|
1141 |
+
* }
|
1142 |
+
* ?>
|
1143 |
+
*/
|
1144 |
+
do_action( 'um_admin_field_modal_header' );
|
1145 |
+
}
|
1146 |
+
|
1147 |
+
|
1148 |
+
/**
|
1149 |
+
* Modal Footer loading
|
1150 |
+
*
|
1151 |
+
* @param $arg2
|
1152 |
+
* @param $args
|
1153 |
+
* @param $metabox
|
1154 |
+
*/
|
1155 |
+
function modal_footer( $arg2, $args, $metabox ) {
|
1156 |
+
/**
|
1157 |
+
* UM hook
|
1158 |
+
*
|
1159 |
+
* @type action
|
1160 |
+
* @title um_admin_field_modal_footer
|
1161 |
+
* @description Modal Window Footer
|
1162 |
+
* @input_vars
|
1163 |
+
* [{"var":"$arg2","type":"string","desc":"Ajax Action"},
|
1164 |
+
* {"var":"$args","type":"array","desc":"Modal window arguments"},
|
1165 |
+
* {"var":"$in_edit","type":"bool","desc":"Is edit mode?"},
|
1166 |
+
* {"var":"$edit_array","type":"array","desc":"Edit Array"}]
|
1167 |
+
* @change_log
|
1168 |
+
* ["Since: 2.0"]
|
1169 |
+
* @usage add_action( 'um_admin_field_modal_footer', 'function_name', 10, 4 );
|
1170 |
+
* @example
|
1171 |
+
* <?php
|
1172 |
+
* add_action( 'um_admin_field_modal_footer', 'my_admin_field_modal_footer', 10, 4 );
|
1173 |
+
* function my_admin_field_modal_footer( $arg2, $args, $in_edit, $edit_array ) {
|
1174 |
+
* // your code here
|
1175 |
+
* }
|
1176 |
+
* ?>
|
1177 |
+
*/
|
1178 |
+
do_action( 'um_admin_field_modal_footer', $arg2, $args, $metabox->in_edit, ( isset( $metabox->edit_array ) ) ? $metabox->edit_array : '' );
|
1179 |
+
}
|
1180 |
+
|
1181 |
+
|
1182 |
+
/**
|
1183 |
+
* Skip field validation for:
|
1184 |
+
* - '_options' if Choices Callback specified
|
1185 |
+
*
|
1186 |
+
* @param boolean $skip
|
1187 |
+
* @param string $post_input
|
1188 |
+
* @param array $array
|
1189 |
+
* @return boolean
|
1190 |
+
*/
|
1191 |
+
public function skip_field_validation( $skip, $post_input, $array ) {
|
1192 |
+
if ( $post_input === '_options' && isset( $array['post']['_custom_dropdown_options_source'] ) ) {
|
1193 |
+
$skip = function_exists( wp_unslash( $array['post']['_custom_dropdown_options_source'] ) );
|
1194 |
+
}
|
1195 |
+
|
1196 |
+
return $skip;
|
1197 |
+
}
|
1198 |
+
|
1199 |
+
|
1200 |
+
/**
|
1201 |
+
* Retrieves dropdown/multi-select options from a callback function
|
1202 |
+
*/
|
1203 |
+
function populate_dropdown_options() {
|
1204 |
+
UM()->admin()->check_ajax_nonce();
|
1205 |
+
|
1206 |
+
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
|
1207 |
+
wp_send_json_error( __( 'This is not possible for security reasons.', 'ultimate-member' ) );
|
1208 |
+
}
|
1209 |
+
|
1210 |
+
$arr_options = array();
|
1211 |
+
|
1212 |
+
// we can not use `sanitize_key()` because it removes backslash needed for namespace and uppercase symbols
|
1213 |
+
$um_callback_func = sanitize_text_field( $_POST['um_option_callback'] );
|
1214 |
+
// removed added by sanitize slashes for the namespaces
|
1215 |
+
$um_callback_func = wp_unslash( $um_callback_func );
|
1216 |
+
|
1217 |
+
if ( empty( $um_callback_func ) ) {
|
1218 |
+
$arr_options['status'] = 'empty';
|
1219 |
+
$arr_options['function_name'] = $um_callback_func;
|
1220 |
+
$arr_options['function_exists'] = function_exists( $um_callback_func );
|
1221 |
+
}
|
1222 |
+
|
1223 |
+
$arr_options['data'] = array();
|
1224 |
+
if ( function_exists( $um_callback_func ) ) {
|
1225 |
+
$arr_options['data'] = call_user_func( $um_callback_func );
|
1226 |
+
}
|
1227 |
+
|
1228 |
+
wp_send_json( $arr_options );
|
1229 |
+
}
|
1230 |
+
|
1231 |
+
}
|
1232 |
+
}
|
includes/admin/core/class-admin-metabox.php
CHANGED
@@ -1,2427 +1,2426 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\admin\core;
|
3 |
-
|
4 |
-
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
|
8 |
-
if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Admin_Metabox
|
13 |
-
*
|
14 |
-
* @package um\admin\core
|
15 |
-
*/
|
16 |
-
class Admin_Metabox {
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* @var bool
|
21 |
-
*/
|
22 |
-
private $form_nonce_added = false;
|
23 |
-
|
24 |
-
|
25 |
-
/**
|
26 |
-
* @var bool
|
27 |
-
*/
|
28 |
-
private $directory_nonce_added = false;
|
29 |
-
|
30 |
-
|
31 |
-
/**
|
32 |
-
* @var bool
|
33 |
-
*/
|
34 |
-
private $custom_nonce_added = false;
|
35 |
-
|
36 |
-
|
37 |
-
var $init_icon = false;
|
38 |
-
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Admin_Metabox constructor.
|
42 |
-
*/
|
43 |
-
function __construct() {
|
44 |
-
$this->in_edit = false;
|
45 |
-
$this->edit_mode_value = null;
|
46 |
-
$this->edit_array = [];
|
47 |
-
|
48 |
-
add_action( 'admin_head', array( &$this, 'admin_head' ), 9);
|
49 |
-
add_action( 'admin_footer', array( &$this, 'load_modal_content' ), 9 );
|
50 |
-
|
51 |
-
add_action( 'load-post.php', array( &$this, 'add_metabox' ), 9 );
|
52 |
-
add_action( 'load-post-new.php', array( &$this, 'add_metabox' ), 9 );
|
53 |
-
|
54 |
-
add_action( 'admin_init', array( &$this, 'add_taxonomy_metabox' ), 9 );
|
55 |
-
|
56 |
-
//roles metaboxes
|
57 |
-
add_action( 'um_roles_add_meta_boxes', array( &$this, 'add_metabox_role' ) );
|
58 |
-
|
59 |
-
add_filter( 'um_builtin_validation_types_continue_loop', array( &$this, 'validation_types_continue_loop' ), 1, 4 );
|
60 |
-
add_filter( 'um_restrict_content_hide_metabox', array( &$this, 'hide_metabox_restrict_content_shop' ), 10, 1 );
|
61 |
-
|
62 |
-
add_filter( 'um_member_directory_meta_value_before_save', array( UM()->member_directory(), 'before_save_data' ), 10, 3 );
|
63 |
-
}
|
64 |
-
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Hide Woocommerce Shop page restrict content metabox
|
68 |
-
* @param $hide
|
69 |
-
*
|
70 |
-
* @return bool
|
71 |
-
*/
|
72 |
-
function hide_metabox_restrict_content_shop( $hide ) {
|
73 |
-
if ( function_exists( 'wc_get_page_id' ) && ! empty( $_GET['post'] ) &&
|
74 |
-
absint( $_GET['post'] ) == wc_get_page_id( 'shop' ) ) {
|
75 |
-
return true;
|
76 |
-
}
|
77 |
-
|
78 |
-
return $hide;
|
79 |
-
}
|
80 |
-
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Filter validation types on loop
|
84 |
-
*
|
85 |
-
* @param $break
|
86 |
-
* @param $key
|
87 |
-
* @param $form_id
|
88 |
-
* @param $field_array
|
89 |
-
*
|
90 |
-
* @return bool
|
91 |
-
*/
|
92 |
-
function validation_types_continue_loop( $break, $key, $form_id, $field_array ) {
|
93 |
-
|
94 |
-
// show unique username validation only for user_login field
|
95 |
-
if ( isset( $field_array['metakey'] ) && $field_array['metakey'] == 'user_login' && $key !== 'unique_username' ) {
|
96 |
-
return false;
|
97 |
-
}
|
98 |
-
|
99 |
-
return $break;
|
100 |
-
}
|
101 |
-
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Gets the role meta
|
105 |
-
*
|
106 |
-
* @param $id
|
107 |
-
*
|
108 |
-
* @return mixed
|
109 |
-
*/
|
110 |
-
function get_custom_post_meta( $id ) {
|
111 |
-
$all_meta = get_post_custom( $id );
|
112 |
-
foreach ( $all_meta as $k => $v ) {
|
113 |
-
if ( strstr( $k, '_um_' ) ) {
|
114 |
-
$um_meta[ $k ] = $v;
|
115 |
-
}
|
116 |
-
}
|
117 |
-
if ( isset( $um_meta ) ) {
|
118 |
-
return $um_meta;
|
119 |
-
}
|
120 |
-
|
121 |
-
return false;
|
122 |
-
}
|
123 |
-
|
124 |
-
|
125 |
-
/**
|
126 |
-
* Runs on admin head
|
127 |
-
*/
|
128 |
-
function admin_head(){
|
129 |
-
global $post;
|
130 |
-
if ( UM()->admin()->is_plugin_post_type() && isset($post->ID) ){
|
131 |
-
$this->postmeta = $this->get_custom_post_meta($post->ID);
|
132 |
-
}
|
133 |
-
}
|
134 |
-
|
135 |
-
|
136 |
-
/**
|
137 |
-
* Init the metaboxes
|
138 |
-
*/
|
139 |
-
function add_metabox() {
|
140 |
-
global $current_screen;
|
141 |
-
|
142 |
-
if ( $current_screen->id == 'um_form' ) {
|
143 |
-
add_action( 'add_meta_boxes', array(&$this, 'add_metabox_form'), 1 );
|
144 |
-
add_action( 'save_post', array(&$this, 'save_metabox_form'), 10, 2 );
|
145 |
-
}
|
146 |
-
|
147 |
-
if ( $current_screen->id == 'um_directory' ) {
|
148 |
-
add_action( 'add_meta_boxes', array(&$this, 'add_metabox_directory'), 1 );
|
149 |
-
add_action( 'save_post', array(&$this, 'save_metabox_directory'), 10, 2 );
|
150 |
-
}
|
151 |
-
|
152 |
-
//restrict content metabox
|
153 |
-
$post_types = UM()->options()->get( 'restricted_access_post_metabox' );
|
154 |
-
if ( ! empty( $post_types[ $current_screen->id ] ) ) {
|
155 |
-
|
156 |
-
/**
|
157 |
-
* UM hook
|
158 |
-
*
|
159 |
-
* @type filter
|
160 |
-
* @title um_restrict_content_hide_metabox
|
161 |
-
* @description Show/Hide Restrict content metabox
|
162 |
-
* @input_vars
|
163 |
-
* [{"var":"$show","type":"bool","desc":"Show Metabox"}]
|
164 |
-
* @change_log
|
165 |
-
* ["Since: 2.0"]
|
166 |
-
* @usage add_filter( 'um_restrict_content_hide_metabox', 'function_name', 10, 1 );
|
167 |
-
* @example
|
168 |
-
* <?php
|
169 |
-
* add_filter( 'um_restrict_content_hide_metabox', 'my_restrict_content_hide_metabox', 10, 1 );
|
170 |
-
* function my_restrict_content_hide_metabox( $show ) {
|
171 |
-
* // your code here
|
172 |
-
* return $show;
|
173 |
-
* }
|
174 |
-
* ?>
|
175 |
-
*/
|
176 |
-
$hide_metabox = apply_filters( 'um_restrict_content_hide_metabox', false );
|
177 |
-
|
178 |
-
if ( ! $hide_metabox ) {
|
179 |
-
add_action( 'add_meta_boxes', array(&$this, 'add_metabox_restrict_content'), 1 );
|
180 |
-
add_action( 'save_post', array( &$this, 'save_metabox_restrict_content' ), 10, 2 );
|
181 |
-
}
|
182 |
-
|
183 |
-
if ( $current_screen->id == 'attachment' ) {
|
184 |
-
add_action( 'add_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 );
|
185 |
-
add_action( 'edit_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 );
|
186 |
-
}
|
187 |
-
}
|
188 |
-
|
189 |
-
|
190 |
-
add_action( 'save_post', array( &$this, 'save_metabox_custom' ), 10, 2 );
|
191 |
-
}
|
192 |
-
|
193 |
-
|
194 |
-
/**
|
195 |
-
* @param $post_id
|
196 |
-
* @param $post
|
197 |
-
*/
|
198 |
-
public function save_metabox_custom( $post_id, $post ) {
|
199 |
-
// validate nonce
|
200 |
-
if ( ! isset( $_POST['um_admin_save_metabox_custom_nonce'] ) ||
|
201 |
-
! wp_verify_nonce( $_POST['um_admin_save_metabox_custom_nonce'], basename( __FILE__ ) ) ) {
|
202 |
-
return;
|
203 |
-
}
|
204 |
-
|
205 |
-
/**
|
206 |
-
* UM hook
|
207 |
-
*
|
208 |
-
* @type action
|
209 |
-
* @title um_admin_custom_restrict_content_metaboxes
|
210 |
-
* @description Save metabox custom with restrict content
|
211 |
-
* @input_vars
|
212 |
-
* [{"var":"$post_id","type":"int","desc":"Post ID"},
|
213 |
-
* {"var":"$post","type":"array","desc":"Post data"}]
|
214 |
-
* @change_log
|
215 |
-
* ["Since: 2.0"]
|
216 |
-
* @usage add_action( 'um_admin_custom_restrict_content_metaboxes', 'function_name', 10, 2 );
|
217 |
-
* @example
|
218 |
-
* <?php
|
219 |
-
* add_action( 'um_admin_custom_restrict_content_metaboxes', 'my_admin_custom_restrict_content', 10, 2 );
|
220 |
-
* function my_admin_custom_restrict_content( $post_id, $post ) {
|
221 |
-
* // your code here
|
222 |
-
* }
|
223 |
-
* ?>
|
224 |
-
*/
|
225 |
-
do_action( 'um_admin_custom_restrict_content_metaboxes', $post_id, $post );
|
226 |
-
}
|
227 |
-
|
228 |
-
|
229 |
-
/**
|
230 |
-
*
|
231 |
-
*/
|
232 |
-
function add_metabox_restrict_content() {
|
233 |
-
global $current_screen;
|
234 |
-
|
235 |
-
add_meta_box(
|
236 |
-
'um-admin-restrict-content',
|
237 |
-
__( 'Ultimate Member: Content Restriction', 'ultimate-member' ),
|
238 |
-
array( &$this, 'restrict_content_cb' ),
|
239 |
-
$current_screen->id,
|
240 |
-
'normal',
|
241 |
-
'default'
|
242 |
-
);
|
243 |
-
|
244 |
-
/**
|
245 |
-
* UM hook
|
246 |
-
*
|
247 |
-
* @type action
|
248 |
-
* @title um_admin_custom_restrict_content_metaboxes
|
249 |
-
* @description Add restrict content custom metabox
|
250 |
-
* @change_log
|
251 |
-
* ["Since: 2.0"]
|
252 |
-
* @usage add_action( 'um_admin_custom_restrict_content_metaboxes', 'function_name', 10 );
|
253 |
-
* @example
|
254 |
-
* <?php
|
255 |
-
* add_action( 'um_admin_custom_restrict_content_metaboxes', 'my_admin_custom_restrict_content', 10 );
|
256 |
-
* function my_admin_custom_restrict_content() {
|
257 |
-
* // your code here
|
258 |
-
* }
|
259 |
-
* ?>
|
260 |
-
*/
|
261 |
-
do_action( 'um_admin_custom_restrict_content_metaboxes' );
|
262 |
-
}
|
263 |
-
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Content restriction metabox
|
267 |
-
*
|
268 |
-
* @param $object
|
269 |
-
* @param $box
|
270 |
-
*/
|
271 |
-
function restrict_content_cb( $object, $box ) {
|
272 |
-
include_once UM()->admin()->templates_path . 'access/restrict_content.php';
|
273 |
-
wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_restrict_content_nonce' );
|
274 |
-
}
|
275 |
-
|
276 |
-
|
277 |
-
/**
|
278 |
-
* Init the metaboxes
|
279 |
-
*/
|
280 |
-
function add_taxonomy_metabox() {
|
281 |
-
//restrict content metabox
|
282 |
-
$all_taxonomies = get_taxonomies( array( 'public' => true ) );
|
283 |
-
$tax_types = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
284 |
-
$exclude_taxonomies = UM()->excluded_taxonomies();
|
285 |
-
|
286 |
-
foreach ( $all_taxonomies as $key => $taxonomy ) {
|
287 |
-
if ( in_array( $key, $exclude_taxonomies ) || empty( $tax_types[$key] ) )
|
288 |
-
continue;
|
289 |
-
|
290 |
-
add_action( $taxonomy . '_add_form_fields', array( &$this, 'um_category_access_fields_create' ) );
|
291 |
-
add_action( $taxonomy . '_edit_form_fields', array( &$this, 'um_category_access_fields_edit' ) );
|
292 |
-
add_action( 'create_' . $taxonomy, array( &$this, 'um_category_access_fields_save' ) );
|
293 |
-
add_action( 'edited_' . $taxonomy, array( &$this, 'um_category_access_fields_save' ) );
|
294 |
-
}
|
295 |
-
}
|
296 |
-
|
297 |
-
|
298 |
-
/**
|
299 |
-
* @param $post_id
|
300 |
-
* @param $post
|
301 |
-
*/
|
302 |
-
function save_metabox_restrict_content( $post_id, $post ) {
|
303 |
-
// validate nonce
|
304 |
-
if ( ! isset( $_POST['um_admin_save_metabox_restrict_content_nonce'] ) ||
|
305 |
-
! wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) ) {
|
306 |
-
return;
|
307 |
-
}
|
308 |
-
|
309 |
-
// validate user
|
310 |
-
$post_type = get_post_type_object( $post->post_type );
|
311 |
-
if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
|
312 |
-
return;
|
313 |
-
}
|
314 |
-
|
315 |
-
if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) {
|
316 |
-
$restriction_meta = UM()->admin()->sanitize_post_restriction_meta( $_POST['um_content_restriction'] );
|
317 |
-
|
318 |
-
update_post_meta( $post_id, 'um_content_restriction', $restriction_meta );
|
319 |
-
} else {
|
320 |
-
delete_post_meta( $post_id, 'um_content_restriction' );
|
321 |
-
}
|
322 |
-
}
|
323 |
-
|
324 |
-
|
325 |
-
/**
|
326 |
-
* @param $post_id
|
327 |
-
*
|
328 |
-
*/
|
329 |
-
function save_attachment_metabox_restrict_content( $post_id ) {
|
330 |
-
// validate nonce
|
331 |
-
if ( ! isset( $_POST['um_admin_save_metabox_restrict_content_nonce'] )
|
332 |
-
|| ! wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) ) {
|
333 |
-
return;
|
334 |
-
}
|
335 |
-
|
336 |
-
$post = get_post( $post_id );
|
337 |
-
|
338 |
-
// validate user
|
339 |
-
$post_type = get_post_type_object( $post->post_type );
|
340 |
-
if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
|
341 |
-
return;
|
342 |
-
}
|
343 |
-
|
344 |
-
if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) {
|
345 |
-
$restriction_meta = UM()->admin()->sanitize_post_restriction_meta( $_POST['um_content_restriction'] );
|
346 |
-
|
347 |
-
update_post_meta( $post_id, 'um_content_restriction', $restriction_meta );
|
348 |
-
} else {
|
349 |
-
delete_post_meta( $post_id, 'um_content_restriction' );
|
350 |
-
}
|
351 |
-
}
|
352 |
-
|
353 |
-
|
354 |
-
/**
|
355 |
-
*
|
356 |
-
*/
|
357 |
-
function um_category_access_fields_create() {
|
358 |
-
/**
|
359 |
-
* UM hook
|
360 |
-
*
|
361 |
-
* @type filter
|
362 |
-
* @title um_admin_category_access_settings_fields
|
363 |
-
* @description Settings fields for terms
|
364 |
-
* @input_vars
|
365 |
-
* [{"var":"$access_settings_fields","type":"array","desc":"Settings Fields"},
|
366 |
-
* {"var":"$data","type":"array","desc":"Settings Data"},
|
367 |
-
* {"var":"$screen","type":"string","desc":"Category Screen"}]
|
368 |
-
* @change_log
|
369 |
-
* ["Since: 2.0"]
|
370 |
-
* @usage add_filter( 'um_admin_category_access_settings_fields', 'function_name', 10, 3 );
|
371 |
-
* @example
|
372 |
-
* <?php
|
373 |
-
* add_filter( 'um_admin_category_access_settings_fields', 'my_admin_category_access_settings_fields', 10, 3 );
|
374 |
-
* function my_admin_category_access_settings_fields( $access_settings_fields, $data, $screen ) {
|
375 |
-
* // your code here
|
376 |
-
* $access_settings_fields[] = array(
|
377 |
-
* 'id' => 'my-field-key',
|
378 |
-
* 'type' => 'my-field-type',
|
379 |
-
* 'label' => __( 'My field Label', 'ultimate-member' ),
|
380 |
-
* 'description' => __( 'My Field Description', 'ultimate-member' ),
|
381 |
-
* 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
|
382 |
-
* );
|
383 |
-
* return $access_settings_fields;
|
384 |
-
* }
|
385 |
-
* ?>
|
386 |
-
*/
|
387 |
-
$fields = apply_filters( 'um_admin_category_access_settings_fields', array(
|
388 |
-
array(
|
389 |
-
'id' => '_um_custom_access_settings',
|
390 |
-
'type' => 'checkbox',
|
391 |
-
'label' => __( 'Restrict access to this term and its posts?', 'ultimate-member' ),
|
392 |
-
'description' => __( 'Activate content restriction for this term and its posts. Affects only posts that do not have individual Restriction Content settings', 'ultimate-member' ),
|
393 |
-
'value' => 0,
|
394 |
-
),
|
395 |
-
array(
|
396 |
-
'id' => '_um_accessible',
|
397 |
-
'type' => 'select',
|
398 |
-
'label' => __( 'Who can access this term and its posts?', 'ultimate-member' ),
|
399 |
-
'value' => '0',
|
400 |
-
'options' => array(
|
401 |
-
'0' => __( 'Everyone', 'ultimate-member' ),
|
402 |
-
'1' => __( 'Logged out users', 'ultimate-member' ),
|
403 |
-
'2' => __( 'Logged in users', 'ultimate-member' ),
|
404 |
-
),
|
405 |
-
'conditional' => array( '_um_custom_access_settings', '=', '1' ),
|
406 |
-
),
|
407 |
-
array(
|
408 |
-
'id' => '_um_access_roles',
|
409 |
-
'type' => 'multi_checkbox',
|
410 |
-
'label' => __( 'Select which roles can access this term and its posts', 'ultimate-member' ),
|
411 |
-
'description' => __( 'Leave empty if you want to display a term for all logged in users', 'ultimate-member' ),
|
412 |
-
'options' => UM()->roles()->get_roles( false ),
|
413 |
-
'columns' => 3,
|
414 |
-
'conditional' => array( '_um_accessible', '=', '2' ),
|
415 |
-
),
|
416 |
-
array(
|
417 |
-
'id' => '_um_access_hide_from_queries',
|
418 |
-
'type' => 'checkbox',
|
419 |
-
'label' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? __( 'Hide from queries', 'ultimate-member' ) : __( 'Would you like to display 404 error on the term\'s archive page and terms\' posts single pages when users haven\'t access?', 'ultimate-member' ),
|
420 |
-
'description' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? __( 'Exclude only from WP queries results', 'ultimate-member' ) : __( 'Recommended to be enabled. Restricted term\'s archive page and all terms\' posts will be hidden by exclusion from WP Query. The safest and most effective method that hides post and its comments from all requests, RSS feeds, etc. on your site', 'ultimate-member' ),
|
421 |
-
'value' => 1,
|
422 |
-
'conditional' => array( '_um_accessible', '!=', '0' ),
|
423 |
-
),
|
424 |
-
array(
|
425 |
-
'id' => '_um_noaccess_action',
|
426 |
-
'type' => 'select',
|
427 |
-
'label' => __( 'What happens when users without access try to view the term\'s post?', 'ultimate-member' ),
|
428 |
-
'description' => __( 'Action when users without access tries to view the term\'s post', 'ultimate-member' ),
|
429 |
-
'value' => '0',
|
430 |
-
'options' => array(
|
431 |
-
'0' => __( 'Show access restricted message', 'ultimate-member' ),
|
432 |
-
'1' => __( 'Redirect user', 'ultimate-member' ),
|
433 |
-
),
|
434 |
-
'conditional' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? array( '_um_accessible', '!=', '0' ) : array( '_um_access_hide_from_queries', '=', '0' ),
|
435 |
-
),
|
436 |
-
array(
|
437 |
-
'id' => '_um_restrict_by_custom_message',
|
438 |
-
'type' => 'select',
|
439 |
-
'label' => __( 'Restricted access message type', 'ultimate-member' ),
|
440 |
-
'description' => __( 'Would you like to use the global default message or apply a custom message to this term\'s post?', 'ultimate-member' ),
|
441 |
-
'value' => '0',
|
442 |
-
'options' => array(
|
443 |
-
'0' => __( 'Global default message', 'ultimate-member' ),
|
444 |
-
'1' => __( 'Custom message', 'ultimate-member' ),
|
445 |
-
),
|
446 |
-
'conditional' => array( '_um_noaccess_action', '=', '0' ),
|
447 |
-
),
|
448 |
-
array(
|
449 |
-
'id' => '_um_restrict_custom_message',
|
450 |
-
'type' => 'wp_editor',
|
451 |
-
'label' => __( 'Custom restricted access message', 'ultimate-member' ),
|
452 |
-
'description' => __( 'You may replace global restricted access message here', 'ultimate-member' ),
|
453 |
-
'value' => '',
|
454 |
-
'conditional' => array( '_um_restrict_by_custom_message', '=', '1' ),
|
455 |
-
),
|
456 |
-
array(
|
457 |
-
'id' => '_um_access_redirect',
|
458 |
-
'type' => 'select',
|
459 |
-
'label' => __( 'Where should users be redirected to?', 'ultimate-member' ),
|
460 |
-
'description' => __( 'Select redirect to page when user hasn\'t access to the term\'s post', 'ultimate-member' ),
|
461 |
-
'value' => '0',
|
462 |
-
'conditional' => array( '_um_noaccess_action', '=', '1' ),
|
463 |
-
'options' => array(
|
464 |
-
'0' => __( 'Login page', 'ultimate-member' ),
|
465 |
-
'1' => __( 'Custom URL', 'ultimate-member' ),
|
466 |
-
),
|
467 |
-
),
|
468 |
-
array(
|
469 |
-
'id' => '_um_access_redirect_url',
|
470 |
-
'type' => 'text',
|
471 |
-
'label' => __( 'Redirect URL', 'ultimate-member' ),
|
472 |
-
'description' => __( 'Set full URL where do you want to redirect the user', 'ultimate-member' ),
|
473 |
-
'value' => '',
|
474 |
-
'conditional' => array( '_um_access_redirect', '=', '1' ),
|
475 |
-
),
|
476 |
-
), array(), 'create' );
|
477 |
-
|
478 |
-
UM()->admin_forms(
|
479 |
-
array(
|
480 |
-
'class' => 'um-restrict-content um-third-column',
|
481 |
-
'prefix_id' => 'um_content_restriction',
|
482 |
-
'without_wrapper' => true,
|
483 |
-
'div_line' => true,
|
484 |
-
'fields' => $fields,
|
485 |
-
)
|
486 |
-
)->render_form();
|
487 |
-
|
488 |
-
wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' );
|
489 |
-
}
|
490 |
-
|
491 |
-
|
492 |
-
/**
|
493 |
-
* @param $term
|
494 |
-
*/
|
495 |
-
function um_category_access_fields_edit( $term ) {
|
496 |
-
$termID = $term->term_id;
|
497 |
-
|
498 |
-
$data = get_term_meta( $termID, 'um_content_restriction', true );
|
499 |
-
|
500 |
-
$_um_access_roles_value = array();
|
501 |
-
if ( ! empty( $data['_um_access_roles'] ) ) {
|
502 |
-
foreach ( $data['_um_access_roles'] as $key => $value ) {
|
503 |
-
if ( $value ) {
|
504 |
-
$_um_access_roles_value[] = $key;
|
505 |
-
}
|
506 |
-
}
|
507 |
-
}
|
508 |
-
|
509 |
-
/**
|
510 |
-
* UM hook
|
511 |
-
*
|
512 |
-
* @type filter
|
513 |
-
* @title um_admin_category_access_settings_fields
|
514 |
-
* @description Settings fields for terms
|
515 |
-
* @input_vars
|
516 |
-
* [{"var":"$access_settings_fields","type":"array","desc":"Settings Fields"},
|
517 |
-
* {"var":"$data","type":"array","desc":"Settings Data"},
|
518 |
-
* {"var":"$screen","type":"string","desc":"Category Screen"}]
|
519 |
-
* @change_log
|
520 |
-
* ["Since: 2.0"]
|
521 |
-
* @usage add_filter( 'um_admin_category_access_settings_fields', 'function_name', 10, 3 );
|
522 |
-
* @example
|
523 |
-
* <?php
|
524 |
-
* add_filter( 'um_admin_category_access_settings_fields', 'my_admin_category_access_settings_fields', 10, 3 );
|
525 |
-
* function my_admin_category_access_settings_fields( $access_settings_fields, $data, $screen ) {
|
526 |
-
* // your code here
|
527 |
-
* $access_settings_fields[] = array(
|
528 |
-
* 'id' => 'my-field-key',
|
529 |
-
* 'type' => 'my-field-type',
|
530 |
-
* 'label' => __( 'My field Label', 'ultimate-member' ),
|
531 |
-
* 'description' => __( 'My Field Description', 'ultimate-member' ),
|
532 |
-
* 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
|
533 |
-
* );
|
534 |
-
* return $access_settings_fields;
|
535 |
-
* }
|
536 |
-
* ?>
|
537 |
-
*/
|
538 |
-
$fields = apply_filters( 'um_admin_category_access_settings_fields', array(
|
539 |
-
array(
|
540 |
-
'id' => '_um_custom_access_settings',
|
541 |
-
'type' => 'checkbox',
|
542 |
-
'label' => __( 'Restrict access to this term and its posts?', 'ultimate-member' ),
|
543 |
-
'description' => __( 'Activate content restriction for this term and its posts. Affects only posts that do not have individual Restriction Content settings', 'ultimate-member' ),
|
544 |
-
'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
|
545 |
-
),
|
546 |
-
array(
|
547 |
-
'id' => '_um_accessible',
|
548 |
-
'type' => 'select',
|
549 |
-
'label' => __( 'Who can access this term and its posts?', 'ultimate-member' ),
|
550 |
-
'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : '0',
|
551 |
-
'options' => array(
|
552 |
-
'0' => __( 'Everyone', 'ultimate-member' ),
|
553 |
-
'1' => __( 'Logged out users', 'ultimate-member' ),
|
554 |
-
'2' => __( 'Logged in users', 'ultimate-member' ),
|
555 |
-
),
|
556 |
-
'conditional' => array( '_um_custom_access_settings', '=', '1' ),
|
557 |
-
),
|
558 |
-
array(
|
559 |
-
'id' => '_um_access_roles',
|
560 |
-
'type' => 'multi_checkbox',
|
561 |
-
'label' => __( 'Select which roles can access this term and its posts', 'ultimate-member' ),
|
562 |
-
'description' => __( 'Leave empty if you want to display a term for all logged in users', 'ultimate-member' ),
|
563 |
-
'value' => $_um_access_roles_value,
|
564 |
-
'options' => UM()->roles()->get_roles( false ),
|
565 |
-
'columns' => 3,
|
566 |
-
'conditional' => array( '_um_accessible', '=', '2' ),
|
567 |
-
),
|
568 |
-
array(
|
569 |
-
'id' => '_um_access_hide_from_queries',
|
570 |
-
'type' => 'checkbox',
|
571 |
-
'label' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? __( 'Hide from queries', 'ultimate-member' ) : __( 'Would you like to display 404 error on the term\'s archive page and terms\' posts single pages when users haven\'t access?', 'ultimate-member' ),
|
572 |
-
'description' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? __( 'Exclude only from WP queries results', 'ultimate-member' ) : __( 'Recommended to be enabled. Restricted term\'s archive page and all terms\' posts will be hidden by exclusion from WP Query. The safest and most effective method that hides post and its comments from all requests, RSS feeds, etc. on your site', 'ultimate-member' ),
|
573 |
-
'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '',
|
574 |
-
'conditional' => array( '_um_accessible', '!=', '0' ),
|
575 |
-
),
|
576 |
-
array(
|
577 |
-
'id' => '_um_noaccess_action',
|
578 |
-
'type' => 'select',
|
579 |
-
'label' => __( 'What happens when users without access try to view the term\'s post?', 'ultimate-member' ),
|
580 |
-
'description' => __( 'Action when users without access tries to view the term\'s post', 'ultimate-member' ),
|
581 |
-
'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : '0',
|
582 |
-
'options' => array(
|
583 |
-
'0' => __( 'Show access restricted message', 'ultimate-member' ),
|
584 |
-
'1' => __( 'Redirect user', 'ultimate-member' ),
|
585 |
-
),
|
586 |
-
'conditional' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? array( '_um_accessible', '!=', '0' ) : array( '_um_access_hide_from_queries', '=', '0' ),
|
587 |
-
),
|
588 |
-
array(
|
589 |
-
'id' => '_um_restrict_by_custom_message',
|
590 |
-
'type' => 'select',
|
591 |
-
'label' => __( 'Restricted access message type', 'ultimate-member' ),
|
592 |
-
'description' => __( 'Would you like to use the global default message or apply a custom message to this term\'s post?', 'ultimate-member' ),
|
593 |
-
'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0',
|
594 |
-
'options' => array(
|
595 |
-
'0' => __( 'Global default message', 'ultimate-member' ),
|
596 |
-
'1' => __( 'Custom message', 'ultimate-member' ),
|
597 |
-
),
|
598 |
-
'conditional' => array( '_um_noaccess_action', '=', '0' ),
|
599 |
-
),
|
600 |
-
array(
|
601 |
-
'id' => '_um_restrict_custom_message',
|
602 |
-
'type' => 'wp_editor',
|
603 |
-
'label' => __( 'Custom restricted access message', 'ultimate-member' ),
|
604 |
-
'description' => __( 'You may replace global restricted access message here', 'ultimate-member' ),
|
605 |
-
'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '',
|
606 |
-
'conditional' => array( '_um_restrict_by_custom_message', '=', '1' ),
|
607 |
-
),
|
608 |
-
array(
|
609 |
-
'id' => '_um_access_redirect',
|
610 |
-
'type' => 'select',
|
611 |
-
'label' => __( 'Where should users be redirected to?', 'ultimate-member' ),
|
612 |
-
'description' => __( 'Select redirect to page when user hasn\'t access to the term\'s post', 'ultimate-member' ),
|
613 |
-
'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0',
|
614 |
-
'options' => array(
|
615 |
-
'0' => __( 'Login page', 'ultimate-member' ),
|
616 |
-
'1' => __( 'Custom URL', 'ultimate-member' ),
|
617 |
-
),
|
618 |
-
'conditional' => array( '_um_noaccess_action', '=', '1' ),
|
619 |
-
),
|
620 |
-
array(
|
621 |
-
'id' => '_um_access_redirect_url',
|
622 |
-
'type' => 'text',
|
623 |
-
'label' => __( 'Redirect URL', 'ultimate-member' ),
|
624 |
-
'description' => __( 'Set full URL where do you want to redirect the user', 'ultimate-member' ),
|
625 |
-
'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '',
|
626 |
-
'conditional' => array( '_um_access_redirect', '=', '1' ),
|
627 |
-
),
|
628 |
-
), $data, 'edit' );
|
629 |
-
|
630 |
-
UM()->admin_forms(
|
631 |
-
array(
|
632 |
-
'class' => 'um-restrict-content um-third-column',
|
633 |
-
'prefix_id' => 'um_content_restriction',
|
634 |
-
'without_wrapper' => true,
|
635 |
-
'fields' => $fields,
|
636 |
-
)
|
637 |
-
)->render_form();
|
638 |
-
|
639 |
-
wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' );
|
640 |
-
}
|
641 |
-
|
642 |
-
|
643 |
-
/**
|
644 |
-
* @param $termID
|
645 |
-
*
|
646 |
-
* @return mixed
|
647 |
-
*/
|
648 |
-
function um_category_access_fields_save( $termID ) {
|
649 |
-
|
650 |
-
// validate nonce
|
651 |
-
if ( ! isset( $_REQUEST['um_admin_save_taxonomy_restrict_content_nonce'] ) || ! wp_verify_nonce( $_REQUEST['um_admin_save_taxonomy_restrict_content_nonce'], basename( __FILE__ ) ) ) {
|
652 |
-
return $termID;
|
653 |
-
}
|
654 |
-
|
655 |
-
// validate user
|
656 |
-
$term = get_term( $termID );
|
657 |
-
$taxonomy = get_taxonomy( $term->taxonomy );
|
658 |
-
|
659 |
-
if ( ! current_user_can( $taxonomy->cap->edit_terms, $termID ) ) {
|
660 |
-
return $termID;
|
661 |
-
}
|
662 |
-
|
663 |
-
if ( ! empty( $_REQUEST['um_content_restriction'] ) && is_array( $_REQUEST['um_content_restriction'] ) ) {
|
664 |
-
$restriction_meta = UM()->admin()->sanitize_term_restriction_meta( $_REQUEST['um_content_restriction'] );
|
665 |
-
|
666 |
-
update_term_meta( $termID, 'um_content_restriction', $restriction_meta );
|
667 |
-
} else {
|
668 |
-
delete_term_meta( $termID, 'um_content_restriction' );
|
669 |
-
}
|
670 |
-
|
671 |
-
return $termID;
|
672 |
-
}
|
673 |
-
|
674 |
-
|
675 |
-
/**
|
676 |
-
* Load a directory metabox
|
677 |
-
*
|
678 |
-
* @param $object
|
679 |
-
* @param $box
|
680 |
-
*/
|
681 |
-
function load_metabox_directory( $object, $box ) {
|
682 |
-
$box['id'] = str_replace( 'um-admin-form-', '', $box['id'] );
|
683 |
-
|
684 |
-
preg_match('#\{.*?\}#s', $box['id'], $matches );
|
685 |
-
|
686 |
-
if ( isset( $matches[0] ) ) {
|
687 |
-
$path = $matches[0];
|
688 |
-
$box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
|
689 |
-
} else {
|
690 |
-
$path = um_path;
|
691 |
-
}
|
692 |
-
|
693 |
-
$path = str_replace('{','', $path );
|
694 |
-
$path = str_replace('}','', $path );
|
695 |
-
|
696 |
-
|
697 |
-
include_once $path . 'includes/admin/templates/directory/'. $box['id'] . '.php';
|
698 |
-
if ( ! $this->directory_nonce_added ) {
|
699 |
-
$this->directory_nonce_added = true;
|
700 |
-
wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_directory_nonce' );
|
701 |
-
}
|
702 |
-
}
|
703 |
-
|
704 |
-
|
705 |
-
/**
|
706 |
-
* Load a role metabox
|
707 |
-
*
|
708 |
-
* @param $object
|
709 |
-
* @param $box
|
710 |
-
*/
|
711 |
-
function load_metabox_role( $object, $box ) {
|
712 |
-
global $post;
|
713 |
-
|
714 |
-
$box['id'] = str_replace( 'um-admin-form-', '', $box['id'] );
|
715 |
-
|
716 |
-
if ( $box['id'] == 'builder' ) {
|
717 |
-
UM()->builder()->form_id = get_the_ID();
|
718 |
-
}
|
719 |
-
|
720 |
-
preg_match('#\{.*?\}#s', $box['id'], $matches);
|
721 |
-
|
722 |
-
if ( isset($matches[0]) ){
|
723 |
-
$path = $matches[0];
|
724 |
-
$box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
|
725 |
-
} else {
|
726 |
-
$path = um_path;
|
727 |
-
}
|
728 |
-
|
729 |
-
$path = str_replace('{','', $path );
|
730 |
-
$path = str_replace('}','', $path );
|
731 |
-
|
732 |
-
include_once $path . 'includes/admin/templates/role/'. $box['id'] . '.php';
|
733 |
-
//wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_role_nonce' );
|
734 |
-
}
|
735 |
-
|
736 |
-
|
737 |
-
/**
|
738 |
-
* Load a form metabox
|
739 |
-
*
|
740 |
-
* @param $object
|
741 |
-
* @param $box
|
742 |
-
*/
|
743 |
-
function load_metabox_form( $object, $box ) {
|
744 |
-
global $post;
|
745 |
-
|
746 |
-
$box['id'] = str_replace( 'um-admin-form-','', $box['id'] );
|
747 |
-
|
748 |
-
if ( $box['id'] == 'builder' ) {
|
749 |
-
UM()->builder()->form_id = get_the_ID();
|
750 |
-
}
|
751 |
-
|
752 |
-
preg_match('#\{.*?\}#s', $box['id'], $matches);
|
753 |
-
|
754 |
-
if ( isset( $matches[0] ) ) {
|
755 |
-
$path = $matches[0];
|
756 |
-
$box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
|
757 |
-
} else {
|
758 |
-
$path = um_path;
|
759 |
-
}
|
760 |
-
|
761 |
-
$path = str_replace('{','', $path );
|
762 |
-
$path = str_replace('}','', $path );
|
763 |
-
|
764 |
-
include_once $path . 'includes/admin/templates/form/'. $box['id'] . '.php';
|
765 |
-
|
766 |
-
if ( ! $this->form_nonce_added ) {
|
767 |
-
$this->form_nonce_added = true;
|
768 |
-
wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_form_nonce' );
|
769 |
-
}
|
770 |
-
}
|
771 |
-
|
772 |
-
|
773 |
-
/**
|
774 |
-
* Load admin custom metabox
|
775 |
-
*
|
776 |
-
* @param $object
|
777 |
-
* @param $box
|
778 |
-
*/
|
779 |
-
function load_metabox_custom( $object, $box ) {
|
780 |
-
global $post;
|
781 |
-
|
782 |
-
$box['id'] = str_replace('um-admin-custom-','', $box['id']);
|
783 |
-
|
784 |
-
preg_match('#\{.*?\}#s', $box['id'], $matches);
|
785 |
-
|
786 |
-
if ( isset($matches[0]) ){
|
787 |
-
$path = $matches[0];
|
788 |
-
$box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
|
789 |
-
} else {
|
790 |
-
$path = um_path;
|
791 |
-
}
|
792 |
-
|
793 |
-
$path = str_replace('{','', $path );
|
794 |
-
$path = str_replace('}','', $path );
|
795 |
-
|
796 |
-
include_once $path . 'includes/admin/templates/'. $box['id'] . '.php';
|
797 |
-
if ( ! $this->custom_nonce_added ) {
|
798 |
-
$this->custom_nonce_added = true;
|
799 |
-
wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_custom_nonce' );
|
800 |
-
}
|
801 |
-
}
|
802 |
-
|
803 |
-
|
804 |
-
/**
|
805 |
-
* Add directory metabox
|
806 |
-
*/
|
807 |
-
function add_metabox_directory() {
|
808 |
-
add_meta_box( 'um-admin-form-general', __( 'General Options', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
|
809 |
-
add_meta_box( 'um-admin-form-sorting', __( 'Sorting', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
|
810 |
-
add_meta_box( 'um-admin-form-profile', __( 'Profile Card', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
|
811 |
-
add_meta_box( 'um-admin-form-search', __( 'Search Options', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
|
812 |
-
add_meta_box( 'um-admin-form-pagination', __( 'Results & Pagination', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
|
813 |
-
add_meta_box( 'um-admin-form-shortcode', __( 'Shortcode', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'side', 'default' );
|
814 |
-
add_meta_box( 'um-admin-form-appearance', __( 'Styling: General', 'ultimate-member' ), array( &$this, 'load_metabox_directory'), 'um_directory', 'side', 'default' );
|
815 |
-
}
|
816 |
-
|
817 |
-
|
818 |
-
/**
|
819 |
-
* Add role metabox
|
820 |
-
*/
|
821 |
-
function add_metabox_role() {
|
822 |
-
$callback = array( &$this, 'load_metabox_role' );
|
823 |
-
|
824 |
-
$roles_metaboxes = array(
|
825 |
-
array(
|
826 |
-
'id' => 'um-admin-form-admin-permissions',
|
827 |
-
'title' => __( 'Administrative Permissions', 'ultimate-member' ),
|
828 |
-
'callback' => $callback,
|
829 |
-
'screen' => 'um_role_meta',
|
830 |
-
'context' => 'normal',
|
831 |
-
'priority' => 'default'
|
832 |
-
),
|
833 |
-
array(
|
834 |
-
'id' => 'um-admin-form-general',
|
835 |
-
'title' => __( 'General Permissions', 'ultimate-member' ),
|
836 |
-
'callback' => $callback,
|
837 |
-
'screen' => 'um_role_meta',
|
838 |
-
'context' => 'normal',
|
839 |
-
'priority' => 'default'
|
840 |
-
),
|
841 |
-
array(
|
842 |
-
'id' => 'um-admin-form-profile',
|
843 |
-
'title' => __( 'Profile Access', 'ultimate-member' ),
|
844 |
-
'callback' => $callback,
|
845 |
-
'screen' => 'um_role_meta',
|
846 |
-
'context' => 'normal',
|
847 |
-
'priority' => 'default'
|
848 |
-
)
|
849 |
-
);
|
850 |
-
|
851 |
-
if ( ! isset( $_GET['id'] ) || 'administrator' !== sanitize_key( $_GET['id'] ) ) {
|
852 |
-
$roles_metaboxes[] = array(
|
853 |
-
'id' => 'um-admin-form-home',
|
854 |
-
'title' => __( 'Homepage Options', 'ultimate-member' ),
|
855 |
-
'callback' => $callback,
|
856 |
-
'screen' => 'um_role_meta',
|
857 |
-
'context' => 'normal',
|
858 |
-
'priority' => 'default'
|
859 |
-
);
|
860 |
-
}
|
861 |
-
|
862 |
-
$roles_metaboxes = array_merge( $roles_metaboxes, array(
|
863 |
-
array(
|
864 |
-
'id' => 'um-admin-form-register',
|
865 |
-
'title' => __( 'Registration Options', 'ultimate-member' ),
|
866 |
-
'callback' => $callback,
|
867 |
-
'screen' => 'um_role_meta',
|
868 |
-
'context' => 'normal',
|
869 |
-
'priority' => 'default'
|
870 |
-
),
|
871 |
-
array(
|
872 |
-
'id' => 'um-admin-form-login',
|
873 |
-
'title' => __( 'Login Options', 'ultimate-member' ),
|
874 |
-
'callback' => $callback,
|
875 |
-
'screen' => 'um_role_meta',
|
876 |
-
'context' => 'normal',
|
877 |
-
'priority' => 'default'
|
878 |
-
),
|
879 |
-
array(
|
880 |
-
'id' => 'um-admin-form-logout',
|
881 |
-
'title' => __( 'Logout Options', 'ultimate-member' ),
|
882 |
-
'callback' => $callback,
|
883 |
-
'screen' => 'um_role_meta',
|
884 |
-
'context' => 'normal',
|
885 |
-
'priority' => 'default'
|
886 |
-
),
|
887 |
-
array(
|
888 |
-
'id' => 'um-admin-form-delete',
|
889 |
-
'title' => __( 'Delete Options', 'ultimate-member' ),
|
890 |
-
'callback' => $callback,
|
891 |
-
'screen' => 'um_role_meta',
|
892 |
-
'context' => 'normal',
|
893 |
-
'priority' => 'default'
|
894 |
-
),
|
895 |
-
array(
|
896 |
-
'id' => 'um-admin-form-publish',
|
897 |
-
'title' => __( 'Publish', 'ultimate-member' ),
|
898 |
-
'callback' => $callback,
|
899 |
-
'screen' => 'um_role_meta',
|
900 |
-
'context' => 'side',
|
901 |
-
'priority' => 'default'
|
902 |
-
)
|
903 |
-
) );
|
904 |
-
|
905 |
-
/**
|
906 |
-
* UM hook
|
907 |
-
*
|
908 |
-
* @type filter
|
909 |
-
* @title um_admin_role_metaboxes
|
910 |
-
* @description Extend metaboxes at Add/Edit User Role
|
911 |
-
* @input_vars
|
912 |
-
* [{"var":"$roles_metaboxes","type":"array","desc":"Metaboxes at Add/Edit UM Role"}]
|
913 |
-
* @change_log
|
914 |
-
* ["Since: 2.0"]
|
915 |
-
* @usage add_filter( 'um_admin_role_metaboxes', 'function_name', 10, 1 );
|
916 |
-
* @example
|
917 |
-
* <?php
|
918 |
-
* add_filter( 'um_admin_role_metaboxes', 'my_admin_role_metaboxes', 10, 1 );
|
919 |
-
* function my_admin_role_metaboxes( $roles_metaboxes ) {
|
920 |
-
* // your code here
|
921 |
-
* $roles_metaboxes[] = array(
|
922 |
-
* 'id' => 'um-admin-form-your-custom',
|
923 |
-
* 'title' => __( 'My Roles Metabox', 'ultimate-member' ),
|
924 |
-
* 'callback' => 'my-metabox-callback',
|
925 |
-
* 'screen' => 'um_role_meta',
|
926 |
-
* 'context' => 'side',
|
927 |
-
* 'priority' => 'default'
|
928 |
-
* );
|
929 |
-
*
|
930 |
-
* return $roles_metaboxes;
|
931 |
-
* }
|
932 |
-
* ?>
|
933 |
-
*/
|
934 |
-
$roles_metaboxes = apply_filters( 'um_admin_role_metaboxes', $roles_metaboxes );
|
935 |
-
|
936 |
-
$wp_caps_metabox = false;
|
937 |
-
if ( ! empty( $_GET['id'] ) ) {
|
938 |
-
$data = get_option( 'um_role_' . sanitize_key( $_GET['id'] ) . '_meta' );
|
939 |
-
if ( ! empty( $data['_um_is_custom'] ) ) {
|
940 |
-
$wp_caps_metabox = true;
|
941 |
-
}
|
942 |
-
}
|
943 |
-
if ( 'add' == sanitize_key( $_GET['tab'] ) || $wp_caps_metabox ) {
|
944 |
-
$roles_metaboxes[] = array(
|
945 |
-
'id' => 'um-admin-form-wp-capabilities',
|
946 |
-
'title' => __( 'WP Capabilities', 'ultimate-member' ),
|
947 |
-
'callback' => $callback,
|
948 |
-
'screen' => 'um_role_meta',
|
949 |
-
'context' => 'normal',
|
950 |
-
'priority' => 'default'
|
951 |
-
);
|
952 |
-
}
|
953 |
-
|
954 |
-
|
955 |
-
foreach ( $roles_metaboxes as $metabox ) {
|
956 |
-
add_meta_box(
|
957 |
-
$metabox['id'],
|
958 |
-
$metabox['title'],
|
959 |
-
$metabox['callback'],
|
960 |
-
$metabox['screen'],
|
961 |
-
$metabox['context'],
|
962 |
-
$metabox['priority']
|
963 |
-
);
|
964 |
-
}
|
965 |
-
}
|
966 |
-
|
967 |
-
|
968 |
-
/**
|
969 |
-
* Add form metabox
|
970 |
-
*/
|
971 |
-
function add_metabox_form() {
|
972 |
-
|
973 |
-
add_meta_box( 'um-admin-form-mode', __( 'Select Form Type', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' );
|
974 |
-
add_meta_box( 'um-admin-form-builder', __( 'Form Builder', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' );
|
975 |
-
add_meta_box( 'um-admin-form-shortcode', __( 'Shortcode', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
|
976 |
-
|
977 |
-
add_meta_box( 'um-admin-form-register_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
|
978 |
-
|
979 |
-
/**
|
980 |
-
* UM hook
|
981 |
-
*
|
982 |
-
* @type action
|
983 |
-
* @title um_admin_custom_register_metaboxes
|
984 |
-
* @description Add custom metaboxes for register form
|
985 |
-
* @change_log
|
986 |
-
* ["Since: 2.0"]
|
987 |
-
* @usage add_action( 'um_admin_custom_register_metaboxes', 'function_name', 10 );
|
988 |
-
* @example
|
989 |
-
* <?php
|
990 |
-
* add_action( 'um_admin_custom_register_metaboxes', 'my_admin_custom_register_metaboxes', 10 );
|
991 |
-
* function my_admin_custom_register_metaboxes() {
|
992 |
-
* // your code here
|
993 |
-
* }
|
994 |
-
* ?>
|
995 |
-
*/
|
996 |
-
do_action( 'um_admin_custom_register_metaboxes' );
|
997 |
-
|
998 |
-
add_meta_box( 'um-admin-form-profile_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
|
999 |
-
add_meta_box( 'um-admin-form-profile_settings', __( 'User Meta', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
|
1000 |
-
|
1001 |
-
/**
|
1002 |
-
* UM hook
|
1003 |
-
*
|
1004 |
-
* @type action
|
1005 |
-
* @title um_admin_custom_profile_metaboxes
|
1006 |
-
* @description Add custom metaboxes for profile form
|
1007 |
-
* @change_log
|
1008 |
-
* ["Since: 2.0"]
|
1009 |
-
* @usage add_action( 'um_admin_custom_profile_metaboxes', 'function_name', 10 );
|
1010 |
-
* @example
|
1011 |
-
* <?php
|
1012 |
-
* add_action( 'um_admin_custom_profile_metaboxes', 'my_admin_custom_profile_metaboxes', 10 );
|
1013 |
-
* function my_admin_custom_profile_metaboxes() {
|
1014 |
-
* // your code here
|
1015 |
-
* }
|
1016 |
-
* ?>
|
1017 |
-
*/
|
1018 |
-
do_action( 'um_admin_custom_profile_metaboxes' );
|
1019 |
-
|
1020 |
-
add_meta_box( 'um-admin-form-login_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
|
1021 |
-
add_meta_box( 'um-admin-form-login_settings', __( 'Options', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
|
1022 |
-
|
1023 |
-
/**
|
1024 |
-
* UM hook
|
1025 |
-
*
|
1026 |
-
* @type action
|
1027 |
-
* @title um_admin_custom_login_metaboxes
|
1028 |
-
* @description Add custom metaboxes for login form
|
1029 |
-
* @change_log
|
1030 |
-
* ["Since: 2.0"]
|
1031 |
-
* @usage add_action( 'um_admin_custom_login_metaboxes', 'function_name', 10 );
|
1032 |
-
* @example
|
1033 |
-
* <?php
|
1034 |
-
* add_action( 'um_admin_custom_login_metaboxes', 'my_admin_custom_login_metaboxes', 10 );
|
1035 |
-
* function my_admin_custom_login_metaboxes() {
|
1036 |
-
* // your code here
|
1037 |
-
* }
|
1038 |
-
* ?>
|
1039 |
-
*/
|
1040 |
-
do_action( 'um_admin_custom_login_metaboxes' );
|
1041 |
-
}
|
1042 |
-
|
1043 |
-
|
1044 |
-
/**
|
1045 |
-
* Save directory metabox
|
1046 |
-
*
|
1047 |
-
* @param $post_id
|
1048 |
-
* @param $post
|
1049 |
-
*/
|
1050 |
-
function save_metabox_directory( $post_id, $post ) {
|
1051 |
-
global $wpdb;
|
1052 |
-
|
1053 |
-
// validate nonce
|
1054 |
-
if ( ! isset( $_POST['um_admin_save_metabox_directory_nonce'] ) ||
|
1055 |
-
! wp_verify_nonce( $_POST['um_admin_save_metabox_directory_nonce'], basename( __FILE__ ) ) ) {
|
1056 |
-
return;
|
1057 |
-
}
|
1058 |
-
|
1059 |
-
// validate post type
|
1060 |
-
if ( $post->post_type != 'um_directory' ) {
|
1061 |
-
return;
|
1062 |
-
}
|
1063 |
-
|
1064 |
-
// validate user
|
1065 |
-
$post_type = get_post_type_object( $post->post_type );
|
1066 |
-
if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
|
1067 |
-
return;
|
1068 |
-
}
|
1069 |
-
|
1070 |
-
$where = array( 'ID' => $post_id );
|
1071 |
-
|
1072 |
-
if ( empty( $_POST['post_title'] ) ) {
|
1073 |
-
$_POST['post_title'] = sprintf( __( 'Directory #%s', 'ultimate-member' ), $post_id );
|
1074 |
-
}
|
1075 |
-
|
1076 |
-
$wpdb->update( $wpdb->posts, array( 'post_title' => sanitize_text_field( $_POST['post_title'] ) ), $where );
|
1077 |
-
|
1078 |
-
do_action( 'um_before_member_directory_save', $post_id );
|
1079 |
-
|
1080 |
-
// save
|
1081 |
-
delete_post_meta( $post_id, '_um_roles' );
|
1082 |
-
delete_post_meta( $post_id, '_um_tagline_fields' );
|
1083 |
-
delete_post_meta( $post_id, '_um_reveal_fields' );
|
1084 |
-
delete_post_meta( $post_id, '_um_search_fields' );
|
1085 |
-
delete_post_meta( $post_id, '_um_roles_can_search' );
|
1086 |
-
delete_post_meta( $post_id, '_um_roles_can_filter' );
|
1087 |
-
delete_post_meta( $post_id, '_um_show_these_users' );
|
1088 |
-
delete_post_meta( $post_id, '_um_exclude_these_users' );
|
1089 |
-
|
1090 |
-
delete_post_meta( $post_id, '_um_search_filters' );
|
1091 |
-
delete_post_meta( $post_id, '_um_search_filters_gmt' );
|
1092 |
-
|
1093 |
-
delete_post_meta( $post_id, '_um_sorting_fields' );
|
1094 |
-
|
1095 |
-
//save metadata
|
1096 |
-
$metadata = UM()->admin()->sanitize_member_directory_meta( $_POST['um_metadata'] );
|
1097 |
-
foreach ( $metadata as $k => $v ) {
|
1098 |
-
|
1099 |
-
if ( $k == '_um_show_these_users' && trim( $v ) ) {
|
1100 |
-
$v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
|
1101 |
-
}
|
1102 |
-
|
1103 |
-
if ( $k == '_um_exclude_these_users' && trim( $v ) ) {
|
1104 |
-
$v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
|
1105 |
-
}
|
1106 |
-
|
1107 |
-
if ( strstr( $k, '_um_' ) ) {
|
1108 |
-
|
1109 |
-
if ( $k === '_um_is_default' ) {
|
1110 |
-
|
1111 |
-
$mode = UM()->query()->get_attr( 'mode', $post_id );
|
1112 |
-
|
1113 |
-
if ( ! empty( $mode ) ) {
|
1114 |
-
|
1115 |
-
$posts = $wpdb->get_col(
|
1116 |
-
"SELECT post_id
|
1117 |
-
FROM {$wpdb->postmeta}
|
1118 |
-
WHERE meta_key = '_um_mode' AND
|
1119 |
-
meta_value = 'directory'"
|
1120 |
-
);
|
1121 |
-
|
1122 |
-
foreach ( $posts as $p_id ) {
|
1123 |
-
delete_post_meta( $p_id, '_um_is_default' );
|
1124 |
-
}
|
1125 |
-
|
1126 |
-
}
|
1127 |
-
|
1128 |
-
}
|
1129 |
-
|
1130 |
-
$v = apply_filters( 'um_member_directory_meta_value_before_save', $v, $k, $post_id );
|
1131 |
-
|
1132 |
-
update_post_meta( $post_id, $k, $v );
|
1133 |
-
|
1134 |
-
}
|
1135 |
-
}
|
1136 |
-
|
1137 |
-
update_post_meta( $post_id, '_um_search_filters_gmt', (int) $_POST['um-gmt-offset'] );
|
1138 |
-
}
|
1139 |
-
|
1140 |
-
|
1141 |
-
/**
|
1142 |
-
* Save form metabox
|
1143 |
-
*
|
1144 |
-
* @param $post_id
|
1145 |
-
* @param $post
|
1146 |
-
*/
|
1147 |
-
function save_metabox_form( $post_id, $post ) {
|
1148 |
-
global $wpdb;
|
1149 |
-
|
1150 |
-
// validate nonce
|
1151 |
-
if ( ! isset( $_POST['um_admin_save_metabox_form_nonce'] ) ||
|
1152 |
-
! wp_verify_nonce( $_POST['um_admin_save_metabox_form_nonce'], basename( __FILE__ ) ) ) {
|
1153 |
-
return;
|
1154 |
-
}
|
1155 |
-
|
1156 |
-
// validate post type
|
1157 |
-
if ( $post->post_type != 'um_form' ) {
|
1158 |
-
return;
|
1159 |
-
}
|
1160 |
-
|
1161 |
-
// validate user
|
1162 |
-
$post_type = get_post_type_object( $post->post_type );
|
1163 |
-
if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
|
1164 |
-
return;
|
1165 |
-
}
|
1166 |
-
|
1167 |
-
$where = array( 'ID' => $post_id );
|
1168 |
-
if ( empty( $_POST['post_title'] ) ) {
|
1169 |
-
$_POST['post_title'] = sprintf( __( 'Form #%s', 'ultimate-member' ), $post_id );
|
1170 |
-
}
|
1171 |
-
$wpdb->update( $wpdb->posts, array( 'post_title' => sanitize_text_field( $_POST['post_title'] ) ), $where );
|
1172 |
-
|
1173 |
-
// save
|
1174 |
-
delete_post_meta( $post_id, '_um_profile_metafields' );
|
1175 |
-
|
1176 |
-
$form_meta = UM()->admin()->sanitize_form_meta( $_POST['form'] );
|
1177 |
-
|
1178 |
-
foreach ( $form_meta as $k => $v ) {
|
1179 |
-
if ( strstr( $k, '_um_' ) ) {
|
1180 |
-
if ( $k === '_um_is_default' ) {
|
1181 |
-
$mode = UM()->query()->get_attr( 'mode', $post_id );
|
1182 |
-
if ( ! empty( $mode ) ) {
|
1183 |
-
$posts = $wpdb->get_col( $wpdb->prepare(
|
1184 |
-
"SELECT post_id
|
1185 |
-
FROM {$wpdb->postmeta}
|
1186 |
-
WHERE meta_key = '_um_mode' AND
|
1187 |
-
meta_value = %s",
|
1188 |
-
$mode
|
1189 |
-
) );
|
1190 |
-
foreach ( $posts as $p_id ) {
|
1191 |
-
delete_post_meta( $p_id, '_um_is_default' );
|
1192 |
-
}
|
1193 |
-
}
|
1194 |
-
}
|
1195 |
-
|
1196 |
-
update_post_meta( $post_id, $k, $v );
|
1197 |
-
}
|
1198 |
-
}
|
1199 |
-
|
1200 |
-
}
|
1201 |
-
|
1202 |
-
|
1203 |
-
/**
|
1204 |
-
* Load modal content
|
1205 |
-
*/
|
1206 |
-
function load_modal_content() {
|
1207 |
-
$screen = get_current_screen();
|
1208 |
-
|
1209 |
-
if ( isset( $screen->id ) && strstr( $screen->id, 'um_form' ) ) {
|
1210 |
-
foreach ( glob( um_path . 'includes/admin/templates/modal/forms/*.php' ) as $modal_content ) {
|
1211 |
-
include_once $modal_content;
|
1212 |
-
}
|
1213 |
-
}
|
1214 |
-
|
1215 |
-
if ( $this->init_icon ) {
|
1216 |
-
include_once um_path . 'includes/admin/templates/modal/forms/fonticons.php';
|
1217 |
-
}
|
1218 |
-
|
1219 |
-
if ( $screen->id == 'users' ) {
|
1220 |
-
include_once um_path . 'includes/admin/templates/modal/dynamic_registration_preview.php';
|
1221 |
-
}
|
1222 |
-
|
1223 |
-
// needed on forms only
|
1224 |
-
if ( ! isset( $this->is_loaded ) && isset( $screen->id ) && strstr( $screen->id, 'um_form' ) ) {
|
1225 |
-
$settings['textarea_rows'] = 8;
|
1226 |
-
|
1227 |
-
echo '<div class="um-hidden-editor-edit" style="display:none;">';
|
1228 |
-
wp_editor( '', 'um_editor_edit', $settings );
|
1229 |
-
echo '</div>';
|
1230 |
-
|
1231 |
-
echo '<div class="um-hidden-editor-new" style="display:none;">';
|
1232 |
-
wp_editor( '', 'um_editor_new', $settings );
|
1233 |
-
echo '</div>';
|
1234 |
-
|
1235 |
-
$this->is_loaded = true;
|
1236 |
-
}
|
1237 |
-
}
|
1238 |
-
|
1239 |
-
|
1240 |
-
/**
|
1241 |
-
* Show field input for edit at modal field
|
1242 |
-
*
|
1243 |
-
* @param $attribute
|
1244 |
-
* @param null $form_id
|
1245 |
-
* @param array $field_args
|
1246 |
-
*/
|
1247 |
-
function field_input( $attribute, $form_id = null, $field_args = array() ) {
|
1248 |
-
|
1249 |
-
if ( $this->in_edit == true ) { // we're editing a field
|
1250 |
-
$real_attr = substr( $attribute, 1 );
|
1251 |
-
$this->edit_mode_value = isset( $this->edit_array[ $real_attr ] ) ? $this->edit_array[ $real_attr ] : null;
|
1252 |
-
}
|
1253 |
-
|
1254 |
-
switch ( $attribute ) {
|
1255 |
-
|
1256 |
-
default:
|
1257 |
-
|
1258 |
-
/**
|
1259 |
-
* UM hook
|
1260 |
-
*
|
1261 |
-
* @type action
|
1262 |
-
* @title um_admin_field_edit_hook{$attribute}
|
1263 |
-
* @description Integration for 3-d party fields at wp-admin
|
1264 |
-
* @input_vars
|
1265 |
-
* [{"var":"$edit_mode_value","type":"string","desc":"Post ID"}]
|
1266 |
-
* @change_log
|
1267 |
-
* ["Since: 2.0"]
|
1268 |
-
* @usage add_action( 'um_admin_field_edit_hook{$attribute}', 'function_name', 10, 1 );
|
1269 |
-
* @example
|
1270 |
-
* <?php
|
1271 |
-
* add_action( 'um_admin_field_edit_hook{$attribute}', 'my_admin_field_edit', 10, 1 );
|
1272 |
-
* function my_admin_field_edit( $edit_mode_value ) {
|
1273 |
-
* // your code here
|
1274 |
-
* }
|
1275 |
-
* ?>
|
1276 |
-
*/
|
1277 |
-
do_action( "um_admin_field_edit_hook{$attribute}", $this->edit_mode_value, $form_id, $this->edit_array );
|
1278 |
-
|
1279 |
-
break;
|
1280 |
-
|
1281 |
-
case '_visibility':
|
1282 |
-
?>
|
1283 |
-
|
1284 |
-
<p><label for="_visibility"><?php _e( 'Visibility', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select where this field should appear. This option should only be changed on the profile form and allows you to show a field in one mode only (edit or view) or in both modes.','ultimate-member' ) ); ?></label>
|
1285 |
-
<select name="_visibility" id="_visibility" style="width: 100%">
|
1286 |
-
<option value="all" <?php selected( 'all', $this->edit_mode_value ); ?>><?php _e( 'View everywhere', 'ultimate-member' ) ?></option>
|
1287 |
-
<option value="edit" <?php selected( 'edit', $this->edit_mode_value ); ?>><?php _e( 'Edit mode only', 'ultimate-member' ) ?></option>
|
1288 |
-
<option value="view" <?php selected( 'view', $this->edit_mode_value ); ?>><?php _e( 'View mode only', 'ultimate-member' ) ?></option>
|
1289 |
-
</select>
|
1290 |
-
</p>
|
1291 |
-
|
1292 |
-
<?php
|
1293 |
-
break;
|
1294 |
-
|
1295 |
-
case '_conditional_action':
|
1296 |
-
case '_conditional_action1':
|
1297 |
-
case '_conditional_action2':
|
1298 |
-
case '_conditional_action3':
|
1299 |
-
case '_conditional_action4':
|
1300 |
-
?>
|
1301 |
-
|
1302 |
-
<p>
|
1303 |
-
<select name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" style="width: 90px">
|
1304 |
-
|
1305 |
-
<option></option>
|
1306 |
-
|
1307 |
-
<?php $actions = array( 'show', 'hide' );
|
1308 |
-
foreach ( $actions as $action ) { ?>
|
1309 |
-
|
1310 |
-
<option value="<?php echo esc_attr( $action ); ?>" <?php selected( $action, $this->edit_mode_value ); ?>><?php echo $action; ?></option>
|
1311 |
-
|
1312 |
-
<?php } ?>
|
1313 |
-
|
1314 |
-
</select>
|
1315 |
-
|
1316 |
-
<?php _e( 'If' ); ?>
|
1317 |
-
</p>
|
1318 |
-
|
1319 |
-
<?php
|
1320 |
-
break;
|
1321 |
-
|
1322 |
-
case '_conditional_field':
|
1323 |
-
case '_conditional_field1':
|
1324 |
-
case '_conditional_field2':
|
1325 |
-
case '_conditional_field3':
|
1326 |
-
case '_conditional_field4':
|
1327 |
-
?>
|
1328 |
-
|
1329 |
-
<p>
|
1330 |
-
<select name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" style="width: 150px">
|
1331 |
-
|
1332 |
-
<option></option>
|
1333 |
-
|
1334 |
-
<?php $fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
1335 |
-
|
1336 |
-
foreach ( $fields as $key => $array ) {
|
1337 |
-
if ( isset( $array['title'] ) &&
|
1338 |
-
( ! isset( $this->edit_array['metakey'] ) || $key != $this->edit_array['metakey'] ) ) { ?>
|
1339 |
-
|
1340 |
-
<option value="<?php echo esc_attr( $key ) ?>" <?php selected( $key, $this->edit_mode_value ) ?>><?php echo $array['title'] ?></option>
|
1341 |
-
|
1342 |
-
<?php }
|
1343 |
-
} ?>
|
1344 |
-
|
1345 |
-
</select>
|
1346 |
-
</p>
|
1347 |
-
|
1348 |
-
<?php
|
1349 |
-
break;
|
1350 |
-
|
1351 |
-
case '_conditional_operator':
|
1352 |
-
case '_conditional_operator1':
|
1353 |
-
case '_conditional_operator2':
|
1354 |
-
case '_conditional_operator3':
|
1355 |
-
case '_conditional_operator4':
|
1356 |
-
?>
|
1357 |
-
|
1358 |
-
<p>
|
1359 |
-
<select name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" style="width: 150px">
|
1360 |
-
|
1361 |
-
<option></option>
|
1362 |
-
|
1363 |
-
<?php $operators = array(
|
1364 |
-
'empty',
|
1365 |
-
'not empty',
|
1366 |
-
'equals to',
|
1367 |
-
'not equals',
|
1368 |
-
'greater than',
|
1369 |
-
'less than',
|
1370 |
-
'contains'
|
1371 |
-
);
|
1372 |
-
|
1373 |
-
foreach ( $operators as $operator ) { ?>
|
1374 |
-
|
1375 |
-
<option value="<?php echo esc_attr( $operator ); ?>" <?php selected( $operator, $this->edit_mode_value ); ?>><?php echo $operator; ?></option>
|
1376 |
-
|
1377 |
-
<?php } ?>
|
1378 |
-
|
1379 |
-
</select>
|
1380 |
-
</p>
|
1381 |
-
|
1382 |
-
<?php
|
1383 |
-
break;
|
1384 |
-
|
1385 |
-
case '_conditional_value':
|
1386 |
-
case '_conditional_value1':
|
1387 |
-
case '_conditional_value2':
|
1388 |
-
case '_conditional_value3':
|
1389 |
-
case '_conditional_value4':
|
1390 |
-
?>
|
1391 |
-
|
1392 |
-
<p>
|
1393 |
-
<input type="text" name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" value="<?php echo isset( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" placeholder="<?php esc_attr_e( 'Value', 'ultimate-member' ); ?>" style="width: 150px!important;position: relative;top: -1px;" />
|
1394 |
-
</p>
|
1395 |
-
|
1396 |
-
<?php
|
1397 |
-
break;
|
1398 |
-
|
1399 |
-
case '_validate':
|
1400 |
-
?>
|
1401 |
-
|
1402 |
-
<p><label for="_validate"><?php _e( 'Validate', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Does this field require a special validation', 'ultimate-member' ) ); ?></label>
|
1403 |
-
<select name="_validate" id="_validate" data-placeholder="<?php esc_attr_e( 'Select a validation type...', 'ultimate-member' ) ?>" class="um-adm-conditional" data-cond1="custom" data-cond1-show="_custom_validate" style="width: 100%">
|
1404 |
-
|
1405 |
-
<option value="" <?php selected( '', $this->edit_mode_value ); ?>></option>
|
1406 |
-
|
1407 |
-
<?php foreach( UM()->builtin()->validation_types() as $key => $name ) { ?>
|
1408 |
-
<?php
|
1409 |
-
/**
|
1410 |
-
* UM hook
|
1411 |
-
*
|
1412 |
-
* @type filter
|
1413 |
-
* @title um_builtin_validation_types_continue_loop
|
1414 |
-
* @description Builtin Validation Types
|
1415 |
-
* @input_vars
|
1416 |
-
* [{"var":"$continue","type":"bool","desc":"Validate?"},
|
1417 |
-
* {"var":"$key","type":"string","desc":"Field Key"},
|
1418 |
-
* {"var":"$form_id","type":"int","desc":"Form ID"},
|
1419 |
-
* {"var":"$field_args","type":"array","desc":"Field Settings"}]
|
1420 |
-
* @change_log
|
1421 |
-
* ["Since: 2.0"]
|
1422 |
-
* @usage add_filter( 'um_builtin_validation_types_continue_loop', 'function_name', 10, 4 );
|
1423 |
-
* @example
|
1424 |
-
* <?php
|
1425 |
-
* add_filter( 'um_builtin_validation_types_continue_loop', 'my_builtin_validation_types', 10, 4 );
|
1426 |
-
* function my_builtin_validation_types( $continue, $key, $form_id, $field_args ) {
|
1427 |
-
* // your code here
|
1428 |
-
* return $continue;
|
1429 |
-
* }
|
1430 |
-
* ?>
|
1431 |
-
*/
|
1432 |
-
$continue = apply_filters( "um_builtin_validation_types_continue_loop", true, $key, $form_id, $field_args );
|
1433 |
-
if ( $continue ) { ?>
|
1434 |
-
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $this->edit_mode_value ); ?>><?php echo $name; ?></option>
|
1435 |
-
<?php } ?>
|
1436 |
-
<?php } ?>
|
1437 |
-
|
1438 |
-
</select>
|
1439 |
-
</p>
|
1440 |
-
|
1441 |
-
<?php
|
1442 |
-
break;
|
1443 |
-
|
1444 |
-
case '_custom_validate':
|
1445 |
-
?>
|
1446 |
-
|
1447 |
-
<p class="_custom_validate"><label for="_custom_validate"><?php _e( 'Custom Action', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to apply your custom validation, you can use action hooks to add custom validation. Please refer to documentation for further details.', 'ultimate-member' ) ); ?></label>
|
1448 |
-
<input type="text" name="_custom_validate" id="_custom_validate" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1449 |
-
</p>
|
1450 |
-
|
1451 |
-
<?php
|
1452 |
-
break;
|
1453 |
-
|
1454 |
-
case '_icon':
|
1455 |
-
|
1456 |
-
if ( $this->set_field_type == 'row' ) {
|
1457 |
-
$back = 'UM_edit_row';
|
1458 |
-
|
1459 |
-
?>
|
1460 |
-
|
1461 |
-
<p class="_heading_text"><label for="_icon"><?php _e( 'Icon', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field.', 'ultimate-member' ) ); ?></label>
|
1462 |
-
|
1463 |
-
<a href="javascript:void(0);" class="button" data-modal="UM_fonticons" data-modal-size="normal" data-dynamic-content="um_admin_fonticon_selector" data-arg1="" data-arg2="" data-back="<?php echo esc_attr( $back ); ?>"><?php _e( 'Choose Icon', 'ultimate-member' ) ?></a>
|
1464 |
-
|
1465 |
-
<span class="um-admin-icon-value"><?php if ( $this->edit_mode_value ) { ?><i class="<?php echo $this->edit_mode_value; ?>"></i><?php } else { ?><?php _e( 'No Icon', 'ultimate-member' ) ?><?php } ?></span>
|
1466 |
-
|
1467 |
-
<input type="hidden" name="_icon" id="_icon" value="<?php echo (isset( $this->edit_mode_value ) ) ? $this->edit_mode_value : ''; ?>" />
|
1468 |
-
|
1469 |
-
<?php if ( $this->edit_mode_value ) { ?>
|
1470 |
-
<span class="um-admin-icon-clear show"><i class="um-icon-android-cancel"></i></span>
|
1471 |
-
<?php } else { ?>
|
1472 |
-
<span class="um-admin-icon-clear"><i class="um-icon-android-cancel"></i></span>
|
1473 |
-
<?php } ?>
|
1474 |
-
|
1475 |
-
</p>
|
1476 |
-
|
1477 |
-
<?php } else {
|
1478 |
-
|
1479 |
-
if ( $this->in_edit ) {
|
1480 |
-
$back = 'UM_edit_field';
|
1481 |
-
} else {
|
1482 |
-
$back = 'UM_add_field';
|
1483 |
-
}
|
1484 |
-
|
1485 |
-
?>
|
1486 |
-
|
1487 |
-
<div class="um-admin-tri">
|
1488 |
-
|
1489 |
-
<p><label for="_icon"><?php _e( 'Icon', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field.', 'ultimate-member' ) ); ?></label>
|
1490 |
-
|
1491 |
-
<a href="javascript:void(0);" class="button" data-modal="UM_fonticons" data-modal-size="normal" data-dynamic-content="um_admin_fonticon_selector" data-arg1="" data-arg2="" data-back="<?php echo esc_attr( $back ); ?>"><?php _e( 'Choose Icon', 'ultimate-member' ) ?></a>
|
1492 |
-
|
1493 |
-
<span class="um-admin-icon-value"><?php if ( $this->edit_mode_value ) { ?><i class="<?php echo $this->edit_mode_value; ?>"></i><?php } else { ?><?php _e( 'No Icon', 'ultimate-member' ) ?><?php } ?></span>
|
1494 |
-
|
1495 |
-
<input type="hidden" name="_icon" id="_icon" value="<?php echo (isset( $this->edit_mode_value ) ) ? $this->edit_mode_value : ''; ?>" />
|
1496 |
-
|
1497 |
-
<?php if ( $this->edit_mode_value ) { ?>
|
1498 |
-
<span class="um-admin-icon-clear show"><i class="um-icon-android-cancel"></i></span>
|
1499 |
-
<?php } else { ?>
|
1500 |
-
<span class="um-admin-icon-clear"><i class="um-icon-android-cancel"></i></span>
|
1501 |
-
<?php } ?>
|
1502 |
-
|
1503 |
-
</p>
|
1504 |
-
|
1505 |
-
</div>
|
1506 |
-
|
1507 |
-
<?php
|
1508 |
-
|
1509 |
-
}
|
1510 |
-
|
1511 |
-
break;
|
1512 |
-
|
1513 |
-
case '_css_class':
|
1514 |
-
?>
|
1515 |
-
|
1516 |
-
<p><label for="_css_class"><?php _e( 'CSS Class', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Specify a custom CSS class to be applied to this element', 'ultimate-member' ) ); ?></label>
|
1517 |
-
<input type="text" name="_css_class" id="_css_class" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1518 |
-
</p>
|
1519 |
-
|
1520 |
-
<?php
|
1521 |
-
break;
|
1522 |
-
|
1523 |
-
case '_width':
|
1524 |
-
?>
|
1525 |
-
|
1526 |
-
<p><label for="_width"><?php _e( 'Thickness (in pixels)', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the width in pixels, e.g. 4 or 2, etc', 'ultimate-member' ) ); ?></label>
|
1527 |
-
<input type="text" name="_width" id="_width" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 4; ?>" />
|
1528 |
-
</p>
|
1529 |
-
|
1530 |
-
<?php
|
1531 |
-
break;
|
1532 |
-
|
1533 |
-
case '_divider_text':
|
1534 |
-
?>
|
1535 |
-
|
1536 |
-
<p><label for="_divider_text"><?php _e( 'Optional Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Optional text to include with the divider', 'ultimate-member' ) ); ?></label>
|
1537 |
-
<input type="text" name="_divider_text" id="_divider_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1538 |
-
</p>
|
1539 |
-
|
1540 |
-
<?php
|
1541 |
-
break;
|
1542 |
-
|
1543 |
-
case '_padding':
|
1544 |
-
?>
|
1545 |
-
|
1546 |
-
<p><label for="_padding"><?php _e( 'Padding', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set padding for this section', 'ultimate-member' ) ); ?></label>
|
1547 |
-
<input type="text" name="_padding" id="_padding" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px 0px 0px 0px'; ?>" />
|
1548 |
-
</p>
|
1549 |
-
|
1550 |
-
<?php
|
1551 |
-
break;
|
1552 |
-
|
1553 |
-
case '_margin':
|
1554 |
-
?>
|
1555 |
-
|
1556 |
-
<p><label for="_margin"><?php _e( 'Margin', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set margin for this section', 'ultimate-member' ) ); ?></label>
|
1557 |
-
<input type="text" name="_margin" id="_margin" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px 0px 30px 0px'; ?>" />
|
1558 |
-
</p>
|
1559 |
-
|
1560 |
-
<?php
|
1561 |
-
break;
|
1562 |
-
|
1563 |
-
case '_border':
|
1564 |
-
?>
|
1565 |
-
|
1566 |
-
<p><label for="_border"><?php _e( 'Border', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set border for this section', 'ultimate-member' ) ); ?></label>
|
1567 |
-
<input type="text" name="_border" id="_border" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px 0px 0px 0px'; ?>" />
|
1568 |
-
</p>
|
1569 |
-
|
1570 |
-
<?php
|
1571 |
-
break;
|
1572 |
-
|
1573 |
-
case '_borderstyle':
|
1574 |
-
?>
|
1575 |
-
|
1576 |
-
<p><label for="_borderstyle"><?php _e( 'Style', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose the border style', 'ultimate-member' ) ); ?></label>
|
1577 |
-
<select name="_borderstyle" id="_borderstyle" style="width: 100%">
|
1578 |
-
<option value="solid" <?php selected( 'solid', $this->edit_mode_value ); ?>><?php _e( 'Solid', 'ultimate-member' ) ?></option>
|
1579 |
-
<option value="dotted" <?php selected( 'dotted', $this->edit_mode_value ); ?>><?php _e( 'Dotted', 'ultimate-member' ) ?></option>
|
1580 |
-
<option value="dashed" <?php selected( 'dashed', $this->edit_mode_value ); ?>><?php _e( 'Dashed', 'ultimate-member' ) ?></option>
|
1581 |
-
<option value="double" <?php selected( 'double', $this->edit_mode_value ); ?>><?php _e( 'Double', 'ultimate-member' ) ?></option>
|
1582 |
-
</select>
|
1583 |
-
</p>
|
1584 |
-
|
1585 |
-
<?php
|
1586 |
-
break;
|
1587 |
-
|
1588 |
-
case '_borderradius':
|
1589 |
-
?>
|
1590 |
-
|
1591 |
-
<p><label for="_borderradius"><?php _e( 'Border Radius', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Rounded corners can be applied by setting a pixels value here. e.g. 5px', 'ultimate-member' ) ); ?></label>
|
1592 |
-
<input type="text" name="_borderradius" id="_borderradius" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px'; ?>" />
|
1593 |
-
</p>
|
1594 |
-
|
1595 |
-
<?php
|
1596 |
-
break;
|
1597 |
-
|
1598 |
-
case '_bordercolor':
|
1599 |
-
?>
|
1600 |
-
|
1601 |
-
<p><label for="_bordercolor"><?php _e( 'Border Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Give a color to this border', 'ultimate-member' ) ); ?></label>
|
1602 |
-
<input type="text" name="_bordercolor" id="_bordercolor" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1603 |
-
</p>
|
1604 |
-
|
1605 |
-
<?php
|
1606 |
-
break;
|
1607 |
-
|
1608 |
-
case '_heading':
|
1609 |
-
?>
|
1610 |
-
|
1611 |
-
<p><label for="_heading"><?php _e( 'Enable Row Heading', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether to enable a heading for this row', 'ultimate-member' ) ); ?></label>
|
1612 |
-
<input type="checkbox" name="_heading" id="_heading" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_heading_text" data-cond1-hide="xxx" />
|
1613 |
-
</p>
|
1614 |
-
|
1615 |
-
<?php
|
1616 |
-
break;
|
1617 |
-
|
1618 |
-
case '_heading_text':
|
1619 |
-
?>
|
1620 |
-
|
1621 |
-
<p class="_heading_text"><label for="_heading_text"><?php _e( 'Heading Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter the row heading text here', 'ultimate-member' ) ); ?></label>
|
1622 |
-
<input type="text" name="_heading_text" id="_heading_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1623 |
-
</p>
|
1624 |
-
|
1625 |
-
<?php
|
1626 |
-
break;
|
1627 |
-
|
1628 |
-
case '_background':
|
1629 |
-
?>
|
1630 |
-
|
1631 |
-
<p><label for="_background"><?php _e( 'Background Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the background of entire section', 'ultimate-member' ) ); ?></label>
|
1632 |
-
<input type="text" name="_background" id="_background" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1633 |
-
</p>
|
1634 |
-
|
1635 |
-
<?php
|
1636 |
-
break;
|
1637 |
-
|
1638 |
-
case '_heading_background_color':
|
1639 |
-
?>
|
1640 |
-
|
1641 |
-
<p class="_heading_text"><label for="_heading_background_color"><?php _e( 'Heading Background Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the background of the heading section', 'ultimate-member' ) ); ?></label>
|
1642 |
-
<input type="text" name="_heading_background_color" id="_heading_background_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1643 |
-
</p>
|
1644 |
-
|
1645 |
-
<?php
|
1646 |
-
break;
|
1647 |
-
|
1648 |
-
case '_heading_text_color':
|
1649 |
-
?>
|
1650 |
-
|
1651 |
-
<p class="_heading_text"><label for="_heading_text_color"><?php _e( 'Heading Text Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the text color of heading part only', 'ultimate-member' ) ); ?></label>
|
1652 |
-
<input type="text" name="_heading_text_color" id="_heading_text_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1653 |
-
</p>
|
1654 |
-
|
1655 |
-
<?php
|
1656 |
-
break;
|
1657 |
-
|
1658 |
-
case '_text_color':
|
1659 |
-
?>
|
1660 |
-
|
1661 |
-
<p><label for="_text_color"><?php _e( 'Text Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the text color of entire section', 'ultimate-member' ) ); ?></label>
|
1662 |
-
<input type="text" name="_text_color" id="_text_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1663 |
-
</p>
|
1664 |
-
|
1665 |
-
<?php
|
1666 |
-
break;
|
1667 |
-
|
1668 |
-
case '_icon_color':
|
1669 |
-
?>
|
1670 |
-
|
1671 |
-
<p class="_heading_text"><label for="_icon_color"><?php _e( 'Icon Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the color of selected icon. By default It will be the same color as heading text color', 'ultimate-member' ) ); ?></label>
|
1672 |
-
<input type="text" name="_icon_color" id="_icon_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1673 |
-
</p>
|
1674 |
-
|
1675 |
-
<?php
|
1676 |
-
break;
|
1677 |
-
|
1678 |
-
case '_color':
|
1679 |
-
?>
|
1680 |
-
|
1681 |
-
<p><label for="_color"><?php _e( 'Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select a color for this divider', 'ultimate-member' ) ); ?></label>
|
1682 |
-
<input type="text" name="_color" id="_color" class="um-admin-colorpicker" data-default-color="#eeeeee" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '#eeeeee'; ?>" />
|
1683 |
-
</p>
|
1684 |
-
|
1685 |
-
<?php
|
1686 |
-
break;
|
1687 |
-
|
1688 |
-
case '_url_text':
|
1689 |
-
?>
|
1690 |
-
|
1691 |
-
<p><label for="_url_text"><?php _e( 'URL Alt Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Entering custom text here will replace the url with a text link', 'ultimate-member' ) ); ?></label>
|
1692 |
-
<input type="text" name="_url_text" id="_url_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1693 |
-
</p>
|
1694 |
-
|
1695 |
-
<?php
|
1696 |
-
break;
|
1697 |
-
|
1698 |
-
case '_url_target':
|
1699 |
-
?>
|
1700 |
-
|
1701 |
-
<p><label for="_url_target"><?php _e( 'Link Target', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose whether to open this link in same window or in a new window', 'ultimate-member' ) ); ?></label>
|
1702 |
-
<select name="_url_target" id="_url_target" style="width: 100%">
|
1703 |
-
<option value="_blank" <?php selected( '_blank', $this->edit_mode_value ); ?>><?php _e( 'Open in new window', 'ultimate-member' ) ?></option>
|
1704 |
-
<option value="_self" <?php selected( '_self', $this->edit_mode_value ); ?>><?php _e( 'Same window', 'ultimate-member' ) ?></option>
|
1705 |
-
</select>
|
1706 |
-
</p>
|
1707 |
-
|
1708 |
-
<?php
|
1709 |
-
break;
|
1710 |
-
|
1711 |
-
case '_url_rel':
|
1712 |
-
?>
|
1713 |
-
|
1714 |
-
<p><label for="_url_rel"><?php _e( 'SEO Follow', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether to follow or nofollow this link by search engines', 'ultimate-member' ) ); ?></label>
|
1715 |
-
<select name="_url_rel" id="_url_rel" style="width: 100%">
|
1716 |
-
<option value="follow" <?php selected( 'follow', $this->edit_mode_value ); ?>><?php _e( 'Follow', 'ultimate-member' ) ?></option>
|
1717 |
-
<option value="nofollow" <?php selected( 'nofollow', $this->edit_mode_value ); ?>><?php _e( 'No-Follow', 'ultimate-member' ) ?></option>
|
1718 |
-
</select>
|
1719 |
-
</p>
|
1720 |
-
|
1721 |
-
<?php
|
1722 |
-
break;
|
1723 |
-
|
1724 |
-
case '_force_good_pass':
|
1725 |
-
?>
|
1726 |
-
|
1727 |
-
<p><label for="_force_good_pass"><?php _e( 'Force strong password?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Turn on to force users to create a strong password (A combination of one lowercase letter, one uppercase letter, and one number). If turned on this option is only applied to register forms and not to login forms.', 'ultimate-member' ) ); ?></label>
|
1728 |
-
<input type="checkbox" name="_force_good_pass" id="_force_good_pass" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : UM()->options()->get( 'require_strongpass' ) ) ?> />
|
1729 |
-
</p>
|
1730 |
-
|
1731 |
-
<?php
|
1732 |
-
break;
|
1733 |
-
|
1734 |
-
case '_force_confirm_pass':
|
1735 |
-
?>
|
1736 |
-
|
1737 |
-
<p><label for="_force_confirm_pass"><?php _e( 'Automatically add a confirm password field?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Turn on to add a confirm password field. If turned on the confirm password field will only show on register forms and not on login forms.', 'ultimate-member' ) ); ?></label>
|
1738 |
-
<input type="checkbox" name="_force_confirm_pass" id="_force_confirm_pass" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_label_confirm_pass" data-cond1-hide="xxx" />
|
1739 |
-
</p>
|
1740 |
-
|
1741 |
-
<?php
|
1742 |
-
break;
|
1743 |
-
|
1744 |
-
case '_style':
|
1745 |
-
?>
|
1746 |
-
|
1747 |
-
<p><label for="_style"><?php _e( 'Style', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the line-style of divider', 'ultimate-member' ) ); ?></label>
|
1748 |
-
<select name="_style" id="_style" style="width: 100%">
|
1749 |
-
<option value="solid" <?php selected( 'solid', $this->edit_mode_value ); ?>><?php _e( 'Solid', 'ultimate-member' ) ?></option>
|
1750 |
-
<option value="dotted" <?php selected( 'dotted', $this->edit_mode_value ); ?>><?php _e( 'Dotted', 'ultimate-member' ) ?></option>
|
1751 |
-
<option value="dashed" <?php selected( 'dashed', $this->edit_mode_value ); ?>><?php _e( 'Dashed', 'ultimate-member' ) ?></option>
|
1752 |
-
<option value="double" <?php selected( 'double', $this->edit_mode_value ); ?>><?php _e( 'Double', 'ultimate-member' ) ?></option>
|
1753 |
-
</select>
|
1754 |
-
</p>
|
1755 |
-
|
1756 |
-
<?php
|
1757 |
-
break;
|
1758 |
-
|
1759 |
-
case '_intervals':
|
1760 |
-
|
1761 |
-
?>
|
1762 |
-
|
1763 |
-
<p><label for="_intervals"><?php _e( 'Time Intervals (in minutes)', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose the minutes interval between each time in the time picker.', 'ultimate-member' ) ); ?></label>
|
1764 |
-
<input type="text" name="_intervals" id="_intervals" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 60; ?>" placeholder="<?php esc_attr_e( 'e.g. 30, 60, 120', 'ultimate-member' ) ?>" />
|
1765 |
-
</p>
|
1766 |
-
|
1767 |
-
<?php
|
1768 |
-
break;
|
1769 |
-
|
1770 |
-
|
1771 |
-
case '_format':
|
1772 |
-
|
1773 |
-
if ( $this->set_field_type == 'date' ) {
|
1774 |
-
?>
|
1775 |
-
|
1776 |
-
<p><label for="_format"><?php _e( 'Date User-Friendly Format', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The display format of the date which is visible to user.', 'ultimate-member' ) ); ?></label>
|
1777 |
-
<select name="_format" id="_format" style="width: 100%">
|
1778 |
-
<option value="j M Y" <?php selected( 'j M Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('j M Y'); ?></option>
|
1779 |
-
<option value="M j Y" <?php selected( 'M j Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('M j Y'); ?></option>
|
1780 |
-
<option value="j F Y" <?php selected( 'j F Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('j F Y'); ?></option>
|
1781 |
-
<option value="F j Y" <?php selected( 'F j Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('F j Y'); ?></option>
|
1782 |
-
</select>
|
1783 |
-
</p>
|
1784 |
-
|
1785 |
-
<?php } else { ?>
|
1786 |
-
|
1787 |
-
<p><label for="_format"><?php _e( 'Time Format', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose the displayed time-format for this field', 'ultimate-member' ) ); ?></label>
|
1788 |
-
<select name="_format" id="_format" style="width: 100%">
|
1789 |
-
<option value="g:i a" <?php selected( 'g:i a', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('g:i a'); ?><?php _e( '( 12-hr format )', 'ultimate-member' ) ?></option>
|
1790 |
-
<option value="g:i A" <?php selected( 'g:i A', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('g:i A'); ?><?php _e( '( 12-hr format )', 'ultimate-member' ) ?></option>
|
1791 |
-
<option value="H:i" <?php selected( 'H:i', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('H:i'); ?><?php _e( '( 24-hr format )', 'ultimate-member' ) ?></option>
|
1792 |
-
</select>
|
1793 |
-
</p>
|
1794 |
-
|
1795 |
-
<?php
|
1796 |
-
}
|
1797 |
-
break;
|
1798 |
-
|
1799 |
-
case '_format_custom':
|
1800 |
-
?>
|
1801 |
-
|
1802 |
-
<p><label for="_format_custom"><?php _e( 'Use custom Date format', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'This option overrides "Date User-Friendly Format" option. See https://www.php.net/manual/en/function.date.php', 'ultimate-member' ) ); ?></label>
|
1803 |
-
<input type="text" name="_format_custom" id="_format_custom" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" placeholder="j M Y" />
|
1804 |
-
</p>
|
1805 |
-
|
1806 |
-
<?php
|
1807 |
-
break;
|
1808 |
-
|
1809 |
-
case '_pretty_format':
|
1810 |
-
?>
|
1811 |
-
|
1812 |
-
<p><label for="_pretty_format"><?php _e( 'Displayed Date Format', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether you wish to show the date in full or only show the years e.g. 25 Years', 'ultimate-member' ) ); ?></label>
|
1813 |
-
<select name="_pretty_format" id="_pretty_format" style="width: 100%">
|
1814 |
-
<option value="0" <?php selected( 0, $this->edit_mode_value ); ?>><?php _e( 'Show full date', 'ultimate-member' ) ?></option>
|
1815 |
-
<option value="1" <?php selected( 1, $this->edit_mode_value ); ?>><?php _e( 'Show years only', 'ultimate-member' ) ?></option>
|
1816 |
-
</select>
|
1817 |
-
</p>
|
1818 |
-
|
1819 |
-
<?php
|
1820 |
-
break;
|
1821 |
-
|
1822 |
-
case '_disabled_weekdays':
|
1823 |
-
|
1824 |
-
if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
|
1825 |
-
$values = $this->edit_mode_value;
|
1826 |
-
} else {
|
1827 |
-
$values = array('');
|
1828 |
-
}
|
1829 |
-
?>
|
1830 |
-
|
1831 |
-
<p><label for="_disabled_weekdays"><?php _e( 'Disable specific weekdays', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Disable specific week days from being available for selection in this date picker', 'ultimate-member' ) ); ?></label>
|
1832 |
-
<select name="_disabled_weekdays[]" id="_disabled_weekdays" multiple="multiple" style="width: 100%">
|
1833 |
-
<option value="1" <?php if ( in_array( 1, $values ) ) { echo 'selected'; } ?>><?php _e( 'Sunday', 'ultimate-member' ) ?></option>
|
1834 |
-
<option value="2" <?php if ( in_array( 2, $values ) ) { echo 'selected'; } ?>><?php _e( 'Monday', 'ultimate-member' ) ?></option>
|
1835 |
-
<option value="3" <?php if ( in_array( 3, $values ) ) { echo 'selected'; } ?>><?php _e( 'Tuesday', 'ultimate-member' ) ?></option>
|
1836 |
-
<option value="4" <?php if ( in_array( 4, $values ) ) { echo 'selected'; } ?>><?php _e( 'Wednesday', 'ultimate-member' ) ?></option>
|
1837 |
-
<option value="5" <?php if ( in_array( 5, $values ) ) { echo 'selected'; } ?>><?php _e( 'Thursday', 'ultimate-member' ) ?></option>
|
1838 |
-
<option value="6" <?php if ( in_array( 6, $values ) ) { echo 'selected'; } ?>><?php _e( 'Friday', 'ultimate-member' ) ?></option>
|
1839 |
-
<option value="7" <?php if ( in_array( 7, $values ) ) { echo 'selected'; } ?>><?php _e( 'Saturday', 'ultimate-member' ) ?></option>
|
1840 |
-
</select>
|
1841 |
-
</p>
|
1842 |
-
|
1843 |
-
<?php
|
1844 |
-
break;
|
1845 |
-
|
1846 |
-
case '_years':
|
1847 |
-
?>
|
1848 |
-
|
1849 |
-
<p class="_years"><label for="_years"><?php _e( 'Number of Years to pick from', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Number of years available for the date selection. Default to last 50 years', 'ultimate-member' ) ); ?></label>
|
1850 |
-
<input type="text" name="_years" id="_years" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 50; ?>" />
|
1851 |
-
</p>
|
1852 |
-
|
1853 |
-
<?php
|
1854 |
-
break;
|
1855 |
-
|
1856 |
-
case '_years_x':
|
1857 |
-
?>
|
1858 |
-
|
1859 |
-
<p class="_years"><label for="_years_x"><?php _e( 'Years Selection', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This decides which years should be shown relative to today date', 'ultimate-member' ) ); ?></label>
|
1860 |
-
<select name="_years_x" id="_years_x" style="width: 100%">
|
1861 |
-
<option value="equal" <?php selected( 'equal', $this->edit_mode_value ); ?>><?php _e( 'Equal years before / after today', 'ultimate-member' ) ?></option>
|
1862 |
-
<option value="past" <?php selected( 'past', $this->edit_mode_value ); ?>><?php _e( 'Past years only', 'ultimate-member' ) ?></option>
|
1863 |
-
<option value="future" <?php selected( 'future', $this->edit_mode_value ); ?>><?php _e( 'Future years only', 'ultimate-member' ) ?></option>
|
1864 |
-
</select>
|
1865 |
-
</p>
|
1866 |
-
|
1867 |
-
<?php
|
1868 |
-
break;
|
1869 |
-
|
1870 |
-
case '_range_start':
|
1871 |
-
?>
|
1872 |
-
|
1873 |
-
<p class="_date_range"><label for="_range_start"><?php _e( 'Date Range Start', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set the minimum date/day in range in the format YYYY/MM/DD', 'ultimate-member' ) ); ?></label>
|
1874 |
-
<input type="text" name="_range_start" id="_range_start" value="<?php echo $this->edit_mode_value; ?>" placeholder="<?php esc_attr_e( 'YYYY/MM/DD', 'ultimate-member' ) ?>" />
|
1875 |
-
</p>
|
1876 |
-
|
1877 |
-
<?php
|
1878 |
-
break;
|
1879 |
-
|
1880 |
-
case '_range_end':
|
1881 |
-
?>
|
1882 |
-
|
1883 |
-
<p class="_date_range"><label for="_range_end"><?php _e( 'Date Range End', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set the maximum date/day in range in the format YYYY/MM/DD', 'ultimate-member' ) ); ?></label>
|
1884 |
-
<input type="text" name="_range_end" id="_range_end" value="<?php echo $this->edit_mode_value; ?>" placeholder="<?php esc_attr_e( 'YYYY/MM/DD', 'ultimate-member' ) ?>" />
|
1885 |
-
</p>
|
1886 |
-
|
1887 |
-
<?php
|
1888 |
-
break;
|
1889 |
-
|
1890 |
-
case '_range':
|
1891 |
-
?>
|
1892 |
-
|
1893 |
-
<p><label for="_range"><?php _e( 'Set Date Range', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether to show a specific number of years or specify a date range to be available for the date picker.', 'ultimate-member' ) ); ?></label>
|
1894 |
-
<select name="_range" id="_range" class="um-adm-conditional" data-cond1='years' data-cond1-show='_years' data-cond2="date_range" data-cond2-show="_date_range" style="width: 100%">
|
1895 |
-
<option value="years" <?php selected( 'years', $this->edit_mode_value ); ?>><?php _e( 'Fixed Number of Years', 'ultimate-member' ) ?></option>
|
1896 |
-
<option value="date_range" <?php selected( 'date_range', $this->edit_mode_value ); ?>><?php _e( 'Specific Date Range', 'ultimate-member' ) ?></option>
|
1897 |
-
</select>
|
1898 |
-
</p>
|
1899 |
-
|
1900 |
-
<?php
|
1901 |
-
break;
|
1902 |
-
|
1903 |
-
case '_content':
|
1904 |
-
|
1905 |
-
if ( $this->set_field_type == 'shortcode' ) {
|
1906 |
-
|
1907 |
-
?>
|
1908 |
-
|
1909 |
-
<p><label for="_content"><?php _e( 'Enter Shortcode', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter the shortcode in the following textarea and it will be displayed on the fields', 'ultimate-member' ) ); ?></label>
|
1910 |
-
<textarea name="_content" id="_content" placeholder="<?php esc_attr_e( 'e.g. [my_custom_shortcode]', 'ultimate-member' ) ?>"><?php echo $this->edit_mode_value; ?></textarea>
|
1911 |
-
</p>
|
1912 |
-
|
1913 |
-
<?php
|
1914 |
-
|
1915 |
-
} else {
|
1916 |
-
|
1917 |
-
?>
|
1918 |
-
|
1919 |
-
<div class="um-admin-editor-h"><label><?php _e( 'Content Editor', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Edit the content of this field here', 'ultimate-member' ) ); ?></label></div>
|
1920 |
-
|
1921 |
-
<div class="um-admin-editor"><!-- editor dynamically loaded here --></div>
|
1922 |
-
|
1923 |
-
<?php
|
1924 |
-
|
1925 |
-
}
|
1926 |
-
|
1927 |
-
break;
|
1928 |
-
|
1929 |
-
case '_crop':
|
1930 |
-
?>
|
1931 |
-
|
1932 |
-
<p><label for="_crop"><?php _e( 'Crop Feature', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enable/disable crop feature for this image upload and define ratio', 'ultimate-member' ) ); ?></label>
|
1933 |
-
<select name="_crop" id="_crop" style="width: 100%">
|
1934 |
-
<option value="0" <?php selected( '0', $this->edit_mode_value ); ?>><?php _e( 'Turn Off (Default)', 'ultimate-member' ) ?></option>
|
1935 |
-
<option value="1" <?php selected( '1', $this->edit_mode_value ); ?>><?php _e( 'Crop and force 1:1 ratio', 'ultimate-member' ) ?></option>
|
1936 |
-
<option value="3" <?php selected( '3', $this->edit_mode_value ); ?>><?php _e( 'Crop and force user-defined ratio', 'ultimate-member' ) ?></option>
|
1937 |
-
</select>
|
1938 |
-
</p>
|
1939 |
-
|
1940 |
-
<?php
|
1941 |
-
break;
|
1942 |
-
|
1943 |
-
case '_allowed_types':
|
1944 |
-
|
1945 |
-
if ( $this->set_field_type == 'image' ) {
|
1946 |
-
|
1947 |
-
if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
|
1948 |
-
$values = $this->edit_mode_value;
|
1949 |
-
} else {
|
1950 |
-
$values = array( 'png','jpeg','jpg','gif' );
|
1951 |
-
} ?>
|
1952 |
-
|
1953 |
-
<p><label for="_allowed_types"><?php _e( 'Allowed Image Types', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select the image types that you want to allow to be uploaded via this field.', 'ultimate-member' ) ); ?></label>
|
1954 |
-
<select name="_allowed_types[]" id="_allowed_types" multiple="multiple" style="width: 100%">
|
1955 |
-
<?php foreach( UM()->files()->allowed_image_types() as $e => $n ) { ?>
|
1956 |
-
<option value="<?php echo $e; ?>" <?php if ( in_array( $e, $values ) ) { echo 'selected'; } ?>><?php echo $n; ?></option>
|
1957 |
-
<?php } ?>
|
1958 |
-
</select>
|
1959 |
-
</p>
|
1960 |
-
|
1961 |
-
<?php
|
1962 |
-
|
1963 |
-
} else {
|
1964 |
-
|
1965 |
-
if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
|
1966 |
-
$values = $this->edit_mode_value;
|
1967 |
-
} else {
|
1968 |
-
$values = array( 'pdf', 'txt' );
|
1969 |
-
} ?>
|
1970 |
-
|
1971 |
-
<p><label for="_allowed_types"><?php _e( 'Allowed File Types', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select the image types that you want to allow to be uploaded via this field.', 'ultimate-member' ) ); ?></label>
|
1972 |
-
<select name="_allowed_types[]" id="_allowed_types" multiple="multiple" style="width: 100%">
|
1973 |
-
<?php foreach( UM()->files()->allowed_file_types() as $e => $n ) { ?>
|
1974 |
-
<option value="<?php echo $e; ?>" <?php if ( in_array( $e, $values ) ) { echo 'selected'; } ?>><?php echo $n; ?></option>
|
1975 |
-
<?php } ?>
|
1976 |
-
</select>
|
1977 |
-
</p>
|
1978 |
-
|
1979 |
-
<?php
|
1980 |
-
|
1981 |
-
}
|
1982 |
-
|
1983 |
-
break;
|
1984 |
-
|
1985 |
-
case '_upload_text':
|
1986 |
-
|
1987 |
-
if ( $this->set_field_type == 'image' ) {
|
1988 |
-
$value = __( 'Drag & Drop Photo', 'ultimate-member' );
|
1989 |
-
}
|
1990 |
-
if ( $this->set_field_type == 'file' ) {
|
1991 |
-
$value = __( 'Drag & Drop File', 'ultimate-member' );
|
1992 |
-
}
|
1993 |
-
|
1994 |
-
?>
|
1995 |
-
|
1996 |
-
<p><label for="_upload_text"><?php _e( 'Upload Box Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the headline that appears in the upload box for this field', 'ultimate-member' ) ); ?></label>
|
1997 |
-
<input type="text" name="_upload_text" id="_upload_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : $value; ?>" />
|
1998 |
-
</p>
|
1999 |
-
|
2000 |
-
<?php
|
2001 |
-
break;
|
2002 |
-
|
2003 |
-
case '_upload_help_text':
|
2004 |
-
?>
|
2005 |
-
|
2006 |
-
<p><label for="_upload_help_text"><?php _e( 'Additional Instructions Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you need to add information or secondary line below the headline of upload box, enter it here', 'ultimate-member' ) ); ?></label>
|
2007 |
-
<input type="text" name="_upload_help_text" id="_upload_help_text" value="<?php echo $this->edit_mode_value; ?>" />
|
2008 |
-
</p>
|
2009 |
-
|
2010 |
-
<?php
|
2011 |
-
break;
|
2012 |
-
|
2013 |
-
case '_button_text':
|
2014 |
-
?>
|
2015 |
-
|
2016 |
-
<p><label for="_button_text"><?php _e( 'Upload Box Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The text that appears on the button. e.g. Upload', 'ultimate-member' ) ); ?></label>
|
2017 |
-
<input type="text" name="_button_text" id="_button_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : __( 'Upload', 'ultimate-member' ); ?>" />
|
2018 |
-
</p>
|
2019 |
-
|
2020 |
-
<?php
|
2021 |
-
break;
|
2022 |
-
|
2023 |
-
case '_max_size':
|
2024 |
-
?>
|
2025 |
-
|
2026 |
-
<p><label for="_max_size"><?php _e( 'Maximum Size in bytes', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The maximum size for image that can be uploaded through this field. Leave empty for unlimited size.', 'ultimate-member' ) ); ?></label>
|
2027 |
-
<input type="text" name="_max_size" id="_max_size" value="<?php echo $this->edit_mode_value; ?>" />
|
2028 |
-
</p>
|
2029 |
-
|
2030 |
-
<?php
|
2031 |
-
break;
|
2032 |
-
|
2033 |
-
case '_height':
|
2034 |
-
?>
|
2035 |
-
|
2036 |
-
<p><label for="_height"><?php _e( 'Textarea Height', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The height of textarea in pixels. Default is 100 pixels', 'ultimate-member' ) ); ?></label>
|
2037 |
-
<input type="text" name="_height" id="_height" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '100px'; ?>" />
|
2038 |
-
</p>
|
2039 |
-
|
2040 |
-
<?php
|
2041 |
-
break;
|
2042 |
-
|
2043 |
-
case '_spacing':
|
2044 |
-
?>
|
2045 |
-
|
2046 |
-
<p><label for="_spacing"><?php _e( 'Spacing', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the required spacing in pixels. e.g. 20px', 'ultimate-member' ) ); ?></label>
|
2047 |
-
<input type="text" name="_spacing" id="_spacing" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '20px'; ?>" />
|
2048 |
-
</p>
|
2049 |
-
|
2050 |
-
<?php
|
2051 |
-
break;
|
2052 |
-
|
2053 |
-
case '_is_multi':
|
2054 |
-
?>
|
2055 |
-
|
2056 |
-
<p><label for="_is_multi"><?php _e( 'Allow multiple selections', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enable/disable multiple selections for this field', 'ultimate-member' ) ); ?></label>
|
2057 |
-
<input type="checkbox" name="_is_multi" id="_is_multi" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_max_selections" data-cond1-hide="xxx" />
|
2058 |
-
</p>
|
2059 |
-
|
2060 |
-
<?php
|
2061 |
-
break;
|
2062 |
-
|
2063 |
-
case '_max_selections':
|
2064 |
-
?>
|
2065 |
-
|
2066 |
-
<p class="_max_selections"><label for="_max_selections"><?php _e( 'Maximum number of selections', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter a number here to force a maximum number of selections by user for this field', 'ultimate-member' ) ); ?></label>
|
2067 |
-
<input type="text" name="_max_selections" id="_max_selections" value="<?php echo $this->edit_mode_value; ?>" />
|
2068 |
-
</p>
|
2069 |
-
|
2070 |
-
<?php
|
2071 |
-
break;
|
2072 |
-
|
2073 |
-
case '_min_selections':
|
2074 |
-
?>
|
2075 |
-
|
2076 |
-
<p class="_min_selections"><label for="_min_selections"><?php _e( 'Minimum number of selections', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter a number here to force a minimum number of selections by user for this field', 'ultimate-member' ) ); ?></label>
|
2077 |
-
<input type="text" name="_min_selections" id="_min_selections" value="<?php echo $this->edit_mode_value; ?>" />
|
2078 |
-
</p>
|
2079 |
-
|
2080 |
-
<?php
|
2081 |
-
break;
|
2082 |
-
|
2083 |
-
case '_max_entries':
|
2084 |
-
?>
|
2085 |
-
|
2086 |
-
<p class="_max_entries"><label for="_max_selections"><?php _e( 'Maximum number of entries', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the max number of entries the user can add via field group.', 'ultimate-member' ) ); ?></label>
|
2087 |
-
<input type="text" name="_max_entries" id="_max_entries" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 10; ?>" />
|
2088 |
-
</p>
|
2089 |
-
|
2090 |
-
<?php
|
2091 |
-
break;
|
2092 |
-
|
2093 |
-
case '_max_words':
|
2094 |
-
?>
|
2095 |
-
|
2096 |
-
<p><label for="_max_words"><?php _e( 'Maximum allowed words', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to enable a maximum number of words to be input in this textarea. Leave empty to disable this setting', 'ultimate-member' ) ); ?></label>
|
2097 |
-
<input type="text" name="_max_words" id="_max_words" value="<?php echo $this->edit_mode_value; ?>" />
|
2098 |
-
</p>
|
2099 |
-
|
2100 |
-
<?php
|
2101 |
-
break;
|
2102 |
-
|
2103 |
-
case '_min':
|
2104 |
-
?>
|
2105 |
-
|
2106 |
-
<p><label for="_min"><?php _e( 'Minimum Number', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Minimum number that can be entered in this field', 'ultimate-member' ) ); ?></label>
|
2107 |
-
<input type="text" name="_min" id="_min" value="<?php echo $this->edit_mode_value; ?>" />
|
2108 |
-
</p>
|
2109 |
-
|
2110 |
-
<?php
|
2111 |
-
break;
|
2112 |
-
|
2113 |
-
case '_max':
|
2114 |
-
?>
|
2115 |
-
|
2116 |
-
<p><label for="_max"><?php _e( 'Maximum Number', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Maximum number that can be entered in this field', 'ultimate-member' ) ); ?></label>
|
2117 |
-
<input type="text" name="_max" id="_max" value="<?php echo $this->edit_mode_value; ?>" />
|
2118 |
-
</p>
|
2119 |
-
|
2120 |
-
<?php
|
2121 |
-
break;
|
2122 |
-
|
2123 |
-
case '_min_chars':
|
2124 |
-
?>
|
2125 |
-
|
2126 |
-
<p><label for="_min_chars"><?php _e( 'Minimum length', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to enable a minimum number of characters to be input in this field. Leave empty to disable this setting', 'ultimate-member' ) ); ?></label>
|
2127 |
-
<input type="text" name="_min_chars" id="_min_chars" value="<?php echo $this->edit_mode_value; ?>" />
|
2128 |
-
</p>
|
2129 |
-
|
2130 |
-
<?php
|
2131 |
-
break;
|
2132 |
-
|
2133 |
-
case '_max_chars':
|
2134 |
-
?>
|
2135 |
-
|
2136 |
-
<p><label for="_max_chars"><?php _e( 'Maximum length', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to enable a maximum number of characters to be input in this field. Leave empty to disable this setting', 'ultimate-member' ) ); ?></label>
|
2137 |
-
<input type="text" name="_max_chars" id="_max_chars" value="<?php echo $this->edit_mode_value; ?>" />
|
2138 |
-
</p>
|
2139 |
-
|
2140 |
-
<?php
|
2141 |
-
break;
|
2142 |
-
|
2143 |
-
case '_html':
|
2144 |
-
?>
|
2145 |
-
|
2146 |
-
<p><label for="_html"><?php _e( 'Does this textarea accept HTML?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Turn on/off HTML tags for this textarea', 'ultimate-member' ) ); ?></label>
|
2147 |
-
<input type="checkbox" name="_html" id="_html" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> />
|
2148 |
-
</p>
|
2149 |
-
|
2150 |
-
<?php
|
2151 |
-
break;
|
2152 |
-
|
2153 |
-
case '_options':
|
2154 |
-
|
2155 |
-
if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
|
2156 |
-
$values = implode("\n", $this->edit_mode_value);
|
2157 |
-
} else if ( $this->edit_mode_value ) {
|
2158 |
-
$values = $this->edit_mode_value;
|
2159 |
-
} else {
|
2160 |
-
$values = '';
|
2161 |
-
} ?>
|
2162 |
-
|
2163 |
-
<p><label for="_options"><?php _e( 'Edit Choices', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter one choice per line. This will represent the available choices or selections available for user.', 'ultimate-member' ) ); ?></label>
|
2164 |
-
<textarea name="_options" id="_options"><?php echo $values; ?></textarea>
|
2165 |
-
</p>
|
2166 |
-
|
2167 |
-
<?php
|
2168 |
-
break;
|
2169 |
-
|
2170 |
-
case '_title':
|
2171 |
-
?>
|
2172 |
-
|
2173 |
-
<p><label for="_title"><?php _e( 'Title', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the title of the field for your reference in the backend. The title will not appear on the front-end of your website.', 'ultimate-member' ) ); ?></label>
|
2174 |
-
<input type="text" name="_title" id="_title" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
|
2175 |
-
</p>
|
2176 |
-
|
2177 |
-
<?php
|
2178 |
-
break;
|
2179 |
-
|
2180 |
-
case '_id':
|
2181 |
-
|
2182 |
-
?>
|
2183 |
-
|
2184 |
-
<p style="display:none"><label for="_id"><?php _e( 'Unique ID', 'ultimate-member' ) ?></label>
|
2185 |
-
<input type="text" name="_id" id="_id" value="<?php echo $this->edit_mode_value; ?>" />
|
2186 |
-
</p>
|
2187 |
-
|
2188 |
-
<?php
|
2189 |
-
|
2190 |
-
break;
|
2191 |
-
|
2192 |
-
case '_metakey':
|
2193 |
-
|
2194 |
-
if ( $this->in_edit ) {
|
2195 |
-
|
2196 |
-
?>
|
2197 |
-
|
2198 |
-
<p><label for="_metakey"><?php _e( 'Meta Key', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The meta key cannot be changed for duplicated fields or when editing an existing field. If you require a different meta key please create a new field.', 'ultimate-member' ) ); ?></label>
|
2199 |
-
<input type="text" name="_metakey_locked" id="_metakey_locked" value="<?php echo $this->edit_mode_value; ?>" disabled />
|
2200 |
-
</p>
|
2201 |
-
|
2202 |
-
<?php } else { ?>
|
2203 |
-
|
2204 |
-
<p><label for="_metakey"><?php _e( 'Meta Key', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'A meta key is required to store the entered info in this field in the database. The meta key should be unique to this field and be written in lowercase with an underscore ( _ ) separating words e.g country_list or job_title', 'ultimate-member' ) ); ?></label>
|
2205 |
-
<input type="text" name="_metakey" id="_metakey" value="" />
|
2206 |
-
</p>
|
2207 |
-
|
2208 |
-
<?php
|
2209 |
-
|
2210 |
-
}
|
2211 |
-
|
2212 |
-
break;
|
2213 |
-
|
2214 |
-
case '_help':
|
2215 |
-
?>
|
2216 |
-
|
2217 |
-
<p><label for="_help"><?php _e( 'Help Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __('This is the text that appears in a tooltip when a user hovers over the info icon. Help text is useful for providing users with more information about what they should enter in the field. Leave blank if no help text is needed for field.', 'ultimate-member' ) ); ?></label>
|
2218 |
-
<input type="text" name="_help" id="_help" value="<?php echo $this->edit_mode_value; ?>" />
|
2219 |
-
</p>
|
2220 |
-
|
2221 |
-
<?php
|
2222 |
-
break;
|
2223 |
-
|
2224 |
-
case '_default':
|
2225 |
-
?>
|
2226 |
-
|
2227 |
-
<?php if ( $this->set_field_type == 'textarea' ) { ?>
|
2228 |
-
|
2229 |
-
<p><label for="_default"><?php _e( 'Default Text', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'Text to display by default in this field', 'ultimate-member' ) ); ?></label>
|
2230 |
-
<textarea name="_default" id="_default"><?php echo $this->edit_mode_value; ?></textarea>
|
2231 |
-
</p>
|
2232 |
-
|
2233 |
-
<?php } elseif ( $this->set_field_type == 'date' ) { ?>
|
2234 |
-
|
2235 |
-
<p class="um"><label for="_default"><?php _e( 'Default Date', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'You may use all PHP compatible date formats such as: 2020-02-02, 02/02/2020, yesterday, today, tomorrow, next monday, first day of next month, +3 day', 'ultimate-member' ) ); ?></label>
|
2236 |
-
<input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" class="um-datepicker" data-format="yyyy/mm/dd" />
|
2237 |
-
</p>
|
2238 |
-
|
2239 |
-
<?php } elseif ( $this->set_field_type == 'time' ) { ?>
|
2240 |
-
|
2241 |
-
<p class="um"><label for="_default"><?php _e( 'Default Time', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'You may use all PHP compatible date formats such as: 2020-02-02, 02/02/2020, yesterday, today, tomorrow, next monday, first day of next month, +3 day', 'ultimate-member' ) ); ?></label>
|
2242 |
-
<input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" class="um-timepicker" data-format="HH:i" />
|
2243 |
-
</p>
|
2244 |
-
|
2245 |
-
<?php } elseif ( $this->set_field_type == 'rating' ) { ?>
|
2246 |
-
|
2247 |
-
<p><label for="_default"><?php _e( 'Default Rating', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'If you wish the rating field to be prefilled with a number of stars, enter it here.', 'ultimate-member' ) ); ?></label>
|
2248 |
-
<input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" />
|
2249 |
-
</p>
|
2250 |
-
|
2251 |
-
<?php } else { ?>
|
2252 |
-
|
2253 |
-
<p><label for="_default"><?php _e( 'Default Value', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'This option allows you to pre-fill the field with a default value prior to the user entering a value in the field. Leave blank to have no default value', 'ultimate-member' ) ); ?></label>
|
2254 |
-
<input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" />
|
2255 |
-
</p>
|
2256 |
-
|
2257 |
-
<?php } ?>
|
2258 |
-
|
2259 |
-
<?php
|
2260 |
-
break;
|
2261 |
-
|
2262 |
-
case '_label':
|
2263 |
-
?>
|
2264 |
-
|
2265 |
-
<p><label for="_label"><?php _e( 'Label', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The field label is the text that appears above the field on your front-end form. Leave blank to not show a label above field.', 'ultimate-member' ) ); ?></label>
|
2266 |
-
<input type="text" name="_label" id="_label" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
|
2267 |
-
</p>
|
2268 |
-
|
2269 |
-
<?php
|
2270 |
-
break;
|
2271 |
-
|
2272 |
-
case '_label_confirm_pass':
|
2273 |
-
?>
|
2274 |
-
|
2275 |
-
<p><label for="_label_confirm_pass"><?php _e( 'Confirm password field label', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This label is the text that appears above the confirm password field. Leave blank to show default label.', 'ultimate-member' ) ); ?></label>
|
2276 |
-
<input type="text" name="_label_confirm_pass" id="_label_confirm_pass" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
|
2277 |
-
</p>
|
2278 |
-
|
2279 |
-
<?php
|
2280 |
-
break;
|
2281 |
-
|
2282 |
-
case '_placeholder':
|
2283 |
-
?>
|
2284 |
-
|
2285 |
-
<p><label for="_placeholder"><?php _e( 'Placeholder', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the text that appears within the field e.g please enter your email address. Leave blank to not show any placeholder text.', 'ultimate-member' ) ); ?></label>
|
2286 |
-
<input type="text" name="_placeholder" id="_placeholder" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
|
2287 |
-
</p>
|
2288 |
-
|
2289 |
-
<?php
|
2290 |
-
break;
|
2291 |
-
|
2292 |
-
case '_public':
|
2293 |
-
$privacy_options = array(
|
2294 |
-
'1' => __( 'Everyone', 'ultimate-member' ),
|
2295 |
-
'2' => __( 'Members', 'ultimate-member' ),
|
2296 |
-
'-1' => __( 'Only visible to profile owner and users who can edit other member accounts', 'ultimate-member' ),
|
2297 |
-
'-3' => __( 'Only visible to profile owner and specific roles', 'ultimate-member' ),
|
2298 |
-
'-2' => __( 'Only specific member roles', 'ultimate-member' ),
|
2299 |
-
);
|
2300 |
-
|
2301 |
-
$privacy_options = apply_filters( 'um_field_privacy_options', $privacy_options ); ?>
|
2302 |
-
|
2303 |
-
<p>
|
2304 |
-
<label for="_public"><?php _e( 'Privacy', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Field privacy allows you to select who can view this field on the front-end. The site admin can view all fields regardless of the option set here.', 'ultimate-member' ) ); ?></label>
|
2305 |
-
<select name="_public" id="_public" class="um-adm-conditional" data-cond1="-2" data-cond1-show="_roles" data-cond2="-3" data-cond2-show="_roles" style="width: 100%">
|
2306 |
-
<?php foreach ( $privacy_options as $value => $title ) { ?>
|
2307 |
-
<option value="<?php echo esc_attr( $value ) ?>" <?php selected( $value, $this->edit_mode_value ); ?>>
|
2308 |
-
<?php echo $title ?>
|
2309 |
-
</option>
|
2310 |
-
<?php } ?>
|
2311 |
-
</select>
|
2312 |
-
</p>
|
2313 |
-
|
2314 |
-
<?php
|
2315 |
-
break;
|
2316 |
-
|
2317 |
-
case '_roles':
|
2318 |
-
|
2319 |
-
if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
|
2320 |
-
$values = $this->edit_mode_value;
|
2321 |
-
} else {
|
2322 |
-
$values = array('');
|
2323 |
-
}
|
2324 |
-
|
2325 |
-
?>
|
2326 |
-
|
2327 |
-
<p class="_roles"><label for="_roles"><?php _e( 'Select member roles', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select the member roles that can view this field on the front-end.', 'ultimate-member' ) ); ?></label>
|
2328 |
-
<select name="_roles[]" id="_roles" style="width: 100%" multiple="multiple">
|
2329 |
-
|
2330 |
-
<?php foreach ( UM()->roles()->get_roles() as $key => $value) { ?>
|
2331 |
-
|
2332 |
-
<option value="<?php echo $key; ?>" <?php if ( in_array( $key, $values ) ) { echo 'selected'; } ?>><?php echo $value; ?></option>
|
2333 |
-
|
2334 |
-
<?php } ?>
|
2335 |
-
|
2336 |
-
</select>
|
2337 |
-
</p>
|
2338 |
-
|
2339 |
-
<?php
|
2340 |
-
break;
|
2341 |
-
|
2342 |
-
case '_required':
|
2343 |
-
|
2344 |
-
if ( $this->set_field_type == 'password' )
|
2345 |
-
$def_required = 1;
|
2346 |
-
else
|
2347 |
-
$def_required = 0;
|
2348 |
-
|
2349 |
-
?>
|
2350 |
-
|
2351 |
-
<div class="um-admin-tri">
|
2352 |
-
|
2353 |
-
<p><label for="_required"><?php _e( 'Is this field required?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This option allows you to set whether the field must be filled in before the form can be processed.', 'ultimate-member' ) ); ?></label>
|
2354 |
-
<input type="checkbox" name="_required" id="_required" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : $def_required ) ?> />
|
2355 |
-
</p>
|
2356 |
-
|
2357 |
-
</div>
|
2358 |
-
|
2359 |
-
<?php
|
2360 |
-
break;
|
2361 |
-
|
2362 |
-
case '_editable':
|
2363 |
-
?>
|
2364 |
-
|
2365 |
-
<div class="um-admin-tri">
|
2366 |
-
|
2367 |
-
<p><label for="_editable"><?php _e( 'Can user edit this field?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This option allows you to set whether or not the user can edit the information in this field. The site admin can edit all fields regardless of the option set here.', 'ultimate-member' ) ); ?></label>
|
2368 |
-
<input type="hidden" name="_editable" id="_editable_hidden" value="0" />
|
2369 |
-
<input type="checkbox" name="_editable" id="_editable" value="1" <?php checked( null === $this->edit_mode_value || $this->edit_mode_value ) ?> />
|
2370 |
-
</p>
|
2371 |
-
|
2372 |
-
</div>
|
2373 |
-
|
2374 |
-
<?php
|
2375 |
-
break;
|
2376 |
-
|
2377 |
-
case '_number':
|
2378 |
-
?>
|
2379 |
-
|
2380 |
-
<p><label for="_number"><?php _e( 'Rating System', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose whether you want a 5-stars or 10-stars ratings based here.', 'ultimate-member' ) ); ?></label>
|
2381 |
-
<select name="_number" id="_number" style="width: 100%">
|
2382 |
-
<option value="5" <?php selected( 5, $this->edit_mode_value ); ?>><?php _e( '5 stars rating system', 'ultimate-member' ) ?></option>
|
2383 |
-
<option value="10" <?php selected( 10, $this->edit_mode_value ); ?>><?php _e( '10 stars rating system', 'ultimate-member' ) ?></option>
|
2384 |
-
</select>
|
2385 |
-
</p>
|
2386 |
-
|
2387 |
-
<?php
|
2388 |
-
break;
|
2389 |
-
|
2390 |
-
case '_custom_dropdown_options_source':
|
2391 |
-
?>
|
2392 |
-
|
2393 |
-
<p><label for="_custom_dropdown_options_source"><?php _e( 'Choices Callback', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Add a callback source to retrieve choices.', 'ultimate-member' ) ); ?></label>
|
2394 |
-
<input type="text" name="_custom_dropdown_options_source" id="_custom_dropdown_options_source" value="<?php echo
|
2395 |
-
</p>
|
2396 |
-
|
2397 |
-
<?php
|
2398 |
-
break;
|
2399 |
-
|
2400 |
-
|
2401 |
-
|
2402 |
-
|
2403 |
-
|
2404 |
-
|
2405 |
-
|
2406 |
-
|
2407 |
-
|
2408 |
-
|
2409 |
-
|
2410 |
-
|
2411 |
-
|
2412 |
-
|
2413 |
-
|
2414 |
-
|
2415 |
-
|
2416 |
-
|
2417 |
-
|
2418 |
-
|
2419 |
-
|
2420 |
-
|
2421 |
-
|
2422 |
-
|
2423 |
-
|
2424 |
-
|
2425 |
-
|
2426 |
-
|
2427 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\admin\core;
|
3 |
+
|
4 |
+
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Admin_Metabox
|
13 |
+
*
|
14 |
+
* @package um\admin\core
|
15 |
+
*/
|
16 |
+
class Admin_Metabox {
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @var bool
|
21 |
+
*/
|
22 |
+
private $form_nonce_added = false;
|
23 |
+
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @var bool
|
27 |
+
*/
|
28 |
+
private $directory_nonce_added = false;
|
29 |
+
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @var bool
|
33 |
+
*/
|
34 |
+
private $custom_nonce_added = false;
|
35 |
+
|
36 |
+
|
37 |
+
var $init_icon = false;
|
38 |
+
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Admin_Metabox constructor.
|
42 |
+
*/
|
43 |
+
function __construct() {
|
44 |
+
$this->in_edit = false;
|
45 |
+
$this->edit_mode_value = null;
|
46 |
+
$this->edit_array = [];
|
47 |
+
|
48 |
+
add_action( 'admin_head', array( &$this, 'admin_head' ), 9);
|
49 |
+
add_action( 'admin_footer', array( &$this, 'load_modal_content' ), 9 );
|
50 |
+
|
51 |
+
add_action( 'load-post.php', array( &$this, 'add_metabox' ), 9 );
|
52 |
+
add_action( 'load-post-new.php', array( &$this, 'add_metabox' ), 9 );
|
53 |
+
|
54 |
+
add_action( 'admin_init', array( &$this, 'add_taxonomy_metabox' ), 9 );
|
55 |
+
|
56 |
+
//roles metaboxes
|
57 |
+
add_action( 'um_roles_add_meta_boxes', array( &$this, 'add_metabox_role' ) );
|
58 |
+
|
59 |
+
add_filter( 'um_builtin_validation_types_continue_loop', array( &$this, 'validation_types_continue_loop' ), 1, 4 );
|
60 |
+
add_filter( 'um_restrict_content_hide_metabox', array( &$this, 'hide_metabox_restrict_content_shop' ), 10, 1 );
|
61 |
+
|
62 |
+
add_filter( 'um_member_directory_meta_value_before_save', array( UM()->member_directory(), 'before_save_data' ), 10, 3 );
|
63 |
+
}
|
64 |
+
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Hide Woocommerce Shop page restrict content metabox
|
68 |
+
* @param $hide
|
69 |
+
*
|
70 |
+
* @return bool
|
71 |
+
*/
|
72 |
+
function hide_metabox_restrict_content_shop( $hide ) {
|
73 |
+
if ( function_exists( 'wc_get_page_id' ) && ! empty( $_GET['post'] ) &&
|
74 |
+
absint( $_GET['post'] ) == wc_get_page_id( 'shop' ) ) {
|
75 |
+
return true;
|
76 |
+
}
|
77 |
+
|
78 |
+
return $hide;
|
79 |
+
}
|
80 |
+
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Filter validation types on loop
|
84 |
+
*
|
85 |
+
* @param $break
|
86 |
+
* @param $key
|
87 |
+
* @param $form_id
|
88 |
+
* @param $field_array
|
89 |
+
*
|
90 |
+
* @return bool
|
91 |
+
*/
|
92 |
+
function validation_types_continue_loop( $break, $key, $form_id, $field_array ) {
|
93 |
+
|
94 |
+
// show unique username validation only for user_login field
|
95 |
+
if ( isset( $field_array['metakey'] ) && $field_array['metakey'] == 'user_login' && $key !== 'unique_username' ) {
|
96 |
+
return false;
|
97 |
+
}
|
98 |
+
|
99 |
+
return $break;
|
100 |
+
}
|
101 |
+
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Gets the role meta
|
105 |
+
*
|
106 |
+
* @param $id
|
107 |
+
*
|
108 |
+
* @return mixed
|
109 |
+
*/
|
110 |
+
function get_custom_post_meta( $id ) {
|
111 |
+
$all_meta = get_post_custom( $id );
|
112 |
+
foreach ( $all_meta as $k => $v ) {
|
113 |
+
if ( strstr( $k, '_um_' ) ) {
|
114 |
+
$um_meta[ $k ] = $v;
|
115 |
+
}
|
116 |
+
}
|
117 |
+
if ( isset( $um_meta ) ) {
|
118 |
+
return $um_meta;
|
119 |
+
}
|
120 |
+
|
121 |
+
return false;
|
122 |
+
}
|
123 |
+
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Runs on admin head
|
127 |
+
*/
|
128 |
+
function admin_head(){
|
129 |
+
global $post;
|
130 |
+
if ( UM()->admin()->is_plugin_post_type() && isset($post->ID) ){
|
131 |
+
$this->postmeta = $this->get_custom_post_meta($post->ID);
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Init the metaboxes
|
138 |
+
*/
|
139 |
+
function add_metabox() {
|
140 |
+
global $current_screen;
|
141 |
+
|
142 |
+
if ( $current_screen->id == 'um_form' ) {
|
143 |
+
add_action( 'add_meta_boxes', array(&$this, 'add_metabox_form'), 1 );
|
144 |
+
add_action( 'save_post', array(&$this, 'save_metabox_form'), 10, 2 );
|
145 |
+
}
|
146 |
+
|
147 |
+
if ( $current_screen->id == 'um_directory' ) {
|
148 |
+
add_action( 'add_meta_boxes', array(&$this, 'add_metabox_directory'), 1 );
|
149 |
+
add_action( 'save_post', array(&$this, 'save_metabox_directory'), 10, 2 );
|
150 |
+
}
|
151 |
+
|
152 |
+
//restrict content metabox
|
153 |
+
$post_types = UM()->options()->get( 'restricted_access_post_metabox' );
|
154 |
+
if ( ! empty( $post_types[ $current_screen->id ] ) ) {
|
155 |
+
|
156 |
+
/**
|
157 |
+
* UM hook
|
158 |
+
*
|
159 |
+
* @type filter
|
160 |
+
* @title um_restrict_content_hide_metabox
|
161 |
+
* @description Show/Hide Restrict content metabox
|
162 |
+
* @input_vars
|
163 |
+
* [{"var":"$show","type":"bool","desc":"Show Metabox"}]
|
164 |
+
* @change_log
|
165 |
+
* ["Since: 2.0"]
|
166 |
+
* @usage add_filter( 'um_restrict_content_hide_metabox', 'function_name', 10, 1 );
|
167 |
+
* @example
|
168 |
+
* <?php
|
169 |
+
* add_filter( 'um_restrict_content_hide_metabox', 'my_restrict_content_hide_metabox', 10, 1 );
|
170 |
+
* function my_restrict_content_hide_metabox( $show ) {
|
171 |
+
* // your code here
|
172 |
+
* return $show;
|
173 |
+
* }
|
174 |
+
* ?>
|
175 |
+
*/
|
176 |
+
$hide_metabox = apply_filters( 'um_restrict_content_hide_metabox', false );
|
177 |
+
|
178 |
+
if ( ! $hide_metabox ) {
|
179 |
+
add_action( 'add_meta_boxes', array(&$this, 'add_metabox_restrict_content'), 1 );
|
180 |
+
add_action( 'save_post', array( &$this, 'save_metabox_restrict_content' ), 10, 2 );
|
181 |
+
}
|
182 |
+
|
183 |
+
if ( $current_screen->id == 'attachment' ) {
|
184 |
+
add_action( 'add_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 );
|
185 |
+
add_action( 'edit_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 );
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
|
190 |
+
add_action( 'save_post', array( &$this, 'save_metabox_custom' ), 10, 2 );
|
191 |
+
}
|
192 |
+
|
193 |
+
|
194 |
+
/**
|
195 |
+
* @param $post_id
|
196 |
+
* @param $post
|
197 |
+
*/
|
198 |
+
public function save_metabox_custom( $post_id, $post ) {
|
199 |
+
// validate nonce
|
200 |
+
if ( ! isset( $_POST['um_admin_save_metabox_custom_nonce'] ) ||
|
201 |
+
! wp_verify_nonce( $_POST['um_admin_save_metabox_custom_nonce'], basename( __FILE__ ) ) ) {
|
202 |
+
return;
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* UM hook
|
207 |
+
*
|
208 |
+
* @type action
|
209 |
+
* @title um_admin_custom_restrict_content_metaboxes
|
210 |
+
* @description Save metabox custom with restrict content
|
211 |
+
* @input_vars
|
212 |
+
* [{"var":"$post_id","type":"int","desc":"Post ID"},
|
213 |
+
* {"var":"$post","type":"array","desc":"Post data"}]
|
214 |
+
* @change_log
|
215 |
+
* ["Since: 2.0"]
|
216 |
+
* @usage add_action( 'um_admin_custom_restrict_content_metaboxes', 'function_name', 10, 2 );
|
217 |
+
* @example
|
218 |
+
* <?php
|
219 |
+
* add_action( 'um_admin_custom_restrict_content_metaboxes', 'my_admin_custom_restrict_content', 10, 2 );
|
220 |
+
* function my_admin_custom_restrict_content( $post_id, $post ) {
|
221 |
+
* // your code here
|
222 |
+
* }
|
223 |
+
* ?>
|
224 |
+
*/
|
225 |
+
do_action( 'um_admin_custom_restrict_content_metaboxes', $post_id, $post );
|
226 |
+
}
|
227 |
+
|
228 |
+
|
229 |
+
/**
|
230 |
+
*
|
231 |
+
*/
|
232 |
+
function add_metabox_restrict_content() {
|
233 |
+
global $current_screen;
|
234 |
+
|
235 |
+
add_meta_box(
|
236 |
+
'um-admin-restrict-content',
|
237 |
+
__( 'Ultimate Member: Content Restriction', 'ultimate-member' ),
|
238 |
+
array( &$this, 'restrict_content_cb' ),
|
239 |
+
$current_screen->id,
|
240 |
+
'normal',
|
241 |
+
'default'
|
242 |
+
);
|
243 |
+
|
244 |
+
/**
|
245 |
+
* UM hook
|
246 |
+
*
|
247 |
+
* @type action
|
248 |
+
* @title um_admin_custom_restrict_content_metaboxes
|
249 |
+
* @description Add restrict content custom metabox
|
250 |
+
* @change_log
|
251 |
+
* ["Since: 2.0"]
|
252 |
+
* @usage add_action( 'um_admin_custom_restrict_content_metaboxes', 'function_name', 10 );
|
253 |
+
* @example
|
254 |
+
* <?php
|
255 |
+
* add_action( 'um_admin_custom_restrict_content_metaboxes', 'my_admin_custom_restrict_content', 10 );
|
256 |
+
* function my_admin_custom_restrict_content() {
|
257 |
+
* // your code here
|
258 |
+
* }
|
259 |
+
* ?>
|
260 |
+
*/
|
261 |
+
do_action( 'um_admin_custom_restrict_content_metaboxes' );
|
262 |
+
}
|
263 |
+
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Content restriction metabox
|
267 |
+
*
|
268 |
+
* @param $object
|
269 |
+
* @param $box
|
270 |
+
*/
|
271 |
+
function restrict_content_cb( $object, $box ) {
|
272 |
+
include_once UM()->admin()->templates_path . 'access/restrict_content.php';
|
273 |
+
wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_restrict_content_nonce' );
|
274 |
+
}
|
275 |
+
|
276 |
+
|
277 |
+
/**
|
278 |
+
* Init the metaboxes
|
279 |
+
*/
|
280 |
+
function add_taxonomy_metabox() {
|
281 |
+
//restrict content metabox
|
282 |
+
$all_taxonomies = get_taxonomies( array( 'public' => true ) );
|
283 |
+
$tax_types = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
284 |
+
$exclude_taxonomies = UM()->excluded_taxonomies();
|
285 |
+
|
286 |
+
foreach ( $all_taxonomies as $key => $taxonomy ) {
|
287 |
+
if ( in_array( $key, $exclude_taxonomies ) || empty( $tax_types[$key] ) )
|
288 |
+
continue;
|
289 |
+
|
290 |
+
add_action( $taxonomy . '_add_form_fields', array( &$this, 'um_category_access_fields_create' ) );
|
291 |
+
add_action( $taxonomy . '_edit_form_fields', array( &$this, 'um_category_access_fields_edit' ) );
|
292 |
+
add_action( 'create_' . $taxonomy, array( &$this, 'um_category_access_fields_save' ) );
|
293 |
+
add_action( 'edited_' . $taxonomy, array( &$this, 'um_category_access_fields_save' ) );
|
294 |
+
}
|
295 |
+
}
|
296 |
+
|
297 |
+
|
298 |
+
/**
|
299 |
+
* @param $post_id
|
300 |
+
* @param $post
|
301 |
+
*/
|
302 |
+
function save_metabox_restrict_content( $post_id, $post ) {
|
303 |
+
// validate nonce
|
304 |
+
if ( ! isset( $_POST['um_admin_save_metabox_restrict_content_nonce'] ) ||
|
305 |
+
! wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) ) {
|
306 |
+
return;
|
307 |
+
}
|
308 |
+
|
309 |
+
// validate user
|
310 |
+
$post_type = get_post_type_object( $post->post_type );
|
311 |
+
if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
|
312 |
+
return;
|
313 |
+
}
|
314 |
+
|
315 |
+
if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) {
|
316 |
+
$restriction_meta = UM()->admin()->sanitize_post_restriction_meta( $_POST['um_content_restriction'] );
|
317 |
+
|
318 |
+
update_post_meta( $post_id, 'um_content_restriction', $restriction_meta );
|
319 |
+
} else {
|
320 |
+
delete_post_meta( $post_id, 'um_content_restriction' );
|
321 |
+
}
|
322 |
+
}
|
323 |
+
|
324 |
+
|
325 |
+
/**
|
326 |
+
* @param $post_id
|
327 |
+
*
|
328 |
+
*/
|
329 |
+
function save_attachment_metabox_restrict_content( $post_id ) {
|
330 |
+
// validate nonce
|
331 |
+
if ( ! isset( $_POST['um_admin_save_metabox_restrict_content_nonce'] )
|
332 |
+
|| ! wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) ) {
|
333 |
+
return;
|
334 |
+
}
|
335 |
+
|
336 |
+
$post = get_post( $post_id );
|
337 |
+
|
338 |
+
// validate user
|
339 |
+
$post_type = get_post_type_object( $post->post_type );
|
340 |
+
if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
|
341 |
+
return;
|
342 |
+
}
|
343 |
+
|
344 |
+
if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) {
|
345 |
+
$restriction_meta = UM()->admin()->sanitize_post_restriction_meta( $_POST['um_content_restriction'] );
|
346 |
+
|
347 |
+
update_post_meta( $post_id, 'um_content_restriction', $restriction_meta );
|
348 |
+
} else {
|
349 |
+
delete_post_meta( $post_id, 'um_content_restriction' );
|
350 |
+
}
|
351 |
+
}
|
352 |
+
|
353 |
+
|
354 |
+
/**
|
355 |
+
*
|
356 |
+
*/
|
357 |
+
function um_category_access_fields_create() {
|
358 |
+
/**
|
359 |
+
* UM hook
|
360 |
+
*
|
361 |
+
* @type filter
|
362 |
+
* @title um_admin_category_access_settings_fields
|
363 |
+
* @description Settings fields for terms
|
364 |
+
* @input_vars
|
365 |
+
* [{"var":"$access_settings_fields","type":"array","desc":"Settings Fields"},
|
366 |
+
* {"var":"$data","type":"array","desc":"Settings Data"},
|
367 |
+
* {"var":"$screen","type":"string","desc":"Category Screen"}]
|
368 |
+
* @change_log
|
369 |
+
* ["Since: 2.0"]
|
370 |
+
* @usage add_filter( 'um_admin_category_access_settings_fields', 'function_name', 10, 3 );
|
371 |
+
* @example
|
372 |
+
* <?php
|
373 |
+
* add_filter( 'um_admin_category_access_settings_fields', 'my_admin_category_access_settings_fields', 10, 3 );
|
374 |
+
* function my_admin_category_access_settings_fields( $access_settings_fields, $data, $screen ) {
|
375 |
+
* // your code here
|
376 |
+
* $access_settings_fields[] = array(
|
377 |
+
* 'id' => 'my-field-key',
|
378 |
+
* 'type' => 'my-field-type',
|
379 |
+
* 'label' => __( 'My field Label', 'ultimate-member' ),
|
380 |
+
* 'description' => __( 'My Field Description', 'ultimate-member' ),
|
381 |
+
* 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
|
382 |
+
* );
|
383 |
+
* return $access_settings_fields;
|
384 |
+
* }
|
385 |
+
* ?>
|
386 |
+
*/
|
387 |
+
$fields = apply_filters( 'um_admin_category_access_settings_fields', array(
|
388 |
+
array(
|
389 |
+
'id' => '_um_custom_access_settings',
|
390 |
+
'type' => 'checkbox',
|
391 |
+
'label' => __( 'Restrict access to this term and its posts?', 'ultimate-member' ),
|
392 |
+
'description' => __( 'Activate content restriction for this term and its posts. Affects only posts that do not have individual Restriction Content settings', 'ultimate-member' ),
|
393 |
+
'value' => 0,
|
394 |
+
),
|
395 |
+
array(
|
396 |
+
'id' => '_um_accessible',
|
397 |
+
'type' => 'select',
|
398 |
+
'label' => __( 'Who can access this term and its posts?', 'ultimate-member' ),
|
399 |
+
'value' => '0',
|
400 |
+
'options' => array(
|
401 |
+
'0' => __( 'Everyone', 'ultimate-member' ),
|
402 |
+
'1' => __( 'Logged out users', 'ultimate-member' ),
|
403 |
+
'2' => __( 'Logged in users', 'ultimate-member' ),
|
404 |
+
),
|
405 |
+
'conditional' => array( '_um_custom_access_settings', '=', '1' ),
|
406 |
+
),
|
407 |
+
array(
|
408 |
+
'id' => '_um_access_roles',
|
409 |
+
'type' => 'multi_checkbox',
|
410 |
+
'label' => __( 'Select which roles can access this term and its posts', 'ultimate-member' ),
|
411 |
+
'description' => __( 'Leave empty if you want to display a term for all logged in users', 'ultimate-member' ),
|
412 |
+
'options' => UM()->roles()->get_roles( false ),
|
413 |
+
'columns' => 3,
|
414 |
+
'conditional' => array( '_um_accessible', '=', '2' ),
|
415 |
+
),
|
416 |
+
array(
|
417 |
+
'id' => '_um_access_hide_from_queries',
|
418 |
+
'type' => 'checkbox',
|
419 |
+
'label' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? __( 'Hide from queries', 'ultimate-member' ) : __( 'Would you like to display 404 error on the term\'s archive page and terms\' posts single pages when users haven\'t access?', 'ultimate-member' ),
|
420 |
+
'description' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? __( 'Exclude only from WP queries results', 'ultimate-member' ) : __( 'Recommended to be enabled. Restricted term\'s archive page and all terms\' posts will be hidden by exclusion from WP Query. The safest and most effective method that hides post and its comments from all requests, RSS feeds, etc. on your site', 'ultimate-member' ),
|
421 |
+
'value' => 1,
|
422 |
+
'conditional' => array( '_um_accessible', '!=', '0' ),
|
423 |
+
),
|
424 |
+
array(
|
425 |
+
'id' => '_um_noaccess_action',
|
426 |
+
'type' => 'select',
|
427 |
+
'label' => __( 'What happens when users without access try to view the term\'s post?', 'ultimate-member' ),
|
428 |
+
'description' => __( 'Action when users without access tries to view the term\'s post', 'ultimate-member' ),
|
429 |
+
'value' => '0',
|
430 |
+
'options' => array(
|
431 |
+
'0' => __( 'Show access restricted message', 'ultimate-member' ),
|
432 |
+
'1' => __( 'Redirect user', 'ultimate-member' ),
|
433 |
+
),
|
434 |
+
'conditional' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? array( '_um_accessible', '!=', '0' ) : array( '_um_access_hide_from_queries', '=', '0' ),
|
435 |
+
),
|
436 |
+
array(
|
437 |
+
'id' => '_um_restrict_by_custom_message',
|
438 |
+
'type' => 'select',
|
439 |
+
'label' => __( 'Restricted access message type', 'ultimate-member' ),
|
440 |
+
'description' => __( 'Would you like to use the global default message or apply a custom message to this term\'s post?', 'ultimate-member' ),
|
441 |
+
'value' => '0',
|
442 |
+
'options' => array(
|
443 |
+
'0' => __( 'Global default message', 'ultimate-member' ),
|
444 |
+
'1' => __( 'Custom message', 'ultimate-member' ),
|
445 |
+
),
|
446 |
+
'conditional' => array( '_um_noaccess_action', '=', '0' ),
|
447 |
+
),
|
448 |
+
array(
|
449 |
+
'id' => '_um_restrict_custom_message',
|
450 |
+
'type' => 'wp_editor',
|
451 |
+
'label' => __( 'Custom restricted access message', 'ultimate-member' ),
|
452 |
+
'description' => __( 'You may replace global restricted access message here', 'ultimate-member' ),
|
453 |
+
'value' => '',
|
454 |
+
'conditional' => array( '_um_restrict_by_custom_message', '=', '1' ),
|
455 |
+
),
|
456 |
+
array(
|
457 |
+
'id' => '_um_access_redirect',
|
458 |
+
'type' => 'select',
|
459 |
+
'label' => __( 'Where should users be redirected to?', 'ultimate-member' ),
|
460 |
+
'description' => __( 'Select redirect to page when user hasn\'t access to the term\'s post', 'ultimate-member' ),
|
461 |
+
'value' => '0',
|
462 |
+
'conditional' => array( '_um_noaccess_action', '=', '1' ),
|
463 |
+
'options' => array(
|
464 |
+
'0' => __( 'Login page', 'ultimate-member' ),
|
465 |
+
'1' => __( 'Custom URL', 'ultimate-member' ),
|
466 |
+
),
|
467 |
+
),
|
468 |
+
array(
|
469 |
+
'id' => '_um_access_redirect_url',
|
470 |
+
'type' => 'text',
|
471 |
+
'label' => __( 'Redirect URL', 'ultimate-member' ),
|
472 |
+
'description' => __( 'Set full URL where do you want to redirect the user', 'ultimate-member' ),
|
473 |
+
'value' => '',
|
474 |
+
'conditional' => array( '_um_access_redirect', '=', '1' ),
|
475 |
+
),
|
476 |
+
), array(), 'create' );
|
477 |
+
|
478 |
+
UM()->admin_forms(
|
479 |
+
array(
|
480 |
+
'class' => 'um-restrict-content um-third-column',
|
481 |
+
'prefix_id' => 'um_content_restriction',
|
482 |
+
'without_wrapper' => true,
|
483 |
+
'div_line' => true,
|
484 |
+
'fields' => $fields,
|
485 |
+
)
|
486 |
+
)->render_form();
|
487 |
+
|
488 |
+
wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' );
|
489 |
+
}
|
490 |
+
|
491 |
+
|
492 |
+
/**
|
493 |
+
* @param $term
|
494 |
+
*/
|
495 |
+
function um_category_access_fields_edit( $term ) {
|
496 |
+
$termID = $term->term_id;
|
497 |
+
|
498 |
+
$data = get_term_meta( $termID, 'um_content_restriction', true );
|
499 |
+
|
500 |
+
$_um_access_roles_value = array();
|
501 |
+
if ( ! empty( $data['_um_access_roles'] ) ) {
|
502 |
+
foreach ( $data['_um_access_roles'] as $key => $value ) {
|
503 |
+
if ( $value ) {
|
504 |
+
$_um_access_roles_value[] = $key;
|
505 |
+
}
|
506 |
+
}
|
507 |
+
}
|
508 |
+
|
509 |
+
/**
|
510 |
+
* UM hook
|
511 |
+
*
|
512 |
+
* @type filter
|
513 |
+
* @title um_admin_category_access_settings_fields
|
514 |
+
* @description Settings fields for terms
|
515 |
+
* @input_vars
|
516 |
+
* [{"var":"$access_settings_fields","type":"array","desc":"Settings Fields"},
|
517 |
+
* {"var":"$data","type":"array","desc":"Settings Data"},
|
518 |
+
* {"var":"$screen","type":"string","desc":"Category Screen"}]
|
519 |
+
* @change_log
|
520 |
+
* ["Since: 2.0"]
|
521 |
+
* @usage add_filter( 'um_admin_category_access_settings_fields', 'function_name', 10, 3 );
|
522 |
+
* @example
|
523 |
+
* <?php
|
524 |
+
* add_filter( 'um_admin_category_access_settings_fields', 'my_admin_category_access_settings_fields', 10, 3 );
|
525 |
+
* function my_admin_category_access_settings_fields( $access_settings_fields, $data, $screen ) {
|
526 |
+
* // your code here
|
527 |
+
* $access_settings_fields[] = array(
|
528 |
+
* 'id' => 'my-field-key',
|
529 |
+
* 'type' => 'my-field-type',
|
530 |
+
* 'label' => __( 'My field Label', 'ultimate-member' ),
|
531 |
+
* 'description' => __( 'My Field Description', 'ultimate-member' ),
|
532 |
+
* 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
|
533 |
+
* );
|
534 |
+
* return $access_settings_fields;
|
535 |
+
* }
|
536 |
+
* ?>
|
537 |
+
*/
|
538 |
+
$fields = apply_filters( 'um_admin_category_access_settings_fields', array(
|
539 |
+
array(
|
540 |
+
'id' => '_um_custom_access_settings',
|
541 |
+
'type' => 'checkbox',
|
542 |
+
'label' => __( 'Restrict access to this term and its posts?', 'ultimate-member' ),
|
543 |
+
'description' => __( 'Activate content restriction for this term and its posts. Affects only posts that do not have individual Restriction Content settings', 'ultimate-member' ),
|
544 |
+
'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
|
545 |
+
),
|
546 |
+
array(
|
547 |
+
'id' => '_um_accessible',
|
548 |
+
'type' => 'select',
|
549 |
+
'label' => __( 'Who can access this term and its posts?', 'ultimate-member' ),
|
550 |
+
'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : '0',
|
551 |
+
'options' => array(
|
552 |
+
'0' => __( 'Everyone', 'ultimate-member' ),
|
553 |
+
'1' => __( 'Logged out users', 'ultimate-member' ),
|
554 |
+
'2' => __( 'Logged in users', 'ultimate-member' ),
|
555 |
+
),
|
556 |
+
'conditional' => array( '_um_custom_access_settings', '=', '1' ),
|
557 |
+
),
|
558 |
+
array(
|
559 |
+
'id' => '_um_access_roles',
|
560 |
+
'type' => 'multi_checkbox',
|
561 |
+
'label' => __( 'Select which roles can access this term and its posts', 'ultimate-member' ),
|
562 |
+
'description' => __( 'Leave empty if you want to display a term for all logged in users', 'ultimate-member' ),
|
563 |
+
'value' => $_um_access_roles_value,
|
564 |
+
'options' => UM()->roles()->get_roles( false ),
|
565 |
+
'columns' => 3,
|
566 |
+
'conditional' => array( '_um_accessible', '=', '2' ),
|
567 |
+
),
|
568 |
+
array(
|
569 |
+
'id' => '_um_access_hide_from_queries',
|
570 |
+
'type' => 'checkbox',
|
571 |
+
'label' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? __( 'Hide from queries', 'ultimate-member' ) : __( 'Would you like to display 404 error on the term\'s archive page and terms\' posts single pages when users haven\'t access?', 'ultimate-member' ),
|
572 |
+
'description' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? __( 'Exclude only from WP queries results', 'ultimate-member' ) : __( 'Recommended to be enabled. Restricted term\'s archive page and all terms\' posts will be hidden by exclusion from WP Query. The safest and most effective method that hides post and its comments from all requests, RSS feeds, etc. on your site', 'ultimate-member' ),
|
573 |
+
'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '',
|
574 |
+
'conditional' => array( '_um_accessible', '!=', '0' ),
|
575 |
+
),
|
576 |
+
array(
|
577 |
+
'id' => '_um_noaccess_action',
|
578 |
+
'type' => 'select',
|
579 |
+
'label' => __( 'What happens when users without access try to view the term\'s post?', 'ultimate-member' ),
|
580 |
+
'description' => __( 'Action when users without access tries to view the term\'s post', 'ultimate-member' ),
|
581 |
+
'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : '0',
|
582 |
+
'options' => array(
|
583 |
+
'0' => __( 'Show access restricted message', 'ultimate-member' ),
|
584 |
+
'1' => __( 'Redirect user', 'ultimate-member' ),
|
585 |
+
),
|
586 |
+
'conditional' => UM()->options()->get( 'disable_restriction_pre_queries' ) ? array( '_um_accessible', '!=', '0' ) : array( '_um_access_hide_from_queries', '=', '0' ),
|
587 |
+
),
|
588 |
+
array(
|
589 |
+
'id' => '_um_restrict_by_custom_message',
|
590 |
+
'type' => 'select',
|
591 |
+
'label' => __( 'Restricted access message type', 'ultimate-member' ),
|
592 |
+
'description' => __( 'Would you like to use the global default message or apply a custom message to this term\'s post?', 'ultimate-member' ),
|
593 |
+
'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0',
|
594 |
+
'options' => array(
|
595 |
+
'0' => __( 'Global default message', 'ultimate-member' ),
|
596 |
+
'1' => __( 'Custom message', 'ultimate-member' ),
|
597 |
+
),
|
598 |
+
'conditional' => array( '_um_noaccess_action', '=', '0' ),
|
599 |
+
),
|
600 |
+
array(
|
601 |
+
'id' => '_um_restrict_custom_message',
|
602 |
+
'type' => 'wp_editor',
|
603 |
+
'label' => __( 'Custom restricted access message', 'ultimate-member' ),
|
604 |
+
'description' => __( 'You may replace global restricted access message here', 'ultimate-member' ),
|
605 |
+
'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '',
|
606 |
+
'conditional' => array( '_um_restrict_by_custom_message', '=', '1' ),
|
607 |
+
),
|
608 |
+
array(
|
609 |
+
'id' => '_um_access_redirect',
|
610 |
+
'type' => 'select',
|
611 |
+
'label' => __( 'Where should users be redirected to?', 'ultimate-member' ),
|
612 |
+
'description' => __( 'Select redirect to page when user hasn\'t access to the term\'s post', 'ultimate-member' ),
|
613 |
+
'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0',
|
614 |
+
'options' => array(
|
615 |
+
'0' => __( 'Login page', 'ultimate-member' ),
|
616 |
+
'1' => __( 'Custom URL', 'ultimate-member' ),
|
617 |
+
),
|
618 |
+
'conditional' => array( '_um_noaccess_action', '=', '1' ),
|
619 |
+
),
|
620 |
+
array(
|
621 |
+
'id' => '_um_access_redirect_url',
|
622 |
+
'type' => 'text',
|
623 |
+
'label' => __( 'Redirect URL', 'ultimate-member' ),
|
624 |
+
'description' => __( 'Set full URL where do you want to redirect the user', 'ultimate-member' ),
|
625 |
+
'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '',
|
626 |
+
'conditional' => array( '_um_access_redirect', '=', '1' ),
|
627 |
+
),
|
628 |
+
), $data, 'edit' );
|
629 |
+
|
630 |
+
UM()->admin_forms(
|
631 |
+
array(
|
632 |
+
'class' => 'um-restrict-content um-third-column',
|
633 |
+
'prefix_id' => 'um_content_restriction',
|
634 |
+
'without_wrapper' => true,
|
635 |
+
'fields' => $fields,
|
636 |
+
)
|
637 |
+
)->render_form();
|
638 |
+
|
639 |
+
wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' );
|
640 |
+
}
|
641 |
+
|
642 |
+
|
643 |
+
/**
|
644 |
+
* @param $termID
|
645 |
+
*
|
646 |
+
* @return mixed
|
647 |
+
*/
|
648 |
+
function um_category_access_fields_save( $termID ) {
|
649 |
+
|
650 |
+
// validate nonce
|
651 |
+
if ( ! isset( $_REQUEST['um_admin_save_taxonomy_restrict_content_nonce'] ) || ! wp_verify_nonce( $_REQUEST['um_admin_save_taxonomy_restrict_content_nonce'], basename( __FILE__ ) ) ) {
|
652 |
+
return $termID;
|
653 |
+
}
|
654 |
+
|
655 |
+
// validate user
|
656 |
+
$term = get_term( $termID );
|
657 |
+
$taxonomy = get_taxonomy( $term->taxonomy );
|
658 |
+
|
659 |
+
if ( ! current_user_can( $taxonomy->cap->edit_terms, $termID ) ) {
|
660 |
+
return $termID;
|
661 |
+
}
|
662 |
+
|
663 |
+
if ( ! empty( $_REQUEST['um_content_restriction'] ) && is_array( $_REQUEST['um_content_restriction'] ) ) {
|
664 |
+
$restriction_meta = UM()->admin()->sanitize_term_restriction_meta( $_REQUEST['um_content_restriction'] );
|
665 |
+
|
666 |
+
update_term_meta( $termID, 'um_content_restriction', $restriction_meta );
|
667 |
+
} else {
|
668 |
+
delete_term_meta( $termID, 'um_content_restriction' );
|
669 |
+
}
|
670 |
+
|
671 |
+
return $termID;
|
672 |
+
}
|
673 |
+
|
674 |
+
|
675 |
+
/**
|
676 |
+
* Load a directory metabox
|
677 |
+
*
|
678 |
+
* @param $object
|
679 |
+
* @param $box
|
680 |
+
*/
|
681 |
+
function load_metabox_directory( $object, $box ) {
|
682 |
+
$box['id'] = str_replace( 'um-admin-form-', '', $box['id'] );
|
683 |
+
|
684 |
+
preg_match('#\{.*?\}#s', $box['id'], $matches );
|
685 |
+
|
686 |
+
if ( isset( $matches[0] ) ) {
|
687 |
+
$path = $matches[0];
|
688 |
+
$box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
|
689 |
+
} else {
|
690 |
+
$path = um_path;
|
691 |
+
}
|
692 |
+
|
693 |
+
$path = str_replace('{','', $path );
|
694 |
+
$path = str_replace('}','', $path );
|
695 |
+
|
696 |
+
|
697 |
+
include_once $path . 'includes/admin/templates/directory/'. $box['id'] . '.php';
|
698 |
+
if ( ! $this->directory_nonce_added ) {
|
699 |
+
$this->directory_nonce_added = true;
|
700 |
+
wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_directory_nonce' );
|
701 |
+
}
|
702 |
+
}
|
703 |
+
|
704 |
+
|
705 |
+
/**
|
706 |
+
* Load a role metabox
|
707 |
+
*
|
708 |
+
* @param $object
|
709 |
+
* @param $box
|
710 |
+
*/
|
711 |
+
function load_metabox_role( $object, $box ) {
|
712 |
+
global $post;
|
713 |
+
|
714 |
+
$box['id'] = str_replace( 'um-admin-form-', '', $box['id'] );
|
715 |
+
|
716 |
+
if ( $box['id'] == 'builder' ) {
|
717 |
+
UM()->builder()->form_id = get_the_ID();
|
718 |
+
}
|
719 |
+
|
720 |
+
preg_match('#\{.*?\}#s', $box['id'], $matches);
|
721 |
+
|
722 |
+
if ( isset($matches[0]) ){
|
723 |
+
$path = $matches[0];
|
724 |
+
$box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
|
725 |
+
} else {
|
726 |
+
$path = um_path;
|
727 |
+
}
|
728 |
+
|
729 |
+
$path = str_replace('{','', $path );
|
730 |
+
$path = str_replace('}','', $path );
|
731 |
+
|
732 |
+
include_once $path . 'includes/admin/templates/role/'. $box['id'] . '.php';
|
733 |
+
//wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_role_nonce' );
|
734 |
+
}
|
735 |
+
|
736 |
+
|
737 |
+
/**
|
738 |
+
* Load a form metabox
|
739 |
+
*
|
740 |
+
* @param $object
|
741 |
+
* @param $box
|
742 |
+
*/
|
743 |
+
function load_metabox_form( $object, $box ) {
|
744 |
+
global $post;
|
745 |
+
|
746 |
+
$box['id'] = str_replace( 'um-admin-form-','', $box['id'] );
|
747 |
+
|
748 |
+
if ( $box['id'] == 'builder' ) {
|
749 |
+
UM()->builder()->form_id = get_the_ID();
|
750 |
+
}
|
751 |
+
|
752 |
+
preg_match('#\{.*?\}#s', $box['id'], $matches);
|
753 |
+
|
754 |
+
if ( isset( $matches[0] ) ) {
|
755 |
+
$path = $matches[0];
|
756 |
+
$box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
|
757 |
+
} else {
|
758 |
+
$path = um_path;
|
759 |
+
}
|
760 |
+
|
761 |
+
$path = str_replace('{','', $path );
|
762 |
+
$path = str_replace('}','', $path );
|
763 |
+
|
764 |
+
include_once $path . 'includes/admin/templates/form/'. $box['id'] . '.php';
|
765 |
+
|
766 |
+
if ( ! $this->form_nonce_added ) {
|
767 |
+
$this->form_nonce_added = true;
|
768 |
+
wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_form_nonce' );
|
769 |
+
}
|
770 |
+
}
|
771 |
+
|
772 |
+
|
773 |
+
/**
|
774 |
+
* Load admin custom metabox
|
775 |
+
*
|
776 |
+
* @param $object
|
777 |
+
* @param $box
|
778 |
+
*/
|
779 |
+
function load_metabox_custom( $object, $box ) {
|
780 |
+
global $post;
|
781 |
+
|
782 |
+
$box['id'] = str_replace('um-admin-custom-','', $box['id']);
|
783 |
+
|
784 |
+
preg_match('#\{.*?\}#s', $box['id'], $matches);
|
785 |
+
|
786 |
+
if ( isset($matches[0]) ){
|
787 |
+
$path = $matches[0];
|
788 |
+
$box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] );
|
789 |
+
} else {
|
790 |
+
$path = um_path;
|
791 |
+
}
|
792 |
+
|
793 |
+
$path = str_replace('{','', $path );
|
794 |
+
$path = str_replace('}','', $path );
|
795 |
+
|
796 |
+
include_once $path . 'includes/admin/templates/'. $box['id'] . '.php';
|
797 |
+
if ( ! $this->custom_nonce_added ) {
|
798 |
+
$this->custom_nonce_added = true;
|
799 |
+
wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_custom_nonce' );
|
800 |
+
}
|
801 |
+
}
|
802 |
+
|
803 |
+
|
804 |
+
/**
|
805 |
+
* Add directory metabox
|
806 |
+
*/
|
807 |
+
function add_metabox_directory() {
|
808 |
+
add_meta_box( 'um-admin-form-general', __( 'General Options', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
|
809 |
+
add_meta_box( 'um-admin-form-sorting', __( 'Sorting', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
|
810 |
+
add_meta_box( 'um-admin-form-profile', __( 'Profile Card', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
|
811 |
+
add_meta_box( 'um-admin-form-search', __( 'Search Options', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
|
812 |
+
add_meta_box( 'um-admin-form-pagination', __( 'Results & Pagination', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' );
|
813 |
+
add_meta_box( 'um-admin-form-shortcode', __( 'Shortcode', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'side', 'default' );
|
814 |
+
add_meta_box( 'um-admin-form-appearance', __( 'Styling: General', 'ultimate-member' ), array( &$this, 'load_metabox_directory'), 'um_directory', 'side', 'default' );
|
815 |
+
}
|
816 |
+
|
817 |
+
|
818 |
+
/**
|
819 |
+
* Add role metabox
|
820 |
+
*/
|
821 |
+
function add_metabox_role() {
|
822 |
+
$callback = array( &$this, 'load_metabox_role' );
|
823 |
+
|
824 |
+
$roles_metaboxes = array(
|
825 |
+
array(
|
826 |
+
'id' => 'um-admin-form-admin-permissions',
|
827 |
+
'title' => __( 'Administrative Permissions', 'ultimate-member' ),
|
828 |
+
'callback' => $callback,
|
829 |
+
'screen' => 'um_role_meta',
|
830 |
+
'context' => 'normal',
|
831 |
+
'priority' => 'default'
|
832 |
+
),
|
833 |
+
array(
|
834 |
+
'id' => 'um-admin-form-general',
|
835 |
+
'title' => __( 'General Permissions', 'ultimate-member' ),
|
836 |
+
'callback' => $callback,
|
837 |
+
'screen' => 'um_role_meta',
|
838 |
+
'context' => 'normal',
|
839 |
+
'priority' => 'default'
|
840 |
+
),
|
841 |
+
array(
|
842 |
+
'id' => 'um-admin-form-profile',
|
843 |
+
'title' => __( 'Profile Access', 'ultimate-member' ),
|
844 |
+
'callback' => $callback,
|
845 |
+
'screen' => 'um_role_meta',
|
846 |
+
'context' => 'normal',
|
847 |
+
'priority' => 'default'
|
848 |
+
)
|
849 |
+
);
|
850 |
+
|
851 |
+
if ( ! isset( $_GET['id'] ) || 'administrator' !== sanitize_key( $_GET['id'] ) ) {
|
852 |
+
$roles_metaboxes[] = array(
|
853 |
+
'id' => 'um-admin-form-home',
|
854 |
+
'title' => __( 'Homepage Options', 'ultimate-member' ),
|
855 |
+
'callback' => $callback,
|
856 |
+
'screen' => 'um_role_meta',
|
857 |
+
'context' => 'normal',
|
858 |
+
'priority' => 'default'
|
859 |
+
);
|
860 |
+
}
|
861 |
+
|
862 |
+
$roles_metaboxes = array_merge( $roles_metaboxes, array(
|
863 |
+
array(
|
864 |
+
'id' => 'um-admin-form-register',
|
865 |
+
'title' => __( 'Registration Options', 'ultimate-member' ),
|
866 |
+
'callback' => $callback,
|
867 |
+
'screen' => 'um_role_meta',
|
868 |
+
'context' => 'normal',
|
869 |
+
'priority' => 'default'
|
870 |
+
),
|
871 |
+
array(
|
872 |
+
'id' => 'um-admin-form-login',
|
873 |
+
'title' => __( 'Login Options', 'ultimate-member' ),
|
874 |
+
'callback' => $callback,
|
875 |
+
'screen' => 'um_role_meta',
|
876 |
+
'context' => 'normal',
|
877 |
+
'priority' => 'default'
|
878 |
+
),
|
879 |
+
array(
|
880 |
+
'id' => 'um-admin-form-logout',
|
881 |
+
'title' => __( 'Logout Options', 'ultimate-member' ),
|
882 |
+
'callback' => $callback,
|
883 |
+
'screen' => 'um_role_meta',
|
884 |
+
'context' => 'normal',
|
885 |
+
'priority' => 'default'
|
886 |
+
),
|
887 |
+
array(
|
888 |
+
'id' => 'um-admin-form-delete',
|
889 |
+
'title' => __( 'Delete Options', 'ultimate-member' ),
|
890 |
+
'callback' => $callback,
|
891 |
+
'screen' => 'um_role_meta',
|
892 |
+
'context' => 'normal',
|
893 |
+
'priority' => 'default'
|
894 |
+
),
|
895 |
+
array(
|
896 |
+
'id' => 'um-admin-form-publish',
|
897 |
+
'title' => __( 'Publish', 'ultimate-member' ),
|
898 |
+
'callback' => $callback,
|
899 |
+
'screen' => 'um_role_meta',
|
900 |
+
'context' => 'side',
|
901 |
+
'priority' => 'default'
|
902 |
+
)
|
903 |
+
) );
|
904 |
+
|
905 |
+
/**
|
906 |
+
* UM hook
|
907 |
+
*
|
908 |
+
* @type filter
|
909 |
+
* @title um_admin_role_metaboxes
|
910 |
+
* @description Extend metaboxes at Add/Edit User Role
|
911 |
+
* @input_vars
|
912 |
+
* [{"var":"$roles_metaboxes","type":"array","desc":"Metaboxes at Add/Edit UM Role"}]
|
913 |
+
* @change_log
|
914 |
+
* ["Since: 2.0"]
|
915 |
+
* @usage add_filter( 'um_admin_role_metaboxes', 'function_name', 10, 1 );
|
916 |
+
* @example
|
917 |
+
* <?php
|
918 |
+
* add_filter( 'um_admin_role_metaboxes', 'my_admin_role_metaboxes', 10, 1 );
|
919 |
+
* function my_admin_role_metaboxes( $roles_metaboxes ) {
|
920 |
+
* // your code here
|
921 |
+
* $roles_metaboxes[] = array(
|
922 |
+
* 'id' => 'um-admin-form-your-custom',
|
923 |
+
* 'title' => __( 'My Roles Metabox', 'ultimate-member' ),
|
924 |
+
* 'callback' => 'my-metabox-callback',
|
925 |
+
* 'screen' => 'um_role_meta',
|
926 |
+
* 'context' => 'side',
|
927 |
+
* 'priority' => 'default'
|
928 |
+
* );
|
929 |
+
*
|
930 |
+
* return $roles_metaboxes;
|
931 |
+
* }
|
932 |
+
* ?>
|
933 |
+
*/
|
934 |
+
$roles_metaboxes = apply_filters( 'um_admin_role_metaboxes', $roles_metaboxes );
|
935 |
+
|
936 |
+
$wp_caps_metabox = false;
|
937 |
+
if ( ! empty( $_GET['id'] ) ) {
|
938 |
+
$data = get_option( 'um_role_' . sanitize_key( $_GET['id'] ) . '_meta' );
|
939 |
+
if ( ! empty( $data['_um_is_custom'] ) ) {
|
940 |
+
$wp_caps_metabox = true;
|
941 |
+
}
|
942 |
+
}
|
943 |
+
if ( 'add' == sanitize_key( $_GET['tab'] ) || $wp_caps_metabox ) {
|
944 |
+
$roles_metaboxes[] = array(
|
945 |
+
'id' => 'um-admin-form-wp-capabilities',
|
946 |
+
'title' => __( 'WP Capabilities', 'ultimate-member' ),
|
947 |
+
'callback' => $callback,
|
948 |
+
'screen' => 'um_role_meta',
|
949 |
+
'context' => 'normal',
|
950 |
+
'priority' => 'default'
|
951 |
+
);
|
952 |
+
}
|
953 |
+
|
954 |
+
|
955 |
+
foreach ( $roles_metaboxes as $metabox ) {
|
956 |
+
add_meta_box(
|
957 |
+
$metabox['id'],
|
958 |
+
$metabox['title'],
|
959 |
+
$metabox['callback'],
|
960 |
+
$metabox['screen'],
|
961 |
+
$metabox['context'],
|
962 |
+
$metabox['priority']
|
963 |
+
);
|
964 |
+
}
|
965 |
+
}
|
966 |
+
|
967 |
+
|
968 |
+
/**
|
969 |
+
* Add form metabox
|
970 |
+
*/
|
971 |
+
function add_metabox_form() {
|
972 |
+
|
973 |
+
add_meta_box( 'um-admin-form-mode', __( 'Select Form Type', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' );
|
974 |
+
add_meta_box( 'um-admin-form-builder', __( 'Form Builder', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' );
|
975 |
+
add_meta_box( 'um-admin-form-shortcode', __( 'Shortcode', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
|
976 |
+
|
977 |
+
add_meta_box( 'um-admin-form-register_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
|
978 |
+
|
979 |
+
/**
|
980 |
+
* UM hook
|
981 |
+
*
|
982 |
+
* @type action
|
983 |
+
* @title um_admin_custom_register_metaboxes
|
984 |
+
* @description Add custom metaboxes for register form
|
985 |
+
* @change_log
|
986 |
+
* ["Since: 2.0"]
|
987 |
+
* @usage add_action( 'um_admin_custom_register_metaboxes', 'function_name', 10 );
|
988 |
+
* @example
|
989 |
+
* <?php
|
990 |
+
* add_action( 'um_admin_custom_register_metaboxes', 'my_admin_custom_register_metaboxes', 10 );
|
991 |
+
* function my_admin_custom_register_metaboxes() {
|
992 |
+
* // your code here
|
993 |
+
* }
|
994 |
+
* ?>
|
995 |
+
*/
|
996 |
+
do_action( 'um_admin_custom_register_metaboxes' );
|
997 |
+
|
998 |
+
add_meta_box( 'um-admin-form-profile_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
|
999 |
+
add_meta_box( 'um-admin-form-profile_settings', __( 'User Meta', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
|
1000 |
+
|
1001 |
+
/**
|
1002 |
+
* UM hook
|
1003 |
+
*
|
1004 |
+
* @type action
|
1005 |
+
* @title um_admin_custom_profile_metaboxes
|
1006 |
+
* @description Add custom metaboxes for profile form
|
1007 |
+
* @change_log
|
1008 |
+
* ["Since: 2.0"]
|
1009 |
+
* @usage add_action( 'um_admin_custom_profile_metaboxes', 'function_name', 10 );
|
1010 |
+
* @example
|
1011 |
+
* <?php
|
1012 |
+
* add_action( 'um_admin_custom_profile_metaboxes', 'my_admin_custom_profile_metaboxes', 10 );
|
1013 |
+
* function my_admin_custom_profile_metaboxes() {
|
1014 |
+
* // your code here
|
1015 |
+
* }
|
1016 |
+
* ?>
|
1017 |
+
*/
|
1018 |
+
do_action( 'um_admin_custom_profile_metaboxes' );
|
1019 |
+
|
1020 |
+
add_meta_box( 'um-admin-form-login_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
|
1021 |
+
add_meta_box( 'um-admin-form-login_settings', __( 'Options', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' );
|
1022 |
+
|
1023 |
+
/**
|
1024 |
+
* UM hook
|
1025 |
+
*
|
1026 |
+
* @type action
|
1027 |
+
* @title um_admin_custom_login_metaboxes
|
1028 |
+
* @description Add custom metaboxes for login form
|
1029 |
+
* @change_log
|
1030 |
+
* ["Since: 2.0"]
|
1031 |
+
* @usage add_action( 'um_admin_custom_login_metaboxes', 'function_name', 10 );
|
1032 |
+
* @example
|
1033 |
+
* <?php
|
1034 |
+
* add_action( 'um_admin_custom_login_metaboxes', 'my_admin_custom_login_metaboxes', 10 );
|
1035 |
+
* function my_admin_custom_login_metaboxes() {
|
1036 |
+
* // your code here
|
1037 |
+
* }
|
1038 |
+
* ?>
|
1039 |
+
*/
|
1040 |
+
do_action( 'um_admin_custom_login_metaboxes' );
|
1041 |
+
}
|
1042 |
+
|
1043 |
+
|
1044 |
+
/**
|
1045 |
+
* Save directory metabox
|
1046 |
+
*
|
1047 |
+
* @param $post_id
|
1048 |
+
* @param $post
|
1049 |
+
*/
|
1050 |
+
function save_metabox_directory( $post_id, $post ) {
|
1051 |
+
global $wpdb;
|
1052 |
+
|
1053 |
+
// validate nonce
|
1054 |
+
if ( ! isset( $_POST['um_admin_save_metabox_directory_nonce'] ) ||
|
1055 |
+
! wp_verify_nonce( $_POST['um_admin_save_metabox_directory_nonce'], basename( __FILE__ ) ) ) {
|
1056 |
+
return;
|
1057 |
+
}
|
1058 |
+
|
1059 |
+
// validate post type
|
1060 |
+
if ( $post->post_type != 'um_directory' ) {
|
1061 |
+
return;
|
1062 |
+
}
|
1063 |
+
|
1064 |
+
// validate user
|
1065 |
+
$post_type = get_post_type_object( $post->post_type );
|
1066 |
+
if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
|
1067 |
+
return;
|
1068 |
+
}
|
1069 |
+
|
1070 |
+
$where = array( 'ID' => $post_id );
|
1071 |
+
|
1072 |
+
if ( empty( $_POST['post_title'] ) ) {
|
1073 |
+
$_POST['post_title'] = sprintf( __( 'Directory #%s', 'ultimate-member' ), $post_id );
|
1074 |
+
}
|
1075 |
+
|
1076 |
+
$wpdb->update( $wpdb->posts, array( 'post_title' => sanitize_text_field( $_POST['post_title'] ) ), $where );
|
1077 |
+
|
1078 |
+
do_action( 'um_before_member_directory_save', $post_id );
|
1079 |
+
|
1080 |
+
// save
|
1081 |
+
delete_post_meta( $post_id, '_um_roles' );
|
1082 |
+
delete_post_meta( $post_id, '_um_tagline_fields' );
|
1083 |
+
delete_post_meta( $post_id, '_um_reveal_fields' );
|
1084 |
+
delete_post_meta( $post_id, '_um_search_fields' );
|
1085 |
+
delete_post_meta( $post_id, '_um_roles_can_search' );
|
1086 |
+
delete_post_meta( $post_id, '_um_roles_can_filter' );
|
1087 |
+
delete_post_meta( $post_id, '_um_show_these_users' );
|
1088 |
+
delete_post_meta( $post_id, '_um_exclude_these_users' );
|
1089 |
+
|
1090 |
+
delete_post_meta( $post_id, '_um_search_filters' );
|
1091 |
+
delete_post_meta( $post_id, '_um_search_filters_gmt' );
|
1092 |
+
|
1093 |
+
delete_post_meta( $post_id, '_um_sorting_fields' );
|
1094 |
+
|
1095 |
+
//save metadata
|
1096 |
+
$metadata = UM()->admin()->sanitize_member_directory_meta( $_POST['um_metadata'] );
|
1097 |
+
foreach ( $metadata as $k => $v ) {
|
1098 |
+
|
1099 |
+
if ( $k == '_um_show_these_users' && trim( $v ) ) {
|
1100 |
+
$v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
|
1101 |
+
}
|
1102 |
+
|
1103 |
+
if ( $k == '_um_exclude_these_users' && trim( $v ) ) {
|
1104 |
+
$v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
|
1105 |
+
}
|
1106 |
+
|
1107 |
+
if ( strstr( $k, '_um_' ) ) {
|
1108 |
+
|
1109 |
+
if ( $k === '_um_is_default' ) {
|
1110 |
+
|
1111 |
+
$mode = UM()->query()->get_attr( 'mode', $post_id );
|
1112 |
+
|
1113 |
+
if ( ! empty( $mode ) ) {
|
1114 |
+
|
1115 |
+
$posts = $wpdb->get_col(
|
1116 |
+
"SELECT post_id
|
1117 |
+
FROM {$wpdb->postmeta}
|
1118 |
+
WHERE meta_key = '_um_mode' AND
|
1119 |
+
meta_value = 'directory'"
|
1120 |
+
);
|
1121 |
+
|
1122 |
+
foreach ( $posts as $p_id ) {
|
1123 |
+
delete_post_meta( $p_id, '_um_is_default' );
|
1124 |
+
}
|
1125 |
+
|
1126 |
+
}
|
1127 |
+
|
1128 |
+
}
|
1129 |
+
|
1130 |
+
$v = apply_filters( 'um_member_directory_meta_value_before_save', $v, $k, $post_id );
|
1131 |
+
|
1132 |
+
update_post_meta( $post_id, $k, $v );
|
1133 |
+
|
1134 |
+
}
|
1135 |
+
}
|
1136 |
+
|
1137 |
+
update_post_meta( $post_id, '_um_search_filters_gmt', (int) $_POST['um-gmt-offset'] );
|
1138 |
+
}
|
1139 |
+
|
1140 |
+
|
1141 |
+
/**
|
1142 |
+
* Save form metabox
|
1143 |
+
*
|
1144 |
+
* @param $post_id
|
1145 |
+
* @param $post
|
1146 |
+
*/
|
1147 |
+
function save_metabox_form( $post_id, $post ) {
|
1148 |
+
global $wpdb;
|
1149 |
+
|
1150 |
+
// validate nonce
|
1151 |
+
if ( ! isset( $_POST['um_admin_save_metabox_form_nonce'] ) ||
|
1152 |
+
! wp_verify_nonce( $_POST['um_admin_save_metabox_form_nonce'], basename( __FILE__ ) ) ) {
|
1153 |
+
return;
|
1154 |
+
}
|
1155 |
+
|
1156 |
+
// validate post type
|
1157 |
+
if ( $post->post_type != 'um_form' ) {
|
1158 |
+
return;
|
1159 |
+
}
|
1160 |
+
|
1161 |
+
// validate user
|
1162 |
+
$post_type = get_post_type_object( $post->post_type );
|
1163 |
+
if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
|
1164 |
+
return;
|
1165 |
+
}
|
1166 |
+
|
1167 |
+
$where = array( 'ID' => $post_id );
|
1168 |
+
if ( empty( $_POST['post_title'] ) ) {
|
1169 |
+
$_POST['post_title'] = sprintf( __( 'Form #%s', 'ultimate-member' ), $post_id );
|
1170 |
+
}
|
1171 |
+
$wpdb->update( $wpdb->posts, array( 'post_title' => sanitize_text_field( $_POST['post_title'] ) ), $where );
|
1172 |
+
|
1173 |
+
// save
|
1174 |
+
delete_post_meta( $post_id, '_um_profile_metafields' );
|
1175 |
+
|
1176 |
+
$form_meta = UM()->admin()->sanitize_form_meta( $_POST['form'] );
|
1177 |
+
|
1178 |
+
foreach ( $form_meta as $k => $v ) {
|
1179 |
+
if ( strstr( $k, '_um_' ) ) {
|
1180 |
+
if ( $k === '_um_is_default' ) {
|
1181 |
+
$mode = UM()->query()->get_attr( 'mode', $post_id );
|
1182 |
+
if ( ! empty( $mode ) ) {
|
1183 |
+
$posts = $wpdb->get_col( $wpdb->prepare(
|
1184 |
+
"SELECT post_id
|
1185 |
+
FROM {$wpdb->postmeta}
|
1186 |
+
WHERE meta_key = '_um_mode' AND
|
1187 |
+
meta_value = %s",
|
1188 |
+
$mode
|
1189 |
+
) );
|
1190 |
+
foreach ( $posts as $p_id ) {
|
1191 |
+
delete_post_meta( $p_id, '_um_is_default' );
|
1192 |
+
}
|
1193 |
+
}
|
1194 |
+
}
|
1195 |
+
|
1196 |
+
update_post_meta( $post_id, $k, $v );
|
1197 |
+
}
|
1198 |
+
}
|
1199 |
+
|
1200 |
+
}
|
1201 |
+
|
1202 |
+
|
1203 |
+
/**
|
1204 |
+
* Load modal content
|
1205 |
+
*/
|
1206 |
+
function load_modal_content() {
|
1207 |
+
$screen = get_current_screen();
|
1208 |
+
|
1209 |
+
if ( isset( $screen->id ) && strstr( $screen->id, 'um_form' ) ) {
|
1210 |
+
foreach ( glob( um_path . 'includes/admin/templates/modal/forms/*.php' ) as $modal_content ) {
|
1211 |
+
include_once $modal_content;
|
1212 |
+
}
|
1213 |
+
}
|
1214 |
+
|
1215 |
+
if ( $this->init_icon ) {
|
1216 |
+
include_once um_path . 'includes/admin/templates/modal/forms/fonticons.php';
|
1217 |
+
}
|
1218 |
+
|
1219 |
+
if ( $screen->id == 'users' ) {
|
1220 |
+
include_once um_path . 'includes/admin/templates/modal/dynamic_registration_preview.php';
|
1221 |
+
}
|
1222 |
+
|
1223 |
+
// needed on forms only
|
1224 |
+
if ( ! isset( $this->is_loaded ) && isset( $screen->id ) && strstr( $screen->id, 'um_form' ) ) {
|
1225 |
+
$settings['textarea_rows'] = 8;
|
1226 |
+
|
1227 |
+
echo '<div class="um-hidden-editor-edit" style="display:none;">';
|
1228 |
+
wp_editor( '', 'um_editor_edit', $settings );
|
1229 |
+
echo '</div>';
|
1230 |
+
|
1231 |
+
echo '<div class="um-hidden-editor-new" style="display:none;">';
|
1232 |
+
wp_editor( '', 'um_editor_new', $settings );
|
1233 |
+
echo '</div>';
|
1234 |
+
|
1235 |
+
$this->is_loaded = true;
|
1236 |
+
}
|
1237 |
+
}
|
1238 |
+
|
1239 |
+
|
1240 |
+
/**
|
1241 |
+
* Show field input for edit at modal field
|
1242 |
+
*
|
1243 |
+
* @param $attribute
|
1244 |
+
* @param null $form_id
|
1245 |
+
* @param array $field_args
|
1246 |
+
*/
|
1247 |
+
function field_input( $attribute, $form_id = null, $field_args = array() ) {
|
1248 |
+
|
1249 |
+
if ( $this->in_edit == true ) { // we're editing a field
|
1250 |
+
$real_attr = substr( $attribute, 1 );
|
1251 |
+
$this->edit_mode_value = isset( $this->edit_array[ $real_attr ] ) ? $this->edit_array[ $real_attr ] : null;
|
1252 |
+
}
|
1253 |
+
|
1254 |
+
switch ( $attribute ) {
|
1255 |
+
|
1256 |
+
default:
|
1257 |
+
|
1258 |
+
/**
|
1259 |
+
* UM hook
|
1260 |
+
*
|
1261 |
+
* @type action
|
1262 |
+
* @title um_admin_field_edit_hook{$attribute}
|
1263 |
+
* @description Integration for 3-d party fields at wp-admin
|
1264 |
+
* @input_vars
|
1265 |
+
* [{"var":"$edit_mode_value","type":"string","desc":"Post ID"}]
|
1266 |
+
* @change_log
|
1267 |
+
* ["Since: 2.0"]
|
1268 |
+
* @usage add_action( 'um_admin_field_edit_hook{$attribute}', 'function_name', 10, 1 );
|
1269 |
+
* @example
|
1270 |
+
* <?php
|
1271 |
+
* add_action( 'um_admin_field_edit_hook{$attribute}', 'my_admin_field_edit', 10, 1 );
|
1272 |
+
* function my_admin_field_edit( $edit_mode_value ) {
|
1273 |
+
* // your code here
|
1274 |
+
* }
|
1275 |
+
* ?>
|
1276 |
+
*/
|
1277 |
+
do_action( "um_admin_field_edit_hook{$attribute}", $this->edit_mode_value, $form_id, $this->edit_array );
|
1278 |
+
|
1279 |
+
break;
|
1280 |
+
|
1281 |
+
case '_visibility':
|
1282 |
+
?>
|
1283 |
+
|
1284 |
+
<p><label for="_visibility"><?php _e( 'Visibility', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select where this field should appear. This option should only be changed on the profile form and allows you to show a field in one mode only (edit or view) or in both modes.','ultimate-member' ) ); ?></label>
|
1285 |
+
<select name="_visibility" id="_visibility" style="width: 100%">
|
1286 |
+
<option value="all" <?php selected( 'all', $this->edit_mode_value ); ?>><?php _e( 'View everywhere', 'ultimate-member' ) ?></option>
|
1287 |
+
<option value="edit" <?php selected( 'edit', $this->edit_mode_value ); ?>><?php _e( 'Edit mode only', 'ultimate-member' ) ?></option>
|
1288 |
+
<option value="view" <?php selected( 'view', $this->edit_mode_value ); ?>><?php _e( 'View mode only', 'ultimate-member' ) ?></option>
|
1289 |
+
</select>
|
1290 |
+
</p>
|
1291 |
+
|
1292 |
+
<?php
|
1293 |
+
break;
|
1294 |
+
|
1295 |
+
case '_conditional_action':
|
1296 |
+
case '_conditional_action1':
|
1297 |
+
case '_conditional_action2':
|
1298 |
+
case '_conditional_action3':
|
1299 |
+
case '_conditional_action4':
|
1300 |
+
?>
|
1301 |
+
|
1302 |
+
<p>
|
1303 |
+
<select name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" style="width: 90px">
|
1304 |
+
|
1305 |
+
<option></option>
|
1306 |
+
|
1307 |
+
<?php $actions = array( 'show', 'hide' );
|
1308 |
+
foreach ( $actions as $action ) { ?>
|
1309 |
+
|
1310 |
+
<option value="<?php echo esc_attr( $action ); ?>" <?php selected( $action, $this->edit_mode_value ); ?>><?php echo $action; ?></option>
|
1311 |
+
|
1312 |
+
<?php } ?>
|
1313 |
+
|
1314 |
+
</select>
|
1315 |
+
|
1316 |
+
<?php _e( 'If' ); ?>
|
1317 |
+
</p>
|
1318 |
+
|
1319 |
+
<?php
|
1320 |
+
break;
|
1321 |
+
|
1322 |
+
case '_conditional_field':
|
1323 |
+
case '_conditional_field1':
|
1324 |
+
case '_conditional_field2':
|
1325 |
+
case '_conditional_field3':
|
1326 |
+
case '_conditional_field4':
|
1327 |
+
?>
|
1328 |
+
|
1329 |
+
<p>
|
1330 |
+
<select name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" style="width: 150px">
|
1331 |
+
|
1332 |
+
<option></option>
|
1333 |
+
|
1334 |
+
<?php $fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
1335 |
+
|
1336 |
+
foreach ( $fields as $key => $array ) {
|
1337 |
+
if ( isset( $array['title'] ) &&
|
1338 |
+
( ! isset( $this->edit_array['metakey'] ) || $key != $this->edit_array['metakey'] ) ) { ?>
|
1339 |
+
|
1340 |
+
<option value="<?php echo esc_attr( $key ) ?>" <?php selected( $key, $this->edit_mode_value ) ?>><?php echo $array['title'] ?></option>
|
1341 |
+
|
1342 |
+
<?php }
|
1343 |
+
} ?>
|
1344 |
+
|
1345 |
+
</select>
|
1346 |
+
</p>
|
1347 |
+
|
1348 |
+
<?php
|
1349 |
+
break;
|
1350 |
+
|
1351 |
+
case '_conditional_operator':
|
1352 |
+
case '_conditional_operator1':
|
1353 |
+
case '_conditional_operator2':
|
1354 |
+
case '_conditional_operator3':
|
1355 |
+
case '_conditional_operator4':
|
1356 |
+
?>
|
1357 |
+
|
1358 |
+
<p>
|
1359 |
+
<select name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" style="width: 150px">
|
1360 |
+
|
1361 |
+
<option></option>
|
1362 |
+
|
1363 |
+
<?php $operators = array(
|
1364 |
+
'empty',
|
1365 |
+
'not empty',
|
1366 |
+
'equals to',
|
1367 |
+
'not equals',
|
1368 |
+
'greater than',
|
1369 |
+
'less than',
|
1370 |
+
'contains'
|
1371 |
+
);
|
1372 |
+
|
1373 |
+
foreach ( $operators as $operator ) { ?>
|
1374 |
+
|
1375 |
+
<option value="<?php echo esc_attr( $operator ); ?>" <?php selected( $operator, $this->edit_mode_value ); ?>><?php echo $operator; ?></option>
|
1376 |
+
|
1377 |
+
<?php } ?>
|
1378 |
+
|
1379 |
+
</select>
|
1380 |
+
</p>
|
1381 |
+
|
1382 |
+
<?php
|
1383 |
+
break;
|
1384 |
+
|
1385 |
+
case '_conditional_value':
|
1386 |
+
case '_conditional_value1':
|
1387 |
+
case '_conditional_value2':
|
1388 |
+
case '_conditional_value3':
|
1389 |
+
case '_conditional_value4':
|
1390 |
+
?>
|
1391 |
+
|
1392 |
+
<p>
|
1393 |
+
<input type="text" name="<?php echo esc_attr( $attribute ); ?>" id="<?php echo esc_attr( $attribute ); ?>" value="<?php echo isset( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" placeholder="<?php esc_attr_e( 'Value', 'ultimate-member' ); ?>" style="width: 150px!important;position: relative;top: -1px;" />
|
1394 |
+
</p>
|
1395 |
+
|
1396 |
+
<?php
|
1397 |
+
break;
|
1398 |
+
|
1399 |
+
case '_validate':
|
1400 |
+
?>
|
1401 |
+
|
1402 |
+
<p><label for="_validate"><?php _e( 'Validate', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Does this field require a special validation', 'ultimate-member' ) ); ?></label>
|
1403 |
+
<select name="_validate" id="_validate" data-placeholder="<?php esc_attr_e( 'Select a validation type...', 'ultimate-member' ) ?>" class="um-adm-conditional" data-cond1="custom" data-cond1-show="_custom_validate" style="width: 100%">
|
1404 |
+
|
1405 |
+
<option value="" <?php selected( '', $this->edit_mode_value ); ?>></option>
|
1406 |
+
|
1407 |
+
<?php foreach( UM()->builtin()->validation_types() as $key => $name ) { ?>
|
1408 |
+
<?php
|
1409 |
+
/**
|
1410 |
+
* UM hook
|
1411 |
+
*
|
1412 |
+
* @type filter
|
1413 |
+
* @title um_builtin_validation_types_continue_loop
|
1414 |
+
* @description Builtin Validation Types
|
1415 |
+
* @input_vars
|
1416 |
+
* [{"var":"$continue","type":"bool","desc":"Validate?"},
|
1417 |
+
* {"var":"$key","type":"string","desc":"Field Key"},
|
1418 |
+
* {"var":"$form_id","type":"int","desc":"Form ID"},
|
1419 |
+
* {"var":"$field_args","type":"array","desc":"Field Settings"}]
|
1420 |
+
* @change_log
|
1421 |
+
* ["Since: 2.0"]
|
1422 |
+
* @usage add_filter( 'um_builtin_validation_types_continue_loop', 'function_name', 10, 4 );
|
1423 |
+
* @example
|
1424 |
+
* <?php
|
1425 |
+
* add_filter( 'um_builtin_validation_types_continue_loop', 'my_builtin_validation_types', 10, 4 );
|
1426 |
+
* function my_builtin_validation_types( $continue, $key, $form_id, $field_args ) {
|
1427 |
+
* // your code here
|
1428 |
+
* return $continue;
|
1429 |
+
* }
|
1430 |
+
* ?>
|
1431 |
+
*/
|
1432 |
+
$continue = apply_filters( "um_builtin_validation_types_continue_loop", true, $key, $form_id, $field_args );
|
1433 |
+
if ( $continue ) { ?>
|
1434 |
+
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $this->edit_mode_value ); ?>><?php echo $name; ?></option>
|
1435 |
+
<?php } ?>
|
1436 |
+
<?php } ?>
|
1437 |
+
|
1438 |
+
</select>
|
1439 |
+
</p>
|
1440 |
+
|
1441 |
+
<?php
|
1442 |
+
break;
|
1443 |
+
|
1444 |
+
case '_custom_validate':
|
1445 |
+
?>
|
1446 |
+
|
1447 |
+
<p class="_custom_validate"><label for="_custom_validate"><?php _e( 'Custom Action', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to apply your custom validation, you can use action hooks to add custom validation. Please refer to documentation for further details.', 'ultimate-member' ) ); ?></label>
|
1448 |
+
<input type="text" name="_custom_validate" id="_custom_validate" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1449 |
+
</p>
|
1450 |
+
|
1451 |
+
<?php
|
1452 |
+
break;
|
1453 |
+
|
1454 |
+
case '_icon':
|
1455 |
+
|
1456 |
+
if ( $this->set_field_type == 'row' ) {
|
1457 |
+
$back = 'UM_edit_row';
|
1458 |
+
|
1459 |
+
?>
|
1460 |
+
|
1461 |
+
<p class="_heading_text"><label for="_icon"><?php _e( 'Icon', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field.', 'ultimate-member' ) ); ?></label>
|
1462 |
+
|
1463 |
+
<a href="javascript:void(0);" class="button" data-modal="UM_fonticons" data-modal-size="normal" data-dynamic-content="um_admin_fonticon_selector" data-arg1="" data-arg2="" data-back="<?php echo esc_attr( $back ); ?>"><?php _e( 'Choose Icon', 'ultimate-member' ) ?></a>
|
1464 |
+
|
1465 |
+
<span class="um-admin-icon-value"><?php if ( $this->edit_mode_value ) { ?><i class="<?php echo $this->edit_mode_value; ?>"></i><?php } else { ?><?php _e( 'No Icon', 'ultimate-member' ) ?><?php } ?></span>
|
1466 |
+
|
1467 |
+
<input type="hidden" name="_icon" id="_icon" value="<?php echo (isset( $this->edit_mode_value ) ) ? $this->edit_mode_value : ''; ?>" />
|
1468 |
+
|
1469 |
+
<?php if ( $this->edit_mode_value ) { ?>
|
1470 |
+
<span class="um-admin-icon-clear show"><i class="um-icon-android-cancel"></i></span>
|
1471 |
+
<?php } else { ?>
|
1472 |
+
<span class="um-admin-icon-clear"><i class="um-icon-android-cancel"></i></span>
|
1473 |
+
<?php } ?>
|
1474 |
+
|
1475 |
+
</p>
|
1476 |
+
|
1477 |
+
<?php } else {
|
1478 |
+
|
1479 |
+
if ( $this->in_edit ) {
|
1480 |
+
$back = 'UM_edit_field';
|
1481 |
+
} else {
|
1482 |
+
$back = 'UM_add_field';
|
1483 |
+
}
|
1484 |
+
|
1485 |
+
?>
|
1486 |
+
|
1487 |
+
<div class="um-admin-tri">
|
1488 |
+
|
1489 |
+
<p><label for="_icon"><?php _e( 'Icon', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field.', 'ultimate-member' ) ); ?></label>
|
1490 |
+
|
1491 |
+
<a href="javascript:void(0);" class="button" data-modal="UM_fonticons" data-modal-size="normal" data-dynamic-content="um_admin_fonticon_selector" data-arg1="" data-arg2="" data-back="<?php echo esc_attr( $back ); ?>"><?php _e( 'Choose Icon', 'ultimate-member' ) ?></a>
|
1492 |
+
|
1493 |
+
<span class="um-admin-icon-value"><?php if ( $this->edit_mode_value ) { ?><i class="<?php echo $this->edit_mode_value; ?>"></i><?php } else { ?><?php _e( 'No Icon', 'ultimate-member' ) ?><?php } ?></span>
|
1494 |
+
|
1495 |
+
<input type="hidden" name="_icon" id="_icon" value="<?php echo (isset( $this->edit_mode_value ) ) ? $this->edit_mode_value : ''; ?>" />
|
1496 |
+
|
1497 |
+
<?php if ( $this->edit_mode_value ) { ?>
|
1498 |
+
<span class="um-admin-icon-clear show"><i class="um-icon-android-cancel"></i></span>
|
1499 |
+
<?php } else { ?>
|
1500 |
+
<span class="um-admin-icon-clear"><i class="um-icon-android-cancel"></i></span>
|
1501 |
+
<?php } ?>
|
1502 |
+
|
1503 |
+
</p>
|
1504 |
+
|
1505 |
+
</div>
|
1506 |
+
|
1507 |
+
<?php
|
1508 |
+
|
1509 |
+
}
|
1510 |
+
|
1511 |
+
break;
|
1512 |
+
|
1513 |
+
case '_css_class':
|
1514 |
+
?>
|
1515 |
+
|
1516 |
+
<p><label for="_css_class"><?php _e( 'CSS Class', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Specify a custom CSS class to be applied to this element', 'ultimate-member' ) ); ?></label>
|
1517 |
+
<input type="text" name="_css_class" id="_css_class" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1518 |
+
</p>
|
1519 |
+
|
1520 |
+
<?php
|
1521 |
+
break;
|
1522 |
+
|
1523 |
+
case '_width':
|
1524 |
+
?>
|
1525 |
+
|
1526 |
+
<p><label for="_width"><?php _e( 'Thickness (in pixels)', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the width in pixels, e.g. 4 or 2, etc', 'ultimate-member' ) ); ?></label>
|
1527 |
+
<input type="text" name="_width" id="_width" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 4; ?>" />
|
1528 |
+
</p>
|
1529 |
+
|
1530 |
+
<?php
|
1531 |
+
break;
|
1532 |
+
|
1533 |
+
case '_divider_text':
|
1534 |
+
?>
|
1535 |
+
|
1536 |
+
<p><label for="_divider_text"><?php _e( 'Optional Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Optional text to include with the divider', 'ultimate-member' ) ); ?></label>
|
1537 |
+
<input type="text" name="_divider_text" id="_divider_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1538 |
+
</p>
|
1539 |
+
|
1540 |
+
<?php
|
1541 |
+
break;
|
1542 |
+
|
1543 |
+
case '_padding':
|
1544 |
+
?>
|
1545 |
+
|
1546 |
+
<p><label for="_padding"><?php _e( 'Padding', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set padding for this section', 'ultimate-member' ) ); ?></label>
|
1547 |
+
<input type="text" name="_padding" id="_padding" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px 0px 0px 0px'; ?>" />
|
1548 |
+
</p>
|
1549 |
+
|
1550 |
+
<?php
|
1551 |
+
break;
|
1552 |
+
|
1553 |
+
case '_margin':
|
1554 |
+
?>
|
1555 |
+
|
1556 |
+
<p><label for="_margin"><?php _e( 'Margin', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set margin for this section', 'ultimate-member' ) ); ?></label>
|
1557 |
+
<input type="text" name="_margin" id="_margin" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px 0px 30px 0px'; ?>" />
|
1558 |
+
</p>
|
1559 |
+
|
1560 |
+
<?php
|
1561 |
+
break;
|
1562 |
+
|
1563 |
+
case '_border':
|
1564 |
+
?>
|
1565 |
+
|
1566 |
+
<p><label for="_border"><?php _e( 'Border', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set border for this section', 'ultimate-member' ) ); ?></label>
|
1567 |
+
<input type="text" name="_border" id="_border" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px 0px 0px 0px'; ?>" />
|
1568 |
+
</p>
|
1569 |
+
|
1570 |
+
<?php
|
1571 |
+
break;
|
1572 |
+
|
1573 |
+
case '_borderstyle':
|
1574 |
+
?>
|
1575 |
+
|
1576 |
+
<p><label for="_borderstyle"><?php _e( 'Style', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose the border style', 'ultimate-member' ) ); ?></label>
|
1577 |
+
<select name="_borderstyle" id="_borderstyle" style="width: 100%">
|
1578 |
+
<option value="solid" <?php selected( 'solid', $this->edit_mode_value ); ?>><?php _e( 'Solid', 'ultimate-member' ) ?></option>
|
1579 |
+
<option value="dotted" <?php selected( 'dotted', $this->edit_mode_value ); ?>><?php _e( 'Dotted', 'ultimate-member' ) ?></option>
|
1580 |
+
<option value="dashed" <?php selected( 'dashed', $this->edit_mode_value ); ?>><?php _e( 'Dashed', 'ultimate-member' ) ?></option>
|
1581 |
+
<option value="double" <?php selected( 'double', $this->edit_mode_value ); ?>><?php _e( 'Double', 'ultimate-member' ) ?></option>
|
1582 |
+
</select>
|
1583 |
+
</p>
|
1584 |
+
|
1585 |
+
<?php
|
1586 |
+
break;
|
1587 |
+
|
1588 |
+
case '_borderradius':
|
1589 |
+
?>
|
1590 |
+
|
1591 |
+
<p><label for="_borderradius"><?php _e( 'Border Radius', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Rounded corners can be applied by setting a pixels value here. e.g. 5px', 'ultimate-member' ) ); ?></label>
|
1592 |
+
<input type="text" name="_borderradius" id="_borderradius" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '0px'; ?>" />
|
1593 |
+
</p>
|
1594 |
+
|
1595 |
+
<?php
|
1596 |
+
break;
|
1597 |
+
|
1598 |
+
case '_bordercolor':
|
1599 |
+
?>
|
1600 |
+
|
1601 |
+
<p><label for="_bordercolor"><?php _e( 'Border Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Give a color to this border', 'ultimate-member' ) ); ?></label>
|
1602 |
+
<input type="text" name="_bordercolor" id="_bordercolor" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1603 |
+
</p>
|
1604 |
+
|
1605 |
+
<?php
|
1606 |
+
break;
|
1607 |
+
|
1608 |
+
case '_heading':
|
1609 |
+
?>
|
1610 |
+
|
1611 |
+
<p><label for="_heading"><?php _e( 'Enable Row Heading', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether to enable a heading for this row', 'ultimate-member' ) ); ?></label>
|
1612 |
+
<input type="checkbox" name="_heading" id="_heading" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_heading_text" data-cond1-hide="xxx" />
|
1613 |
+
</p>
|
1614 |
+
|
1615 |
+
<?php
|
1616 |
+
break;
|
1617 |
+
|
1618 |
+
case '_heading_text':
|
1619 |
+
?>
|
1620 |
+
|
1621 |
+
<p class="_heading_text"><label for="_heading_text"><?php _e( 'Heading Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter the row heading text here', 'ultimate-member' ) ); ?></label>
|
1622 |
+
<input type="text" name="_heading_text" id="_heading_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1623 |
+
</p>
|
1624 |
+
|
1625 |
+
<?php
|
1626 |
+
break;
|
1627 |
+
|
1628 |
+
case '_background':
|
1629 |
+
?>
|
1630 |
+
|
1631 |
+
<p><label for="_background"><?php _e( 'Background Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the background of entire section', 'ultimate-member' ) ); ?></label>
|
1632 |
+
<input type="text" name="_background" id="_background" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1633 |
+
</p>
|
1634 |
+
|
1635 |
+
<?php
|
1636 |
+
break;
|
1637 |
+
|
1638 |
+
case '_heading_background_color':
|
1639 |
+
?>
|
1640 |
+
|
1641 |
+
<p class="_heading_text"><label for="_heading_background_color"><?php _e( 'Heading Background Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the background of the heading section', 'ultimate-member' ) ); ?></label>
|
1642 |
+
<input type="text" name="_heading_background_color" id="_heading_background_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1643 |
+
</p>
|
1644 |
+
|
1645 |
+
<?php
|
1646 |
+
break;
|
1647 |
+
|
1648 |
+
case '_heading_text_color':
|
1649 |
+
?>
|
1650 |
+
|
1651 |
+
<p class="_heading_text"><label for="_heading_text_color"><?php _e( 'Heading Text Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the text color of heading part only', 'ultimate-member' ) ); ?></label>
|
1652 |
+
<input type="text" name="_heading_text_color" id="_heading_text_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1653 |
+
</p>
|
1654 |
+
|
1655 |
+
<?php
|
1656 |
+
break;
|
1657 |
+
|
1658 |
+
case '_text_color':
|
1659 |
+
?>
|
1660 |
+
|
1661 |
+
<p><label for="_text_color"><?php _e( 'Text Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the text color of entire section', 'ultimate-member' ) ); ?></label>
|
1662 |
+
<input type="text" name="_text_color" id="_text_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1663 |
+
</p>
|
1664 |
+
|
1665 |
+
<?php
|
1666 |
+
break;
|
1667 |
+
|
1668 |
+
case '_icon_color':
|
1669 |
+
?>
|
1670 |
+
|
1671 |
+
<p class="_heading_text"><label for="_icon_color"><?php _e( 'Icon Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This will be the color of selected icon. By default It will be the same color as heading text color', 'ultimate-member' ) ); ?></label>
|
1672 |
+
<input type="text" name="_icon_color" id="_icon_color" class="um-admin-colorpicker" data-default-color="" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1673 |
+
</p>
|
1674 |
+
|
1675 |
+
<?php
|
1676 |
+
break;
|
1677 |
+
|
1678 |
+
case '_color':
|
1679 |
+
?>
|
1680 |
+
|
1681 |
+
<p><label for="_color"><?php _e( 'Color', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select a color for this divider', 'ultimate-member' ) ); ?></label>
|
1682 |
+
<input type="text" name="_color" id="_color" class="um-admin-colorpicker" data-default-color="#eeeeee" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '#eeeeee'; ?>" />
|
1683 |
+
</p>
|
1684 |
+
|
1685 |
+
<?php
|
1686 |
+
break;
|
1687 |
+
|
1688 |
+
case '_url_text':
|
1689 |
+
?>
|
1690 |
+
|
1691 |
+
<p><label for="_url_text"><?php _e( 'URL Alt Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Entering custom text here will replace the url with a text link', 'ultimate-member' ) ); ?></label>
|
1692 |
+
<input type="text" name="_url_text" id="_url_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : ''; ?>" />
|
1693 |
+
</p>
|
1694 |
+
|
1695 |
+
<?php
|
1696 |
+
break;
|
1697 |
+
|
1698 |
+
case '_url_target':
|
1699 |
+
?>
|
1700 |
+
|
1701 |
+
<p><label for="_url_target"><?php _e( 'Link Target', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose whether to open this link in same window or in a new window', 'ultimate-member' ) ); ?></label>
|
1702 |
+
<select name="_url_target" id="_url_target" style="width: 100%">
|
1703 |
+
<option value="_blank" <?php selected( '_blank', $this->edit_mode_value ); ?>><?php _e( 'Open in new window', 'ultimate-member' ) ?></option>
|
1704 |
+
<option value="_self" <?php selected( '_self', $this->edit_mode_value ); ?>><?php _e( 'Same window', 'ultimate-member' ) ?></option>
|
1705 |
+
</select>
|
1706 |
+
</p>
|
1707 |
+
|
1708 |
+
<?php
|
1709 |
+
break;
|
1710 |
+
|
1711 |
+
case '_url_rel':
|
1712 |
+
?>
|
1713 |
+
|
1714 |
+
<p><label for="_url_rel"><?php _e( 'SEO Follow', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether to follow or nofollow this link by search engines', 'ultimate-member' ) ); ?></label>
|
1715 |
+
<select name="_url_rel" id="_url_rel" style="width: 100%">
|
1716 |
+
<option value="follow" <?php selected( 'follow', $this->edit_mode_value ); ?>><?php _e( 'Follow', 'ultimate-member' ) ?></option>
|
1717 |
+
<option value="nofollow" <?php selected( 'nofollow', $this->edit_mode_value ); ?>><?php _e( 'No-Follow', 'ultimate-member' ) ?></option>
|
1718 |
+
</select>
|
1719 |
+
</p>
|
1720 |
+
|
1721 |
+
<?php
|
1722 |
+
break;
|
1723 |
+
|
1724 |
+
case '_force_good_pass':
|
1725 |
+
?>
|
1726 |
+
|
1727 |
+
<p><label for="_force_good_pass"><?php _e( 'Force strong password?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Turn on to force users to create a strong password (A combination of one lowercase letter, one uppercase letter, and one number). If turned on this option is only applied to register forms and not to login forms.', 'ultimate-member' ) ); ?></label>
|
1728 |
+
<input type="checkbox" name="_force_good_pass" id="_force_good_pass" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : UM()->options()->get( 'require_strongpass' ) ) ?> />
|
1729 |
+
</p>
|
1730 |
+
|
1731 |
+
<?php
|
1732 |
+
break;
|
1733 |
+
|
1734 |
+
case '_force_confirm_pass':
|
1735 |
+
?>
|
1736 |
+
|
1737 |
+
<p><label for="_force_confirm_pass"><?php _e( 'Automatically add a confirm password field?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Turn on to add a confirm password field. If turned on the confirm password field will only show on register forms and not on login forms.', 'ultimate-member' ) ); ?></label>
|
1738 |
+
<input type="checkbox" name="_force_confirm_pass" id="_force_confirm_pass" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_label_confirm_pass" data-cond1-hide="xxx" />
|
1739 |
+
</p>
|
1740 |
+
|
1741 |
+
<?php
|
1742 |
+
break;
|
1743 |
+
|
1744 |
+
case '_style':
|
1745 |
+
?>
|
1746 |
+
|
1747 |
+
<p><label for="_style"><?php _e( 'Style', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the line-style of divider', 'ultimate-member' ) ); ?></label>
|
1748 |
+
<select name="_style" id="_style" style="width: 100%">
|
1749 |
+
<option value="solid" <?php selected( 'solid', $this->edit_mode_value ); ?>><?php _e( 'Solid', 'ultimate-member' ) ?></option>
|
1750 |
+
<option value="dotted" <?php selected( 'dotted', $this->edit_mode_value ); ?>><?php _e( 'Dotted', 'ultimate-member' ) ?></option>
|
1751 |
+
<option value="dashed" <?php selected( 'dashed', $this->edit_mode_value ); ?>><?php _e( 'Dashed', 'ultimate-member' ) ?></option>
|
1752 |
+
<option value="double" <?php selected( 'double', $this->edit_mode_value ); ?>><?php _e( 'Double', 'ultimate-member' ) ?></option>
|
1753 |
+
</select>
|
1754 |
+
</p>
|
1755 |
+
|
1756 |
+
<?php
|
1757 |
+
break;
|
1758 |
+
|
1759 |
+
case '_intervals':
|
1760 |
+
|
1761 |
+
?>
|
1762 |
+
|
1763 |
+
<p><label for="_intervals"><?php _e( 'Time Intervals (in minutes)', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose the minutes interval between each time in the time picker.', 'ultimate-member' ) ); ?></label>
|
1764 |
+
<input type="text" name="_intervals" id="_intervals" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 60; ?>" placeholder="<?php esc_attr_e( 'e.g. 30, 60, 120', 'ultimate-member' ) ?>" />
|
1765 |
+
</p>
|
1766 |
+
|
1767 |
+
<?php
|
1768 |
+
break;
|
1769 |
+
|
1770 |
+
|
1771 |
+
case '_format':
|
1772 |
+
|
1773 |
+
if ( $this->set_field_type == 'date' ) {
|
1774 |
+
?>
|
1775 |
+
|
1776 |
+
<p><label for="_format"><?php _e( 'Date User-Friendly Format', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The display format of the date which is visible to user.', 'ultimate-member' ) ); ?></label>
|
1777 |
+
<select name="_format" id="_format" style="width: 100%">
|
1778 |
+
<option value="j M Y" <?php selected( 'j M Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('j M Y'); ?></option>
|
1779 |
+
<option value="M j Y" <?php selected( 'M j Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('M j Y'); ?></option>
|
1780 |
+
<option value="j F Y" <?php selected( 'j F Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('j F Y'); ?></option>
|
1781 |
+
<option value="F j Y" <?php selected( 'F j Y', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('F j Y'); ?></option>
|
1782 |
+
</select>
|
1783 |
+
</p>
|
1784 |
+
|
1785 |
+
<?php } else { ?>
|
1786 |
+
|
1787 |
+
<p><label for="_format"><?php _e( 'Time Format', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose the displayed time-format for this field', 'ultimate-member' ) ); ?></label>
|
1788 |
+
<select name="_format" id="_format" style="width: 100%">
|
1789 |
+
<option value="g:i a" <?php selected( 'g:i a', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('g:i a'); ?><?php _e( '( 12-hr format )', 'ultimate-member' ) ?></option>
|
1790 |
+
<option value="g:i A" <?php selected( 'g:i A', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('g:i A'); ?><?php _e( '( 12-hr format )', 'ultimate-member' ) ?></option>
|
1791 |
+
<option value="H:i" <?php selected( 'H:i', $this->edit_mode_value ); ?>><?php echo UM()->datetime()->get_time('H:i'); ?><?php _e( '( 24-hr format )', 'ultimate-member' ) ?></option>
|
1792 |
+
</select>
|
1793 |
+
</p>
|
1794 |
+
|
1795 |
+
<?php
|
1796 |
+
}
|
1797 |
+
break;
|
1798 |
+
|
1799 |
+
case '_format_custom':
|
1800 |
+
?>
|
1801 |
+
|
1802 |
+
<p><label for="_format_custom"><?php _e( 'Use custom Date format', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'This option overrides "Date User-Friendly Format" option. See https://www.php.net/manual/en/function.date.php', 'ultimate-member' ) ); ?></label>
|
1803 |
+
<input type="text" name="_format_custom" id="_format_custom" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" placeholder="j M Y" />
|
1804 |
+
</p>
|
1805 |
+
|
1806 |
+
<?php
|
1807 |
+
break;
|
1808 |
+
|
1809 |
+
case '_pretty_format':
|
1810 |
+
?>
|
1811 |
+
|
1812 |
+
<p><label for="_pretty_format"><?php _e( 'Displayed Date Format', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether you wish to show the date in full or only show the years e.g. 25 Years', 'ultimate-member' ) ); ?></label>
|
1813 |
+
<select name="_pretty_format" id="_pretty_format" style="width: 100%">
|
1814 |
+
<option value="0" <?php selected( 0, $this->edit_mode_value ); ?>><?php _e( 'Show full date', 'ultimate-member' ) ?></option>
|
1815 |
+
<option value="1" <?php selected( 1, $this->edit_mode_value ); ?>><?php _e( 'Show years only', 'ultimate-member' ) ?></option>
|
1816 |
+
</select>
|
1817 |
+
</p>
|
1818 |
+
|
1819 |
+
<?php
|
1820 |
+
break;
|
1821 |
+
|
1822 |
+
case '_disabled_weekdays':
|
1823 |
+
|
1824 |
+
if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
|
1825 |
+
$values = $this->edit_mode_value;
|
1826 |
+
} else {
|
1827 |
+
$values = array('');
|
1828 |
+
}
|
1829 |
+
?>
|
1830 |
+
|
1831 |
+
<p><label for="_disabled_weekdays"><?php _e( 'Disable specific weekdays', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Disable specific week days from being available for selection in this date picker', 'ultimate-member' ) ); ?></label>
|
1832 |
+
<select name="_disabled_weekdays[]" id="_disabled_weekdays" multiple="multiple" style="width: 100%">
|
1833 |
+
<option value="1" <?php if ( in_array( 1, $values ) ) { echo 'selected'; } ?>><?php _e( 'Sunday', 'ultimate-member' ) ?></option>
|
1834 |
+
<option value="2" <?php if ( in_array( 2, $values ) ) { echo 'selected'; } ?>><?php _e( 'Monday', 'ultimate-member' ) ?></option>
|
1835 |
+
<option value="3" <?php if ( in_array( 3, $values ) ) { echo 'selected'; } ?>><?php _e( 'Tuesday', 'ultimate-member' ) ?></option>
|
1836 |
+
<option value="4" <?php if ( in_array( 4, $values ) ) { echo 'selected'; } ?>><?php _e( 'Wednesday', 'ultimate-member' ) ?></option>
|
1837 |
+
<option value="5" <?php if ( in_array( 5, $values ) ) { echo 'selected'; } ?>><?php _e( 'Thursday', 'ultimate-member' ) ?></option>
|
1838 |
+
<option value="6" <?php if ( in_array( 6, $values ) ) { echo 'selected'; } ?>><?php _e( 'Friday', 'ultimate-member' ) ?></option>
|
1839 |
+
<option value="7" <?php if ( in_array( 7, $values ) ) { echo 'selected'; } ?>><?php _e( 'Saturday', 'ultimate-member' ) ?></option>
|
1840 |
+
</select>
|
1841 |
+
</p>
|
1842 |
+
|
1843 |
+
<?php
|
1844 |
+
break;
|
1845 |
+
|
1846 |
+
case '_years':
|
1847 |
+
?>
|
1848 |
+
|
1849 |
+
<p class="_years"><label for="_years"><?php _e( 'Number of Years to pick from', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Number of years available for the date selection. Default to last 50 years', 'ultimate-member' ) ); ?></label>
|
1850 |
+
<input type="text" name="_years" id="_years" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 50; ?>" />
|
1851 |
+
</p>
|
1852 |
+
|
1853 |
+
<?php
|
1854 |
+
break;
|
1855 |
+
|
1856 |
+
case '_years_x':
|
1857 |
+
?>
|
1858 |
+
|
1859 |
+
<p class="_years"><label for="_years_x"><?php _e( 'Years Selection', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This decides which years should be shown relative to today date', 'ultimate-member' ) ); ?></label>
|
1860 |
+
<select name="_years_x" id="_years_x" style="width: 100%">
|
1861 |
+
<option value="equal" <?php selected( 'equal', $this->edit_mode_value ); ?>><?php _e( 'Equal years before / after today', 'ultimate-member' ) ?></option>
|
1862 |
+
<option value="past" <?php selected( 'past', $this->edit_mode_value ); ?>><?php _e( 'Past years only', 'ultimate-member' ) ?></option>
|
1863 |
+
<option value="future" <?php selected( 'future', $this->edit_mode_value ); ?>><?php _e( 'Future years only', 'ultimate-member' ) ?></option>
|
1864 |
+
</select>
|
1865 |
+
</p>
|
1866 |
+
|
1867 |
+
<?php
|
1868 |
+
break;
|
1869 |
+
|
1870 |
+
case '_range_start':
|
1871 |
+
?>
|
1872 |
+
|
1873 |
+
<p class="_date_range"><label for="_range_start"><?php _e( 'Date Range Start', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set the minimum date/day in range in the format YYYY/MM/DD', 'ultimate-member' ) ); ?></label>
|
1874 |
+
<input type="text" name="_range_start" id="_range_start" value="<?php echo $this->edit_mode_value; ?>" placeholder="<?php esc_attr_e( 'YYYY/MM/DD', 'ultimate-member' ) ?>" />
|
1875 |
+
</p>
|
1876 |
+
|
1877 |
+
<?php
|
1878 |
+
break;
|
1879 |
+
|
1880 |
+
case '_range_end':
|
1881 |
+
?>
|
1882 |
+
|
1883 |
+
<p class="_date_range"><label for="_range_end"><?php _e( 'Date Range End', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Set the maximum date/day in range in the format YYYY/MM/DD', 'ultimate-member' ) ); ?></label>
|
1884 |
+
<input type="text" name="_range_end" id="_range_end" value="<?php echo $this->edit_mode_value; ?>" placeholder="<?php esc_attr_e( 'YYYY/MM/DD', 'ultimate-member' ) ?>" />
|
1885 |
+
</p>
|
1886 |
+
|
1887 |
+
<?php
|
1888 |
+
break;
|
1889 |
+
|
1890 |
+
case '_range':
|
1891 |
+
?>
|
1892 |
+
|
1893 |
+
<p><label for="_range"><?php _e( 'Set Date Range', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Whether to show a specific number of years or specify a date range to be available for the date picker.', 'ultimate-member' ) ); ?></label>
|
1894 |
+
<select name="_range" id="_range" class="um-adm-conditional" data-cond1='years' data-cond1-show='_years' data-cond2="date_range" data-cond2-show="_date_range" style="width: 100%">
|
1895 |
+
<option value="years" <?php selected( 'years', $this->edit_mode_value ); ?>><?php _e( 'Fixed Number of Years', 'ultimate-member' ) ?></option>
|
1896 |
+
<option value="date_range" <?php selected( 'date_range', $this->edit_mode_value ); ?>><?php _e( 'Specific Date Range', 'ultimate-member' ) ?></option>
|
1897 |
+
</select>
|
1898 |
+
</p>
|
1899 |
+
|
1900 |
+
<?php
|
1901 |
+
break;
|
1902 |
+
|
1903 |
+
case '_content':
|
1904 |
+
|
1905 |
+
if ( $this->set_field_type == 'shortcode' ) {
|
1906 |
+
|
1907 |
+
?>
|
1908 |
+
|
1909 |
+
<p><label for="_content"><?php _e( 'Enter Shortcode', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter the shortcode in the following textarea and it will be displayed on the fields', 'ultimate-member' ) ); ?></label>
|
1910 |
+
<textarea name="_content" id="_content" placeholder="<?php esc_attr_e( 'e.g. [my_custom_shortcode]', 'ultimate-member' ) ?>"><?php echo $this->edit_mode_value; ?></textarea>
|
1911 |
+
</p>
|
1912 |
+
|
1913 |
+
<?php
|
1914 |
+
|
1915 |
+
} else {
|
1916 |
+
|
1917 |
+
?>
|
1918 |
+
|
1919 |
+
<div class="um-admin-editor-h"><label><?php _e( 'Content Editor', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Edit the content of this field here', 'ultimate-member' ) ); ?></label></div>
|
1920 |
+
|
1921 |
+
<div class="um-admin-editor"><!-- editor dynamically loaded here --></div>
|
1922 |
+
|
1923 |
+
<?php
|
1924 |
+
|
1925 |
+
}
|
1926 |
+
|
1927 |
+
break;
|
1928 |
+
|
1929 |
+
case '_crop':
|
1930 |
+
?>
|
1931 |
+
|
1932 |
+
<p><label for="_crop"><?php _e( 'Crop Feature', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enable/disable crop feature for this image upload and define ratio', 'ultimate-member' ) ); ?></label>
|
1933 |
+
<select name="_crop" id="_crop" style="width: 100%">
|
1934 |
+
<option value="0" <?php selected( '0', $this->edit_mode_value ); ?>><?php _e( 'Turn Off (Default)', 'ultimate-member' ) ?></option>
|
1935 |
+
<option value="1" <?php selected( '1', $this->edit_mode_value ); ?>><?php _e( 'Crop and force 1:1 ratio', 'ultimate-member' ) ?></option>
|
1936 |
+
<option value="3" <?php selected( '3', $this->edit_mode_value ); ?>><?php _e( 'Crop and force user-defined ratio', 'ultimate-member' ) ?></option>
|
1937 |
+
</select>
|
1938 |
+
</p>
|
1939 |
+
|
1940 |
+
<?php
|
1941 |
+
break;
|
1942 |
+
|
1943 |
+
case '_allowed_types':
|
1944 |
+
|
1945 |
+
if ( $this->set_field_type == 'image' ) {
|
1946 |
+
|
1947 |
+
if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
|
1948 |
+
$values = $this->edit_mode_value;
|
1949 |
+
} else {
|
1950 |
+
$values = array( 'png','jpeg','jpg','gif' );
|
1951 |
+
} ?>
|
1952 |
+
|
1953 |
+
<p><label for="_allowed_types"><?php _e( 'Allowed Image Types', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select the image types that you want to allow to be uploaded via this field.', 'ultimate-member' ) ); ?></label>
|
1954 |
+
<select name="_allowed_types[]" id="_allowed_types" multiple="multiple" style="width: 100%">
|
1955 |
+
<?php foreach( UM()->files()->allowed_image_types() as $e => $n ) { ?>
|
1956 |
+
<option value="<?php echo $e; ?>" <?php if ( in_array( $e, $values ) ) { echo 'selected'; } ?>><?php echo $n; ?></option>
|
1957 |
+
<?php } ?>
|
1958 |
+
</select>
|
1959 |
+
</p>
|
1960 |
+
|
1961 |
+
<?php
|
1962 |
+
|
1963 |
+
} else {
|
1964 |
+
|
1965 |
+
if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
|
1966 |
+
$values = $this->edit_mode_value;
|
1967 |
+
} else {
|
1968 |
+
$values = array( 'pdf', 'txt' );
|
1969 |
+
} ?>
|
1970 |
+
|
1971 |
+
<p><label for="_allowed_types"><?php _e( 'Allowed File Types', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select the image types that you want to allow to be uploaded via this field.', 'ultimate-member' ) ); ?></label>
|
1972 |
+
<select name="_allowed_types[]" id="_allowed_types" multiple="multiple" style="width: 100%">
|
1973 |
+
<?php foreach( UM()->files()->allowed_file_types() as $e => $n ) { ?>
|
1974 |
+
<option value="<?php echo $e; ?>" <?php if ( in_array( $e, $values ) ) { echo 'selected'; } ?>><?php echo $n; ?></option>
|
1975 |
+
<?php } ?>
|
1976 |
+
</select>
|
1977 |
+
</p>
|
1978 |
+
|
1979 |
+
<?php
|
1980 |
+
|
1981 |
+
}
|
1982 |
+
|
1983 |
+
break;
|
1984 |
+
|
1985 |
+
case '_upload_text':
|
1986 |
+
|
1987 |
+
if ( $this->set_field_type == 'image' ) {
|
1988 |
+
$value = __( 'Drag & Drop Photo', 'ultimate-member' );
|
1989 |
+
}
|
1990 |
+
if ( $this->set_field_type == 'file' ) {
|
1991 |
+
$value = __( 'Drag & Drop File', 'ultimate-member' );
|
1992 |
+
}
|
1993 |
+
|
1994 |
+
?>
|
1995 |
+
|
1996 |
+
<p><label for="_upload_text"><?php _e( 'Upload Box Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the headline that appears in the upload box for this field', 'ultimate-member' ) ); ?></label>
|
1997 |
+
<input type="text" name="_upload_text" id="_upload_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : $value; ?>" />
|
1998 |
+
</p>
|
1999 |
+
|
2000 |
+
<?php
|
2001 |
+
break;
|
2002 |
+
|
2003 |
+
case '_upload_help_text':
|
2004 |
+
?>
|
2005 |
+
|
2006 |
+
<p><label for="_upload_help_text"><?php _e( 'Additional Instructions Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you need to add information or secondary line below the headline of upload box, enter it here', 'ultimate-member' ) ); ?></label>
|
2007 |
+
<input type="text" name="_upload_help_text" id="_upload_help_text" value="<?php echo $this->edit_mode_value; ?>" />
|
2008 |
+
</p>
|
2009 |
+
|
2010 |
+
<?php
|
2011 |
+
break;
|
2012 |
+
|
2013 |
+
case '_button_text':
|
2014 |
+
?>
|
2015 |
+
|
2016 |
+
<p><label for="_button_text"><?php _e( 'Upload Box Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The text that appears on the button. e.g. Upload', 'ultimate-member' ) ); ?></label>
|
2017 |
+
<input type="text" name="_button_text" id="_button_text" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : __( 'Upload', 'ultimate-member' ); ?>" />
|
2018 |
+
</p>
|
2019 |
+
|
2020 |
+
<?php
|
2021 |
+
break;
|
2022 |
+
|
2023 |
+
case '_max_size':
|
2024 |
+
?>
|
2025 |
+
|
2026 |
+
<p><label for="_max_size"><?php _e( 'Maximum Size in bytes', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The maximum size for image that can be uploaded through this field. Leave empty for unlimited size.', 'ultimate-member' ) ); ?></label>
|
2027 |
+
<input type="text" name="_max_size" id="_max_size" value="<?php echo $this->edit_mode_value; ?>" />
|
2028 |
+
</p>
|
2029 |
+
|
2030 |
+
<?php
|
2031 |
+
break;
|
2032 |
+
|
2033 |
+
case '_height':
|
2034 |
+
?>
|
2035 |
+
|
2036 |
+
<p><label for="_height"><?php _e( 'Textarea Height', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The height of textarea in pixels. Default is 100 pixels', 'ultimate-member' ) ); ?></label>
|
2037 |
+
<input type="text" name="_height" id="_height" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '100px'; ?>" />
|
2038 |
+
</p>
|
2039 |
+
|
2040 |
+
<?php
|
2041 |
+
break;
|
2042 |
+
|
2043 |
+
case '_spacing':
|
2044 |
+
?>
|
2045 |
+
|
2046 |
+
<p><label for="_spacing"><?php _e( 'Spacing', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the required spacing in pixels. e.g. 20px', 'ultimate-member' ) ); ?></label>
|
2047 |
+
<input type="text" name="_spacing" id="_spacing" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : '20px'; ?>" />
|
2048 |
+
</p>
|
2049 |
+
|
2050 |
+
<?php
|
2051 |
+
break;
|
2052 |
+
|
2053 |
+
case '_is_multi':
|
2054 |
+
?>
|
2055 |
+
|
2056 |
+
<p><label for="_is_multi"><?php _e( 'Allow multiple selections', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enable/disable multiple selections for this field', 'ultimate-member' ) ); ?></label>
|
2057 |
+
<input type="checkbox" name="_is_multi" id="_is_multi" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_max_selections" data-cond1-hide="xxx" />
|
2058 |
+
</p>
|
2059 |
+
|
2060 |
+
<?php
|
2061 |
+
break;
|
2062 |
+
|
2063 |
+
case '_max_selections':
|
2064 |
+
?>
|
2065 |
+
|
2066 |
+
<p class="_max_selections"><label for="_max_selections"><?php _e( 'Maximum number of selections', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter a number here to force a maximum number of selections by user for this field', 'ultimate-member' ) ); ?></label>
|
2067 |
+
<input type="text" name="_max_selections" id="_max_selections" value="<?php echo $this->edit_mode_value; ?>" />
|
2068 |
+
</p>
|
2069 |
+
|
2070 |
+
<?php
|
2071 |
+
break;
|
2072 |
+
|
2073 |
+
case '_min_selections':
|
2074 |
+
?>
|
2075 |
+
|
2076 |
+
<p class="_min_selections"><label for="_min_selections"><?php _e( 'Minimum number of selections', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter a number here to force a minimum number of selections by user for this field', 'ultimate-member' ) ); ?></label>
|
2077 |
+
<input type="text" name="_min_selections" id="_min_selections" value="<?php echo $this->edit_mode_value; ?>" />
|
2078 |
+
</p>
|
2079 |
+
|
2080 |
+
<?php
|
2081 |
+
break;
|
2082 |
+
|
2083 |
+
case '_max_entries':
|
2084 |
+
?>
|
2085 |
+
|
2086 |
+
<p class="_max_entries"><label for="_max_selections"><?php _e( 'Maximum number of entries', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the max number of entries the user can add via field group.', 'ultimate-member' ) ); ?></label>
|
2087 |
+
<input type="text" name="_max_entries" id="_max_entries" value="<?php echo ( $this->edit_mode_value ) ? $this->edit_mode_value : 10; ?>" />
|
2088 |
+
</p>
|
2089 |
+
|
2090 |
+
<?php
|
2091 |
+
break;
|
2092 |
+
|
2093 |
+
case '_max_words':
|
2094 |
+
?>
|
2095 |
+
|
2096 |
+
<p><label for="_max_words"><?php _e( 'Maximum allowed words', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to enable a maximum number of words to be input in this textarea. Leave empty to disable this setting', 'ultimate-member' ) ); ?></label>
|
2097 |
+
<input type="text" name="_max_words" id="_max_words" value="<?php echo $this->edit_mode_value; ?>" />
|
2098 |
+
</p>
|
2099 |
+
|
2100 |
+
<?php
|
2101 |
+
break;
|
2102 |
+
|
2103 |
+
case '_min':
|
2104 |
+
?>
|
2105 |
+
|
2106 |
+
<p><label for="_min"><?php _e( 'Minimum Number', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Minimum number that can be entered in this field', 'ultimate-member' ) ); ?></label>
|
2107 |
+
<input type="text" name="_min" id="_min" value="<?php echo $this->edit_mode_value; ?>" />
|
2108 |
+
</p>
|
2109 |
+
|
2110 |
+
<?php
|
2111 |
+
break;
|
2112 |
+
|
2113 |
+
case '_max':
|
2114 |
+
?>
|
2115 |
+
|
2116 |
+
<p><label for="_max"><?php _e( 'Maximum Number', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Maximum number that can be entered in this field', 'ultimate-member' ) ); ?></label>
|
2117 |
+
<input type="text" name="_max" id="_max" value="<?php echo $this->edit_mode_value; ?>" />
|
2118 |
+
</p>
|
2119 |
+
|
2120 |
+
<?php
|
2121 |
+
break;
|
2122 |
+
|
2123 |
+
case '_min_chars':
|
2124 |
+
?>
|
2125 |
+
|
2126 |
+
<p><label for="_min_chars"><?php _e( 'Minimum length', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to enable a minimum number of characters to be input in this field. Leave empty to disable this setting', 'ultimate-member' ) ); ?></label>
|
2127 |
+
<input type="text" name="_min_chars" id="_min_chars" value="<?php echo $this->edit_mode_value; ?>" />
|
2128 |
+
</p>
|
2129 |
+
|
2130 |
+
<?php
|
2131 |
+
break;
|
2132 |
+
|
2133 |
+
case '_max_chars':
|
2134 |
+
?>
|
2135 |
+
|
2136 |
+
<p><label for="_max_chars"><?php _e( 'Maximum length', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'If you want to enable a maximum number of characters to be input in this field. Leave empty to disable this setting', 'ultimate-member' ) ); ?></label>
|
2137 |
+
<input type="text" name="_max_chars" id="_max_chars" value="<?php echo $this->edit_mode_value; ?>" />
|
2138 |
+
</p>
|
2139 |
+
|
2140 |
+
<?php
|
2141 |
+
break;
|
2142 |
+
|
2143 |
+
case '_html':
|
2144 |
+
?>
|
2145 |
+
|
2146 |
+
<p><label for="_html"><?php _e( 'Does this textarea accept HTML?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Turn on/off HTML tags for this textarea', 'ultimate-member' ) ); ?></label>
|
2147 |
+
<input type="checkbox" name="_html" id="_html" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> />
|
2148 |
+
</p>
|
2149 |
+
|
2150 |
+
<?php
|
2151 |
+
break;
|
2152 |
+
|
2153 |
+
case '_options':
|
2154 |
+
|
2155 |
+
if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
|
2156 |
+
$values = implode("\n", $this->edit_mode_value);
|
2157 |
+
} else if ( $this->edit_mode_value ) {
|
2158 |
+
$values = $this->edit_mode_value;
|
2159 |
+
} else {
|
2160 |
+
$values = '';
|
2161 |
+
} ?>
|
2162 |
+
|
2163 |
+
<p><label for="_options"><?php _e( 'Edit Choices', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Enter one choice per line. This will represent the available choices or selections available for user.', 'ultimate-member' ) ); ?></label>
|
2164 |
+
<textarea name="_options" id="_options"><?php echo $values; ?></textarea>
|
2165 |
+
</p>
|
2166 |
+
|
2167 |
+
<?php
|
2168 |
+
break;
|
2169 |
+
|
2170 |
+
case '_title':
|
2171 |
+
?>
|
2172 |
+
|
2173 |
+
<p><label for="_title"><?php _e( 'Title', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the title of the field for your reference in the backend. The title will not appear on the front-end of your website.', 'ultimate-member' ) ); ?></label>
|
2174 |
+
<input type="text" name="_title" id="_title" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
|
2175 |
+
</p>
|
2176 |
+
|
2177 |
+
<?php
|
2178 |
+
break;
|
2179 |
+
|
2180 |
+
case '_id':
|
2181 |
+
|
2182 |
+
?>
|
2183 |
+
|
2184 |
+
<p style="display:none"><label for="_id"><?php _e( 'Unique ID', 'ultimate-member' ) ?></label>
|
2185 |
+
<input type="text" name="_id" id="_id" value="<?php echo $this->edit_mode_value; ?>" />
|
2186 |
+
</p>
|
2187 |
+
|
2188 |
+
<?php
|
2189 |
+
|
2190 |
+
break;
|
2191 |
+
|
2192 |
+
case '_metakey':
|
2193 |
+
|
2194 |
+
if ( $this->in_edit ) {
|
2195 |
+
|
2196 |
+
?>
|
2197 |
+
|
2198 |
+
<p><label for="_metakey"><?php _e( 'Meta Key', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The meta key cannot be changed for duplicated fields or when editing an existing field. If you require a different meta key please create a new field.', 'ultimate-member' ) ); ?></label>
|
2199 |
+
<input type="text" name="_metakey_locked" id="_metakey_locked" value="<?php echo $this->edit_mode_value; ?>" disabled />
|
2200 |
+
</p>
|
2201 |
+
|
2202 |
+
<?php } else { ?>
|
2203 |
+
|
2204 |
+
<p><label for="_metakey"><?php _e( 'Meta Key', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'A meta key is required to store the entered info in this field in the database. The meta key should be unique to this field and be written in lowercase with an underscore ( _ ) separating words e.g country_list or job_title', 'ultimate-member' ) ); ?></label>
|
2205 |
+
<input type="text" name="_metakey" id="_metakey" value="" />
|
2206 |
+
</p>
|
2207 |
+
|
2208 |
+
<?php
|
2209 |
+
|
2210 |
+
}
|
2211 |
+
|
2212 |
+
break;
|
2213 |
+
|
2214 |
+
case '_help':
|
2215 |
+
?>
|
2216 |
+
|
2217 |
+
<p><label for="_help"><?php _e( 'Help Text', 'ultimate-member' ) ?> <?php UM()->tooltip( __('This is the text that appears in a tooltip when a user hovers over the info icon. Help text is useful for providing users with more information about what they should enter in the field. Leave blank if no help text is needed for field.', 'ultimate-member' ) ); ?></label>
|
2218 |
+
<input type="text" name="_help" id="_help" value="<?php echo $this->edit_mode_value; ?>" />
|
2219 |
+
</p>
|
2220 |
+
|
2221 |
+
<?php
|
2222 |
+
break;
|
2223 |
+
|
2224 |
+
case '_default':
|
2225 |
+
?>
|
2226 |
+
|
2227 |
+
<?php if ( $this->set_field_type == 'textarea' ) { ?>
|
2228 |
+
|
2229 |
+
<p><label for="_default"><?php _e( 'Default Text', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'Text to display by default in this field', 'ultimate-member' ) ); ?></label>
|
2230 |
+
<textarea name="_default" id="_default"><?php echo $this->edit_mode_value; ?></textarea>
|
2231 |
+
</p>
|
2232 |
+
|
2233 |
+
<?php } elseif ( $this->set_field_type == 'date' ) { ?>
|
2234 |
+
|
2235 |
+
<p class="um"><label for="_default"><?php _e( 'Default Date', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'You may use all PHP compatible date formats such as: 2020-02-02, 02/02/2020, yesterday, today, tomorrow, next monday, first day of next month, +3 day', 'ultimate-member' ) ); ?></label>
|
2236 |
+
<input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" class="um-datepicker" data-format="yyyy/mm/dd" />
|
2237 |
+
</p>
|
2238 |
+
|
2239 |
+
<?php } elseif ( $this->set_field_type == 'time' ) { ?>
|
2240 |
+
|
2241 |
+
<p class="um"><label for="_default"><?php _e( 'Default Time', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'You may use all PHP compatible date formats such as: 2020-02-02, 02/02/2020, yesterday, today, tomorrow, next monday, first day of next month, +3 day', 'ultimate-member' ) ); ?></label>
|
2242 |
+
<input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" class="um-timepicker" data-format="HH:i" />
|
2243 |
+
</p>
|
2244 |
+
|
2245 |
+
<?php } elseif ( $this->set_field_type == 'rating' ) { ?>
|
2246 |
+
|
2247 |
+
<p><label for="_default"><?php _e( 'Default Rating', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'If you wish the rating field to be prefilled with a number of stars, enter it here.', 'ultimate-member' ) ); ?></label>
|
2248 |
+
<input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" />
|
2249 |
+
</p>
|
2250 |
+
|
2251 |
+
<?php } else { ?>
|
2252 |
+
|
2253 |
+
<p><label for="_default"><?php _e( 'Default Value', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'This option allows you to pre-fill the field with a default value prior to the user entering a value in the field. Leave blank to have no default value', 'ultimate-member' ) ); ?></label>
|
2254 |
+
<input type="text" name="_default" id="_default" value="<?php echo $this->edit_mode_value; ?>" />
|
2255 |
+
</p>
|
2256 |
+
|
2257 |
+
<?php } ?>
|
2258 |
+
|
2259 |
+
<?php
|
2260 |
+
break;
|
2261 |
+
|
2262 |
+
case '_label':
|
2263 |
+
?>
|
2264 |
+
|
2265 |
+
<p><label for="_label"><?php _e( 'Label', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'The field label is the text that appears above the field on your front-end form. Leave blank to not show a label above field.', 'ultimate-member' ) ); ?></label>
|
2266 |
+
<input type="text" name="_label" id="_label" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
|
2267 |
+
</p>
|
2268 |
+
|
2269 |
+
<?php
|
2270 |
+
break;
|
2271 |
+
|
2272 |
+
case '_label_confirm_pass':
|
2273 |
+
?>
|
2274 |
+
|
2275 |
+
<p><label for="_label_confirm_pass"><?php _e( 'Confirm password field label', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This label is the text that appears above the confirm password field. Leave blank to show default label.', 'ultimate-member' ) ); ?></label>
|
2276 |
+
<input type="text" name="_label_confirm_pass" id="_label_confirm_pass" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
|
2277 |
+
</p>
|
2278 |
+
|
2279 |
+
<?php
|
2280 |
+
break;
|
2281 |
+
|
2282 |
+
case '_placeholder':
|
2283 |
+
?>
|
2284 |
+
|
2285 |
+
<p><label for="_placeholder"><?php _e( 'Placeholder', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This is the text that appears within the field e.g please enter your email address. Leave blank to not show any placeholder text.', 'ultimate-member' ) ); ?></label>
|
2286 |
+
<input type="text" name="_placeholder" id="_placeholder" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
|
2287 |
+
</p>
|
2288 |
+
|
2289 |
+
<?php
|
2290 |
+
break;
|
2291 |
+
|
2292 |
+
case '_public':
|
2293 |
+
$privacy_options = array(
|
2294 |
+
'1' => __( 'Everyone', 'ultimate-member' ),
|
2295 |
+
'2' => __( 'Members', 'ultimate-member' ),
|
2296 |
+
'-1' => __( 'Only visible to profile owner and users who can edit other member accounts', 'ultimate-member' ),
|
2297 |
+
'-3' => __( 'Only visible to profile owner and specific roles', 'ultimate-member' ),
|
2298 |
+
'-2' => __( 'Only specific member roles', 'ultimate-member' ),
|
2299 |
+
);
|
2300 |
+
|
2301 |
+
$privacy_options = apply_filters( 'um_field_privacy_options', $privacy_options ); ?>
|
2302 |
+
|
2303 |
+
<p>
|
2304 |
+
<label for="_public"><?php _e( 'Privacy', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Field privacy allows you to select who can view this field on the front-end. The site admin can view all fields regardless of the option set here.', 'ultimate-member' ) ); ?></label>
|
2305 |
+
<select name="_public" id="_public" class="um-adm-conditional" data-cond1="-2" data-cond1-show="_roles" data-cond2="-3" data-cond2-show="_roles" style="width: 100%">
|
2306 |
+
<?php foreach ( $privacy_options as $value => $title ) { ?>
|
2307 |
+
<option value="<?php echo esc_attr( $value ) ?>" <?php selected( $value, $this->edit_mode_value ); ?>>
|
2308 |
+
<?php echo $title ?>
|
2309 |
+
</option>
|
2310 |
+
<?php } ?>
|
2311 |
+
</select>
|
2312 |
+
</p>
|
2313 |
+
|
2314 |
+
<?php
|
2315 |
+
break;
|
2316 |
+
|
2317 |
+
case '_roles':
|
2318 |
+
|
2319 |
+
if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) {
|
2320 |
+
$values = $this->edit_mode_value;
|
2321 |
+
} else {
|
2322 |
+
$values = array('');
|
2323 |
+
}
|
2324 |
+
|
2325 |
+
?>
|
2326 |
+
|
2327 |
+
<p class="_roles"><label for="_roles"><?php _e( 'Select member roles', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Select the member roles that can view this field on the front-end.', 'ultimate-member' ) ); ?></label>
|
2328 |
+
<select name="_roles[]" id="_roles" style="width: 100%" multiple="multiple">
|
2329 |
+
|
2330 |
+
<?php foreach ( UM()->roles()->get_roles() as $key => $value) { ?>
|
2331 |
+
|
2332 |
+
<option value="<?php echo $key; ?>" <?php if ( in_array( $key, $values ) ) { echo 'selected'; } ?>><?php echo $value; ?></option>
|
2333 |
+
|
2334 |
+
<?php } ?>
|
2335 |
+
|
2336 |
+
</select>
|
2337 |
+
</p>
|
2338 |
+
|
2339 |
+
<?php
|
2340 |
+
break;
|
2341 |
+
|
2342 |
+
case '_required':
|
2343 |
+
|
2344 |
+
if ( $this->set_field_type == 'password' )
|
2345 |
+
$def_required = 1;
|
2346 |
+
else
|
2347 |
+
$def_required = 0;
|
2348 |
+
|
2349 |
+
?>
|
2350 |
+
|
2351 |
+
<div class="um-admin-tri">
|
2352 |
+
|
2353 |
+
<p><label for="_required"><?php _e( 'Is this field required?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This option allows you to set whether the field must be filled in before the form can be processed.', 'ultimate-member' ) ); ?></label>
|
2354 |
+
<input type="checkbox" name="_required" id="_required" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : $def_required ) ?> />
|
2355 |
+
</p>
|
2356 |
+
|
2357 |
+
</div>
|
2358 |
+
|
2359 |
+
<?php
|
2360 |
+
break;
|
2361 |
+
|
2362 |
+
case '_editable':
|
2363 |
+
?>
|
2364 |
+
|
2365 |
+
<div class="um-admin-tri">
|
2366 |
+
|
2367 |
+
<p><label for="_editable"><?php _e( 'Can user edit this field?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This option allows you to set whether or not the user can edit the information in this field. The site admin can edit all fields regardless of the option set here.', 'ultimate-member' ) ); ?></label>
|
2368 |
+
<input type="hidden" name="_editable" id="_editable_hidden" value="0" />
|
2369 |
+
<input type="checkbox" name="_editable" id="_editable" value="1" <?php checked( null === $this->edit_mode_value || $this->edit_mode_value ) ?> />
|
2370 |
+
</p>
|
2371 |
+
|
2372 |
+
</div>
|
2373 |
+
|
2374 |
+
<?php
|
2375 |
+
break;
|
2376 |
+
|
2377 |
+
case '_number':
|
2378 |
+
?>
|
2379 |
+
|
2380 |
+
<p><label for="_number"><?php _e( 'Rating System', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Choose whether you want a 5-stars or 10-stars ratings based here.', 'ultimate-member' ) ); ?></label>
|
2381 |
+
<select name="_number" id="_number" style="width: 100%">
|
2382 |
+
<option value="5" <?php selected( 5, $this->edit_mode_value ); ?>><?php _e( '5 stars rating system', 'ultimate-member' ) ?></option>
|
2383 |
+
<option value="10" <?php selected( 10, $this->edit_mode_value ); ?>><?php _e( '10 stars rating system', 'ultimate-member' ) ?></option>
|
2384 |
+
</select>
|
2385 |
+
</p>
|
2386 |
+
|
2387 |
+
<?php
|
2388 |
+
break;
|
2389 |
+
|
2390 |
+
case '_custom_dropdown_options_source':
|
2391 |
+
?>
|
2392 |
+
|
2393 |
+
<p><label for="_custom_dropdown_options_source"><?php _e( 'Choices Callback', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Add a callback source to retrieve choices.', 'ultimate-member' ) ); ?></label>
|
2394 |
+
<input type="text" name="_custom_dropdown_options_source" id="_custom_dropdown_options_source" value="<?php echo esc_attr( $this->edit_mode_value ); ?>" />
|
2395 |
+
</p>
|
2396 |
+
|
2397 |
+
<?php
|
2398 |
+
break;
|
2399 |
+
|
2400 |
+
case '_parent_dropdown_relationship':
|
2401 |
+
?>
|
2402 |
+
|
2403 |
+
<p><label for="_parent_dropdown_relationship"><?php _e( 'Parent Option', 'ultimate-member' ) ?><?php UM()->tooltip( __( 'Dynamically populates the option based from selected parent option.', 'ultimate-member' ) ); ?></label>
|
2404 |
+
<select name="_parent_dropdown_relationship" id="_parent_dropdown_relationship" style="width: 100%">
|
2405 |
+
<option value=""><?php _e( 'No Selected', 'ultimate-member' ) ?></option>
|
2406 |
+
|
2407 |
+
<?php if ( UM()->builtin()->custom_fields ) {
|
2408 |
+
foreach ( UM()->builtin()->custom_fields as $field_key => $array ) {
|
2409 |
+
if ( in_array( $array['type'], array( 'select' ) ) && ( ! isset( $field_args['metakey'] ) || $field_args['metakey'] != $array['metakey'] ) && isset( $array['title'] ) ) { ?>
|
2410 |
+
<option value="<?php echo esc_attr( $array['metakey'] ) ?>" <?php selected( $array['metakey'], $this->edit_mode_value ) ?>><?php echo $array['title'] ?></option>
|
2411 |
+
<?php }
|
2412 |
+
}
|
2413 |
+
} ?>
|
2414 |
+
</select>
|
2415 |
+
</p>
|
2416 |
+
|
2417 |
+
<?php
|
2418 |
+
break;
|
2419 |
+
|
2420 |
+
|
2421 |
+
}
|
2422 |
+
|
2423 |
+
}
|
2424 |
+
|
2425 |
+
}
|
2426 |
+
}
|
|
includes/admin/core/packages/2.4.0/functions.php
CHANGED
@@ -1,50 +1,50 @@
|
|
1 |
-
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
2 |
-
|
3 |
-
|
4 |
-
function um_upgrade_choice_callbacks240() {
|
5 |
-
UM()->admin()->check_ajax_nonce();
|
6 |
-
|
7 |
-
um_maybe_unset_time_limit();
|
8 |
-
|
9 |
-
$functions = array();
|
10 |
-
// hardcoded for UM:Woocommerce function
|
11 |
-
if ( function_exists( 'um_woo_directory_get_states' ) ) {
|
12 |
-
$functions[] = 'um_woo_directory_get_states';
|
13 |
-
}
|
14 |
-
|
15 |
-
$custom_fields = get_option( 'um_fields', array() );
|
16 |
-
foreach ( $custom_fields as $custom_field ) {
|
17 |
-
if ( array_key_exists( 'custom_dropdown_options_source', $custom_field ) && function_exists( $custom_field['custom_dropdown_options_source'] ) ) {
|
18 |
-
$functions[] = $custom_field['custom_dropdown_options_source'];
|
19 |
-
}
|
20 |
-
}
|
21 |
-
|
22 |
-
$forms_query = new WP_Query;
|
23 |
-
$forms = $forms_query->query( array(
|
24 |
-
'post_type' => 'um_form',
|
25 |
-
'posts_per_page' => -1,
|
26 |
-
'fields' => 'ids',
|
27 |
-
) );
|
28 |
-
|
29 |
-
foreach ( $forms as $form_id ) {
|
30 |
-
$forms_fields = get_post_meta( $form_id, '_um_custom_fields', true );
|
31 |
-
if ( ! is_array( $forms_fields ) ) {
|
32 |
-
continue;
|
33 |
-
}
|
34 |
-
|
35 |
-
foreach ( $forms_fields as $key => $field ) {
|
36 |
-
if ( array_key_exists( 'custom_dropdown_options_source', $field ) && function_exists( $field['custom_dropdown_options_source'] ) ) {
|
37 |
-
$functions[] = $field['custom_dropdown_options_source'];
|
38 |
-
}
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
42 |
-
$functions = array_unique( $functions );
|
43 |
-
$functions = implode( "\r\n", $functions );
|
44 |
-
UM()->options()->update( 'allowed_choice_callbacks', $functions );
|
45 |
-
|
46 |
-
// delete temporarily option for fields upgrade
|
47 |
-
update_option( 'um_last_version_upgrade', '2.4.0' );
|
48 |
-
|
49 |
-
wp_send_json_success( array( 'message' => __( 'Custom callback functions whitelisted for 2.4.0 version.', 'ultimate-member' ) ) );
|
50 |
-
}
|
1 |
+
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
2 |
+
|
3 |
+
|
4 |
+
function um_upgrade_choice_callbacks240() {
|
5 |
+
UM()->admin()->check_ajax_nonce();
|
6 |
+
|
7 |
+
um_maybe_unset_time_limit();
|
8 |
+
|
9 |
+
$functions = array();
|
10 |
+
// hardcoded for UM:Woocommerce function
|
11 |
+
if ( function_exists( 'um_woo_directory_get_states' ) ) {
|
12 |
+
$functions[] = 'um_woo_directory_get_states';
|
13 |
+
}
|
14 |
+
|
15 |
+
$custom_fields = get_option( 'um_fields', array() );
|
16 |
+
foreach ( $custom_fields as $custom_field ) {
|
17 |
+
if ( array_key_exists( 'custom_dropdown_options_source', $custom_field ) && function_exists( $custom_field['custom_dropdown_options_source'] ) ) {
|
18 |
+
$functions[] = $custom_field['custom_dropdown_options_source'];
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
$forms_query = new WP_Query;
|
23 |
+
$forms = $forms_query->query( array(
|
24 |
+
'post_type' => 'um_form',
|
25 |
+
'posts_per_page' => -1,
|
26 |
+
'fields' => 'ids',
|
27 |
+
) );
|
28 |
+
|
29 |
+
foreach ( $forms as $form_id ) {
|
30 |
+
$forms_fields = get_post_meta( $form_id, '_um_custom_fields', true );
|
31 |
+
if ( ! is_array( $forms_fields ) ) {
|
32 |
+
continue;
|
33 |
+
}
|
34 |
+
|
35 |
+
foreach ( $forms_fields as $key => $field ) {
|
36 |
+
if ( array_key_exists( 'custom_dropdown_options_source', $field ) && function_exists( $field['custom_dropdown_options_source'] ) ) {
|
37 |
+
$functions[] = $field['custom_dropdown_options_source'];
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
$functions = array_unique( $functions );
|
43 |
+
$functions = implode( "\r\n", $functions );
|
44 |
+
UM()->options()->update( 'allowed_choice_callbacks', $functions );
|
45 |
+
|
46 |
+
// delete temporarily option for fields upgrade
|
47 |
+
update_option( 'um_last_version_upgrade', '2.4.0' );
|
48 |
+
|
49 |
+
wp_send_json_success( array( 'message' => __( 'Custom callback functions whitelisted for 2.4.0 version.', 'ultimate-member' ) ) );
|
50 |
+
}
|
includes/admin/templates/form/builder.php
CHANGED
@@ -1,35 +1,35 @@
|
|
1 |
-
<?php if ( ! defined( 'ABSPATH' ) ) {
|
2 |
-
exit;
|
3 |
-
}
|
4 |
-
|
5 |
-
if ( empty( UM()->builder()->form_id ) ) {
|
6 |
-
UM()->builder()->form_id = $this->form_id;
|
7 |
-
} ?>
|
8 |
-
|
9 |
-
<div class="um-admin-builder" data-form_id="<?php echo esc_attr( UM()->builder()->form_id ); ?>">
|
10 |
-
|
11 |
-
<div class="um-admin-drag-ctrls-demo um-admin-drag-ctrls">
|
12 |
-
|
13 |
-
<a href="javascript:void(0);" class="active" data-modal="UM_preview_form" data-modal-size="smaller"
|
14 |
-
data-dynamic-content="um_admin_preview_form" data-arg1="<?php echo esc_attr( get_the_ID() ); ?>" data-arg2="">
|
15 |
-
<?php esc_html_e( 'Live Preview', 'ultimate-member' ); ?>
|
16 |
-
</a>
|
17 |
-
|
18 |
-
</div>
|
19 |
-
|
20 |
-
<div class="um-admin-clear"></div>
|
21 |
-
|
22 |
-
<div class="um-admin-drag">
|
23 |
-
|
24 |
-
<div class="um-admin-drag-ajax" data-form_id="<?php echo esc_attr( UM()->builder()->form_id ); ?>">
|
25 |
-
<?php UM()->builder()->show_builder(); ?>
|
26 |
-
</div>
|
27 |
-
|
28 |
-
<div class="um-admin-drag-addrow um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Master Row', 'ultimate-member' ); ?>"
|
29 |
-
data-row_action="add_row">
|
30 |
-
<i class="um-icon-plus"></i>
|
31 |
-
</div>
|
32 |
-
|
33 |
-
</div>
|
34 |
-
|
35 |
-
</div>
|
1 |
+
<?php if ( ! defined( 'ABSPATH' ) ) {
|
2 |
+
exit;
|
3 |
+
}
|
4 |
+
|
5 |
+
if ( empty( UM()->builder()->form_id ) ) {
|
6 |
+
UM()->builder()->form_id = $this->form_id;
|
7 |
+
} ?>
|
8 |
+
|
9 |
+
<div class="um-admin-builder" data-form_id="<?php echo esc_attr( UM()->builder()->form_id ); ?>">
|
10 |
+
|
11 |
+
<div class="um-admin-drag-ctrls-demo um-admin-drag-ctrls">
|
12 |
+
|
13 |
+
<a href="javascript:void(0);" class="active" data-modal="UM_preview_form" data-modal-size="smaller"
|
14 |
+
data-dynamic-content="um_admin_preview_form" data-arg1="<?php echo esc_attr( get_the_ID() ); ?>" data-arg2="">
|
15 |
+
<?php esc_html_e( 'Live Preview', 'ultimate-member' ); ?>
|
16 |
+
</a>
|
17 |
+
|
18 |
+
</div>
|
19 |
+
|
20 |
+
<div class="um-admin-clear"></div>
|
21 |
+
|
22 |
+
<div class="um-admin-drag">
|
23 |
+
|
24 |
+
<div class="um-admin-drag-ajax" data-form_id="<?php echo esc_attr( UM()->builder()->form_id ); ?>">
|
25 |
+
<?php UM()->builder()->show_builder(); ?>
|
26 |
+
</div>
|
27 |
+
|
28 |
+
<div class="um-admin-drag-addrow um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Master Row', 'ultimate-member' ); ?>"
|
29 |
+
data-row_action="add_row">
|
30 |
+
<i class="um-icon-plus"></i>
|
31 |
+
</div>
|
32 |
+
|
33 |
+
</div>
|
34 |
+
|
35 |
+
</div>
|
includes/core/class-access.php
CHANGED
@@ -1,2133 +1,2136 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\core;
|
3 |
-
|
4 |
-
// Exit if accessed directly
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
if ( ! class_exists( 'um\core\Access' ) ) {
|
8 |
-
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class Access
|
12 |
-
* @package um\core
|
13 |
-
*/
|
14 |
-
class Access {
|
15 |
-
|
16 |
-
|
17 |
-
/**
|
18 |
-
* If true then we use individual restrict content options
|
19 |
-
* for post
|
20 |
-
*
|
21 |
-
* @var bool
|
22 |
-
*/
|
23 |
-
private $singular_page;
|
24 |
-
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @var bool
|
28 |
-
*/
|
29 |
-
private $redirect_handler;
|
30 |
-
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @var bool
|
34 |
-
*/
|
35 |
-
private $allow_access;
|
36 |
-
|
37 |
-
|
38 |
-
private $ignore_exclude = false;
|
39 |
-
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Access constructor.
|
43 |
-
*/
|
44 |
-
function __construct() {
|
45 |
-
$this->singular_page = false;
|
46 |
-
|
47 |
-
$this->redirect_handler = false;
|
48 |
-
$this->allow_access = false;
|
49 |
-
|
50 |
-
// NEW HOOKS
|
51 |
-
|
52 |
-
//
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
//
|
60 |
-
add_filter( '
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
add_filter( '
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
//
|
76 |
-
add_filter( '
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
// comments
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
add_filter( '
|
87 |
-
|
88 |
-
|
89 |
-
add_filter( '
|
90 |
-
|
91 |
-
//
|
92 |
-
add_filter( '
|
93 |
-
|
94 |
-
//
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
//
|
99 |
-
|
100 |
-
|
101 |
-
//
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
add_action( '
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
if ( ! UM()->options()->get( 'disable_restriction_pre_queries' ) ) {
|
118 |
-
return;
|
119 |
-
}
|
120 |
-
|
121 |
-
remove_action( 'pre_get_terms', array( &$this, 'exclude_hidden_terms_query' ), 99 );
|
122 |
-
remove_filter( 'widget_posts_args', array( &$this, 'exclude_restricted_posts_widget' ), 99 );
|
123 |
-
remove_filter( 'wp_list_pages_excludes', array( &$this, 'exclude_restricted_pages' ), 10 );
|
124 |
-
remove_filter( 'getarchives_where', array( &$this, 'exclude_restricted_posts_archives_widget' ), 99 );
|
125 |
-
remove_filter( 'get_next_post_where', array( &$this, 'exclude_navigation_posts' ), 99 );
|
126 |
-
remove_filter( 'get_previous_post_where', array( &$this, 'exclude_navigation_posts' ), 99 );
|
127 |
-
remove_action( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99 );
|
128 |
-
remove_filter( 'posts_where', array( &$this, 'exclude_posts_where' ), 10 );
|
129 |
-
remove_filter( 'wp_count_posts', array( &$this, 'custom_count_posts_handler' ), 99 );
|
130 |
-
}
|
131 |
-
|
132 |
-
|
133 |
-
/**
|
134 |
-
* Get array with restricted posts
|
135 |
-
*
|
136 |
-
* @param bool $force
|
137 |
-
* @param bool|array|string $post_types
|
138 |
-
*
|
139 |
-
* @return array
|
140 |
-
*/
|
141 |
-
function exclude_posts_array( $force = false, $post_types = false ) {
|
142 |
-
if ( $this->ignore_exclude ) {
|
143 |
-
return array();
|
144 |
-
}
|
145 |
-
|
146 |
-
static $cache = array();
|
147 |
-
|
148 |
-
$cache_key = $force ? 'force' : 'default';
|
149 |
-
|
150 |
-
// `force` cache contains all restricted post IDs we can get them all from cache instead new queries
|
151 |
-
$force_cache_key = '';
|
152 |
-
if ( 'default' === $cache_key ) {
|
153 |
-
$force_cache_key = 'force';
|
154 |
-
}
|
155 |
-
|
156 |
-
// make $post_types as array if string
|
157 |
-
if ( ! empty( $post_types ) ) {
|
158 |
-
$post_types = is_array( $post_types ) ? $post_types : array( $post_types );
|
159 |
-
$cache_key .= md5( serialize( $post_types ) );
|
160 |
-
if ( ! empty( $force_cache_key ) ) {
|
161 |
-
$force_cache_key .= md5( serialize( $post_types ) );
|
162 |
-
}
|
163 |
-
}
|
164 |
-
|
165 |
-
if ( array_key_exists( $cache_key, $cache ) ) {
|
166 |
-
return $cache[ $cache_key ];
|
167 |
-
}
|
168 |
-
|
169 |
-
$exclude_posts = array();
|
170 |
-
if ( current_user_can( 'administrator' ) ) {
|
171 |
-
$cache[ $cache_key ] = $exclude_posts;
|
172 |
-
return $exclude_posts;
|
173 |
-
}
|
174 |
-
|
175 |
-
// @todo using Object Cache `wp_cache_get()` `wp_cache_set()` functions
|
176 |
-
|
177 |
-
// `force` cache contains all restricted post IDs we can get them all from cache instead new queries
|
178 |
-
if ( ! empty( $force_cache_key ) && array_key_exists( $force_cache_key, $cache ) ) {
|
179 |
-
$post_ids = $cache[ $force_cache_key ];
|
180 |
-
|
181 |
-
if ( ! empty( $post_ids ) ) {
|
182 |
-
foreach ( $post_ids as $post_id ) {
|
183 |
-
$content_restriction = $this->get_post_privacy_settings( $post_id );
|
184 |
-
if ( ! empty( $content_restriction['_um_access_hide_from_queries'] ) ) {
|
185 |
-
array_push( $exclude_posts, $post_id );
|
186 |
-
}
|
187 |
-
}
|
188 |
-
}
|
189 |
-
} else {
|
190 |
-
$restricted_posts = UM()->options()->get( 'restricted_access_post_metabox' );
|
191 |
-
if ( ! empty( $restricted_posts ) ) {
|
192 |
-
$restricted_posts = array_keys( $restricted_posts );
|
193 |
-
if ( ! empty( $post_types ) ) {
|
194 |
-
$restricted_posts = array_intersect( $post_types, $restricted_posts );
|
195 |
-
}
|
196 |
-
}
|
197 |
-
|
198 |
-
if ( ! empty( $restricted_posts ) ) {
|
199 |
-
$this->ignore_exclude = true;
|
200 |
-
// exclude all posts assigned to current term without individual restriction settings
|
201 |
-
$post_ids = get_posts(
|
202 |
-
array(
|
203 |
-
'fields' => 'ids',
|
204 |
-
'post_status' => 'any',
|
205 |
-
'post_type' => $restricted_posts,
|
206 |
-
'numberposts' => -1,
|
207 |
-
'meta_query' => array(
|
208 |
-
array(
|
209 |
-
'key' => 'um_content_restriction',
|
210 |
-
'compare' => 'EXISTS',
|
211 |
-
),
|
212 |
-
),
|
213 |
-
)
|
214 |
-
);
|
215 |
-
|
216 |
-
$this->ignore_exclude = false;
|
217 |
-
}
|
218 |
-
|
219 |
-
$post_ids = empty( $post_ids ) ? array() : $post_ids;
|
220 |
-
|
221 |
-
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
222 |
-
|
223 |
-
if ( ! empty( $restricted_taxonomies ) ) {
|
224 |
-
$restricted_taxonomies = array_keys( $restricted_taxonomies );
|
225 |
-
foreach ( $restricted_taxonomies as $k => $taxonomy ) {
|
226 |
-
if ( ! taxonomy_exists( $taxonomy ) ) {
|
227 |
-
unset( $restricted_taxonomies[ $k ] );
|
228 |
-
}
|
229 |
-
}
|
230 |
-
$restricted_taxonomies = array_values( $restricted_taxonomies );
|
231 |
-
|
232 |
-
if ( ! empty( $post_types ) ) {
|
233 |
-
$taxonomies = array();
|
234 |
-
foreach ( $post_types as $p_t ) {
|
235 |
-
$taxonomies = array_merge( $taxonomies, get_object_taxonomies( $p_t ) );
|
236 |
-
}
|
237 |
-
$restricted_taxonomies = array_intersect( $taxonomies, $restricted_taxonomies );
|
238 |
-
}
|
239 |
-
}
|
240 |
-
|
241 |
-
if ( ! empty( $restricted_taxonomies ) ) {
|
242 |
-
global $wpdb;
|
243 |
-
|
244 |
-
$terms = $wpdb->get_results(
|
245 |
-
"SELECT tm.term_id AS term_id,
|
246 |
-
tt.taxonomy AS taxonomy
|
247 |
-
FROM {$wpdb->termmeta} tm
|
248 |
-
LEFT JOIN {$wpdb->term_taxonomy} tt ON tt.term_id = tm.term_id
|
249 |
-
WHERE tm.meta_key = 'um_content_restriction' AND
|
250 |
-
tt.taxonomy IN('" . implode( "','", $restricted_taxonomies ) . "')",
|
251 |
-
ARRAY_A
|
252 |
-
);
|
253 |
-
|
254 |
-
if ( ! empty( $terms ) ) {
|
255 |
-
foreach ( $terms as $term ) {
|
256 |
-
if ( ! $this->is_restricted_term( $term['term_id'] ) ) {
|
257 |
-
continue;
|
258 |
-
}
|
259 |
-
|
260 |
-
$this->ignore_exclude = true;
|
261 |
-
// exclude all posts assigned to current term without individual restriction settings
|
262 |
-
$posts = get_posts(
|
263 |
-
array(
|
264 |
-
'fields' => 'ids',
|
265 |
-
'post_status' => 'any',
|
266 |
-
'numberposts' => -1,
|
267 |
-
'tax_query' => array(
|
268 |
-
array(
|
269 |
-
'taxonomy' => $term['taxonomy'],
|
270 |
-
'field' => 'id',
|
271 |
-
'terms' => $term['term_id'],
|
272 |
-
),
|
273 |
-
),
|
274 |
-
'meta_query' => array(
|
275 |
-
'relation' => 'OR',
|
276 |
-
array(
|
277 |
-
'relation' => 'AND',
|
278 |
-
array(
|
279 |
-
'key' => 'um_content_restriction',
|
280 |
-
'value' => 's:26:"_um_custom_access_settings";s:1:"1"',
|
281 |
-
'compare' => 'NOT LIKE',
|
282 |
-
),
|
283 |
-
array(
|
284 |
-
'key' => 'um_content_restriction',
|
285 |
-
'value' => 's:26:"_um_custom_access_settings";b:1',
|
286 |
-
'compare' => 'NOT LIKE',
|
287 |
-
),
|
288 |
-
),
|
289 |
-
array(
|
290 |
-
'key' => 'um_content_restriction',
|
291 |
-
'compare' => 'NOT EXISTS',
|
292 |
-
),
|
293 |
-
),
|
294 |
-
)
|
295 |
-
);
|
296 |
-
$this->ignore_exclude = false;
|
297 |
-
|
298 |
-
if ( empty( $posts ) ) {
|
299 |
-
continue;
|
300 |
-
}
|
301 |
-
|
302 |
-
$post_ids = array_merge( $post_ids, $posts );
|
303 |
-
}
|
304 |
-
}
|
305 |
-
}
|
306 |
-
|
307 |
-
if ( ! empty( $post_ids ) ) {
|
308 |
-
$post_ids = array_unique( $post_ids );
|
309 |
-
|
310 |
-
foreach ( $post_ids as $post_id ) {
|
311 |
-
// handle every post privacy setting based on post type maybe it's inactive for now
|
312 |
-
// if individual restriction is enabled then get post terms restriction settings
|
313 |
-
if ( $this->is_restricted( $post_id ) ) {
|
314 |
-
if ( true === $force ) {
|
315 |
-
array_push( $exclude_posts, $post_id );
|
316 |
-
} else {
|
317 |
-
$content_restriction = $this->get_post_privacy_settings( $post_id );
|
318 |
-
if ( ! empty( $content_restriction['_um_access_hide_from_queries'] ) ) {
|
319 |
-
array_push( $exclude_posts, $post_id );
|
320 |
-
}
|
321 |
-
}
|
322 |
-
}
|
323 |
-
}
|
324 |
-
}
|
325 |
-
}
|
326 |
-
|
327 |
-
$exclude_posts = apply_filters( 'um_exclude_restricted_posts_ids', $exclude_posts, $force );
|
328 |
-
|
329 |
-
$cache[ $cache_key ] = $exclude_posts;
|
330 |
-
return $exclude_posts;
|
331 |
-
}
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
/**
|
336 |
-
* Get array with restricted terms
|
337 |
-
*
|
338 |
-
* @param \WP_Term_Query $query
|
339 |
-
*
|
340 |
-
* @return array
|
341 |
-
*/
|
342 |
-
function exclude_terms_array( $query ) {
|
343 |
-
$exclude = array();
|
344 |
-
|
345 |
-
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
346 |
-
if ( ! empty( $restricted_taxonomies ) ) {
|
347 |
-
$restricted_taxonomies = array_keys( $restricted_taxonomies );
|
348 |
-
foreach ( $restricted_taxonomies as $k => $taxonomy ) {
|
349 |
-
if ( ! taxonomy_exists( $taxonomy ) ) {
|
350 |
-
unset( $restricted_taxonomies[ $k ] );
|
351 |
-
}
|
352 |
-
}
|
353 |
-
$restricted_taxonomies = array_values( $restricted_taxonomies );
|
354 |
-
|
355 |
-
if ( ! empty( $restricted_taxonomies ) ) {
|
356 |
-
if ( isset( $query->query_vars['taxonomy'] ) && is_array( $query->query_vars['taxonomy'] ) ) {
|
357 |
-
$restricted_taxonomies = array_intersect( $query->query_vars['taxonomy'], $restricted_taxonomies );
|
358 |
-
} elseif ( ! empty( $query->query_vars['term_taxonomy_id'] ) ) {
|
359 |
-
$term_taxonomy_ids = is_array( $query->query_vars['term_taxonomy_id'] ) ? $query->query_vars['term_taxonomy_id'] : array( $query->query_vars['term_taxonomy_id'] );
|
360 |
-
|
361 |
-
global $wpdb;
|
362 |
-
$tax_in_query = $wpdb->get_col( "SELECT DISTINCT taxonomy FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id IN('" . implode( "','", $term_taxonomy_ids ) . "')" );
|
363 |
-
if ( ! empty( $tax_in_query ) ) {
|
364 |
-
$restricted_taxonomies = array_intersect( $tax_in_query, $restricted_taxonomies );
|
365 |
-
} else {
|
366 |
-
$restricted_taxonomies = array();
|
367 |
-
}
|
368 |
-
}
|
369 |
-
}
|
370 |
-
}
|
371 |
-
|
372 |
-
if ( empty( $restricted_taxonomies ) ) {
|
373 |
-
return $exclude;
|
374 |
-
}
|
375 |
-
|
376 |
-
$cache_key = md5( serialize( $restricted_taxonomies ) );
|
377 |
-
|
378 |
-
static $cache = array();
|
379 |
-
|
380 |
-
if ( array_key_exists( $cache_key, $cache ) ) {
|
381 |
-
return $cache[ $cache_key ];
|
382 |
-
}
|
383 |
-
|
384 |
-
$term_ids = get_terms(
|
385 |
-
array(
|
386 |
-
'taxonomy' => $restricted_taxonomies,
|
387 |
-
'hide_empty' => false,
|
388 |
-
'fields' => 'ids',
|
389 |
-
'meta_query' => array(
|
390 |
-
'key' => 'um_content_restriction',
|
391 |
-
'compare' => 'EXISTS',
|
392 |
-
),
|
393 |
-
'um_ignore_exclude' => true,
|
394 |
-
)
|
395 |
-
);
|
396 |
-
|
397 |
-
if ( empty( $term_ids ) || is_wp_error( $term_ids ) ) {
|
398 |
-
$cache[ $cache_key ] = $exclude;
|
399 |
-
return $exclude;
|
400 |
-
}
|
401 |
-
|
402 |
-
foreach ( $term_ids as $term_id ) {
|
403 |
-
if ( $this->is_restricted_term( $term_id ) ) {
|
404 |
-
$exclude[] = $term_id;
|
405 |
-
}
|
406 |
-
}
|
407 |
-
|
408 |
-
$exclude = apply_filters( 'um_exclude_restricted_terms_ids', $exclude );
|
409 |
-
$cache[ $cache_key ] = $exclude;
|
410 |
-
return $exclude;
|
411 |
-
}
|
412 |
-
|
413 |
-
|
414 |
-
/**
|
415 |
-
* @param \WP_Term_Query $query
|
416 |
-
*/
|
417 |
-
function exclude_hidden_terms_query( $query ) {
|
418 |
-
if ( current_user_can( 'administrator' ) || ! empty( $query->query_vars['um_ignore_exclude'] ) ) {
|
419 |
-
return;
|
420 |
-
}
|
421 |
-
|
422 |
-
$exclude = $this->exclude_terms_array( $query );
|
423 |
-
if ( ! empty( $exclude ) ) {
|
424 |
-
$query->query_vars['exclude'] = ! empty( $query->query_vars['exclude'] ) ? wp_parse_id_list( $query->query_vars['exclude'] ) : $exclude;
|
425 |
-
}
|
426 |
-
}
|
427 |
-
|
428 |
-
|
429 |
-
/**
|
430 |
-
* @param \WP_Query $query
|
431 |
-
*/
|
432 |
-
function exclude_posts( $query ) {
|
433 |
-
if ( current_user_can( 'administrator' ) ) {
|
434 |
-
return;
|
435 |
-
}
|
436 |
-
|
437 |
-
// use these functions is_search() || is_admin() for getting force hide all posts
|
438 |
-
// don't handle `hide from WP_Query` and show 404 option for searching and wp-admin query
|
439 |
-
if ( $query->is_main_query() || ! empty( $query->query_vars['um_main_query'] ) ) {
|
440 |
-
$force = is_feed() || is_search() || is_admin();
|
441 |
-
|
442 |
-
if ( is_object( $query ) ) {
|
443 |
-
$is_singular = $query->is_singular();
|
444 |
-
} else {
|
445 |
-
$is_singular = ! empty( $query->is_singular ) ? true : false;
|
446 |
-
}
|
447 |
-
|
448 |
-
if ( ! $is_singular ) {
|
449 |
-
// need to know what post type is here
|
450 |
-
$q_values = ! empty( $query->query_vars['post_type'] ) ? $query->query_vars['post_type'] : array();
|
451 |
-
if ( ! is_array( $q_values ) ) {
|
452 |
-
$q_values = explode( ',', $query->query_vars['post_type'] );
|
453 |
-
}
|
454 |
-
|
455 |
-
// 'any' will cause the query var to be ignored.
|
456 |
-
if ( in_array( 'any', $q_values, true ) || empty( $q_values ) ) {
|
457 |
-
$exclude_posts = $this->exclude_posts_array( $force );
|
458 |
-
} else {
|
459 |
-
$exclude_posts = $this->exclude_posts_array( $force, $q_values );
|
460 |
-
}
|
461 |
-
|
462 |
-
if ( ! empty( $exclude_posts ) ) {
|
463 |
-
$post__not_in = $query->get( 'post__not_in', array() );
|
464 |
-
$query->set( 'post__not_in', array_merge( wp_parse_id_list( $post__not_in ), $exclude_posts ) );
|
465 |
-
}
|
466 |
-
}
|
467 |
-
}
|
468 |
-
}
|
469 |
-
|
470 |
-
|
471 |
-
/**
|
472 |
-
* Exclude restricted post from query if there is a single query that exclude post_not_in by default in \WP_Query
|
473 |
-
*
|
474 |
-
* @param string $where
|
475 |
-
* @param \WP_Query $query
|
476 |
-
*
|
477 |
-
* @return mixed
|
478 |
-
*/
|
479 |
-
function exclude_posts_where( $where, $query ) {
|
480 |
-
if ( current_user_can( 'administrator' ) ) {
|
481 |
-
return $where;
|
482 |
-
}
|
483 |
-
|
484 |
-
if ( ! $query->is_main_query() ) {
|
485 |
-
return $where;
|
486 |
-
}
|
487 |
-
|
488 |
-
if ( ! empty( $query->query_vars['p'] ) && $this->is_restricted( $query->query_vars['p'] ) ) {
|
489 |
-
$restriction_settings = $this->get_post_privacy_settings( $query->query_vars['p'] );
|
490 |
-
if ( ! empty( $restriction_settings['_um_access_hide_from_queries'] ) && ! empty( $query->query_vars['post__not_in'] ) ) {
|
491 |
-
global $wpdb;
|
492 |
-
$post__not_in = implode( ',', array_map( 'absint', $query->query_vars['post__not_in'] ) );
|
493 |
-
$where .= " AND {$wpdb->posts}.ID NOT IN ($post__not_in)";
|
494 |
-
}
|
495 |
-
}
|
496 |
-
|
497 |
-
return $where;
|
498 |
-
}
|
499 |
-
|
500 |
-
|
501 |
-
/**
|
502 |
-
* Change the posts count based on restriction settings
|
503 |
-
*
|
504 |
-
* @param object $counts Post counts
|
505 |
-
* @param string $type Post type
|
506 |
-
* @param string $perm The permission to determine if the posts are 'readable'
|
507 |
-
* by the current user.
|
508 |
-
*
|
509 |
-
* @return object
|
510 |
-
*/
|
511 |
-
function custom_count_posts_handler( $counts, $type = 'post', $perm = '' ) {
|
512 |
-
if ( current_user_can( 'administrator' ) ) {
|
513 |
-
return $counts;
|
514 |
-
}
|
515 |
-
|
516 |
-
global $wpdb;
|
517 |
-
|
518 |
-
static $cache = array();
|
519 |
-
|
520 |
-
$cache_key = _count_posts_cache_key( $type, $perm );
|
521 |
-
$force = is_feed() || is_search() || is_admin();
|
522 |
-
$cache_key .= $force ? 'force' : '';
|
523 |
-
|
524 |
-
if ( array_key_exists( $cache_key, $cache ) ) {
|
525 |
-
return $cache[ $cache_key ];
|
526 |
-
}
|
527 |
-
|
528 |
-
$exclude_posts = $this->exclude_posts_array( $force, array( $type ) );
|
529 |
-
if ( empty( $exclude_posts ) ) {
|
530 |
-
$cache[ $cache_key ] = $counts;
|
531 |
-
return $counts;
|
532 |
-
}
|
533 |
-
|
534 |
-
$query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s";
|
535 |
-
|
536 |
-
if ( 'readable' === $perm && is_user_logged_in() ) {
|
537 |
-
$post_type_object = get_post_type_object( $type );
|
538 |
-
if ( ! current_user_can( $post_type_object->cap->read_private_posts ) ) {
|
539 |
-
$query .= $wpdb->prepare(
|
540 |
-
" AND (post_status != 'private' OR ( post_author = %d AND post_status = 'private' ))",
|
541 |
-
get_current_user_id()
|
542 |
-
);
|
543 |
-
}
|
544 |
-
}
|
545 |
-
|
546 |
-
$query .= " AND ID NOT IN('" . implode( "','", $exclude_posts ) . "')";
|
547 |
-
|
548 |
-
$query .= ' GROUP BY post_status';
|
549 |
-
|
550 |
-
$results = (array) $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A );
|
551 |
-
$counts = array_fill_keys( get_post_stati(), 0 );
|
552 |
-
|
553 |
-
foreach ( $results as $row ) {
|
554 |
-
$counts[ $row['post_status'] ] = $row['num_posts'];
|
555 |
-
}
|
556 |
-
|
557 |
-
$counts = (object) $counts;
|
558 |
-
|
559 |
-
$cache[ $cache_key ] = $counts;
|
560 |
-
return $counts;
|
561 |
-
}
|
562 |
-
|
563 |
-
|
564 |
-
/**
|
565 |
-
* Exclude restricted posts in Recent Posts widget
|
566 |
-
*
|
567 |
-
* @param array $array Query args
|
568 |
-
*
|
569 |
-
* @return array
|
570 |
-
*/
|
571 |
-
function exclude_restricted_posts_widget( $array ) {
|
572 |
-
if ( current_user_can( 'administrator' ) ) {
|
573 |
-
return $array;
|
574 |
-
}
|
575 |
-
|
576 |
-
$exclude_posts = $this->exclude_posts_array( false, 'post' );
|
577 |
-
if ( ! empty( $exclude_posts ) ) {
|
578 |
-
$post__not_in = ! empty( $array['post__not_in'] ) ? $array['post__not_in'] : array();
|
579 |
-
$array['post__not_in'] = array_merge( wp_parse_id_list( $post__not_in ), $exclude_posts );
|
580 |
-
}
|
581 |
-
|
582 |
-
return $array;
|
583 |
-
}
|
584 |
-
|
585 |
-
|
586 |
-
/**
|
587 |
-
* Exclude restricted posts in Recent Posts widget
|
588 |
-
*
|
589 |
-
* @param array $array Query args
|
590 |
-
*
|
591 |
-
* @return array
|
592 |
-
*/
|
593 |
-
function exclude_restricted_pages( $array ) {
|
594 |
-
if ( current_user_can( 'administrator' ) ) {
|
595 |
-
return $array;
|
596 |
-
}
|
597 |
-
|
598 |
-
$exclude_posts = $this->exclude_posts_array( false, 'page' );
|
599 |
-
if ( ! empty( $exclude_posts ) ) {
|
600 |
-
$array = array_merge( $array, $exclude_posts );
|
601 |
-
}
|
602 |
-
|
603 |
-
return $array;
|
604 |
-
}
|
605 |
-
|
606 |
-
|
607 |
-
/**
|
608 |
-
* Exclude restricted posts in widgets
|
609 |
-
*
|
610 |
-
* @param string $sql_where
|
611 |
-
* @param array $parsed_args
|
612 |
-
*
|
613 |
-
* @return string
|
614 |
-
*/
|
615 |
-
function exclude_restricted_posts_archives_widget( $sql_where, $parsed_args = array() ) {
|
616 |
-
if ( current_user_can( 'administrator' ) ) {
|
617 |
-
return $sql_where;
|
618 |
-
}
|
619 |
-
|
620 |
-
$post_type = ! empty( $parsed_args['post_type'] ) ? $parsed_args['post_type'] : false;
|
621 |
-
|
622 |
-
$exclude_posts = $this->exclude_posts_array( false, $post_type );
|
623 |
-
if ( ! empty( $exclude_posts ) ) {
|
624 |
-
$exclude_string = implode( ',', $exclude_posts );
|
625 |
-
$sql_where .= ' AND ID NOT IN ( ' . $exclude_string . ' )';
|
626 |
-
}
|
627 |
-
|
628 |
-
return $sql_where;
|
629 |
-
}
|
630 |
-
|
631 |
-
|
632 |
-
/**
|
633 |
-
* Exclude posts from next, previous navigation
|
634 |
-
*
|
635 |
-
* @param string $where
|
636 |
-
* @param bool $in_same_term
|
637 |
-
* @param string|array $excluded_terms
|
638 |
-
* @param string $taxonomy
|
639 |
-
* @param null|\WP_Post $post
|
640 |
-
*
|
641 |
-
* @return string
|
642 |
-
*/
|
643 |
-
function exclude_navigation_posts( $where, $in_same_term = false, $excluded_terms = '', $taxonomy = 'category', $post = null ) {
|
644 |
-
if ( current_user_can( 'administrator' ) ) {
|
645 |
-
return $where;
|
646 |
-
}
|
647 |
-
|
648 |
-
if ( empty( $post ) ) {
|
649 |
-
return $where;
|
650 |
-
}
|
651 |
-
|
652 |
-
$exclude_posts = $this->exclude_posts_array( false, $post->post_type );
|
653 |
-
if ( ! empty( $exclude_posts ) ) {
|
654 |
-
$exclude_string = implode( ',', $exclude_posts );
|
655 |
-
$where .= ' AND ID NOT IN ( ' . $exclude_string . ' )';
|
656 |
-
}
|
657 |
-
|
658 |
-
return $where;
|
659 |
-
}
|
660 |
-
|
661 |
-
|
662 |
-
/**
|
663 |
-
* Replace titles of restricted posts
|
664 |
-
*
|
665 |
-
* @param string $title
|
666 |
-
* @param int|null $id
|
667 |
-
*
|
668 |
-
* @return string
|
669 |
-
*/
|
670 |
-
function filter_restricted_post_title( $title, $id = null ) {
|
671 |
-
if ( ! UM()->options()->get( 'restricted_post_title_replace' ) ) {
|
672 |
-
return $title;
|
673 |
-
}
|
674 |
-
|
675 |
-
if ( current_user_can( 'administrator' ) ) {
|
676 |
-
return $title;
|
677 |
-
}
|
678 |
-
|
679 |
-
if ( ! isset( $id ) ) {
|
680 |
-
return $title;
|
681 |
-
}
|
682 |
-
|
683 |
-
if ( ! is_numeric( $id ) ) {
|
684 |
-
$id = absint( $id );
|
685 |
-
}
|
686 |
-
|
687 |
-
$ignore = apply_filters( 'um_ignore_restricted_title', false, $id );
|
688 |
-
if ( $ignore ) {
|
689 |
-
return $title;
|
690 |
-
}
|
691 |
-
|
692 |
-
if ( $this->is_restricted( $id ) ) {
|
693 |
-
$restricted_global_title = UM()->options()->get( 'restricted_access_post_title' );
|
694 |
-
$title = stripslashes( $restricted_global_title );
|
695 |
-
}
|
696 |
-
|
697 |
-
return $title;
|
698 |
-
}
|
699 |
-
|
700 |
-
|
701 |
-
/**
|
702 |
-
* Replace content of restricted posts
|
703 |
-
*
|
704 |
-
* @param string $content
|
705 |
-
*
|
706 |
-
* @return string
|
707 |
-
*/
|
708 |
-
function filter_restricted_post_content( $content ) {
|
709 |
-
if ( current_user_can( 'administrator' ) ) {
|
710 |
-
return $content;
|
711 |
-
}
|
712 |
-
|
713 |
-
$id = get_the_ID();
|
714 |
-
if ( ! $id || is_admin() ) {
|
715 |
-
return $content;
|
716 |
-
}
|
717 |
-
|
718 |
-
$ignore = apply_filters( 'um_ignore_restricted_content', false, $id );
|
719 |
-
if ( $ignore ) {
|
720 |
-
return $content;
|
721 |
-
}
|
722 |
-
|
723 |
-
if ( $this->is_restricted( $id ) ) {
|
724 |
-
$restriction = $this->get_post_privacy_settings( $id );
|
725 |
-
|
726 |
-
if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) {
|
727 |
-
$content = stripslashes( UM()->options()->get( 'restricted_access_message' ) );
|
728 |
-
} elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) {
|
729 |
-
$content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
|
730 |
-
}
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
*
|
742 |
-
*
|
743 |
-
* @
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
*
|
772 |
-
*
|
773 |
-
* @
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
*
|
789 |
-
*
|
790 |
-
*
|
791 |
-
* @
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
$
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
*
|
908 |
-
*
|
909 |
-
* @
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
* @
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
$
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
* @
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
'
|
1001 |
-
'
|
1002 |
-
'
|
1003 |
-
'
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
case '
|
1012 |
-
$comment_count['
|
1013 |
-
break;
|
1014 |
-
case '
|
1015 |
-
$comment_count['
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
$comment_count['
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
$comment_count['
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
*
|
1045 |
-
*
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
*
|
1075 |
-
*
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
*
|
1105 |
-
*
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
$
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
}
|
1142 |
-
$filtered_items[] = $menu_item;
|
1143 |
-
continue;
|
1144 |
-
}
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
}
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
* @
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
*
|
1307 |
-
*
|
1308 |
-
*
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
*
|
1375 |
-
*
|
1376 |
-
* @
|
1377 |
-
*
|
1378 |
-
* @
|
1379 |
-
* @
|
1380 |
-
*
|
1381 |
-
* add_action( 'um_access_fix_external_post_content', '
|
1382 |
-
*
|
1383 |
-
*
|
1384 |
-
*
|
1385 |
-
*
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
*
|
1464 |
-
*
|
1465 |
-
* @
|
1466 |
-
*
|
1467 |
-
* @
|
1468 |
-
* @
|
1469 |
-
*
|
1470 |
-
* add_action( 'um_access_check_individual_term_settings', '
|
1471 |
-
*
|
1472 |
-
*
|
1473 |
-
*
|
1474 |
-
*
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
*
|
1487 |
-
*
|
1488 |
-
* @
|
1489 |
-
*
|
1490 |
-
* @
|
1491 |
-
* @
|
1492 |
-
*
|
1493 |
-
* add_action( 'um_access_check_global_settings', '
|
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 |
-
add_filter( '
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
*
|
1567 |
-
* @
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
$
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
*
|
1597 |
-
*
|
1598 |
-
* @
|
1599 |
-
*
|
1600 |
-
*
|
1601 |
-
* @
|
1602 |
-
* ["
|
1603 |
-
*
|
1604 |
-
*
|
1605 |
-
*
|
1606 |
-
*
|
1607 |
-
* add_filter( 'um_custom_homepage_redirect_url', '
|
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 |
-
if
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
$this->
|
1695 |
-
}
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
*
|
1724 |
-
*
|
1725 |
-
* @
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
*
|
1734 |
-
*
|
1735 |
-
* @
|
1736 |
-
*
|
1737 |
-
* @
|
1738 |
-
*
|
1739 |
-
*
|
1740 |
-
* @
|
1741 |
-
*
|
1742 |
-
* add_filter( 'um_access_enable_referer', '
|
1743 |
-
*
|
1744 |
-
*
|
1745 |
-
*
|
1746 |
-
*
|
1747 |
-
*
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
*
|
1764 |
-
*
|
1765 |
-
*
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
$
|
1818 |
-
|
1819 |
-
//get all post
|
1820 |
-
$
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
}
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
'
|
1859 |
-
'
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
'
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
//
|
1883 |
-
$
|
1884 |
-
|
1885 |
-
//get all post
|
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 |
-
* add_filter( 'um_custom_restriction', '
|
1963 |
-
*
|
1964 |
-
*
|
1965 |
-
*
|
1966 |
-
*
|
1967 |
-
*
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
*
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
//
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
*
|
2049 |
-
*
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
|
2075 |
-
|
2076 |
-
|
2077 |
-
|
2078 |
-
|
2079 |
-
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
|
2115 |
-
|
2116 |
-
|
2117 |
-
|
2118 |
-
|
2119 |
-
|
2120 |
-
|
2121 |
-
|
2122 |
-
|
2123 |
-
|
2124 |
-
|
2125 |
-
|
2126 |
-
|
2127 |
-
|
2128 |
-
|
2129 |
-
|
2130 |
-
|
2131 |
-
|
2132 |
-
|
2133 |
-
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace um\core;
|
3 |
+
|
4 |
+
// Exit if accessed directly
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
if ( ! class_exists( 'um\core\Access' ) ) {
|
8 |
+
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Access
|
12 |
+
* @package um\core
|
13 |
+
*/
|
14 |
+
class Access {
|
15 |
+
|
16 |
+
|
17 |
+
/**
|
18 |
+
* If true then we use individual restrict content options
|
19 |
+
* for post
|
20 |
+
*
|
21 |
+
* @var bool
|
22 |
+
*/
|
23 |
+
private $singular_page;
|
24 |
+
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @var bool
|
28 |
+
*/
|
29 |
+
private $redirect_handler;
|
30 |
+
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @var bool
|
34 |
+
*/
|
35 |
+
private $allow_access;
|
36 |
+
|
37 |
+
|
38 |
+
private $ignore_exclude = false;
|
39 |
+
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Access constructor.
|
43 |
+
*/
|
44 |
+
function __construct() {
|
45 |
+
$this->singular_page = false;
|
46 |
+
|
47 |
+
$this->redirect_handler = false;
|
48 |
+
$this->allow_access = false;
|
49 |
+
|
50 |
+
// NEW HOOKS
|
51 |
+
|
52 |
+
// Change recent posts widget query
|
53 |
+
add_filter( 'widget_posts_args', array( &$this, 'exclude_restricted_posts_widget' ), 99, 1 );
|
54 |
+
// Exclude pages displayed by wp_list_pages function
|
55 |
+
add_filter( 'wp_list_pages_excludes', array( &$this, 'exclude_restricted_pages' ), 10, 1 );
|
56 |
+
// Archives list change where based on restricted posts
|
57 |
+
add_filter( 'getarchives_where', array( &$this, 'exclude_restricted_posts_archives_widget' ), 99, 2 );
|
58 |
+
|
59 |
+
// Navigation line below the post content, change query to exclude restricted
|
60 |
+
add_filter( 'get_next_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 );
|
61 |
+
add_filter( 'get_previous_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 );
|
62 |
+
|
63 |
+
// callbacks for changing posts query
|
64 |
+
add_action( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99, 1 );
|
65 |
+
add_filter( 'posts_where', array( &$this, 'exclude_posts_where' ), 10, 2 );
|
66 |
+
add_filter( 'wp_count_posts', array( &$this, 'custom_count_posts_handler' ), 99, 3 );
|
67 |
+
|
68 |
+
// change the title of the post
|
69 |
+
add_filter( 'the_title', array( &$this, 'filter_restricted_post_title' ), 10, 2 );
|
70 |
+
// change the content of the restricted post
|
71 |
+
add_filter( 'the_content', array( &$this, 'filter_restricted_post_content' ), 999999, 1 );
|
72 |
+
// change the excerpt of the restricted post
|
73 |
+
add_filter( 'get_the_excerpt', array( &$this, 'filter_restricted_post_excerpt' ), 999999, 2 );
|
74 |
+
|
75 |
+
// filter attachment
|
76 |
+
add_filter( 'wp_get_attachment_url', array( &$this, 'filter_attachment' ), 99, 2 );
|
77 |
+
add_filter( 'has_post_thumbnail', array( &$this, 'filter_post_thumbnail' ), 99, 3 );
|
78 |
+
|
79 |
+
// comments queries
|
80 |
+
add_action( 'pre_get_comments', array( &$this, 'exclude_posts_comments' ), 99, 1 );
|
81 |
+
add_filter( 'wp_count_comments', array( &$this, 'custom_comments_count_handler' ), 99, 2 );
|
82 |
+
// comments RSS
|
83 |
+
add_filter( 'comment_feed_where', array( &$this, 'exclude_posts_comments_feed' ), 99, 2 );
|
84 |
+
// Disable comments if user has not permission to access current post
|
85 |
+
add_filter( 'comments_open', array( $this, 'disable_comments_open' ), 99, 2 );
|
86 |
+
add_filter( 'get_comments_number', array( $this, 'disable_comments_open_number' ), 99, 2 );
|
87 |
+
|
88 |
+
// filter menu items
|
89 |
+
add_filter( 'wp_nav_menu_objects', array( &$this, 'filter_menu' ), 99, 2 );
|
90 |
+
|
91 |
+
// Gutenberg blocks restrictions
|
92 |
+
add_filter( 'render_block', array( $this, 'restrict_blocks' ), 10, 2 );
|
93 |
+
|
94 |
+
// there is posts (Posts/Page/CPT) filtration if site is accessible
|
95 |
+
// there also will be redirects if they need
|
96 |
+
// protect posts types
|
97 |
+
add_filter( 'the_posts', array( &$this, 'filter_protected_posts' ), 99, 2 );
|
98 |
+
// protect pages for wp_list_pages func
|
99 |
+
add_filter( 'get_pages', array( &$this, 'filter_protected_posts' ), 99, 2 );
|
100 |
+
|
101 |
+
// check the site's accessible more priority have Individual Post/Term Restriction settings
|
102 |
+
add_action( 'template_redirect', array( &$this, 'template_redirect' ), 1000 );
|
103 |
+
add_action( 'um_access_check_individual_term_settings', array( &$this, 'um_access_check_individual_term_settings' ) );
|
104 |
+
add_action( 'um_access_check_global_settings', array( &$this, 'um_access_check_global_settings' ) );
|
105 |
+
|
106 |
+
add_action( 'plugins_loaded', array( &$this, 'disable_restriction_pre_queries' ), 1 );
|
107 |
+
}
|
108 |
+
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Rollback function for old business logic to avoid security enhancements with 404 errors
|
112 |
+
*/
|
113 |
+
function disable_restriction_pre_queries() {
|
114 |
+
// callbacks for changing terms query
|
115 |
+
add_action( 'pre_get_terms', array( &$this, 'exclude_hidden_terms_query' ), 99, 1 );
|
116 |
+
|
117 |
+
if ( ! UM()->options()->get( 'disable_restriction_pre_queries' ) ) {
|
118 |
+
return;
|
119 |
+
}
|
120 |
+
|
121 |
+
remove_action( 'pre_get_terms', array( &$this, 'exclude_hidden_terms_query' ), 99 );
|
122 |
+
remove_filter( 'widget_posts_args', array( &$this, 'exclude_restricted_posts_widget' ), 99 );
|
123 |
+
remove_filter( 'wp_list_pages_excludes', array( &$this, 'exclude_restricted_pages' ), 10 );
|
124 |
+
remove_filter( 'getarchives_where', array( &$this, 'exclude_restricted_posts_archives_widget' ), 99 );
|
125 |
+
remove_filter( 'get_next_post_where', array( &$this, 'exclude_navigation_posts' ), 99 );
|
126 |
+
remove_filter( 'get_previous_post_where', array( &$this, 'exclude_navigation_posts' ), 99 );
|
127 |
+
remove_action( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99 );
|
128 |
+
remove_filter( 'posts_where', array( &$this, 'exclude_posts_where' ), 10 );
|
129 |
+
remove_filter( 'wp_count_posts', array( &$this, 'custom_count_posts_handler' ), 99 );
|
130 |
+
}
|
131 |
+
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Get array with restricted posts
|
135 |
+
*
|
136 |
+
* @param bool $force
|
137 |
+
* @param bool|array|string $post_types
|
138 |
+
*
|
139 |
+
* @return array
|
140 |
+
*/
|
141 |
+
function exclude_posts_array( $force = false, $post_types = false ) {
|
142 |
+
if ( $this->ignore_exclude ) {
|
143 |
+
return array();
|
144 |
+
}
|
145 |
+
|
146 |
+
static $cache = array();
|
147 |
+
|
148 |
+
$cache_key = $force ? 'force' : 'default';
|
149 |
+
|
150 |
+
// `force` cache contains all restricted post IDs we can get them all from cache instead new queries
|
151 |
+
$force_cache_key = '';
|
152 |
+
if ( 'default' === $cache_key ) {
|
153 |
+
$force_cache_key = 'force';
|
154 |
+
}
|
155 |
+
|
156 |
+
// make $post_types as array if string
|
157 |
+
if ( ! empty( $post_types ) ) {
|
158 |
+
$post_types = is_array( $post_types ) ? $post_types : array( $post_types );
|
159 |
+
$cache_key .= md5( serialize( $post_types ) );
|
160 |
+
if ( ! empty( $force_cache_key ) ) {
|
161 |
+
$force_cache_key .= md5( serialize( $post_types ) );
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
if ( array_key_exists( $cache_key, $cache ) ) {
|
166 |
+
return $cache[ $cache_key ];
|
167 |
+
}
|
168 |
+
|
169 |
+
$exclude_posts = array();
|
170 |
+
if ( current_user_can( 'administrator' ) ) {
|
171 |
+
$cache[ $cache_key ] = $exclude_posts;
|
172 |
+
return $exclude_posts;
|
173 |
+
}
|
174 |
+
|
175 |
+
// @todo using Object Cache `wp_cache_get()` `wp_cache_set()` functions
|
176 |
+
|
177 |
+
// `force` cache contains all restricted post IDs we can get them all from cache instead new queries
|
178 |
+
if ( ! empty( $force_cache_key ) && array_key_exists( $force_cache_key, $cache ) ) {
|
179 |
+
$post_ids = $cache[ $force_cache_key ];
|
180 |
+
|
181 |
+
if ( ! empty( $post_ids ) ) {
|
182 |
+
foreach ( $post_ids as $post_id ) {
|
183 |
+
$content_restriction = $this->get_post_privacy_settings( $post_id );
|
184 |
+
if ( ! empty( $content_restriction['_um_access_hide_from_queries'] ) ) {
|
185 |
+
array_push( $exclude_posts, $post_id );
|
186 |
+
}
|
187 |
+
}
|
188 |
+
}
|
189 |
+
} else {
|
190 |
+
$restricted_posts = UM()->options()->get( 'restricted_access_post_metabox' );
|
191 |
+
if ( ! empty( $restricted_posts ) ) {
|
192 |
+
$restricted_posts = array_keys( $restricted_posts );
|
193 |
+
if ( ! empty( $post_types ) ) {
|
194 |
+
$restricted_posts = array_intersect( $post_types, $restricted_posts );
|
195 |
+
}
|
196 |
+
}
|
197 |
+
|
198 |
+
if ( ! empty( $restricted_posts ) ) {
|
199 |
+
$this->ignore_exclude = true;
|
200 |
+
// exclude all posts assigned to current term without individual restriction settings
|
201 |
+
$post_ids = get_posts(
|
202 |
+
array(
|
203 |
+
'fields' => 'ids',
|
204 |
+
'post_status' => 'any',
|
205 |
+
'post_type' => $restricted_posts,
|
206 |
+
'numberposts' => -1,
|
207 |
+
'meta_query' => array(
|
208 |
+
array(
|
209 |
+
'key' => 'um_content_restriction',
|
210 |
+
'compare' => 'EXISTS',
|
211 |
+
),
|
212 |
+
),
|
213 |
+
)
|
214 |
+
);
|
215 |
+
|
216 |
+
$this->ignore_exclude = false;
|
217 |
+
}
|
218 |
+
|
219 |
+
$post_ids = empty( $post_ids ) ? array() : $post_ids;
|
220 |
+
|
221 |
+
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
222 |
+
|
223 |
+
if ( ! empty( $restricted_taxonomies ) ) {
|
224 |
+
$restricted_taxonomies = array_keys( $restricted_taxonomies );
|
225 |
+
foreach ( $restricted_taxonomies as $k => $taxonomy ) {
|
226 |
+
if ( ! taxonomy_exists( $taxonomy ) ) {
|
227 |
+
unset( $restricted_taxonomies[ $k ] );
|
228 |
+
}
|
229 |
+
}
|
230 |
+
$restricted_taxonomies = array_values( $restricted_taxonomies );
|
231 |
+
|
232 |
+
if ( ! empty( $post_types ) ) {
|
233 |
+
$taxonomies = array();
|
234 |
+
foreach ( $post_types as $p_t ) {
|
235 |
+
$taxonomies = array_merge( $taxonomies, get_object_taxonomies( $p_t ) );
|
236 |
+
}
|
237 |
+
$restricted_taxonomies = array_intersect( $taxonomies, $restricted_taxonomies );
|
238 |
+
}
|
239 |
+
}
|
240 |
+
|
241 |
+
if ( ! empty( $restricted_taxonomies ) ) {
|
242 |
+
global $wpdb;
|
243 |
+
|
244 |
+
$terms = $wpdb->get_results(
|
245 |
+
"SELECT tm.term_id AS term_id,
|
246 |
+
tt.taxonomy AS taxonomy
|
247 |
+
FROM {$wpdb->termmeta} tm
|
248 |
+
LEFT JOIN {$wpdb->term_taxonomy} tt ON tt.term_id = tm.term_id
|
249 |
+
WHERE tm.meta_key = 'um_content_restriction' AND
|
250 |
+
tt.taxonomy IN('" . implode( "','", $restricted_taxonomies ) . "')",
|
251 |
+
ARRAY_A
|
252 |
+
);
|
253 |
+
|
254 |
+
if ( ! empty( $terms ) ) {
|
255 |
+
foreach ( $terms as $term ) {
|
256 |
+
if ( ! $this->is_restricted_term( $term['term_id'] ) ) {
|
257 |
+
continue;
|
258 |
+
}
|
259 |
+
|
260 |
+
$this->ignore_exclude = true;
|
261 |
+
// exclude all posts assigned to current term without individual restriction settings
|
262 |
+
$posts = get_posts(
|
263 |
+
array(
|
264 |
+
'fields' => 'ids',
|
265 |
+
'post_status' => 'any',
|
266 |
+
'numberposts' => -1,
|
267 |
+
'tax_query' => array(
|
268 |
+
array(
|
269 |
+
'taxonomy' => $term['taxonomy'],
|
270 |
+
'field' => 'id',
|
271 |
+
'terms' => $term['term_id'],
|
272 |
+
),
|
273 |
+
),
|
274 |
+
'meta_query' => array(
|
275 |
+
'relation' => 'OR',
|
276 |
+
array(
|
277 |
+
'relation' => 'AND',
|
278 |
+
array(
|
279 |
+
'key' => 'um_content_restriction',
|
280 |
+
'value' => 's:26:"_um_custom_access_settings";s:1:"1"',
|
281 |
+
'compare' => 'NOT LIKE',
|
282 |
+
),
|
283 |
+
array(
|
284 |
+
'key' => 'um_content_restriction',
|
285 |
+
'value' => 's:26:"_um_custom_access_settings";b:1',
|
286 |
+
'compare' => 'NOT LIKE',
|
287 |
+
),
|
288 |
+
),
|
289 |
+
array(
|
290 |
+
'key' => 'um_content_restriction',
|
291 |
+
'compare' => 'NOT EXISTS',
|
292 |
+
),
|
293 |
+
),
|
294 |
+
)
|
295 |
+
);
|
296 |
+
$this->ignore_exclude = false;
|
297 |
+
|
298 |
+
if ( empty( $posts ) ) {
|
299 |
+
continue;
|
300 |
+
}
|
301 |
+
|
302 |
+
$post_ids = array_merge( $post_ids, $posts );
|
303 |
+
}
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
if ( ! empty( $post_ids ) ) {
|
308 |
+
$post_ids = array_unique( $post_ids );
|
309 |
+
|
310 |
+
foreach ( $post_ids as $post_id ) {
|
311 |
+
// handle every post privacy setting based on post type maybe it's inactive for now
|
312 |
+
// if individual restriction is enabled then get post terms restriction settings
|
313 |
+
if ( $this->is_restricted( $post_id ) ) {
|
314 |
+
if ( true === $force ) {
|
315 |
+
array_push( $exclude_posts, $post_id );
|
316 |
+
} else {
|
317 |
+
$content_restriction = $this->get_post_privacy_settings( $post_id );
|
318 |
+
if ( ! empty( $content_restriction['_um_access_hide_from_queries'] ) ) {
|
319 |
+
array_push( $exclude_posts, $post_id );
|
320 |
+
}
|
321 |
+
}
|
322 |
+
}
|
323 |
+
}
|
324 |
+
}
|
325 |
+
}
|
326 |
+
|
327 |
+
$exclude_posts = apply_filters( 'um_exclude_restricted_posts_ids', $exclude_posts, $force );
|
328 |
+
|
329 |
+
$cache[ $cache_key ] = $exclude_posts;
|
330 |
+
return $exclude_posts;
|
331 |
+
}
|
332 |
+
|
333 |
+
|
334 |
+
|
335 |
+
/**
|
336 |
+
* Get array with restricted terms
|
337 |
+
*
|
338 |
+
* @param \WP_Term_Query $query
|
339 |
+
*
|
340 |
+
* @return array
|
341 |
+
*/
|
342 |
+
function exclude_terms_array( $query ) {
|
343 |
+
$exclude = array();
|
344 |
+
|
345 |
+
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
346 |
+
if ( ! empty( $restricted_taxonomies ) ) {
|
347 |
+
$restricted_taxonomies = array_keys( $restricted_taxonomies );
|
348 |
+
foreach ( $restricted_taxonomies as $k => $taxonomy ) {
|
349 |
+
if ( ! taxonomy_exists( $taxonomy ) ) {
|
350 |
+
unset( $restricted_taxonomies[ $k ] );
|
351 |
+
}
|
352 |
+
}
|
353 |
+
$restricted_taxonomies = array_values( $restricted_taxonomies );
|
354 |
+
|
355 |
+
if ( ! empty( $restricted_taxonomies ) ) {
|
356 |
+
if ( isset( $query->query_vars['taxonomy'] ) && is_array( $query->query_vars['taxonomy'] ) ) {
|
357 |
+
$restricted_taxonomies = array_intersect( $query->query_vars['taxonomy'], $restricted_taxonomies );
|
358 |
+
} elseif ( ! empty( $query->query_vars['term_taxonomy_id'] ) ) {
|
359 |
+
$term_taxonomy_ids = is_array( $query->query_vars['term_taxonomy_id'] ) ? $query->query_vars['term_taxonomy_id'] : array( $query->query_vars['term_taxonomy_id'] );
|
360 |
+
|
361 |
+
global $wpdb;
|
362 |
+
$tax_in_query = $wpdb->get_col( "SELECT DISTINCT taxonomy FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id IN('" . implode( "','", $term_taxonomy_ids ) . "')" );
|
363 |
+
if ( ! empty( $tax_in_query ) ) {
|
364 |
+
$restricted_taxonomies = array_intersect( $tax_in_query, $restricted_taxonomies );
|
365 |
+
} else {
|
366 |
+
$restricted_taxonomies = array();
|
367 |
+
}
|
368 |
+
}
|
369 |
+
}
|
370 |
+
}
|
371 |
+
|
372 |
+
if ( empty( $restricted_taxonomies ) ) {
|
373 |
+
return $exclude;
|
374 |
+
}
|
375 |
+
|
376 |
+
$cache_key = md5( serialize( $restricted_taxonomies ) );
|
377 |
+
|
378 |
+
static $cache = array();
|
379 |
+
|
380 |
+
if ( array_key_exists( $cache_key, $cache ) ) {
|
381 |
+
return $cache[ $cache_key ];
|
382 |
+
}
|
383 |
+
|
384 |
+
$term_ids = get_terms(
|
385 |
+
array(
|
386 |
+
'taxonomy' => $restricted_taxonomies,
|
387 |
+
'hide_empty' => false,
|
388 |
+
'fields' => 'ids',
|
389 |
+
'meta_query' => array(
|
390 |
+
'key' => 'um_content_restriction',
|
391 |
+
'compare' => 'EXISTS',
|
392 |
+
),
|
393 |
+
'um_ignore_exclude' => true,
|
394 |
+
)
|
395 |
+
);
|
396 |
+
|
397 |
+
if ( empty( $term_ids ) || is_wp_error( $term_ids ) ) {
|
398 |
+
$cache[ $cache_key ] = $exclude;
|
399 |
+
return $exclude;
|
400 |
+
}
|
401 |
+
|
402 |
+
foreach ( $term_ids as $term_id ) {
|
403 |
+
if ( $this->is_restricted_term( $term_id ) ) {
|
404 |
+
$exclude[] = $term_id;
|
405 |
+
}
|
406 |
+
}
|
407 |
+
|
408 |
+
$exclude = apply_filters( 'um_exclude_restricted_terms_ids', $exclude );
|
409 |
+
$cache[ $cache_key ] = $exclude;
|
410 |
+
return $exclude;
|
411 |
+
}
|
412 |
+
|
413 |
+
|
414 |
+
/**
|
415 |
+
* @param \WP_Term_Query $query
|
416 |
+
*/
|
417 |
+
function exclude_hidden_terms_query( $query ) {
|
418 |
+
if ( current_user_can( 'administrator' ) || ! empty( $query->query_vars['um_ignore_exclude'] ) ) {
|
419 |
+
return;
|
420 |
+
}
|
421 |
+
|
422 |
+
$exclude = $this->exclude_terms_array( $query );
|
423 |
+
if ( ! empty( $exclude ) ) {
|
424 |
+
$query->query_vars['exclude'] = ! empty( $query->query_vars['exclude'] ) ? wp_parse_id_list( $query->query_vars['exclude'] ) : $exclude;
|
425 |
+
}
|
426 |
+
}
|
427 |
+
|
428 |
+
|
429 |
+
/**
|
430 |
+
* @param \WP_Query $query
|
431 |
+
*/
|
432 |
+
function exclude_posts( $query ) {
|
433 |
+
if ( current_user_can( 'administrator' ) ) {
|
434 |
+
return;
|
435 |
+
}
|
436 |
+
|
437 |
+
// use these functions is_search() || is_admin() for getting force hide all posts
|
438 |
+
// don't handle `hide from WP_Query` and show 404 option for searching and wp-admin query
|
439 |
+
if ( $query->is_main_query() || ! empty( $query->query_vars['um_main_query'] ) ) {
|
440 |
+
$force = is_feed() || is_search() || is_admin();
|
441 |
+
|
442 |
+
if ( is_object( $query ) ) {
|
443 |
+
$is_singular = $query->is_singular();
|
444 |
+
} else {
|
445 |
+
$is_singular = ! empty( $query->is_singular ) ? true : false;
|
446 |
+
}
|
447 |
+
|
448 |
+
if ( ! $is_singular ) {
|
449 |
+
// need to know what post type is here
|
450 |
+
$q_values = ! empty( $query->query_vars['post_type'] ) ? $query->query_vars['post_type'] : array();
|
451 |
+
if ( ! is_array( $q_values ) ) {
|
452 |
+
$q_values = explode( ',', $query->query_vars['post_type'] );
|
453 |
+
}
|
454 |
+
|
455 |
+
// 'any' will cause the query var to be ignored.
|
456 |
+
if ( in_array( 'any', $q_values, true ) || empty( $q_values ) ) {
|
457 |
+
$exclude_posts = $this->exclude_posts_array( $force );
|
458 |
+
} else {
|
459 |
+
$exclude_posts = $this->exclude_posts_array( $force, $q_values );
|
460 |
+
}
|
461 |
+
|
462 |
+
if ( ! empty( $exclude_posts ) ) {
|
463 |
+
$post__not_in = $query->get( 'post__not_in', array() );
|
464 |
+
$query->set( 'post__not_in', array_merge( wp_parse_id_list( $post__not_in ), $exclude_posts ) );
|
465 |
+
}
|
466 |
+
}
|
467 |
+
}
|
468 |
+
}
|
469 |
+
|
470 |
+
|
471 |
+
/**
|
472 |
+
* Exclude restricted post from query if there is a single query that exclude post_not_in by default in \WP_Query
|
473 |
+
*
|
474 |
+
* @param string $where
|
475 |
+
* @param \WP_Query $query
|
476 |
+
*
|
477 |
+
* @return mixed
|
478 |
+
*/
|
479 |
+
function exclude_posts_where( $where, $query ) {
|
480 |
+
if ( current_user_can( 'administrator' ) ) {
|
481 |
+
return $where;
|
482 |
+
}
|
483 |
+
|
484 |
+
if ( ! $query->is_main_query() ) {
|
485 |
+
return $where;
|
486 |
+
}
|
487 |
+
|
488 |
+
if ( ! empty( $query->query_vars['p'] ) && $this->is_restricted( $query->query_vars['p'] ) ) {
|
489 |
+
$restriction_settings = $this->get_post_privacy_settings( $query->query_vars['p'] );
|
490 |
+
if ( ! empty( $restriction_settings['_um_access_hide_from_queries'] ) && ! empty( $query->query_vars['post__not_in'] ) ) {
|
491 |
+
global $wpdb;
|
492 |
+
$post__not_in = implode( ',', array_map( 'absint', $query->query_vars['post__not_in'] ) );
|
493 |
+
$where .= " AND {$wpdb->posts}.ID NOT IN ($post__not_in)";
|
494 |
+
}
|
495 |
+
}
|
496 |
+
|
497 |
+
return $where;
|
498 |
+
}
|
499 |
+
|
500 |
+
|
501 |
+
/**
|
502 |
+
* Change the posts count based on restriction settings
|
503 |
+
*
|
504 |
+
* @param object $counts Post counts
|
505 |
+
* @param string $type Post type
|
506 |
+
* @param string $perm The permission to determine if the posts are 'readable'
|
507 |
+
* by the current user.
|
508 |
+
*
|
509 |
+
* @return object
|
510 |
+
*/
|
511 |
+
function custom_count_posts_handler( $counts, $type = 'post', $perm = '' ) {
|
512 |
+
if ( current_user_can( 'administrator' ) ) {
|
513 |
+
return $counts;
|
514 |
+
}
|
515 |
+
|
516 |
+
global $wpdb;
|
517 |
+
|
518 |
+
static $cache = array();
|
519 |
+
|
520 |
+
$cache_key = _count_posts_cache_key( $type, $perm );
|
521 |
+
$force = is_feed() || is_search() || is_admin();
|
522 |
+
$cache_key .= $force ? 'force' : '';
|
523 |
+
|
524 |
+
if ( array_key_exists( $cache_key, $cache ) ) {
|
525 |
+
return $cache[ $cache_key ];
|
526 |
+
}
|
527 |
+
|
528 |
+
$exclude_posts = $this->exclude_posts_array( $force, array( $type ) );
|
529 |
+
if ( empty( $exclude_posts ) ) {
|
530 |
+
$cache[ $cache_key ] = $counts;
|
531 |
+
return $counts;
|
532 |
+
}
|
533 |
+
|
534 |
+
$query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s";
|
535 |
+
|
536 |
+
if ( 'readable' === $perm && is_user_logged_in() ) {
|
537 |
+
$post_type_object = get_post_type_object( $type );
|
538 |
+
if ( ! current_user_can( $post_type_object->cap->read_private_posts ) ) {
|
539 |
+
$query .= $wpdb->prepare(
|
540 |
+
" AND (post_status != 'private' OR ( post_author = %d AND post_status = 'private' ))",
|
541 |
+
get_current_user_id()
|
542 |
+
);
|
543 |
+
}
|
544 |
+
}
|
545 |
+
|
546 |
+
$query .= " AND ID NOT IN('" . implode( "','", $exclude_posts ) . "')";
|
547 |
+
|
548 |
+
$query .= ' GROUP BY post_status';
|
549 |
+
|
550 |
+
$results = (array) $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A );
|
551 |
+
$counts = array_fill_keys( get_post_stati(), 0 );
|
552 |
+
|
553 |
+
foreach ( $results as $row ) {
|
554 |
+
$counts[ $row['post_status'] ] = $row['num_posts'];
|
555 |
+
}
|
556 |
+
|
557 |
+
$counts = (object) $counts;
|
558 |
+
|
559 |
+
$cache[ $cache_key ] = $counts;
|
560 |
+
return $counts;
|
561 |
+
}
|
562 |
+
|
563 |
+
|
564 |
+
/**
|
565 |
+
* Exclude restricted posts in Recent Posts widget
|
566 |
+
*
|
567 |
+
* @param array $array Query args
|
568 |
+
*
|
569 |
+
* @return array
|
570 |
+
*/
|
571 |
+
function exclude_restricted_posts_widget( $array ) {
|
572 |
+
if ( current_user_can( 'administrator' ) ) {
|
573 |
+
return $array;
|
574 |
+
}
|
575 |
+
|
576 |
+
$exclude_posts = $this->exclude_posts_array( false, 'post' );
|
577 |
+
if ( ! empty( $exclude_posts ) ) {
|
578 |
+
$post__not_in = ! empty( $array['post__not_in'] ) ? $array['post__not_in'] : array();
|
579 |
+
$array['post__not_in'] = array_merge( wp_parse_id_list( $post__not_in ), $exclude_posts );
|
580 |
+
}
|
581 |
+
|
582 |
+
return $array;
|
583 |
+
}
|
584 |
+
|
585 |
+
|
586 |
+
/**
|
587 |
+
* Exclude restricted posts in Recent Posts widget
|
588 |
+
*
|
589 |
+
* @param array $array Query args
|
590 |
+
*
|
591 |
+
* @return array
|
592 |
+
*/
|
593 |
+
function exclude_restricted_pages( $array ) {
|
594 |
+
if ( current_user_can( 'administrator' ) ) {
|
595 |
+
return $array;
|
596 |
+
}
|
597 |
+
|
598 |
+
$exclude_posts = $this->exclude_posts_array( false, 'page' );
|
599 |
+
if ( ! empty( $exclude_posts ) ) {
|
600 |
+
$array = array_merge( $array, $exclude_posts );
|
601 |
+
}
|
602 |
+
|
603 |
+
return $array;
|
604 |
+
}
|
605 |
+
|
606 |
+
|
607 |
+
/**
|
608 |
+
* Exclude restricted posts in widgets
|
609 |
+
*
|
610 |
+
* @param string $sql_where
|
611 |
+
* @param array $parsed_args
|
612 |
+
*
|
613 |
+
* @return string
|
614 |
+
*/
|
615 |
+
function exclude_restricted_posts_archives_widget( $sql_where, $parsed_args = array() ) {
|
616 |
+
if ( current_user_can( 'administrator' ) ) {
|
617 |
+
return $sql_where;
|
618 |
+
}
|
619 |
+
|
620 |
+
$post_type = ! empty( $parsed_args['post_type'] ) ? $parsed_args['post_type'] : false;
|
621 |
+
|
622 |
+
$exclude_posts = $this->exclude_posts_array( false, $post_type );
|
623 |
+
if ( ! empty( $exclude_posts ) ) {
|
624 |
+
$exclude_string = implode( ',', $exclude_posts );
|
625 |
+
$sql_where .= ' AND ID NOT IN ( ' . $exclude_string . ' )';
|
626 |
+
}
|
627 |
+
|
628 |
+
return $sql_where;
|
629 |
+
}
|
630 |
+
|
631 |
+
|
632 |
+
/**
|
633 |
+
* Exclude posts from next, previous navigation
|
634 |
+
*
|
635 |
+
* @param string $where
|
636 |
+
* @param bool $in_same_term
|
637 |
+
* @param string|array $excluded_terms
|
638 |
+
* @param string $taxonomy
|
639 |
+
* @param null|\WP_Post $post
|
640 |
+
*
|
641 |
+
* @return string
|
642 |
+
*/
|
643 |
+
function exclude_navigation_posts( $where, $in_same_term = false, $excluded_terms = '', $taxonomy = 'category', $post = null ) {
|
644 |
+
if ( current_user_can( 'administrator' ) ) {
|
645 |
+
return $where;
|
646 |
+
}
|
647 |
+
|
648 |
+
if ( empty( $post ) ) {
|
649 |
+
return $where;
|
650 |
+
}
|
651 |
+
|
652 |
+
$exclude_posts = $this->exclude_posts_array( false, $post->post_type );
|
653 |
+
if ( ! empty( $exclude_posts ) ) {
|
654 |
+
$exclude_string = implode( ',', $exclude_posts );
|
655 |
+
$where .= ' AND ID NOT IN ( ' . $exclude_string . ' )';
|
656 |
+
}
|
657 |
+
|
658 |
+
return $where;
|
659 |
+
}
|
660 |
+
|
661 |
+
|
662 |
+
/**
|
663 |
+
* Replace titles of restricted posts
|
664 |
+
*
|
665 |
+
* @param string $title
|
666 |
+
* @param int|null $id
|
667 |
+
*
|
668 |
+
* @return string
|
669 |
+
*/
|
670 |
+
function filter_restricted_post_title( $title, $id = null ) {
|
671 |
+
if ( ! UM()->options()->get( 'restricted_post_title_replace' ) ) {
|
672 |
+
return $title;
|
673 |
+
}
|
674 |
+
|
675 |
+
if ( current_user_can( 'administrator' ) ) {
|
676 |
+
return $title;
|
677 |
+
}
|
678 |
+
|
679 |
+
if ( ! isset( $id ) ) {
|
680 |
+
return $title;
|
681 |
+
}
|
682 |
+
|
683 |
+
if ( ! is_numeric( $id ) ) {
|
684 |
+
$id = absint( $id );
|
685 |
+
}
|
686 |
+
|
687 |
+
$ignore = apply_filters( 'um_ignore_restricted_title', false, $id );
|
688 |
+
if ( $ignore ) {
|
689 |
+
return $title;
|
690 |
+
}
|
691 |
+
|
692 |
+
if ( $this->is_restricted( $id ) ) {
|
693 |
+
$restricted_global_title = UM()->options()->get( 'restricted_access_post_title' );
|
694 |
+
$title = stripslashes( $restricted_global_title );
|
695 |
+
}
|
696 |
+
|
697 |
+
return $title;
|
698 |
+
}
|
699 |
+
|
700 |
+
|
701 |
+
/**
|
702 |
+
* Replace content of restricted posts
|
703 |
+
*
|
704 |
+
* @param string $content
|
705 |
+
*
|
706 |
+
* @return string
|
707 |
+
*/
|
708 |
+
function filter_restricted_post_content( $content ) {
|
709 |
+
if ( current_user_can( 'administrator' ) ) {
|
710 |
+
return $content;
|
711 |
+
}
|
712 |
+
|
713 |
+
$id = get_the_ID();
|
714 |
+
if ( ! $id || is_admin() ) {
|
715 |
+
return $content;
|
716 |
+
}
|
717 |
+
|
718 |
+
$ignore = apply_filters( 'um_ignore_restricted_content', false, $id );
|
719 |
+
if ( $ignore ) {
|
720 |
+
return $content;
|
721 |
+
}
|
722 |
+
|
723 |
+
if ( $this->is_restricted( $id ) ) {
|
724 |
+
$restriction = $this->get_post_privacy_settings( $id );
|
725 |
+
|
726 |
+
if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) {
|
727 |
+
$content = stripslashes( UM()->options()->get( 'restricted_access_message' ) );
|
728 |
+
} elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) {
|
729 |
+
$content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
|
730 |
+
}
|
731 |
+
|
732 |
+
// translators: %s: Restricted post message.
|
733 |
+
$content = sprintf( __( '%s', 'ultimate-member' ), $content );
|
734 |
+
}
|
735 |
+
|
736 |
+
return $content;
|
737 |
+
}
|
738 |
+
|
739 |
+
|
740 |
+
/**
|
741 |
+
* Replace excerpt of restricted posts
|
742 |
+
*
|
743 |
+
* @param string $post_excerpt
|
744 |
+
* @param \WP_Post $post
|
745 |
+
*
|
746 |
+
* @return string
|
747 |
+
*/
|
748 |
+
function filter_restricted_post_excerpt( $post_excerpt = '', $post = null ) {
|
749 |
+
if ( empty( $post ) ) {
|
750 |
+
return $post_excerpt;
|
751 |
+
}
|
752 |
+
|
753 |
+
if ( current_user_can( 'administrator' ) || is_admin() ) {
|
754 |
+
return $post_excerpt;
|
755 |
+
}
|
756 |
+
|
757 |
+
$ignore = apply_filters( 'um_ignore_restricted_excerpt', false, $post->ID );
|
758 |
+
if ( $ignore ) {
|
759 |
+
return $post_excerpt;
|
760 |
+
}
|
761 |
+
|
762 |
+
if ( $this->is_restricted( $post->ID ) ) {
|
763 |
+
$post_excerpt = '';
|
764 |
+
}
|
765 |
+
|
766 |
+
return $post_excerpt;
|
767 |
+
}
|
768 |
+
|
769 |
+
|
770 |
+
/**
|
771 |
+
* Hide attachment if the post is restricted
|
772 |
+
*
|
773 |
+
* @param string $url
|
774 |
+
* @param int $attachment_id
|
775 |
+
*
|
776 |
+
* @return boolean|string
|
777 |
+
*/
|
778 |
+
function filter_attachment( $url, $attachment_id ) {
|
779 |
+
if ( current_user_can( 'administrator' ) ) {
|
780 |
+
return $url;
|
781 |
+
}
|
782 |
+
|
783 |
+
return ( $attachment_id && $this->is_restricted( $attachment_id ) ) ? false : $url;
|
784 |
+
}
|
785 |
+
|
786 |
+
|
787 |
+
/**
|
788 |
+
* Hide attachment if the post is restricted
|
789 |
+
*
|
790 |
+
* @param $has_thumbnail
|
791 |
+
* @param $post
|
792 |
+
* @param $thumbnail_id
|
793 |
+
*
|
794 |
+
* @return bool
|
795 |
+
*/
|
796 |
+
function filter_post_thumbnail( $has_thumbnail, $post = null, $thumbnail_id = false ) {
|
797 |
+
if ( empty( $thumbnail_id ) ) {
|
798 |
+
return $has_thumbnail;
|
799 |
+
}
|
800 |
+
|
801 |
+
if ( current_user_can( 'administrator' ) ) {
|
802 |
+
return $has_thumbnail;
|
803 |
+
}
|
804 |
+
|
805 |
+
if ( $this->is_restricted( $thumbnail_id ) ) {
|
806 |
+
$has_thumbnail = false;
|
807 |
+
} elseif ( ! empty( $post ) && ! empty( $post->ID ) ) {
|
808 |
+
if ( $this->is_restricted( $post->ID ) ) {
|
809 |
+
$has_thumbnail = false;
|
810 |
+
}
|
811 |
+
} else {
|
812 |
+
$post_id = get_the_ID();
|
813 |
+
if ( false !== $post_id && $this->is_restricted( $post_id ) ) {
|
814 |
+
$has_thumbnail = false;
|
815 |
+
}
|
816 |
+
}
|
817 |
+
|
818 |
+
$has_thumbnail = apply_filters( 'um_restrict_post_thumbnail', $has_thumbnail, $post, $thumbnail_id );
|
819 |
+
|
820 |
+
return $has_thumbnail;
|
821 |
+
}
|
822 |
+
|
823 |
+
|
824 |
+
|
825 |
+
/**
|
826 |
+
* Exclude comments from restricted posts in widgets
|
827 |
+
*
|
828 |
+
* @param \WP_Comment_Query $query
|
829 |
+
*/
|
830 |
+
function exclude_posts_comments( $query ) {
|
831 |
+
if ( current_user_can( 'administrator' ) ) {
|
832 |
+
return;
|
833 |
+
}
|
834 |
+
|
835 |
+
if ( ! empty( $query->query_vars['post_id'] ) ) {
|
836 |
+
$exclude_posts = array();
|
837 |
+
if ( $this->is_restricted( $query->query_vars['post_id'] ) ) {
|
838 |
+
$exclude_posts[] = $query->query_vars['post_id'];
|
839 |
+
}
|
840 |
+
} else {
|
841 |
+
$q_values = ! empty( $query->query_vars['post_type'] ) ? $query->query_vars['post_type'] : array();
|
842 |
+
if ( ! is_array( $q_values ) ) {
|
843 |
+
$q_values = explode( ',', $query->query_vars['post_type'] );
|
844 |
+
}
|
845 |
+
|
846 |
+
// 'any' will cause the query var to be ignored.
|
847 |
+
if ( in_array( 'any', $q_values, true ) || empty( $q_values ) ) {
|
848 |
+
$exclude_posts = $this->exclude_posts_array( true, $this->get_available_comments_post_types() );
|
849 |
+
} else {
|
850 |
+
$exclude_posts = $this->exclude_posts_array( true, $q_values );
|
851 |
+
}
|
852 |
+
}
|
853 |
+
|
854 |
+
if ( ! empty( $exclude_posts ) ) {
|
855 |
+
$post__not_in = ! empty( $query->query_vars['post__not_in'] ) ? $query->query_vars['post__not_in'] : array();
|
856 |
+
$query->query_vars['post__not_in'] = array_merge( wp_parse_id_list( $post__not_in ), $exclude_posts );
|
857 |
+
}
|
858 |
+
}
|
859 |
+
|
860 |
+
|
861 |
+
/**
|
862 |
+
* @return array
|
863 |
+
*/
|
864 |
+
function get_available_comments_post_types() {
|
865 |
+
global $wp_taxonomies, $wpdb;
|
866 |
+
|
867 |
+
$restricted_posts = UM()->options()->get( 'restricted_access_post_metabox' );
|
868 |
+
if ( empty( $restricted_posts ) ) {
|
869 |
+
$restricted_posts = array();
|
870 |
+
}
|
871 |
+
$restricted_posts = array_keys( $restricted_posts );
|
872 |
+
|
873 |
+
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
874 |
+
if ( ! empty( $restricted_taxonomies ) ) {
|
875 |
+
$restricted_taxonomies = array_keys( $restricted_taxonomies );
|
876 |
+
foreach ( $restricted_taxonomies as $k => $taxonomy ) {
|
877 |
+
if ( taxonomy_exists( $taxonomy ) ) {
|
878 |
+
$restricted_posts = array_merge( $restricted_posts, $wp_taxonomies[ $taxonomy ]->object_type );
|
879 |
+
}
|
880 |
+
}
|
881 |
+
}
|
882 |
+
|
883 |
+
$restricted_posts = array_unique( $restricted_posts );
|
884 |
+
foreach ( $restricted_posts as $k => $post_type ) {
|
885 |
+
if ( 'closed' === get_default_comment_status( $post_type ) ) {
|
886 |
+
$open_comments = $wpdb->get_var( $wpdb->prepare(
|
887 |
+
"SELECT ID
|
888 |
+
FROM {$wpdb->posts}
|
889 |
+
WHERE post_type = %s AND
|
890 |
+
comment_status != 'closed'",
|
891 |
+
$post_type
|
892 |
+
) );
|
893 |
+
|
894 |
+
if ( empty( $open_comments ) ) {
|
895 |
+
unset( $restricted_posts[ $k ] );
|
896 |
+
}
|
897 |
+
}
|
898 |
+
}
|
899 |
+
|
900 |
+
$restricted_posts = array_values( $restricted_posts );
|
901 |
+
|
902 |
+
return $restricted_posts;
|
903 |
+
}
|
904 |
+
|
905 |
+
|
906 |
+
/**
|
907 |
+
* Exclude comments from comments feed
|
908 |
+
*
|
909 |
+
* @param string $where
|
910 |
+
* @param \WP_Query $query
|
911 |
+
*
|
912 |
+
* @return string
|
913 |
+
*/
|
914 |
+
function exclude_posts_comments_feed( $where, $query ) {
|
915 |
+
if ( current_user_can( 'administrator' ) ) {
|
916 |
+
return $where;
|
917 |
+
}
|
918 |
+
|
919 |
+
$exclude_posts = $this->exclude_posts_array( true, $this->get_available_comments_post_types() );
|
920 |
+
if ( ! empty( $exclude_posts ) ) {
|
921 |
+
$exclude_string = implode( ',', $exclude_posts );
|
922 |
+
$where .= ' AND comment_post_ID NOT IN ( ' . $exclude_string . ' )';
|
923 |
+
}
|
924 |
+
|
925 |
+
return $where;
|
926 |
+
}
|
927 |
+
|
928 |
+
|
929 |
+
/**
|
930 |
+
* @param array|object $stats
|
931 |
+
* @param int $post_id Post ID. Can be 0 for the whole website
|
932 |
+
*
|
933 |
+
* @return object
|
934 |
+
*/
|
935 |
+
function custom_comments_count_handler( $stats = array(), $post_id = 0 ) {
|
936 |
+
if ( ! empty( $stats ) || current_user_can( 'administrator' ) ) {
|
937 |
+
return $stats;
|
938 |
+
}
|
939 |
+
|
940 |
+
if ( $post_id === 0 ) {
|
941 |
+
$exclude_posts = $this->exclude_posts_array( true, $this->get_available_comments_post_types() );
|
942 |
+
if ( empty( $exclude_posts ) ) {
|
943 |
+
return $stats;
|
944 |
+
}
|
945 |
+
} else {
|
946 |
+
$exclude_posts = array();
|
947 |
+
if ( $this->is_restricted( $post_id ) ) {
|
948 |
+
$exclude_posts[] = $post_id;
|
949 |
+
}
|
950 |
+
}
|
951 |
+
|
952 |
+
$stats = $this->get_comment_count( $post_id, $exclude_posts );
|
953 |
+
$stats['moderated'] = $stats['awaiting_moderation'];
|
954 |
+
unset( $stats['awaiting_moderation'] );
|
955 |
+
|
956 |
+
$stats_object = (object) $stats;
|
957 |
+
|
958 |
+
return $stats_object;
|
959 |
+
}
|
960 |
+
|
961 |
+
|
962 |
+
/**
|
963 |
+
* @param int $post_id
|
964 |
+
* @param array $exclude_posts
|
965 |
+
*
|
966 |
+
* @return array
|
967 |
+
*/
|
968 |
+
function get_comment_count( $post_id = 0, $exclude_posts = array() ) {
|
969 |
+
static $cache = array();
|
970 |
+
|
971 |
+
if ( isset( $cache[ $post_id ] ) ) {
|
972 |
+
return $cache[ $post_id ];
|
973 |
+
}
|
974 |
+
|
975 |
+
global $wpdb;
|
976 |
+
|
977 |
+
$post_id = (int) $post_id;
|
978 |
+
|
979 |
+
$where = 'WHERE 1=1';
|
980 |
+
if ( $post_id > 0 ) {
|
981 |
+
$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
|
982 |
+
}
|
983 |
+
|
984 |
+
if ( ! empty( $exclude_posts ) ) {
|
985 |
+
$exclude_string = implode( ',', $exclude_posts );
|
986 |
+
$where .= ' AND comment_post_ID NOT IN ( ' . $exclude_string . ' )';
|
987 |
+
}
|
988 |
+
|
989 |
+
$totals = (array) $wpdb->get_results(
|
990 |
+
"
|
991 |
+
SELECT comment_approved, COUNT( * ) AS total
|
992 |
+
FROM {$wpdb->comments}
|
993 |
+
{$where}
|
994 |
+
GROUP BY comment_approved
|
995 |
+
",
|
996 |
+
ARRAY_A
|
997 |
+
);
|
998 |
+
|
999 |
+
$comment_count = array(
|
1000 |
+
'approved' => 0,
|
1001 |
+
'awaiting_moderation' => 0,
|
1002 |
+
'spam' => 0,
|
1003 |
+
'trash' => 0,
|
1004 |
+
'post-trashed' => 0,
|
1005 |
+
'total_comments' => 0,
|
1006 |
+
'all' => 0,
|
1007 |
+
);
|
1008 |
+
|
1009 |
+
foreach ( $totals as $row ) {
|
1010 |
+
switch ( $row['comment_approved'] ) {
|
1011 |
+
case 'trash':
|
1012 |
+
$comment_count['trash'] = $row['total'];
|
1013 |
+
break;
|
1014 |
+
case 'post-trashed':
|
1015 |
+
$comment_count['post-trashed'] = $row['total'];
|
1016 |
+
break;
|
1017 |
+
case 'spam':
|
1018 |
+
$comment_count['spam'] = $row['total'];
|
1019 |
+
$comment_count['total_comments'] += $row['total'];
|
1020 |
+
break;
|
1021 |
+
case '1':
|
1022 |
+
$comment_count['approved'] = $row['total'];
|
1023 |
+
$comment_count['total_comments'] += $row['total'];
|
1024 |
+
$comment_count['all'] += $row['total'];
|
1025 |
+
break;
|
1026 |
+
case '0':
|
1027 |
+
$comment_count['awaiting_moderation'] = $row['total'];
|
1028 |
+
$comment_count['total_comments'] += $row['total'];
|
1029 |
+
$comment_count['all'] += $row['total'];
|
1030 |
+
break;
|
1031 |
+
default:
|
1032 |
+
break;
|
1033 |
+
}
|
1034 |
+
}
|
1035 |
+
|
1036 |
+
$comment_count = array_map( 'intval', $comment_count );
|
1037 |
+
$cache[ $post_id ] = $comment_count;
|
1038 |
+
|
1039 |
+
return $comment_count;
|
1040 |
+
}
|
1041 |
+
|
1042 |
+
|
1043 |
+
/**
|
1044 |
+
* Disable comments if user has not permission to access this post
|
1045 |
+
*
|
1046 |
+
* @param mixed $open
|
1047 |
+
* @param int $post_id
|
1048 |
+
* @return boolean
|
1049 |
+
*/
|
1050 |
+
function disable_comments_open( $open, $post_id ) {
|
1051 |
+
if ( current_user_can( 'administrator' ) ) {
|
1052 |
+
return $open;
|
1053 |
+
}
|
1054 |
+
|
1055 |
+
static $cache = array();
|
1056 |
+
|
1057 |
+
if ( isset( $cache[ $post_id ] ) ) {
|
1058 |
+
return $cache[ $post_id ] ? $open : false;
|
1059 |
+
}
|
1060 |
+
|
1061 |
+
if ( ! $this->is_restricted( $post_id ) ) {
|
1062 |
+
$cache[ $post_id ] = $open;
|
1063 |
+
return $open;
|
1064 |
+
}
|
1065 |
+
|
1066 |
+
$open = false;
|
1067 |
+
|
1068 |
+
$cache[ $post_id ] = $open;
|
1069 |
+
return $open;
|
1070 |
+
}
|
1071 |
+
|
1072 |
+
|
1073 |
+
/**
|
1074 |
+
* Disable comments if user has not permission to access this post
|
1075 |
+
*
|
1076 |
+
* @param int $count
|
1077 |
+
* @param int $post_id
|
1078 |
+
* @return boolean
|
1079 |
+
*/
|
1080 |
+
function disable_comments_open_number( $count, $post_id = 0 ) {
|
1081 |
+
if ( current_user_can( 'administrator' ) ) {
|
1082 |
+
return $count;
|
1083 |
+
}
|
1084 |
+
|
1085 |
+
static $cache_number = array();
|
1086 |
+
|
1087 |
+
if ( isset( $cache_number[ $post_id ] ) ) {
|
1088 |
+
return $cache_number[ $post_id ];
|
1089 |
+
}
|
1090 |
+
|
1091 |
+
if ( ! $this->is_restricted( $post_id ) ) {
|
1092 |
+
$cache_number[ $post_id ] = $count;
|
1093 |
+
return $count;
|
1094 |
+
}
|
1095 |
+
|
1096 |
+
$count = 0;
|
1097 |
+
|
1098 |
+
$cache_number[ $post_id ] = $count;
|
1099 |
+
return $count;
|
1100 |
+
}
|
1101 |
+
|
1102 |
+
|
1103 |
+
/**
|
1104 |
+
* Protect Post Types in menu query
|
1105 |
+
* Restrict content new logic
|
1106 |
+
* @param array $menu_items
|
1107 |
+
* @param array $args
|
1108 |
+
* @return array
|
1109 |
+
*/
|
1110 |
+
function filter_menu( $menu_items, $args = array() ) {
|
1111 |
+
//if empty
|
1112 |
+
if ( empty( $menu_items ) ) {
|
1113 |
+
return $menu_items;
|
1114 |
+
}
|
1115 |
+
|
1116 |
+
if ( current_user_can( 'administrator' ) ) {
|
1117 |
+
return $menu_items;
|
1118 |
+
}
|
1119 |
+
|
1120 |
+
$filtered_items = array();
|
1121 |
+
|
1122 |
+
//other filter
|
1123 |
+
foreach ( $menu_items as $menu_item ) {
|
1124 |
+
if ( ! empty( $menu_item->object_id ) && ! empty( $menu_item->object ) ) {
|
1125 |
+
if ( isset( $menu_item->type ) && 'taxonomy' === $menu_item->type ) {
|
1126 |
+
if ( ! $this->is_restricted_term( $menu_item->object_id ) ) {
|
1127 |
+
$filtered_items[] = $menu_item;
|
1128 |
+
continue;
|
1129 |
+
}
|
1130 |
+
} elseif ( isset( $menu_item->type ) && 'post_type' === $menu_item->type ) {
|
1131 |
+
if ( ! $this->is_restricted( $menu_item->object_id ) ) {
|
1132 |
+
$filtered_items[] = $menu_item;
|
1133 |
+
continue;
|
1134 |
+
} else {
|
1135 |
+
$restriction_settings = $this->get_post_privacy_settings( $menu_item->object_id );
|
1136 |
+
if ( empty( $restriction_settings['_um_access_hide_from_queries'] ) || ! UM()->options()->get( 'disable_restriction_pre_queries' ) ) {
|
1137 |
+
$filtered_items[] = $this->maybe_replace_nav_menu_title( $menu_item );
|
1138 |
+
continue;
|
1139 |
+
}
|
1140 |
+
}
|
1141 |
+
} elseif ( isset( $menu_item->type ) && 'custom' === $menu_item->type ) {
|
1142 |
+
$filtered_items[] = $menu_item;
|
1143 |
+
continue;
|
1144 |
+
} else {
|
1145 |
+
$filtered_items[] = $menu_item;
|
1146 |
+
continue;
|
1147 |
+
}
|
1148 |
+
} else {
|
1149 |
+
//add all other posts
|
1150 |
+
$filtered_items[] = $menu_item;
|
1151 |
+
}
|
1152 |
+
}
|
1153 |
+
|
1154 |
+
return $filtered_items;
|
1155 |
+
}
|
1156 |
+
|
1157 |
+
|
1158 |
+
/**
|
1159 |
+
* @param $block_content
|
1160 |
+
* @param $block
|
1161 |
+
*
|
1162 |
+
* @return string
|
1163 |
+
*/
|
1164 |
+
function restrict_blocks( $block_content, $block ) {
|
1165 |
+
if ( is_admin() ) {
|
1166 |
+
return $block_content;
|
1167 |
+
}
|
1168 |
+
|
1169 |
+
$restricted_blocks = UM()->options()->get( 'restricted_blocks' );
|
1170 |
+
if ( empty( $restricted_blocks ) ) {
|
1171 |
+
return $block_content;
|
1172 |
+
}
|
1173 |
+
|
1174 |
+
if ( is_user_logged_in() && current_user_can( 'administrator' ) ) {
|
1175 |
+
return $block_content;
|
1176 |
+
}
|
1177 |
+
|
1178 |
+
if ( ! isset( $block['attrs']['um_is_restrict'] ) || $block['attrs']['um_is_restrict'] !== true ) {
|
1179 |
+
return $block_content;
|
1180 |
+
}
|
1181 |
+
|
1182 |
+
if ( empty( $block['attrs']['um_who_access'] ) ) {
|
1183 |
+
return $block_content;
|
1184 |
+
}
|
1185 |
+
|
1186 |
+
$default_message = UM()->options()->get( 'restricted_block_message' );
|
1187 |
+
switch ( $block['attrs']['um_who_access'] ) {
|
1188 |
+
case '1': {
|
1189 |
+
if ( ! is_user_logged_in() ) {
|
1190 |
+
$block_content = '';
|
1191 |
+
if ( isset( $block['attrs']['um_message_type'] ) ) {
|
1192 |
+
if ( $block['attrs']['um_message_type'] == '1' ) {
|
1193 |
+
$block_content = $default_message;
|
1194 |
+
} elseif ( $block['attrs']['um_message_type'] == '2' ) {
|
1195 |
+
$block_content = $block['attrs']['um_message_content'];
|
1196 |
+
}
|
1197 |
+
}
|
1198 |
+
} else {
|
1199 |
+
$display = true;
|
1200 |
+
|
1201 |
+
// What roles can access this content?
|
1202 |
+
if ( ! empty( $block['attrs']['um_roles_access'] ) ) {
|
1203 |
+
$display = false;
|
1204 |
+
foreach ( $block['attrs']['um_roles_access'] as $role ) {
|
1205 |
+
if ( current_user_can( $role ) ) {
|
1206 |
+
$display = true;
|
1207 |
+
}
|
1208 |
+
}
|
1209 |
+
}
|
1210 |
+
|
1211 |
+
$display = apply_filters( 'um_loggedin_block_restriction', $display, $block );
|
1212 |
+
|
1213 |
+
if ( ! $display ) {
|
1214 |
+
$block_content = '';
|
1215 |
+
if ( isset( $block['attrs']['um_message_type'] ) ) {
|
1216 |
+
if ( $block['attrs']['um_message_type'] == '1' ) {
|
1217 |
+
$block_content = $default_message;
|
1218 |
+
} elseif ( $block['attrs']['um_message_type'] == '2' ) {
|
1219 |
+
$block_content = $block['attrs']['um_message_content'];
|
1220 |
+
}
|
1221 |
+
}
|
1222 |
+
}
|
1223 |
+
}
|
1224 |
+
break;
|
1225 |
+
}
|
1226 |
+
case '2': {
|
1227 |
+
if ( is_user_logged_in() ) {
|
1228 |
+
$block_content = '';
|
1229 |
+
if ( isset( $block['attrs']['um_message_type'] ) ) {
|
1230 |
+
if ( $block['attrs']['um_message_type'] == '1' ) {
|
1231 |
+
$block_content = $default_message;
|
1232 |
+
} elseif ( $block['attrs']['um_message_type'] == '2' ) {
|
1233 |
+
$block_content = $block['attrs']['um_message_content'];
|
1234 |
+
}
|
1235 |
+
}
|
1236 |
+
}
|
1237 |
+
break;
|
1238 |
+
}
|
1239 |
+
}
|
1240 |
+
|
1241 |
+
return $block_content;
|
1242 |
+
}
|
1243 |
+
|
1244 |
+
|
1245 |
+
/**
|
1246 |
+
* @param \WP_Post $post
|
1247 |
+
*
|
1248 |
+
* @return \WP_Post
|
1249 |
+
*/
|
1250 |
+
function maybe_replace_title( $post ) {
|
1251 |
+
if ( ! UM()->options()->get( 'restricted_post_title_replace' ) ) {
|
1252 |
+
return $post;
|
1253 |
+
}
|
1254 |
+
|
1255 |
+
if ( current_user_can( 'administrator' ) ) {
|
1256 |
+
return $post;
|
1257 |
+
}
|
1258 |
+
|
1259 |
+
if ( ! is_a( $post, '\WP_Post' ) ) {
|
1260 |
+
return $post;
|
1261 |
+
}
|
1262 |
+
|
1263 |
+
$ignore = apply_filters( 'um_ignore_restricted_title', false, $post->ID );
|
1264 |
+
if ( $ignore ) {
|
1265 |
+
return $post;
|
1266 |
+
}
|
1267 |
+
|
1268 |
+
$restricted_global_title = UM()->options()->get( 'restricted_access_post_title' );
|
1269 |
+
$post->post_title = stripslashes( $restricted_global_title );
|
1270 |
+
|
1271 |
+
return $post;
|
1272 |
+
}
|
1273 |
+
|
1274 |
+
|
1275 |
+
/**
|
1276 |
+
* @param \WP_Post $nav_item
|
1277 |
+
*
|
1278 |
+
* @return \WP_Post
|
1279 |
+
*/
|
1280 |
+
function maybe_replace_nav_menu_title( $nav_item ) {
|
1281 |
+
if ( ! UM()->options()->get( 'restricted_post_title_replace' ) ) {
|
1282 |
+
return $nav_item;
|
1283 |
+
}
|
1284 |
+
|
1285 |
+
if ( current_user_can( 'administrator' ) ) {
|
1286 |
+
return $nav_item;
|
1287 |
+
}
|
1288 |
+
|
1289 |
+
if ( ! is_a( $nav_item, '\WP_Post' ) ) {
|
1290 |
+
return $nav_item;
|
1291 |
+
}
|
1292 |
+
|
1293 |
+
$ignore = apply_filters( 'um_ignore_restricted_title', false, $nav_item->ID );
|
1294 |
+
if ( $ignore ) {
|
1295 |
+
return $nav_item;
|
1296 |
+
}
|
1297 |
+
|
1298 |
+
$restricted_global_title = UM()->options()->get( 'restricted_access_post_title' );
|
1299 |
+
$nav_item->title = stripslashes( $restricted_global_title );
|
1300 |
+
|
1301 |
+
return $nav_item;
|
1302 |
+
}
|
1303 |
+
|
1304 |
+
|
1305 |
+
/**
|
1306 |
+
* Protect Post Types in query
|
1307 |
+
* Restrict content new logic
|
1308 |
+
*
|
1309 |
+
* @param array $posts
|
1310 |
+
* @param array|\WP_Query $query
|
1311 |
+
* @return array
|
1312 |
+
*/
|
1313 |
+
function filter_protected_posts( $posts, $query ) {
|
1314 |
+
if ( current_user_can( 'administrator' ) ) {
|
1315 |
+
return $posts;
|
1316 |
+
}
|
1317 |
+
|
1318 |
+
//Woocommerce AJAX fixes....remove filtration on wc-ajax which goes to Front Page
|
1319 |
+
if ( ! empty( $_GET['wc-ajax'] ) && defined( 'WC_DOING_AJAX' ) && WC_DOING_AJAX ) {
|
1320 |
+
return $posts;
|
1321 |
+
}
|
1322 |
+
|
1323 |
+
//if empty
|
1324 |
+
if ( empty( $posts ) || is_admin() ) {
|
1325 |
+
return $posts;
|
1326 |
+
}
|
1327 |
+
|
1328 |
+
if ( is_object( $query ) ) {
|
1329 |
+
$is_singular = $query->is_singular();
|
1330 |
+
} else {
|
1331 |
+
$is_singular = ! empty( $query->is_singular ) ? true : false;
|
1332 |
+
}
|
1333 |
+
|
1334 |
+
if ( is_object( $query ) && is_a( $query, '\WP_Query' ) &&
|
1335 |
+
( $query->is_main_query() || ! empty( $query->query_vars['um_main_query'] ) ) ) {
|
1336 |
+
if ( $is_singular ) {
|
1337 |
+
if ( ! UM()->options()->get( 'disable_restriction_pre_queries' ) && $this->is_restricted( $posts[0]->ID ) ) {
|
1338 |
+
$content_restriction = $this->get_post_privacy_settings( $posts[0]->ID );
|
1339 |
+
if ( ! empty( $content_restriction['_um_access_hide_from_queries'] ) ) {
|
1340 |
+
unset( $posts[0] );
|
1341 |
+
return $posts;
|
1342 |
+
}
|
1343 |
+
}
|
1344 |
+
}
|
1345 |
+
}
|
1346 |
+
|
1347 |
+
$filtered_posts = array();
|
1348 |
+
|
1349 |
+
//other filter
|
1350 |
+
foreach ( $posts as $post ) {
|
1351 |
+
if ( is_user_logged_in() && isset( $post->post_author ) && $post->post_author == get_current_user_id() ) {
|
1352 |
+
$filtered_posts[] = $post;
|
1353 |
+
continue;
|
1354 |
+
}
|
1355 |
+
|
1356 |
+
$restriction = $this->get_post_privacy_settings( $post );
|
1357 |
+
if ( ! $restriction ) {
|
1358 |
+
$filtered_posts[] = $post;
|
1359 |
+
continue;
|
1360 |
+
}
|
1361 |
+
|
1362 |
+
if ( $is_singular ) {
|
1363 |
+
$this->singular_page = true;
|
1364 |
+
}
|
1365 |
+
|
1366 |
+
if ( ! $this->is_restricted( $post->ID ) ) {
|
1367 |
+
$filtered_posts[] = $post;
|
1368 |
+
continue;
|
1369 |
+
} else {
|
1370 |
+
if ( $is_singular ) {
|
1371 |
+
if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) {
|
1372 |
+
if ( UM()->options()->get( 'disable_restriction_pre_queries' ) || empty( $restriction['_um_access_hide_from_queries'] ) ) {
|
1373 |
+
/**
|
1374 |
+
* UM hook
|
1375 |
+
*
|
1376 |
+
* @type action
|
1377 |
+
* @title um_access_fix_external_post_content
|
1378 |
+
* @description Hook for 3-d party content filtration
|
1379 |
+
* @change_log
|
1380 |
+
* ["Since: 2.0"]
|
1381 |
+
* @usage add_action( 'um_access_fix_external_post_content', 'function_name', 10 );
|
1382 |
+
* @example
|
1383 |
+
* <?php
|
1384 |
+
* add_action( 'um_access_fix_external_post_content', 'my_access_fix_external_post_content', 10 );
|
1385 |
+
* function my_access_fix_external_post_content() {
|
1386 |
+
* // your code here
|
1387 |
+
* }
|
1388 |
+
* ?>
|
1389 |
+
*/
|
1390 |
+
do_action( 'um_access_fix_external_post_content' );
|
1391 |
+
|
1392 |
+
$filtered_posts[] = $this->maybe_replace_title( $post );
|
1393 |
+
continue;
|
1394 |
+
}
|
1395 |
+
} elseif ( '1' == $restriction['_um_noaccess_action'] ) {
|
1396 |
+
$curr = UM()->permalinks()->get_current_url();
|
1397 |
+
|
1398 |
+
if ( ! isset( $restriction['_um_access_redirect'] ) || '0' == $restriction['_um_access_redirect'] ) {
|
1399 |
+
|
1400 |
+
exit( wp_redirect( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) ) ) );
|
1401 |
+
|
1402 |
+
} elseif ( '1' == $restriction['_um_access_redirect'] ) {
|
1403 |
+
|
1404 |
+
if ( ! empty( $restriction['_um_access_redirect_url'] ) ) {
|
1405 |
+
$redirect = $restriction['_um_access_redirect_url'];
|
1406 |
+
} else {
|
1407 |
+
$redirect = esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) );
|
1408 |
+
}
|
1409 |
+
|
1410 |
+
exit( wp_redirect( $redirect ) );
|
1411 |
+
}
|
1412 |
+
}
|
1413 |
+
} else {
|
1414 |
+
if ( empty( $restriction['_um_access_hide_from_queries'] ) || ! UM()->options()->get( 'disable_restriction_pre_queries' ) ) {
|
1415 |
+
$filtered_posts[] = $this->maybe_replace_title( $post );
|
1416 |
+
continue;
|
1417 |
+
}
|
1418 |
+
}
|
1419 |
+
}
|
1420 |
+
}
|
1421 |
+
|
1422 |
+
return $filtered_posts;
|
1423 |
+
}
|
1424 |
+
|
1425 |
+
|
1426 |
+
/**
|
1427 |
+
* Set custom access actions and redirection
|
1428 |
+
*
|
1429 |
+
* Old global restrict content logic
|
1430 |
+
*/
|
1431 |
+
function template_redirect() {
|
1432 |
+
global $post, $wp_query;
|
1433 |
+
|
1434 |
+
//if we logged by administrator it can access to all content
|
1435 |
+
if ( current_user_can( 'administrator' ) ) {
|
1436 |
+
return;
|
1437 |
+
}
|
1438 |
+
|
1439 |
+
if ( is_object( $wp_query ) ) {
|
1440 |
+
$is_singular = $wp_query->is_singular();
|
1441 |
+
} else {
|
1442 |
+
$is_singular = ! empty( $wp_query->is_singular ) ? true : false;
|
1443 |
+
}
|
1444 |
+
|
1445 |
+
//if we use individual restrict content options skip this function
|
1446 |
+
if ( $is_singular && $this->singular_page ) {
|
1447 |
+
return;
|
1448 |
+
}
|
1449 |
+
|
1450 |
+
//also skip if we currently at wp-admin or 404 page
|
1451 |
+
if ( is_admin() || is_404() ) {
|
1452 |
+
return;
|
1453 |
+
}
|
1454 |
+
|
1455 |
+
//also skip if we currently at UM Register|Login|Reset Password pages
|
1456 |
+
if ( um_is_core_post( $post, 'register' ) ||
|
1457 |
+
um_is_core_post( $post, 'password-reset' ) ||
|
1458 |
+
um_is_core_post( $post, 'login' ) ) {
|
1459 |
+
return;
|
1460 |
+
}
|
1461 |
+
|
1462 |
+
/**
|
1463 |
+
* UM hook
|
1464 |
+
*
|
1465 |
+
* @type action
|
1466 |
+
* @title um_roles_add_meta_boxes_um_role_meta
|
1467 |
+
* @description Check terms individual restrict options
|
1468 |
+
* @change_log
|
1469 |
+
* ["Since: 2.0"]
|
1470 |
+
* @usage add_action( 'um_access_check_individual_term_settings', 'function_name', 10 );
|
1471 |
+
* @example
|
1472 |
+
* <?php
|
1473 |
+
* add_action( 'um_access_check_individual_term_settings', 'my_access_check_individual_term_settings', 10 );
|
1474 |
+
* function my_access_check_individual_term_settings() {
|
1475 |
+
* // your code here
|
1476 |
+
* }
|
1477 |
+
* ?>
|
1478 |
+
*/
|
1479 |
+
do_action( 'um_access_check_individual_term_settings' );
|
1480 |
+
//exit from function if term page is accessible
|
1481 |
+
if ( $this->check_access() ) {
|
1482 |
+
return;
|
1483 |
+
}
|
1484 |
+
|
1485 |
+
/**
|
1486 |
+
* UM hook
|
1487 |
+
*
|
1488 |
+
* @type action
|
1489 |
+
* @title um_access_check_global_settings
|
1490 |
+
* @description Check global restrict content options
|
1491 |
+
* @change_log
|
1492 |
+
* ["Since: 2.0"]
|
1493 |
+
* @usage add_action( 'um_access_check_global_settings', 'function_name', 10 );
|
1494 |
+
* @example
|
1495 |
+
* <?php
|
1496 |
+
* add_action( 'um_access_check_global_settings', 'my_access_check_global_settings', 10 );
|
1497 |
+
* function my_access_check_global_settings() {
|
1498 |
+
* // your code here
|
1499 |
+
* }
|
1500 |
+
* ?>
|
1501 |
+
*/
|
1502 |
+
do_action( 'um_access_check_global_settings' );
|
1503 |
+
|
1504 |
+
$this->check_access();
|
1505 |
+
}
|
1506 |
+
|
1507 |
+
|
1508 |
+
/**
|
1509 |
+
* Check individual term Content Restriction settings
|
1510 |
+
*/
|
1511 |
+
function um_access_check_individual_term_settings() {
|
1512 |
+
//check only tax|tags|categories - skip archive, author, and date lists
|
1513 |
+
if ( ! ( is_tax() || is_tag() || is_category() ) ) {
|
1514 |
+
return;
|
1515 |
+
}
|
1516 |
+
|
1517 |
+
$term_id = null;
|
1518 |
+
if ( is_tag() ) {
|
1519 |
+
$term_id = get_query_var( 'tag_id' );
|
1520 |
+
} elseif ( is_category() ) {
|
1521 |
+
$term_id = get_query_var( 'cat' );
|
1522 |
+
} elseif ( is_tax() ) {
|
1523 |
+
$tax_name = get_query_var( 'taxonomy' );
|
1524 |
+
|
1525 |
+
$term_name = get_query_var( 'term' );
|
1526 |
+
$term = get_term_by( 'slug', $term_name, $tax_name );
|
1527 |
+
|
1528 |
+
$term_id = ! empty( $term->term_id ) ? $term->term_id : $term_id;
|
1529 |
+
}
|
1530 |
+
|
1531 |
+
if ( ! isset( $term_id ) ) {
|
1532 |
+
return;
|
1533 |
+
}
|
1534 |
+
|
1535 |
+
if ( $this->is_restricted_term( $term_id, true ) ) {
|
1536 |
+
$restriction = get_term_meta( $term_id, 'um_content_restriction', true );
|
1537 |
+
if ( '1' == $restriction['_um_noaccess_action'] ) {
|
1538 |
+
$curr = UM()->permalinks()->get_current_url();
|
1539 |
+
|
1540 |
+
if ( ! isset( $restriction['_um_access_redirect'] ) || '0' == $restriction['_um_access_redirect'] ) {
|
1541 |
+
|
1542 |
+
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) ), 'individual_term' );
|
1543 |
+
|
1544 |
+
} elseif ( '1' == $restriction['_um_access_redirect'] ) {
|
1545 |
+
|
1546 |
+
if ( ! empty( $restriction['_um_access_redirect_url'] ) ) {
|
1547 |
+
$redirect = $restriction['_um_access_redirect_url'];
|
1548 |
+
} else {
|
1549 |
+
$redirect = esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) );
|
1550 |
+
}
|
1551 |
+
|
1552 |
+
$this->redirect_handler = $this->set_referer( $redirect, 'individual_term' );
|
1553 |
+
|
1554 |
+
}
|
1555 |
+
} else {
|
1556 |
+
add_filter( 'tag_template', array( &$this, 'taxonomy_message' ), 10, 3 );
|
1557 |
+
add_filter( 'archive_template', array( &$this, 'taxonomy_message' ), 10, 3 );
|
1558 |
+
add_filter( 'category_template', array( &$this, 'taxonomy_message' ), 10, 3 );
|
1559 |
+
add_filter( 'taxonomy_template', array( &$this, 'taxonomy_message' ), 10, 3 );
|
1560 |
+
}
|
1561 |
+
}
|
1562 |
+
}
|
1563 |
+
|
1564 |
+
|
1565 |
+
/**
|
1566 |
+
* @param $template
|
1567 |
+
* @param $type
|
1568 |
+
* @param $templates
|
1569 |
+
*
|
1570 |
+
* @return string
|
1571 |
+
*/
|
1572 |
+
function taxonomy_message( $template, $type, $templates ) {
|
1573 |
+
return UM()->locate_template( 'restricted-taxonomy.php' );
|
1574 |
+
}
|
1575 |
+
|
1576 |
+
|
1577 |
+
/**
|
1578 |
+
* Check global accessible settings
|
1579 |
+
*/
|
1580 |
+
function um_access_check_global_settings() {
|
1581 |
+
global $post;
|
1582 |
+
|
1583 |
+
$curr = UM()->permalinks()->get_current_url();
|
1584 |
+
$ms_empty_role_access = is_multisite() && is_user_logged_in() && ! UM()->roles()->get_priority_user_role( um_user( 'ID' ) );
|
1585 |
+
|
1586 |
+
if ( is_front_page() ) {
|
1587 |
+
if ( is_user_logged_in() && ! $ms_empty_role_access ) {
|
1588 |
+
|
1589 |
+
$user_default_homepage = um_user( 'default_homepage' );
|
1590 |
+
if ( ! empty( $user_default_homepage ) ) {
|
1591 |
+
return;
|
1592 |
+
}
|
1593 |
+
|
1594 |
+
$redirect_homepage = um_user( 'redirect_homepage' );
|
1595 |
+
/**
|
1596 |
+
* UM hook
|
1597 |
+
*
|
1598 |
+
* @type filter
|
1599 |
+
* @title um_custom_homepage_redirect_url
|
1600 |
+
* @description Change custom homepage redirect
|
1601 |
+
* @input_vars
|
1602 |
+
* [{"var":"$url","type":"string","desc":"Redirect URL"},
|
1603 |
+
* {"var":"$id","type":"int","desc":"User ID"}]
|
1604 |
+
* @change_log
|
1605 |
+
* ["Since: 2.0"]
|
1606 |
+
* @usage
|
1607 |
+
* <?php add_filter( 'um_custom_homepage_redirect_url', 'function_name', 10, 2 ); ?>
|
1608 |
+
* @example
|
1609 |
+
* <?php
|
1610 |
+
* add_filter( 'um_custom_homepage_redirect_url', 'my_custom_homepage_redirect_url', 10, 2 );
|
1611 |
+
* function my_custom_homepage_redirect_url( $url, $id ) {
|
1612 |
+
* // your code here
|
1613 |
+
* return $url;
|
1614 |
+
* }
|
1615 |
+
* ?>
|
1616 |
+
*/
|
1617 |
+
$redirect_homepage = apply_filters( 'um_custom_homepage_redirect_url', $redirect_homepage, um_user( 'ID' ) );
|
1618 |
+
$redirect_to = ! empty( $redirect_homepage ) ? $redirect_homepage : um_get_core_page( 'user' );
|
1619 |
+
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), $redirect_to ) ), 'custom_homepage' );
|
1620 |
+
|
1621 |
+
} else {
|
1622 |
+
$access = UM()->options()->get( 'accessible' );
|
1623 |
+
|
1624 |
+
if ( $access == 2 ) {
|
1625 |
+
//global settings for accessible home page
|
1626 |
+
$home_page_accessible = UM()->options()->get( 'home_page_accessible' );
|
1627 |
+
|
1628 |
+
if ( $home_page_accessible == 0 ) {
|
1629 |
+
//get redirect URL if not set get login page by default
|
1630 |
+
$redirect = UM()->options()->get( 'access_redirect' );
|
1631 |
+
if ( ! $redirect ) {
|
1632 |
+
$redirect = um_get_core_page( 'login' );
|
1633 |
+
}
|
1634 |
+
|
1635 |
+
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), $redirect ) ), 'global' );
|
1636 |
+
} else {
|
1637 |
+
$this->allow_access = true;
|
1638 |
+
return;
|
1639 |
+
}
|
1640 |
+
}
|
1641 |
+
}
|
1642 |
+
} elseif ( is_category() ) {
|
1643 |
+
if ( ! is_user_logged_in() || $ms_empty_role_access ) {
|
1644 |
+
|
1645 |
+
$access = UM()->options()->get( 'accessible' );
|
1646 |
+
|
1647 |
+
if ( $access == 2 ) {
|
1648 |
+
//global settings for accessible home page
|
1649 |
+
$category_page_accessible = UM()->options()->get( 'category_page_accessible' );
|
1650 |
+
if ( $category_page_accessible == 0 ) {
|
1651 |
+
//get redirect URL if not set get login page by default
|
1652 |
+
$redirect = UM()->options()->get( 'access_redirect' );
|
1653 |
+
if ( ! $redirect ) {
|
1654 |
+
$redirect = um_get_core_page( 'login' );
|
1655 |
+
}
|
1656 |
+
|
1657 |
+
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), $redirect ) ), 'global' );
|
1658 |
+
} else {
|
1659 |
+
$this->allow_access = true;
|
1660 |
+
return;
|
1661 |
+
}
|
1662 |
+
}
|
1663 |
+
}
|
1664 |
+
}
|
1665 |
+
|
1666 |
+
$access = UM()->options()->get( 'accessible' );
|
1667 |
+
|
1668 |
+
if ( $access == 2 && ( ! is_user_logged_in() || $ms_empty_role_access ) ) {
|
1669 |
+
|
1670 |
+
//build exclude URLs pages
|
1671 |
+
$redirects = array();
|
1672 |
+
$redirects[] = trim( untrailingslashit( UM()->options()->get( 'access_redirect' ) ) );
|
1673 |
+
|
1674 |
+
$exclude_uris = UM()->options()->get( 'access_exclude_uris' );
|
1675 |
+
if ( ! empty( $exclude_uris ) ) {
|
1676 |
+
$exclude_uris = array_map( 'trim', $exclude_uris );
|
1677 |
+
$redirects = array_merge( $redirects, $exclude_uris );
|
1678 |
+
}
|
1679 |
+
|
1680 |
+
$redirects = array_unique( $redirects );
|
1681 |
+
|
1682 |
+
$current_url = UM()->permalinks()->get_current_url( get_option( 'permalink_structure' ) );
|
1683 |
+
$current_url = untrailingslashit( $current_url );
|
1684 |
+
$current_url_slash = trailingslashit( $current_url );
|
1685 |
+
|
1686 |
+
if ( ! ( isset( $post->ID ) && ( in_array( $current_url, $redirects ) || in_array( $current_url_slash, $redirects ) ) ) ) {
|
1687 |
+
//if current page not in exclude URLs
|
1688 |
+
//get redirect URL if not set get login page by default
|
1689 |
+
$redirect = UM()->options()->get( 'access_redirect' );
|
1690 |
+
if ( ! $redirect ) {
|
1691 |
+
$redirect = um_get_core_page( 'login' );
|
1692 |
+
}
|
1693 |
+
|
1694 |
+
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), $redirect ) ), 'global' );
|
1695 |
+
} else {
|
1696 |
+
$this->redirect_handler = false;
|
1697 |
+
$this->allow_access = true;
|
1698 |
+
}
|
1699 |
+
}
|
1700 |
+
}
|
1701 |
+
|
1702 |
+
|
1703 |
+
/**
|
1704 |
+
* Check access
|
1705 |
+
*
|
1706 |
+
* @return bool
|
1707 |
+
*/
|
1708 |
+
function check_access() {
|
1709 |
+
if ( $this->allow_access === true ) {
|
1710 |
+
return true;
|
1711 |
+
}
|
1712 |
+
|
1713 |
+
if ( $this->redirect_handler ) {
|
1714 |
+
wp_redirect( $this->redirect_handler );
|
1715 |
+
exit;
|
1716 |
+
}
|
1717 |
+
|
1718 |
+
return false;
|
1719 |
+
}
|
1720 |
+
|
1721 |
+
|
1722 |
+
/**
|
1723 |
+
* Sets a custom access referer in a redirect URL
|
1724 |
+
*
|
1725 |
+
* @param string $url
|
1726 |
+
* @param string $referer
|
1727 |
+
*
|
1728 |
+
* @return string
|
1729 |
+
*/
|
1730 |
+
function set_referer( $url, $referer ) {
|
1731 |
+
|
1732 |
+
/**
|
1733 |
+
* UM hook
|
1734 |
+
*
|
1735 |
+
* @type filter
|
1736 |
+
* @title um_access_enable_referer
|
1737 |
+
* @description Access Referrer Enable/Disable
|
1738 |
+
* @input_vars
|
1739 |
+
* [{"var":"$referrer","type":"bool","desc":"Access referrer"}]
|
1740 |
+
* @change_log
|
1741 |
+
* ["Since: 2.0"]
|
1742 |
+
* @usage add_filter( 'um_access_enable_referer', 'function_name', 10, 1 );
|
1743 |
+
* @example
|
1744 |
+
* <?php
|
1745 |
+
* add_filter( 'um_access_enable_referer', 'my_access_enable_referer', 10, 1 );
|
1746 |
+
* function my_access_enable_referer( $referrer ) {
|
1747 |
+
* // your code here
|
1748 |
+
* return $referrer;
|
1749 |
+
* }
|
1750 |
+
* ?>
|
1751 |
+
*/
|
1752 |
+
$enable_referer = apply_filters( 'um_access_enable_referer', false );
|
1753 |
+
if ( ! $enable_referer ) {
|
1754 |
+
return $url;
|
1755 |
+
}
|
1756 |
+
|
1757 |
+
$url = add_query_arg( 'um_ref', $referer, $url );
|
1758 |
+
return $url;
|
1759 |
+
}
|
1760 |
+
|
1761 |
+
|
1762 |
+
/**
|
1763 |
+
* Get privacy settings for post
|
1764 |
+
* return false if post is not private
|
1765 |
+
* Restrict content new logic
|
1766 |
+
*
|
1767 |
+
* @param \WP_Post|int $post Post ID or object
|
1768 |
+
* @return bool|array
|
1769 |
+
*/
|
1770 |
+
function get_post_privacy_settings( $post ) {
|
1771 |
+
// break for incorrect post
|
1772 |
+
if ( empty( $post ) ) {
|
1773 |
+
return false;
|
1774 |
+
}
|
1775 |
+
|
1776 |
+
static $cache = array();
|
1777 |
+
|
1778 |
+
$cache_key = is_numeric( $post ) ? $post : $post->ID;
|
1779 |
+
|
1780 |
+
if ( isset( $cache[ $cache_key ] ) ) {
|
1781 |
+
return $cache[ $cache_key ];
|
1782 |
+
}
|
1783 |
+
|
1784 |
+
if ( is_numeric( $post ) ) {
|
1785 |
+
$post = get_post( $post );
|
1786 |
+
}
|
1787 |
+
|
1788 |
+
//if logged in administrator all pages are visible
|
1789 |
+
if ( current_user_can( 'administrator' ) ) {
|
1790 |
+
$cache[ $cache_key ] = false;
|
1791 |
+
return false;
|
1792 |
+
}
|
1793 |
+
|
1794 |
+
$exclude = false;
|
1795 |
+
//exclude from privacy UM default pages (except Members list and User(Profile) page)
|
1796 |
+
if ( ! empty( $post->post_type ) && $post->post_type === 'page' ) {
|
1797 |
+
|
1798 |
+
if ( um_is_core_post( $post, 'login' ) || um_is_core_post( $post, 'register' ) ||
|
1799 |
+
um_is_core_post( $post, 'account' ) || um_is_core_post( $post, 'logout' ) ||
|
1800 |
+
um_is_core_post( $post, 'password-reset' ) || ( is_user_logged_in() && um_is_core_post( $post, 'user' ) ) )
|
1801 |
+
$exclude = true;
|
1802 |
+
}
|
1803 |
+
|
1804 |
+
$exclude = apply_filters( 'um_exclude_posts_from_privacy', $exclude, $post );
|
1805 |
+
if ( $exclude ) {
|
1806 |
+
$cache[ $cache_key ] = false;
|
1807 |
+
return false;
|
1808 |
+
}
|
1809 |
+
|
1810 |
+
$restricted_posts = UM()->options()->get( 'restricted_access_post_metabox' );
|
1811 |
+
|
1812 |
+
if ( ! empty( $post->post_type ) && ! empty( $restricted_posts[ $post->post_type ] ) ) {
|
1813 |
+
$restriction = get_post_meta( $post->ID, 'um_content_restriction', true );
|
1814 |
+
|
1815 |
+
if ( ! empty( $restriction['_um_custom_access_settings'] ) ) {
|
1816 |
+
if ( ! isset( $restriction['_um_accessible'] ) ) {
|
1817 |
+
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
1818 |
+
|
1819 |
+
//get all taxonomies for current post type
|
1820 |
+
$taxonomies = get_object_taxonomies( $post );
|
1821 |
+
|
1822 |
+
//get all post terms
|
1823 |
+
$terms = array();
|
1824 |
+
if ( ! empty( $taxonomies ) ) {
|
1825 |
+
foreach ( $taxonomies as $taxonomy ) {
|
1826 |
+
if ( empty( $restricted_taxonomies[ $taxonomy ] ) ) {
|
1827 |
+
continue;
|
1828 |
+
}
|
1829 |
+
|
1830 |
+
$terms = array_merge( $terms, wp_get_post_terms( $post->ID, $taxonomy, array( 'fields' => 'ids', 'um_ignore_exclude' => true, ) ) );
|
1831 |
+
}
|
1832 |
+
}
|
1833 |
+
|
1834 |
+
//get restriction options for first term with privacy settigns
|
1835 |
+
foreach ( $terms as $term_id ) {
|
1836 |
+
$restriction = get_term_meta( $term_id, 'um_content_restriction', true );
|
1837 |
+
|
1838 |
+
if ( ! empty( $restriction['_um_custom_access_settings'] ) ) {
|
1839 |
+
if ( ! isset( $restriction['_um_accessible'] ) ) {
|
1840 |
+
continue;
|
1841 |
+
} else {
|
1842 |
+
$cache[ $cache_key ] = $restriction;
|
1843 |
+
return $restriction;
|
1844 |
+
}
|
1845 |
+
}
|
1846 |
+
}
|
1847 |
+
|
1848 |
+
$cache[ $cache_key ] = false;
|
1849 |
+
return false;
|
1850 |
+
} else {
|
1851 |
+
|
1852 |
+
// set default redirect if Profile page is restricted for not-logged in users and showing message instead of redirect
|
1853 |
+
// this snippet was added to make the same action for {site_url}/user and {site_url}/user/{user_slug} URLs
|
1854 |
+
// by default {site_url}/user is redirected to Homepage in rewrite rules because hasn't found username in query when user is not logged in
|
1855 |
+
if ( ! is_user_logged_in() && um_is_core_post( $post, 'user' ) && $restriction['_um_accessible'] == '2' && $restriction['_um_noaccess_action'] == '0' ) {
|
1856 |
+
if ( isset( $restriction['_um_access_roles'] ) ) {
|
1857 |
+
$restriction = array(
|
1858 |
+
'_um_accessible' => '2',
|
1859 |
+
'_um_access_roles' => $restriction['_um_access_roles'],
|
1860 |
+
'_um_noaccess_action' => '1',
|
1861 |
+
'_um_access_redirect' => '1',
|
1862 |
+
'_um_access_redirect_url' => get_home_url( get_current_blog_id() )
|
1863 |
+
);
|
1864 |
+
} else {
|
1865 |
+
$restriction = array(
|
1866 |
+
'_um_accessible' => '2',
|
1867 |
+
'_um_noaccess_action' => '1',
|
1868 |
+
'_um_access_redirect' => '1',
|
1869 |
+
'_um_access_redirect_url' => get_home_url( get_current_blog_id() )
|
1870 |
+
);
|
1871 |
+
}
|
1872 |
+
}
|
1873 |
+
|
1874 |
+
$restriction = apply_filters( 'um_post_content_restriction_settings', $restriction, $post );
|
1875 |
+
|
1876 |
+
$cache[ $cache_key ] = $restriction;
|
1877 |
+
return $restriction;
|
1878 |
+
}
|
1879 |
+
}
|
1880 |
+
}
|
1881 |
+
|
1882 |
+
//post hasn't privacy settings....check all terms of this post
|
1883 |
+
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
1884 |
+
|
1885 |
+
//get all taxonomies for current post type
|
1886 |
+
$taxonomies = get_object_taxonomies( $post );
|
1887 |
+
|
1888 |
+
//get all post terms
|
1889 |
+
$terms = array();
|
1890 |
+
if ( ! empty( $taxonomies ) ) {
|
1891 |
+
foreach ( $taxonomies as $taxonomy ) {
|
1892 |
+
if ( empty( $restricted_taxonomies[ $taxonomy ] ) ) {
|
1893 |
+
continue;
|
1894 |
+
}
|
1895 |
+
|
1896 |
+
$terms = array_merge( $terms, wp_get_post_terms( $post->ID, $taxonomy, array( 'fields' => 'ids', 'um_ignore_exclude' => true, ) ) );
|
1897 |
+
}
|
1898 |
+
}
|
1899 |
+
|
1900 |
+
//get restriction options for first term with privacy settings
|
1901 |
+
foreach ( $terms as $term_id ) {
|
1902 |
+
$restriction = get_term_meta( $term_id, 'um_content_restriction', true );
|
1903 |
+
|
1904 |
+
if ( ! empty( $restriction['_um_custom_access_settings'] ) ) {
|
1905 |
+
if ( ! isset( $restriction['_um_accessible'] ) ) {
|
1906 |
+
continue;
|
1907 |
+
} else {
|
1908 |
+
$cache[ $cache_key ] = $restriction;
|
1909 |
+
return $restriction;
|
1910 |
+
}
|
1911 |
+
}
|
1912 |
+
}
|
1913 |
+
|
1914 |
+
$cache[ $cache_key ] = false;
|
1915 |
+
//post is public
|
1916 |
+
return false;
|
1917 |
+
}
|
1918 |
+
|
1919 |
+
|
1920 |
+
/**
|
1921 |
+
* Helper for checking if the user can some of the roles array
|
1922 |
+
*
|
1923 |
+
* @param $user_id
|
1924 |
+
* @param $roles
|
1925 |
+
* @return bool
|
1926 |
+
*/
|
1927 |
+
function user_can( $user_id, $roles ) {
|
1928 |
+
$user_can = false;
|
1929 |
+
|
1930 |
+
if ( ! empty( $roles ) ) {
|
1931 |
+
foreach ( $roles as $key => $value ) {
|
1932 |
+
if ( ! empty( $value ) && user_can( $user_id, $key ) ) {
|
1933 |
+
$user_can = true;
|
1934 |
+
break;
|
1935 |
+
}
|
1936 |
+
}
|
1937 |
+
}
|
1938 |
+
|
1939 |
+
return $user_can;
|
1940 |
+
}
|
1941 |
+
|
1942 |
+
|
1943 |
+
/**
|
1944 |
+
* Helper for 3rd-party integrations with content restriction settings
|
1945 |
+
*
|
1946 |
+
* @param array $restriction
|
1947 |
+
*
|
1948 |
+
* @return bool
|
1949 |
+
*/
|
1950 |
+
function um_custom_restriction( $restriction ) {
|
1951 |
+
/**
|
1952 |
+
* UM hook
|
1953 |
+
*
|
1954 |
+
* @type filter
|
1955 |
+
* @title um_custom_restriction
|
1956 |
+
* @description Extend Sort Types for Member Directory
|
1957 |
+
* @input_vars
|
1958 |
+
* [{"var":"$custom_restriction","type":"bool","desc":"Custom Restriction"},
|
1959 |
+
* {"var":"$restriction","type":"array","desc":"Restriction settings"}]
|
1960 |
+
* @change_log
|
1961 |
+
* ["Since: 2.0"]
|
1962 |
+
* @usage add_filter( 'um_custom_restriction', 'function_name', 10, 2 );
|
1963 |
+
* @example
|
1964 |
+
* <?php
|
1965 |
+
* add_filter( 'um_custom_restriction', 'my_custom_restriction', 10, 2 );
|
1966 |
+
* function my_directory_sort_users_select( $custom_restriction, $restriction ) {
|
1967 |
+
* // your code here
|
1968 |
+
* return $custom_restriction;
|
1969 |
+
* }
|
1970 |
+
* ?>
|
1971 |
+
*/
|
1972 |
+
return apply_filters( 'um_custom_restriction', true, $restriction );
|
1973 |
+
}
|
1974 |
+
|
1975 |
+
|
1976 |
+
/**
|
1977 |
+
* Is post restricted?
|
1978 |
+
*
|
1979 |
+
* @param int $post_id
|
1980 |
+
* @return bool
|
1981 |
+
*/
|
1982 |
+
function is_restricted( $post_id ) {
|
1983 |
+
// break for incorrect post
|
1984 |
+
if ( empty( $post_id ) ) {
|
1985 |
+
return false;
|
1986 |
+
}
|
1987 |
+
|
1988 |
+
static $cache = array();
|
1989 |
+
|
1990 |
+
if ( isset( $cache[ $post_id ] ) ) {
|
1991 |
+
return $cache[ $post_id ];
|
1992 |
+
}
|
1993 |
+
|
1994 |
+
if ( current_user_can( 'administrator' ) ) {
|
1995 |
+
$cache[ $post_id ] = false;
|
1996 |
+
return false;
|
1997 |
+
}
|
1998 |
+
|
1999 |
+
$post = get_post( $post_id );
|
2000 |
+
if ( is_user_logged_in() && isset( $post->post_author ) && $post->post_author == get_current_user_id() ) {
|
2001 |
+
$cache[ $post_id ] = false;
|
2002 |
+
return false;
|
2003 |
+
}
|
2004 |
+
|
2005 |
+
$restricted = true;
|
2006 |
+
|
2007 |
+
$restriction = $this->get_post_privacy_settings( $post_id );
|
2008 |
+
if ( ! $restriction ) {
|
2009 |
+
$restricted = false;
|
2010 |
+
} else {
|
2011 |
+
if ( '0' == $restriction['_um_accessible'] ) {
|
2012 |
+
//post is private
|
2013 |
+
$restricted = false;
|
2014 |
+
} elseif ( '1' == $restriction['_um_accessible'] ) {
|
2015 |
+
//if post for not logged in users and user is not logged in
|
2016 |
+
if ( ! is_user_logged_in() ) {
|
2017 |
+
$restricted = false;
|
2018 |
+
}
|
2019 |
+
} elseif ( '2' == $restriction['_um_accessible'] ) {
|
2020 |
+
//if post for logged in users and user is not logged in
|
2021 |
+
if ( is_user_logged_in() ) {
|
2022 |
+
$custom_restrict = $this->um_custom_restriction( $restriction );
|
2023 |
+
|
2024 |
+
if ( empty( $restriction['_um_access_roles'] ) || false === array_search( '1', $restriction['_um_access_roles'] ) ) {
|
2025 |
+
if ( $custom_restrict ) {
|
2026 |
+
$restricted = false;
|
2027 |
+
}
|
2028 |
+
} else {
|
2029 |
+
$user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] );
|
2030 |
+
|
2031 |
+
if ( $user_can && $custom_restrict ) {
|
2032 |
+
$restricted = false;
|
2033 |
+
}
|
2034 |
+
}
|
2035 |
+
}
|
2036 |
+
}
|
2037 |
+
}
|
2038 |
+
|
2039 |
+
$restricted = apply_filters( 'um_is_restricted_post', $restricted, $post_id );
|
2040 |
+
|
2041 |
+
$cache[ $post_id ] = $restricted;
|
2042 |
+
|
2043 |
+
return $restricted;
|
2044 |
+
}
|
2045 |
+
|
2046 |
+
|
2047 |
+
/**
|
2048 |
+
* Is term restricted?
|
2049 |
+
*
|
2050 |
+
* @param int $term_id
|
2051 |
+
* @param bool $on_term_page
|
2052 |
+
* @return bool
|
2053 |
+
*/
|
2054 |
+
function is_restricted_term( $term_id, $on_term_page = false ) {
|
2055 |
+
static $cache = array();
|
2056 |
+
|
2057 |
+
if ( isset( $cache[ $term_id ] ) ) {
|
2058 |
+
return $cache[ $term_id ];
|
2059 |
+
}
|
2060 |
+
|
2061 |
+
if ( current_user_can( 'administrator' ) ) {
|
2062 |
+
$cache[ $term_id ] = false;
|
2063 |
+
return false;
|
2064 |
+
}
|
2065 |
+
|
2066 |
+
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
2067 |
+
if ( empty( $restricted_taxonomies ) ) {
|
2068 |
+
$cache[ $term_id ] = false;
|
2069 |
+
return false;
|
2070 |
+
}
|
2071 |
+
|
2072 |
+
$term = get_term( $term_id );
|
2073 |
+
if ( empty( $term->taxonomy ) || empty( $restricted_taxonomies[ $term->taxonomy ] ) ) {
|
2074 |
+
$cache[ $term_id ] = false;
|
2075 |
+
return false;
|
2076 |
+
}
|
2077 |
+
|
2078 |
+
$restricted = true;
|
2079 |
+
|
2080 |
+
// $this->allow_access = true only in case if the
|
2081 |
+
|
2082 |
+
$restriction = get_term_meta( $term_id, 'um_content_restriction', true );
|
2083 |
+
if ( empty( $restriction ) ) {
|
2084 |
+
$restricted = false;
|
2085 |
+
} else {
|
2086 |
+
if ( empty( $restriction['_um_custom_access_settings'] ) ) {
|
2087 |
+
$restricted = false;
|
2088 |
+
} else {
|
2089 |
+
if ( '0' == $restriction['_um_accessible'] ) {
|
2090 |
+
//term is private
|
2091 |
+
$restricted = false;
|
2092 |
+
if ( $on_term_page ) {
|
2093 |
+
$this->allow_access = true;
|
2094 |
+
}
|
2095 |
+
} elseif ( '1' == $restriction['_um_accessible'] ) {
|
2096 |
+
//if term for not logged in users and user is not logged in
|
2097 |
+
if ( ! is_user_logged_in() ) {
|
2098 |
+
$restricted = false;
|
2099 |
+
if ( $on_term_page ) {
|
2100 |
+
$this->allow_access = true;
|
2101 |
+
}
|
2102 |
+
}
|
2103 |
+
} elseif ( '2' == $restriction['_um_accessible'] ) {
|
2104 |
+
//if term for logged in users and user is not logged in
|
2105 |
+
if ( is_user_logged_in() ) {
|
2106 |
+
$custom_restrict = $this->um_custom_restriction( $restriction );
|
2107 |
+
|
2108 |
+
if ( empty( $restriction['_um_access_roles'] ) || false === array_search( '1', $restriction['_um_access_roles'] ) ) {
|
2109 |
+
if ( $custom_restrict ) {
|
2110 |
+
$restricted = false;
|
2111 |
+
if ( $on_term_page ) {
|
2112 |
+
$this->allow_access = true;
|
2113 |
+
}
|
2114 |
+
}
|
2115 |
+
} else {
|
2116 |
+
$user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] );
|
2117 |
+
|
2118 |
+
if ( $user_can && $custom_restrict ) {
|
2119 |
+
$restricted = false;
|
2120 |
+
if ( $on_term_page ) {
|
2121 |
+
$this->allow_access = true;
|
2122 |
+
}
|
2123 |
+
}
|
2124 |
+
}
|
2125 |
+
}
|
2126 |
+
}
|
2127 |
+
}
|
2128 |
+
}
|
2129 |
+
|
2130 |
+
$restricted = apply_filters( 'um_is_restricted_term', $restricted, $term_id, $on_term_page );
|
2131 |
+
|
2132 |
+
$cache[ $term_id ] = $restricted;
|
2133 |
+
return $restricted;
|
2134 |
+
}
|
2135 |
+
}
|
2136 |
+
}
|
includes/core/class-builtin.php
CHANGED
@@ -1,1976 +1,1976 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\core;
|
3 |
-
|
4 |
-
// Exit if accessed directly
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
if ( ! class_exists( 'um\core\Builtin' ) ) {
|
8 |
-
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class Builtin
|
12 |
-
* @package um\core
|
13 |
-
*/
|
14 |
-
class Builtin {
|
15 |
-
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @var array
|
19 |
-
*/
|
20 |
-
public $predefined_fields = array();
|
21 |
-
|
22 |
-
|
23 |
-
/**
|
24 |
-
* @var array
|
25 |
-
*/
|
26 |
-
var $all_user_fields = array();
|
27 |
-
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @var array
|
31 |
-
*/
|
32 |
-
var $core_fields = array();
|
33 |
-
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Builtin constructor.
|
37 |
-
*/
|
38 |
-
function __construct() {
|
39 |
-
add_action( 'init', array( &$this, 'set_core_fields' ), 1 );
|
40 |
-
add_action( 'init', array( &$this, 'set_predefined_fields' ), 1 );
|
41 |
-
add_action( 'init', array( &$this, 'set_custom_fields' ), 1 );
|
42 |
-
$this->saved_fields = get_option( 'um_fields' );
|
43 |
-
}
|
44 |
-
|
45 |
-
|
46 |
-
/**
|
47 |
-
* @return array
|
48 |
-
*/
|
49 |
-
function get_all_user_fields() {
|
50 |
-
return apply_filters( 'um_builtin_all_user_fields', $this->all_user_fields );
|
51 |
-
}
|
52 |
-
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Regular or multi-select/options
|
56 |
-
*
|
57 |
-
* @param $field
|
58 |
-
* @param $attrs
|
59 |
-
*
|
60 |
-
* @return bool
|
61 |
-
*/
|
62 |
-
function is_dropdown_field( $field, $attrs ) {
|
63 |
-
|
64 |
-
if ( isset( $attrs['options'] ) ) {
|
65 |
-
return true;
|
66 |
-
}
|
67 |
-
|
68 |
-
$fields = $this->all_user_fields;
|
69 |
-
|
70 |
-
if ( isset( $fields[$field]['options'] ) || ! empty( $fields[$field]['custom_dropdown_options_source'] ) ) {
|
71 |
-
return true;
|
72 |
-
}
|
73 |
-
|
74 |
-
return false;
|
75 |
-
}
|
76 |
-
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Get a field
|
80 |
-
*
|
81 |
-
* @param $field
|
82 |
-
*
|
83 |
-
* @return mixed|string
|
84 |
-
*/
|
85 |
-
function get_a_field( $field ) {
|
86 |
-
$fields = $this->all_user_fields;
|
87 |
-
if ( isset( $fields[ $field ] ) ) {
|
88 |
-
return $fields[ $field ];
|
89 |
-
}
|
90 |
-
return '';
|
91 |
-
}
|
92 |
-
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Get specific fields
|
96 |
-
*
|
97 |
-
* @param $fields
|
98 |
-
*
|
99 |
-
* @return array
|
100 |
-
*/
|
101 |
-
function get_specific_fields( $fields ) {
|
102 |
-
$fields = explode( ',', $fields );
|
103 |
-
$array = array();
|
104 |
-
foreach ( $fields as $field ) {
|
105 |
-
if ( isset( $this->predefined_fields[ $field ] ) ) {
|
106 |
-
$array[ $field ] = $this->predefined_fields[ $field ];
|
107 |
-
}
|
108 |
-
}
|
109 |
-
return $array;
|
110 |
-
}
|
111 |
-
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Get specific field
|
115 |
-
*
|
116 |
-
* @param $fields
|
117 |
-
*
|
118 |
-
* @return array|mixed
|
119 |
-
*/
|
120 |
-
function get_specific_field( $fields ) {
|
121 |
-
$fields = explode( ',', $fields );
|
122 |
-
$array = array();
|
123 |
-
foreach ( $fields as $field ) {
|
124 |
-
if ( isset( $this->predefined_fields[ $field ] ) ) {
|
125 |
-
$array = $this->predefined_fields[ $field ];
|
126 |
-
} elseif ( isset( $this->saved_fields[ $field ] ) ) {
|
127 |
-
$array = $this->saved_fields[ $field ];
|
128 |
-
}
|
129 |
-
}
|
130 |
-
return $array;
|
131 |
-
}
|
132 |
-
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Checks for a unique field error
|
136 |
-
*
|
137 |
-
* @param $key
|
138 |
-
*
|
139 |
-
* @return int|string
|
140 |
-
*/
|
141 |
-
function unique_field_err( $key ) {
|
142 |
-
if ( empty( $key ) ) {
|
143 |
-
return __( 'Please provide a meta key', 'ultimate-member' );
|
144 |
-
}
|
145 |
-
if ( isset( $this->core_fields[ $key ] ) ) {
|
146 |
-
return __( 'Your meta key is a reserved core field and cannot be used', 'ultimate-member' );
|
147 |
-
}
|
148 |
-
if ( isset( $this->predefined_fields[ $key ] ) ) {
|
149 |
-
return __( 'Your meta key is a predefined reserved key and cannot be used', 'ultimate-member' );
|
150 |
-
}
|
151 |
-
if ( isset( $this->saved_fields[ $key ] ) ) {
|
152 |
-
return __( 'Your meta key already exists in your fields list', 'ultimate-member' );
|
153 |
-
}
|
154 |
-
if ( ! UM()->validation()->safe_string( $key ) ) {
|
155 |
-
return __( 'Your meta key contains illegal characters. Please correct it.', 'ultimate-member' );
|
156 |
-
}
|
157 |
-
|
158 |
-
return 0;
|
159 |
-
}
|
160 |
-
|
161 |
-
|
162 |
-
/**
|
163 |
-
* Check date range errors (start date)
|
164 |
-
*
|
165 |
-
* @param $date
|
166 |
-
*
|
167 |
-
* @return int|string
|
168 |
-
*/
|
169 |
-
function date_range_start_err( $date ) {
|
170 |
-
if ( empty( $date ) ) {
|
171 |
-
return __( 'Please provide a date range beginning', 'ultimate-member' );
|
172 |
-
}
|
173 |
-
if ( ! UM()->validation()->validate_date( $date ) ) {
|
174 |
-
return __( 'Please enter a valid start date in the date range', 'ultimate-member' );
|
175 |
-
}
|
176 |
-
|
177 |
-
return 0;
|
178 |
-
}
|
179 |
-
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Check date range errors (end date)
|
183 |
-
*
|
184 |
-
* @param $date
|
185 |
-
* @param $start_date
|
186 |
-
*
|
187 |
-
* @return int|string
|
188 |
-
*/
|
189 |
-
function date_range_end_err( $date, $start_date ) {
|
190 |
-
if ( empty( $date ) ) {
|
191 |
-
return __( 'Please provide a date range end', 'ultimate-member' );
|
192 |
-
}
|
193 |
-
if ( ! UM()->validation()->validate_date( $date ) ) {
|
194 |
-
return __( 'Please enter a valid end date in the date range', 'ultimate-member' );
|
195 |
-
}
|
196 |
-
if ( strtotime( $date ) <= strtotime( $start_date ) ) {
|
197 |
-
return __( 'The end of date range must be greater than the start of date range', 'ultimate-member' );
|
198 |
-
}
|
199 |
-
return 0;
|
200 |
-
}
|
201 |
-
|
202 |
-
|
203 |
-
/**
|
204 |
-
* Get a core field attrs
|
205 |
-
*
|
206 |
-
* @param $type
|
207 |
-
*
|
208 |
-
* @return array|mixed
|
209 |
-
*/
|
210 |
-
function get_core_field_attrs( $type ) {
|
211 |
-
return ( isset( $this->core_fields[ $type ] ) ) ? $this->core_fields[ $type ] : array('');
|
212 |
-
}
|
213 |
-
|
214 |
-
|
215 |
-
/**
|
216 |
-
* Core Fields
|
217 |
-
*/
|
218 |
-
function set_core_fields() {
|
219 |
-
|
220 |
-
$this->core_fields = array(
|
221 |
-
|
222 |
-
'row' => array(
|
223 |
-
'name' => 'Row',
|
224 |
-
'in_fields' => false,
|
225 |
-
'form_only' => true,
|
226 |
-
'conditional_support' => 0,
|
227 |
-
'icon' => 'um-faicon-pencil',
|
228 |
-
'col1' => array('_id','_background','_text_color','_padding','_margin','_border','_borderradius','_borderstyle','_bordercolor'),
|
229 |
-
'col2' => array('_heading','_heading_text','_heading_background_color','_heading_text_color','_icon','_icon_color','_css_class'),
|
230 |
-
),
|
231 |
-
|
232 |
-
'text' => array(
|
233 |
-
'name' => 'Text Box',
|
234 |
-
'col1' => array('_title','_metakey','_help','_default','_min_chars','_visibility'),
|
235 |
-
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate','_max_chars'),
|
236 |
-
'col3' => array('_required','_editable','_icon'),
|
237 |
-
'validate' => array(
|
238 |
-
'_title' => array(
|
239 |
-
'mode' => 'required',
|
240 |
-
'error' => __('You must provide a title','ultimate-member')
|
241 |
-
),
|
242 |
-
'_metakey' => array(
|
243 |
-
'mode' => 'unique',
|
244 |
-
),
|
245 |
-
)
|
246 |
-
),
|
247 |
-
|
248 |
-
'number' => array(
|
249 |
-
'name' => __('Number','ultimate-member'),
|
250 |
-
'col1' => array('_title','_metakey','_help','_default','_min','_visibility'),
|
251 |
-
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate','_max'),
|
252 |
-
'col3' => array('_required','_editable','_icon'),
|
253 |
-
'validate' => array(
|
254 |
-
'_title' => array(
|
255 |
-
'mode' => 'required',
|
256 |
-
'error' => __('You must provide a title','ultimate-member')
|
257 |
-
),
|
258 |
-
'_metakey' => array(
|
259 |
-
'mode' => 'unique',
|
260 |
-
),
|
261 |
-
)
|
262 |
-
),
|
263 |
-
|
264 |
-
'textarea' => array(
|
265 |
-
'name' => 'Textarea',
|
266 |
-
'col1' => array('_title','_metakey','_help','_height','_max_chars','_max_words','_visibility'),
|
267 |
-
'col2' => array('_label','_placeholder','_public','_roles','_default','_html'),
|
268 |
-
'col3' => array('_required','_editable','_icon'),
|
269 |
-
'validate' => array(
|
270 |
-
'_title' => array(
|
271 |
-
'mode' => 'required',
|
272 |
-
'error' => __('You must provide a title','ultimate-member')
|
273 |
-
),
|
274 |
-
'_metakey' => array(
|
275 |
-
'mode' => 'unique',
|
276 |
-
),
|
277 |
-
)
|
278 |
-
),
|
279 |
-
|
280 |
-
'select' => array(
|
281 |
-
'name' => 'Dropdown',
|
282 |
-
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
283 |
-
'col2' => array('_label','_placeholder','_public','_roles','_custom_dropdown_options_source','_parent_dropdown_relationship'),
|
284 |
-
'col3' => array('_required','_editable','_icon'),
|
285 |
-
'validate' => array(
|
286 |
-
'_title' => array(
|
287 |
-
'mode' => 'required',
|
288 |
-
'error' => __('You must provide a title','ultimate-member')
|
289 |
-
),
|
290 |
-
'_metakey' => array(
|
291 |
-
'mode' => 'unique',
|
292 |
-
),
|
293 |
-
'_options' => array(
|
294 |
-
'mode' => 'required',
|
295 |
-
'error' => __('You have not added any choices yet.','ultimate-member')
|
296 |
-
),
|
297 |
-
)
|
298 |
-
),
|
299 |
-
|
300 |
-
'multiselect' => array(
|
301 |
-
'name' => 'Multi-Select',
|
302 |
-
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
303 |
-
'col2' => array('_label','_placeholder','_public','_roles','_min_selections','_max_selections','_custom_dropdown_options_source'),
|
304 |
-
'col3' => array('_required','_editable','_icon'),
|
305 |
-
'validate' => array(
|
306 |
-
'_title' => array(
|
307 |
-
'mode' => 'required',
|
308 |
-
'error' => __('You must provide a title','ultimate-member')
|
309 |
-
),
|
310 |
-
'_metakey' => array(
|
311 |
-
'mode' => 'unique',
|
312 |
-
),
|
313 |
-
'_options' => array(
|
314 |
-
'mode' => 'required',
|
315 |
-
'error' => __('You have not added any choices yet.','ultimate-member')
|
316 |
-
),
|
317 |
-
)
|
318 |
-
),
|
319 |
-
|
320 |
-
'radio' => array(
|
321 |
-
'name' => 'Radio',
|
322 |
-
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
323 |
-
'col2' => array('_label','_public','_roles'),
|
324 |
-
'col3' => array('_required','_editable','_icon'),
|
325 |
-
'validate' => array(
|
326 |
-
'_title' => array(
|
327 |
-
'mode' => 'required',
|
328 |
-
'error' => __('You must provide a title','ultimate-member')
|
329 |
-
),
|
330 |
-
'_metakey' => array(
|
331 |
-
'mode' => 'unique',
|
332 |
-
),
|
333 |
-
'_options' => array(
|
334 |
-
'mode' => 'required',
|
335 |
-
'error' => __('You have not added any choices yet.','ultimate-member')
|
336 |
-
),
|
337 |
-
)
|
338 |
-
),
|
339 |
-
|
340 |
-
'checkbox' => array(
|
341 |
-
'name' => 'Checkbox',
|
342 |
-
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
343 |
-
'col2' => array('_label','_public','_roles','_max_selections'),
|
344 |
-
'col3' => array('_required','_editable','_icon'),
|
345 |
-
'validate' => array(
|
346 |
-
'_title' => array(
|
347 |
-
'mode' => 'required',
|
348 |
-
'error' => __('You must provide a title','ultimate-member')
|
349 |
-
),
|
350 |
-
'_metakey' => array(
|
351 |
-
'mode' => 'unique',
|
352 |
-
),
|
353 |
-
'_options' => array(
|
354 |
-
'mode' => 'required',
|
355 |
-
'error' => __('You have not added any choices yet.','ultimate-member')
|
356 |
-
),
|
357 |
-
)
|
358 |
-
),
|
359 |
-
|
360 |
-
'url' => array(
|
361 |
-
'name' => 'URL',
|
362 |
-
'col1' => array('_title','_metakey','_help','_default','_url_text','_visibility'),
|
363 |
-
'col2' => array('_label','_placeholder','_url_target','_url_rel','_public','_roles','_validate','_custom_validate'),
|
364 |
-
'col3' => array('_required','_editable','_icon'),
|
365 |
-
'validate' => array(
|
366 |
-
'_title' => array(
|
367 |
-
'mode' => 'required',
|
368 |
-
'error' => __('You must provide a title','ultimate-member')
|
369 |
-
),
|
370 |
-
'_metakey' => array(
|
371 |
-
'mode' => 'unique',
|
372 |
-
),
|
373 |
-
)
|
374 |
-
),
|
375 |
-
|
376 |
-
'password' => array(
|
377 |
-
'name' => 'Password',
|
378 |
-
'col1' => array('_title','_metakey','_help','_min_chars','_max_chars','_visibility'),
|
379 |
-
'col2' => array('_label','_placeholder','_public','_roles','_force_good_pass','_force_confirm_pass','_label_confirm_pass'),
|
380 |
-
'col3' => array('_required','_editable','_icon'),
|
381 |
-
'validate' => array(
|
382 |
-
'_title' => array(
|
383 |
-
'mode' => 'required',
|
384 |
-
'error' => __('You must provide a title','ultimate-member')
|
385 |
-
),
|
386 |
-
'_metakey' => array(
|
387 |
-
'mode' => 'unique',
|
388 |
-
),
|
389 |
-
)
|
390 |
-
),
|
391 |
-
|
392 |
-
'image' => array(
|
393 |
-
'name' => 'Image Upload',
|
394 |
-
'col1' => array('_title','_metakey','_help','_allowed_types','_max_size','_crop','_visibility'),
|
395 |
-
'col2' => array('_label','_public','_roles','_upload_text','_upload_help_text','_button_text'),
|
396 |
-
'col3' => array('_required','_editable','_icon'),
|
397 |
-
'validate' => array(
|
398 |
-
'_title' => array(
|
399 |
-
'mode' => 'required',
|
400 |
-
'error' => __('You must provide a title','ultimate-member')
|
401 |
-
),
|
402 |
-
'_metakey' => array(
|
403 |
-
'mode' => 'unique',
|
404 |
-
),
|
405 |
-
'_max_size' => array(
|
406 |
-
'mode' => 'numeric',
|
407 |
-
'error' => __('Please enter a valid size','ultimate-member')
|
408 |
-
),
|
409 |
-
)
|
410 |
-
),
|
411 |
-
|
412 |
-
'file' => array(
|
413 |
-
'name' => 'File Upload',
|
414 |
-
'col1' => array('_title','_metakey','_help','_allowed_types','_max_size','_visibility'),
|
415 |
-
'col2' => array('_label','_public','_roles','_upload_text','_upload_help_text','_button_text'),
|
416 |
-
'col3' => array('_required','_editable','_icon'),
|
417 |
-
'validate' => array(
|
418 |
-
'_title' => array(
|
419 |
-
'mode' => 'required',
|
420 |
-
'error' => __('You must provide a title','ultimate-member')
|
421 |
-
),
|
422 |
-
'_metakey' => array(
|
423 |
-
'mode' => 'unique',
|
424 |
-
),
|
425 |
-
'_max_size' => array(
|
426 |
-
'mode' => 'numeric',
|
427 |
-
'error' => __( 'Please enter a valid size', 'ultimate-member' )
|
428 |
-
),
|
429 |
-
)
|
430 |
-
),
|
431 |
-
|
432 |
-
'date' => array(
|
433 |
-
'name' => 'Date Picker',
|
434 |
-
'col1' => array( '_title', '_metakey', '_help', '_default', '_range', '_years', '_years_x', '_range_start', '_range_end', '_visibility' ),
|
435 |
-
'col2' => array( '_label', '_placeholder', '_public', '_roles', '_format', '_format_custom', '_pretty_format', '_disabled_weekdays' ),
|
436 |
-
'col3' => array( '_required', '_editable', '_icon' ),
|
437 |
-
'validate' => array(
|
438 |
-
'_title' => array(
|
439 |
-
'mode' => 'required',
|
440 |
-
'error' => __( 'You must provide a title', 'ultimate-member' )
|
441 |
-
),
|
442 |
-
'_metakey' => array(
|
443 |
-
'mode' => 'unique',
|
444 |
-
),
|
445 |
-
'_years' => array(
|
446 |
-
'mode' => 'numeric',
|
447 |
-
'error' => __( 'Number of years is not valid', 'ultimate-member' )
|
448 |
-
),
|
449 |
-
'_range_start' => array(
|
450 |
-
'mode' => 'range-start',
|
451 |
-
),
|
452 |
-
'_range_end' => array(
|
453 |
-
'mode' => 'range-end',
|
454 |
-
),
|
455 |
-
)
|
456 |
-
),
|
457 |
-
|
458 |
-
'time' => array(
|
459 |
-
'name' => 'Time Picker',
|
460 |
-
'col1' => array('_title','_metakey','_help','_format','_visibility'),
|
461 |
-
'col2' => array('_label','_placeholder','_default','_public','_roles','_intervals'),
|
462 |
-
'col3' => array('_required','_editable','_icon'),
|
463 |
-
'validate' => array(
|
464 |
-
'_title' => array(
|
465 |
-
'mode' => 'required',
|
466 |
-
'error' => __( 'You must provide a title', 'ultimate-member' )
|
467 |
-
),
|
468 |
-
'_metakey' => array(
|
469 |
-
'mode' => 'unique',
|
470 |
-
),
|
471 |
-
)
|
472 |
-
),
|
473 |
-
|
474 |
-
'rating' => array(
|
475 |
-
'name' => 'Rating',
|
476 |
-
'col1' => array('_title','_metakey','_help','_visibility'),
|
477 |
-
'col2' => array('_label','_public','_roles','_number','_default'),
|
478 |
-
'col3' => array('_required','_editable','_icon'),
|
479 |
-
'validate' => array(
|
480 |
-
'_title' => array(
|
481 |
-
'mode' => 'required',
|
482 |
-
'error' => __('You must provide a title','ultimate-member')
|
483 |
-
),
|
484 |
-
'_metakey' => array(
|
485 |
-
'mode' => 'unique',
|
486 |
-
),
|
487 |
-
)
|
488 |
-
),
|
489 |
-
|
490 |
-
'block' => array(
|
491 |
-
'name' => 'Content Block',
|
492 |
-
'col1' => array('_title','_visibility'),
|
493 |
-
'col2' => array('_public','_roles'),
|
494 |
-
'col_full' => array('_content'),
|
495 |
-
'mce_content' => true,
|
496 |
-
'validate' => array(
|
497 |
-
'_title' => array(
|
498 |
-
'mode' => 'required',
|
499 |
-
'error' => __('You must provide a title','ultimate-member')
|
500 |
-
),
|
501 |
-
)
|
502 |
-
),
|
503 |
-
|
504 |
-
'shortcode' => array(
|
505 |
-
'name' => 'Shortcode',
|
506 |
-
'col1' => array('_title','_visibility'),
|
507 |
-
'col2' => array('_public','_roles'),
|
508 |
-
'col_full' => array('_content'),
|
509 |
-
'validate' => array(
|
510 |
-
'_title' => array(
|
511 |
-
'mode' => 'required',
|
512 |
-
'error' => __('You must provide a title','ultimate-member')
|
513 |
-
),
|
514 |
-
'_content' => array(
|
515 |
-
'mode' => 'required',
|
516 |
-
'error' => __('You must add a shortcode to the content area','ultimate-member')
|
517 |
-
),
|
518 |
-
)
|
519 |
-
),
|
520 |
-
|
521 |
-
'spacing' => array(
|
522 |
-
'name' => 'Spacing',
|
523 |
-
'col1' => array('_title','_visibility'),
|
524 |
-
'col2' => array('_spacing'),
|
525 |
-
'form_only' => true,
|
526 |
-
'validate' => array(
|
527 |
-
'_title' => array(
|
528 |
-
'mode' => 'required',
|
529 |
-
'error' => __('You must provide a title','ultimate-member')
|
530 |
-
),
|
531 |
-
)
|
532 |
-
),
|
533 |
-
|
534 |
-
'divider' => array(
|
535 |
-
'name' => 'Divider',
|
536 |
-
'col1' => array('_title','_width','_divider_text','_visibility'),
|
537 |
-
'col2' => array('_style','_color','_public','_roles'),
|
538 |
-
'form_only' => true,
|
539 |
-
'validate' => array(
|
540 |
-
'_title' => array(
|
541 |
-
'mode' => 'required',
|
542 |
-
'error' => __('You must provide a title','ultimate-member')
|
543 |
-
),
|
544 |
-
)
|
545 |
-
),
|
546 |
-
|
547 |
-
'googlemap' => array(
|
548 |
-
'name' => 'Google Map',
|
549 |
-
'col1' => array('_title','_metakey','_help','_visibility'),
|
550 |
-
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
551 |
-
'col3' => array('_required','_editable','_icon'),
|
552 |
-
'validate' => array(
|
553 |
-
'_title' => array(
|
554 |
-
'mode' => 'required',
|
555 |
-
'error' => __('You must provide a title','ultimate-member')
|
556 |
-
),
|
557 |
-
'_metakey' => array(
|
558 |
-
'mode' => 'unique',
|
559 |
-
),
|
560 |
-
)
|
561 |
-
),
|
562 |
-
|
563 |
-
'youtube_video' => array(
|
564 |
-
'name' => 'YouTube Video',
|
565 |
-
'col1' => array('_title','_metakey','_help','_visibility'),
|
566 |
-
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
567 |
-
'col3' => array('_required','_editable','_icon'),
|
568 |
-
'validate' => array(
|
569 |
-
'_title' => array(
|
570 |
-
'mode' => 'required',
|
571 |
-
'error' => __('You must provide a title','ultimate-member')
|
572 |
-
),
|
573 |
-
'_metakey' => array(
|
574 |
-
'mode' => 'unique',
|
575 |
-
),
|
576 |
-
)
|
577 |
-
),
|
578 |
-
|
579 |
-
'vimeo_video' => array(
|
580 |
-
'name' => 'Vimeo Video',
|
581 |
-
'col1' => array('_title','_metakey','_help','_visibility'),
|
582 |
-
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
583 |
-
'col3' => array('_required','_editable','_icon'),
|
584 |
-
'validate' => array(
|
585 |
-
'_title' => array(
|
586 |
-
'mode' => 'required',
|
587 |
-
'error' => __('You must provide a title','ultimate-member')
|
588 |
-
),
|
589 |
-
'_metakey' => array(
|
590 |
-
'mode' => 'unique',
|
591 |
-
),
|
592 |
-
)
|
593 |
-
),
|
594 |
-
|
595 |
-
'soundcloud_track' => array(
|
596 |
-
'name' => 'SoundCloud Track',
|
597 |
-
'col1' => array('_title','_metakey','_help','_visibility'),
|
598 |
-
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
599 |
-
'col3' => array('_required','_editable','_icon'),
|
600 |
-
'validate' => array(
|
601 |
-
'_title' => array(
|
602 |
-
'mode' => 'required',
|
603 |
-
'error' => __('You must provide a title','ultimate-member')
|
604 |
-
),
|
605 |
-
'_metakey' => array(
|
606 |
-
'mode' => 'unique',
|
607 |
-
),
|
608 |
-
)
|
609 |
-
),
|
610 |
-
|
611 |
-
/*'group' => array(
|
612 |
-
'name' => 'Field Group',
|
613 |
-
'col1' => array('_title','_max_entries'),
|
614 |
-
'col2' => array('_label','_public','_roles'),
|
615 |
-
'form_only' => true,
|
616 |
-
'validate' => array(
|
617 |
-
'_title' => array(
|
618 |
-
'mode' => 'required',
|
619 |
-
'error' => 'You must provide a title'
|
620 |
-
),
|
621 |
-
'_label' => array(
|
622 |
-
'mode' => 'required',
|
623 |
-
'error' => 'You must provide a label'
|
624 |
-
),
|
625 |
-
)
|
626 |
-
),*/
|
627 |
-
|
628 |
-
);
|
629 |
-
|
630 |
-
/**
|
631 |
-
* UM hook
|
632 |
-
*
|
633 |
-
* @type filter
|
634 |
-
* @title um_core_fields_hook
|
635 |
-
* @description UM Core Fields
|
636 |
-
* @input_vars
|
637 |
-
* [{"var":"$core_fields","type":"array","desc":"Core Fields"}]
|
638 |
-
* @change_log
|
639 |
-
* ["Since: 2.0"]
|
640 |
-
* @usage add_filter( 'um_core_fields_hook', 'function_name', 10, 1 );
|
641 |
-
* @example
|
642 |
-
* <?php
|
643 |
-
* add_filter( 'um_core_fields_hook', 'my_core_fields', 10, 1 );
|
644 |
-
* function my_core_fields( $core_fields ) {
|
645 |
-
* // your code here
|
646 |
-
* return $core_fields;
|
647 |
-
* }
|
648 |
-
* ?>
|
649 |
-
*/
|
650 |
-
$this->core_fields = apply_filters( 'um_core_fields_hook', $this->core_fields );
|
651 |
-
}
|
652 |
-
|
653 |
-
|
654 |
-
/**
|
655 |
-
* Predefined Fields
|
656 |
-
*/
|
657 |
-
function set_predefined_fields() {
|
658 |
-
global $wp_roles;
|
659 |
-
|
660 |
-
$um_roles = array();
|
661 |
-
if ( ! empty( $wp_roles->roles ) ) {
|
662 |
-
$role_keys = get_option( 'um_roles', array() );
|
663 |
-
if ( ! empty( $role_keys ) && is_array( $role_keys ) ) {
|
664 |
-
$role_keys = array_map( function( $item ) {
|
665 |
-
return 'um_' . $item;
|
666 |
-
}, $role_keys );
|
667 |
-
} else {
|
668 |
-
$role_keys = array();
|
669 |
-
}
|
670 |
-
|
671 |
-
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
672 |
-
$um_roles = UM()->roles()->get_roles( false, $exclude_roles );
|
673 |
-
}
|
674 |
-
|
675 |
-
/**
|
676 |
-
* UM hook
|
677 |
-
*
|
678 |
-
* @type filter
|
679 |
-
* @title um_profile_privacy_options
|
680 |
-
* @description Profile Privacy Options
|
681 |
-
* @input_vars
|
682 |
-
* [{"var":"$privacy_options","type":"array","desc":"Privacy Options"}]
|
683 |
-
* @change_log
|
684 |
-
* ["Since: 2.0"]
|
685 |
-
* @usage add_filter( 'um_profile_privacy_options', 'function_name', 10, 1 );
|
686 |
-
* @example
|
687 |
-
* <?php
|
688 |
-
* add_filter( 'um_profile_privacy_options', 'my_profile_privacy_options', 10, 1 );
|
689 |
-
* function my_profile_privacy_options( $privacy_options ) {
|
690 |
-
* // your code here
|
691 |
-
* return $privacy_options;
|
692 |
-
* }
|
693 |
-
* ?>
|
694 |
-
*/
|
695 |
-
$profile_privacy = apply_filters( 'um_profile_privacy_options', array(
|
696 |
-
'Everyone' => __( 'Everyone', 'ultimate-member' ),
|
697 |
-
'Only me' => __( 'Only me', 'ultimate-member' )
|
698 |
-
) );
|
699 |
-
|
700 |
-
/*
|
701 |
-
* it's important create key for array equals value of 'metakey'.
|
702 |
-
*
|
703 |
-
*/
|
704 |
-
|
705 |
-
$this->predefined_fields = array(
|
706 |
-
|
707 |
-
'user_login' => array(
|
708 |
-
'title' => __('Username','ultimate-member'),
|
709 |
-
'metakey' => 'user_login',
|
710 |
-
'type' => 'text',
|
711 |
-
'label' => __('Username','ultimate-member'),
|
712 |
-
'required' => 1,
|
713 |
-
'public' => 1,
|
714 |
-
'editable' => 0,
|
715 |
-
'validate' => 'unique_username',
|
716 |
-
'min_chars' => 3,
|
717 |
-
'max_chars' => 24
|
718 |
-
),
|
719 |
-
|
720 |
-
'username' => array(
|
721 |
-
'title' => __('Username or E-mail','ultimate-member'),
|
722 |
-
'metakey' => 'username',
|
723 |
-
'type' => 'text',
|
724 |
-
'label' => __('Username or E-mail','ultimate-member'),
|
725 |
-
'required' => 1,
|
726 |
-
'public' => 1,
|
727 |
-
'editable' => 0,
|
728 |
-
'validate' => 'unique_username_or_email',
|
729 |
-
),
|
730 |
-
|
731 |
-
'user_password' => array(
|
732 |
-
'title' => __('Password','ultimate-member'),
|
733 |
-
'metakey' => 'user_password',
|
734 |
-
'type' => 'password',
|
735 |
-
'label' => __('Password','ultimate-member'),
|
736 |
-
'required' => 1,
|
737 |
-
'public' => 1,
|
738 |
-
'editable' => 1,
|
739 |
-
'min_chars' => 8,
|
740 |
-
'max_chars' => 30,
|
741 |
-
'force_good_pass' => 1,
|
742 |
-
'force_confirm_pass' => 1,
|
743 |
-
'label_confirm_pass' => __('Confirm Password','ultimate-member')
|
744 |
-
),
|
745 |
-
|
746 |
-
'first_name' => array(
|
747 |
-
'title' => __('First Name','ultimate-member'),
|
748 |
-
'metakey' => 'first_name',
|
749 |
-
'type' => 'text',
|
750 |
-
'label' => __('First Name','ultimate-member'),
|
751 |
-
'required' => 0,
|
752 |
-
'public' => 1,
|
753 |
-
'editable' => 1,
|
754 |
-
),
|
755 |
-
|
756 |
-
'last_name' => array(
|
757 |
-
'title' => __('Last Name','ultimate-member'),
|
758 |
-
'metakey' => 'last_name',
|
759 |
-
'type' => 'text',
|
760 |
-
'label' => __('Last Name','ultimate-member'),
|
761 |
-
'required' => 0,
|
762 |
-
'public' => 1,
|
763 |
-
'editable' => 1,
|
764 |
-
),
|
765 |
-
|
766 |
-
'nickname' => array(
|
767 |
-
'title' => __('Nickname','ultimate-member'),
|
768 |
-
'metakey' => 'nickname',
|
769 |
-
'type' => 'text',
|
770 |
-
'label' => __('Nickname','ultimate-member'),
|
771 |
-
'required' => 0,
|
772 |
-
'public' => 1,
|
773 |
-
'editable' => 1,
|
774 |
-
),
|
775 |
-
|
776 |
-
'user_url' => array(
|
777 |
-
'title' => __('Website URL','ultimate-member'),
|
778 |
-
'metakey' => 'user_url',
|
779 |
-
'type' => 'url',
|
780 |
-
'label' => __('Website URL','ultimate-member'),
|
781 |
-
'required' => 1,
|
782 |
-
'public' => 1,
|
783 |
-
'editable' => 1,
|
784 |
-
'validate' => 'url'
|
785 |
-
),
|
786 |
-
|
787 |
-
'user_registered' => array(
|
788 |
-
'title' => __('Registration Date','ultimate-member'),
|
789 |
-
'metakey' => 'user_registered',
|
790 |
-
'type' => 'text',
|
791 |
-
'label' => __('Registration Date','ultimate-member'),
|
792 |
-
'required' => 0,
|
793 |
-
'public' => 1,
|
794 |
-
'editable' => 1,
|
795 |
-
'edit_forbidden' => 1,
|
796 |
-
),
|
797 |
-
|
798 |
-
'_um_last_login' => array(
|
799 |
-
'title' => __('Last Login','ultimate-member'),
|
800 |
-
'metakey' => '_um_last_login',
|
801 |
-
'type' => 'text',
|
802 |
-
'label' => __('Last Login','ultimate-member'),
|
803 |
-
'required' => 0,
|
804 |
-
'public' => 1,
|
805 |
-
'editable' => 1,
|
806 |
-
'edit_forbidden' => 1,
|
807 |
-
),
|
808 |
-
|
809 |
-
'user_email' => array(
|
810 |
-
'title' => __('E-mail Address','ultimate-member'),
|
811 |
-
'metakey' => 'user_email',
|
812 |
-
'type' => 'text',
|
813 |
-
'label' => __('E-mail Address','ultimate-member'),
|
814 |
-
'required' => 0,
|
815 |
-
'public' => 1,
|
816 |
-
'validate' => 'unique_email',
|
817 |
-
'autocomplete' => 'off'
|
818 |
-
),
|
819 |
-
|
820 |
-
'secondary_user_email' => array(
|
821 |
-
'title' => __('Secondary E-mail Address','ultimate-member'),
|
822 |
-
'metakey' => 'secondary_user_email',
|
823 |
-
'type' => 'text',
|
824 |
-
'label' => __('Secondary E-mail Address','ultimate-member'),
|
825 |
-
'required' => 0,
|
826 |
-
'public' => 1,
|
827 |
-
'editable' => 1,
|
828 |
-
'validate' => 'unique_email',
|
829 |
-
'autocomplete' => 'off'
|
830 |
-
),
|
831 |
-
|
832 |
-
'description' => array(
|
833 |
-
'title' => __('Biography','ultimate-member'),
|
834 |
-
'metakey' => 'description',
|
835 |
-
'type' => 'textarea',
|
836 |
-
'label' => __('Biography','ultimate-member'),
|
837 |
-
'html' => 0,
|
838 |
-
'required' => 0,
|
839 |
-
'public' => 1,
|
840 |
-
'editable' => 1,
|
841 |
-
'max_words' => 40,
|
842 |
-
'placeholder' => __('Enter a bit about yourself...','ultimate-member'),
|
843 |
-
),
|
844 |
-
|
845 |
-
'birth_date' => array(
|
846 |
-
'title' => __('Birth Date','ultimate-member'),
|
847 |
-
'metakey' => 'birth_date',
|
848 |
-
'type' => 'date',
|
849 |
-
'label' => __('Birth Date','ultimate-member'),
|
850 |
-
'required' => 0,
|
851 |
-
'public' => 1,
|
852 |
-
'editable' => 1,
|
853 |
-
'pretty_format' => 1,
|
854 |
-
'years' => 115,
|
855 |
-
'years_x' => 'past',
|
856 |
-
'icon' => 'um-faicon-calendar'
|
857 |
-
),
|
858 |
-
|
859 |
-
'gender' => array(
|
860 |
-
'title' => __('Gender','ultimate-member'),
|
861 |
-
'metakey' => 'gender',
|
862 |
-
'type' => 'radio',
|
863 |
-
'label' => __('Gender','ultimate-member'),
|
864 |
-
'required' => 0,
|
865 |
-
'public' => 1,
|
866 |
-
'editable' => 1,
|
867 |
-
'options' => array( __('Male','ultimate-member'), __('Female','ultimate-member') )
|
868 |
-
),
|
869 |
-
|
870 |
-
'country' => array(
|
871 |
-
'title' => __('Country','ultimate-member'),
|
872 |
-
'metakey' => 'country',
|
873 |
-
'type' => 'select',
|
874 |
-
'label' => __('Country','ultimate-member'),
|
875 |
-
'placeholder' => __('Choose a Country','ultimate-member'),
|
876 |
-
'required' => 0,
|
877 |
-
'public' => 1,
|
878 |
-
'editable' => 1,
|
879 |
-
'options' => $this->get('countries')
|
880 |
-
),
|
881 |
-
|
882 |
-
'facebook' => array(
|
883 |
-
'title' => __('Facebook','ultimate-member'),
|
884 |
-
'metakey' => 'facebook',
|
885 |
-
'type' => 'url',
|
886 |
-
'label' => __('Facebook','ultimate-member'),
|
887 |
-
'required' => 0,
|
888 |
-
'public' => 1,
|
889 |
-
'editable' => 1,
|
890 |
-
'url_target' => '_blank',
|
891 |
-
'url_rel' => 'nofollow',
|
892 |
-
'icon' => 'um-faicon-facebook',
|
893 |
-
'validate' => 'facebook_url',
|
894 |
-
'url_text' => 'Facebook',
|
895 |
-
'advanced' => 'social',
|
896 |
-
'color' => '#3B5999',
|
897 |
-
'match' => 'https://facebook.com/',
|
898 |
-
),
|
899 |
-
|
900 |
-
'twitter' => array(
|
901 |
-
'title' => __('Twitter','ultimate-member'),
|
902 |
-
'metakey' => 'twitter',
|
903 |
-
'type' => 'url',
|
904 |
-
'label' => __('Twitter','ultimate-member'),
|
905 |
-
'required' => 0,
|
906 |
-
'public' => 1,
|
907 |
-
'editable' => 1,
|
908 |
-
'url_target' => '_blank',
|
909 |
-
'url_rel' => 'nofollow',
|
910 |
-
'icon' => 'um-faicon-twitter',
|
911 |
-
'validate' => 'twitter_url',
|
912 |
-
'url_text' => 'Twitter',
|
913 |
-
'advanced' => 'social',
|
914 |
-
'color' => '#4099FF',
|
915 |
-
'match' => 'https://twitter.com/',
|
916 |
-
),
|
917 |
-
|
918 |
-
'linkedin' => array(
|
919 |
-
'title' => __('LinkedIn','ultimate-member'),
|
920 |
-
'metakey' => 'linkedin',
|
921 |
-
'type' => 'url',
|
922 |
-
'label' => __('LinkedIn','ultimate-member'),
|
923 |
-
'required' => 0,
|
924 |
-
'public' => 1,
|
925 |
-
'editable' => 1,
|
926 |
-
'url_target' => '_blank',
|
927 |
-
'url_rel' => 'nofollow',
|
928 |
-
'icon' => 'um-faicon-linkedin',
|
929 |
-
'validate' => 'linkedin_url',
|
930 |
-
'url_text' => 'LinkedIn',
|
931 |
-
'advanced' => 'social',
|
932 |
-
'color' => '#0976b4',
|
933 |
-
'match' => 'https://linkedin.com/',
|
934 |
-
),
|
935 |
-
|
936 |
-
'googleplus' => array(
|
937 |
-
'title' => __('Google+','ultimate-member'),
|
938 |
-
'metakey' => 'googleplus',
|
939 |
-
'type' => 'url',
|
940 |
-
'label' => __('Google+','ultimate-member'),
|
941 |
-
'required' => 0,
|
942 |
-
'public' => 1,
|
943 |
-
'editable' => 1,
|
944 |
-
'url_target' => '_blank',
|
945 |
-
'url_rel' => 'nofollow',
|
946 |
-
'icon' => 'um-faicon-google-plus',
|
947 |
-
'validate' => 'google_url',
|
948 |
-
'url_text' => 'Google+',
|
949 |
-
'advanced' => 'social',
|
950 |
-
'color' => '#dd4b39',
|
951 |
-
'match' => 'https://google.com/+',
|
952 |
-
),
|
953 |
-
|
954 |
-
'instagram' => array(
|
955 |
-
'title' => __('Instagram','ultimate-member'),
|
956 |
-
'metakey' => 'instagram',
|
957 |
-
'type' => 'url',
|
958 |
-
'label' => __('Instagram','ultimate-member'),
|
959 |
-
'required' => 0,
|
960 |
-
'public' => 1,
|
961 |
-
'editable' => 1,
|
962 |
-
'url_target' => '_blank',
|
963 |
-
'url_rel' => 'nofollow',
|
964 |
-
'icon' => 'um-faicon-instagram',
|
965 |
-
'validate' => 'instagram_url',
|
966 |
-
'url_text' => 'Instagram',
|
967 |
-
'advanced' => 'social',
|
968 |
-
'color' => 'radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%,#d6249f 60%,#285AEB 90%)',
|
969 |
-
'match' => 'https://instagram.com/',
|
970 |
-
),
|
971 |
-
|
972 |
-
'skype' => array(
|
973 |
-
'title' => __('Skype ID','ultimate-member'),
|
974 |
-
'metakey' => 'skype',
|
975 |
-
'type' => 'text',
|
976 |
-
'label' => __('Skype ID','ultimate-member'),
|
977 |
-
'required' => 0,
|
978 |
-
'public' => 1,
|
979 |
-
'editable' => 1,
|
980 |
-
'url_target' => '_blank',
|
981 |
-
'url_rel' => 'nofollow',
|
982 |
-
'icon' => 'um-faicon-skype',
|
983 |
-
'validate' => 'skype',
|
984 |
-
'url_text' => __( 'Join chat', 'ultimate-member' ),
|
985 |
-
),
|
986 |
-
|
987 |
-
'viber' => array(
|
988 |
-
'title' => __('Viber number','ultimate-member'),
|
989 |
-
'metakey' => 'viber',
|
990 |
-
'type' => 'text',
|
991 |
-
'label' => __('Viber number','ultimate-member'),
|
992 |
-
'required' => 0,
|
993 |
-
'public' => 1,
|
994 |
-
'editable' => 1,
|
995 |
-
'url_target' => '_blank',
|
996 |
-
'url_rel' => 'nofollow',
|
997 |
-
'icon' => 'um-icon-ios-telephone',
|
998 |
-
'validate' => 'phone_number',
|
999 |
-
),
|
1000 |
-
|
1001 |
-
'whatsapp' => array(
|
1002 |
-
'title' => __('WhatsApp number','ultimate-member'),
|
1003 |
-
'metakey' => 'whatsapp',
|
1004 |
-
'type' => 'text',
|
1005 |
-
'label' => __('WhatsApp number','ultimate-member'),
|
1006 |
-
'required' => 0,
|
1007 |
-
'public' => 1,
|
1008 |
-
'editable' => 1,
|
1009 |
-
'url_target' => '_blank',
|
1010 |
-
'url_rel' => 'nofollow',
|
1011 |
-
'icon' => 'um-icon-social-whatsapp',
|
1012 |
-
'validate' => 'phone_number',
|
1013 |
-
),
|
1014 |
-
|
1015 |
-
'telegram' => array(
|
1016 |
-
'title' => __('Telegram','ultimate-member'),
|
1017 |
-
'metakey' => 'telegram',
|
1018 |
-
'type' => 'url',
|
1019 |
-
'label' => __('Telegram','ultimate-member'),
|
1020 |
-
'required' => 0,
|
1021 |
-
'public' => 1,
|
1022 |
-
'editable' => 1,
|
1023 |
-
'url_target' => '_blank',
|
1024 |
-
'url_rel' => 'nofollow',
|
1025 |
-
'icon' => 'um-faicon-paper-plane',
|
1026 |
-
'validate' => 'telegram_url',
|
1027 |
-
'url_text' => 'Telegram',
|
1028 |
-
'match' => 'https://t.me/',
|
1029 |
-
),
|
1030 |
-
|
1031 |
-
'discord' => array(
|
1032 |
-
'title' => __('Discord','ultimate-member'),
|
1033 |
-
'metakey' => 'discord',
|
1034 |
-
'type' => 'text',
|
1035 |
-
'label' => __('Discord ID','ultimate-member'),
|
1036 |
-
'required' => 0,
|
1037 |
-
'public' => 1,
|
1038 |
-
'editable' => 1,
|
1039 |
-
'url_target' => '_blank',
|
1040 |
-
'url_rel' => 'nofollow',
|
1041 |
-
'validate' => 'discord',
|
1042 |
-
),
|
1043 |
-
|
1044 |
-
'youtube' => array(
|
1045 |
-
'title' => __('YouTube','ultimate-member'),
|
1046 |
-
'metakey' => 'youtube',
|
1047 |
-
'type' => 'url',
|
1048 |
-
'label' => __('YouTube','ultimate-member'),
|
1049 |
-
'required' => 0,
|
1050 |
-
'public' => 1,
|
1051 |
-
'editable' => 1,
|
1052 |
-
'url_target' => '_blank',
|
1053 |
-
'url_rel' => 'nofollow',
|
1054 |
-
'icon' => 'um-faicon-youtube',
|
1055 |
-
'validate' => 'youtube_url',
|
1056 |
-
'url_text' => 'YouTube',
|
1057 |
-
'advanced' => 'social',
|
1058 |
-
'color' => '#e52d27',
|
1059 |
-
'match' => 'https://youtube.com/',
|
1060 |
-
),
|
1061 |
-
|
1062 |
-
'soundcloud' => array(
|
1063 |
-
'title' => __( 'SoundCloud', 'ultimate-member' ),
|
1064 |
-
'metakey' => 'soundcloud',
|
1065 |
-
'type' => 'url',
|
1066 |
-
'label' => __( 'SoundCloud', 'ultimate-member' ),
|
1067 |
-
'required' => 0,
|
1068 |
-
'public' => 1,
|
1069 |
-
'editable' => 1,
|
1070 |
-
'url_target' => '_blank',
|
1071 |
-
'url_rel' => 'nofollow',
|
1072 |
-
'icon' => 'um-faicon-soundcloud',
|
1073 |
-
'validate' => 'soundcloud_url',
|
1074 |
-
'url_text' => 'SoundCloud',
|
1075 |
-
'advanced' => 'social',
|
1076 |
-
'color' => '#f50',
|
1077 |
-
'match' => 'https://soundcloud.com/',
|
1078 |
-
),
|
1079 |
-
|
1080 |
-
'vkontakte' => array(
|
1081 |
-
'title' => __('VKontakte','ultimate-member'),
|
1082 |
-
'metakey' => 'vkontakte',
|
1083 |
-
'type' => 'url',
|
1084 |
-
'label' => __('VKontakte','ultimate-member'),
|
1085 |
-
'required' => 0,
|
1086 |
-
'public' => 1,
|
1087 |
-
'editable' => 1,
|
1088 |
-
'url_target' => '_blank',
|
1089 |
-
'url_rel' => 'nofollow',
|
1090 |
-
'icon' => 'um-faicon-vk',
|
1091 |
-
'validate' => 'vk_url',
|
1092 |
-
'url_text' => 'VKontakte',
|
1093 |
-
'advanced' => 'social',
|
1094 |
-
'color' => '#2B587A',
|
1095 |
-
'match' => 'https://vk.com/',
|
1096 |
-
),
|
1097 |
-
|
1098 |
-
'role_select' => array(
|
1099 |
-
'title' => __('Roles (Dropdown)','ultimate-member'),
|
1100 |
-
'metakey' => 'role_select',
|
1101 |
-
'type' => 'select',
|
1102 |
-
'label' => __('Account Type','ultimate-member'),
|
1103 |
-
'placeholder' => 'Choose account type',
|
1104 |
-
'required' => 0,
|
1105 |
-
'public' => 1,
|
1106 |
-
'editable' => 1,
|
1107 |
-
'options' => $um_roles,
|
1108 |
-
),
|
1109 |
-
|
1110 |
-
'role_radio' => array(
|
1111 |
-
'title' => __('Roles (Radio)','ultimate-member'),
|
1112 |
-
'metakey' => 'role_radio',
|
1113 |
-
'type' => 'radio',
|
1114 |
-
'label' => __('Account Type','ultimate-member'),
|
1115 |
-
'required' => 0,
|
1116 |
-
'public' => 1,
|
1117 |
-
'editable' => 1,
|
1118 |
-
'options' => $um_roles,
|
1119 |
-
),
|
1120 |
-
|
1121 |
-
'languages' => array(
|
1122 |
-
'title' => __('Languages','ultimate-member'),
|
1123 |
-
'metakey' => 'languages',
|
1124 |
-
'type' => 'multiselect',
|
1125 |
-
'label' => __('Languages Spoken','ultimate-member'),
|
1126 |
-
'placeholder' => __('Select languages','ultimate-member'),
|
1127 |
-
'required' => 0,
|
1128 |
-
'public' => 1,
|
1129 |
-
'editable' => 1,
|
1130 |
-
'options' => $this->get('languages'),
|
1131 |
-
),
|
1132 |
-
|
1133 |
-
'phone_number' => array(
|
1134 |
-
'title' => __('Phone Number','ultimate-member'),
|
1135 |
-
'metakey' => 'phone_number',
|
1136 |
-
'type' => 'text',
|
1137 |
-
'label' => __('Phone Number','ultimate-member'),
|
1138 |
-
'required' => 0,
|
1139 |
-
'public' => 1,
|
1140 |
-
'editable' => 1,
|
1141 |
-
'validate' => 'phone_number',
|
1142 |
-
'icon' => 'um-faicon-phone',
|
1143 |
-
),
|
1144 |
-
|
1145 |
-
'mobile_number' => array(
|
1146 |
-
'title' => __('Mobile Number','ultimate-member'),
|
1147 |
-
'metakey' => 'mobile_number',
|
1148 |
-
'type' => 'text',
|
1149 |
-
'label' => __('Mobile Number','ultimate-member'),
|
1150 |
-
'required' => 0,
|
1151 |
-
'public' => 1,
|
1152 |
-
'editable' => 1,
|
1153 |
-
'validate' => 'phone_number',
|
1154 |
-
'icon' => 'um-faicon-mobile',
|
1155 |
-
),
|
1156 |
-
|
1157 |
-
// private use ( not public list )
|
1158 |
-
|
1159 |
-
'profile_photo' => array(
|
1160 |
-
'title' => __('Profile Photo','ultimate-member'),
|
1161 |
-
'metakey' => 'profile_photo',
|
1162 |
-
'type' => 'image',
|
1163 |
-
'label' => __('Change your profile photo','ultimate-member'),
|
1164 |
-
'upload_text' => __('Upload your photo here','ultimate-member'),
|
1165 |
-
'icon' => 'um-faicon-camera',
|
1166 |
-
'crop' => 1,
|
1167 |
-
'max_size' => ( UM()->options()->get('profile_photo_max_size') ) ? UM()->options()->get('profile_photo_max_size') : 999999999,
|
1168 |
-
'min_width' => str_replace('px','',UM()->options()->get('profile_photosize')),
|
1169 |
-
'min_height' => str_replace('px','',UM()->options()->get('profile_photosize')),
|
1170 |
-
'private_use' => true,
|
1171 |
-
),
|
1172 |
-
|
1173 |
-
'cover_photo' => array(
|
1174 |
-
'title' => __('Cover Photo','ultimate-member'),
|
1175 |
-
'metakey' => 'cover_photo',
|
1176 |
-
'type' => 'image',
|
1177 |
-
'label' => __('Change your cover photo','ultimate-member'),
|
1178 |
-
'upload_text' => __('Upload profile cover here','ultimate-member'),
|
1179 |
-
'icon' => 'um-faicon-picture-o',
|
1180 |
-
'crop' => 2,
|
1181 |
-
'max_size' => ( UM()->options()->get('cover_photo_max_size') ) ? UM()->options()->get('cover_photo_max_size') : 999999999,
|
1182 |
-
'modal_size' => 'large',
|
1183 |
-
'ratio' => str_replace(':1','',UM()->options()->get('profile_cover_ratio')),
|
1184 |
-
'min_width' => UM()->options()->get('cover_min_width'),
|
1185 |
-
'private_use' => true,
|
1186 |
-
),
|
1187 |
-
|
1188 |
-
'username_b' => array(
|
1189 |
-
'title' => __('Username or E-mail','ultimate-member'),
|
1190 |
-
'metakey' => 'username_b',
|
1191 |
-
'type' => 'text',
|
1192 |
-
'placeholder' => __('Enter your username or email','ultimate-member'),
|
1193 |
-
'required' => 1,
|
1194 |
-
'public' => 1,
|
1195 |
-
'editable' => 0,
|
1196 |
-
'private_use' => true,
|
1197 |
-
),
|
1198 |
-
|
1199 |
-
// account page use ( not public )
|
1200 |
-
|
1201 |
-
'profile_privacy' => array(
|
1202 |
-
'title' => __( 'Profile Privacy', 'ultimate-member' ),
|
1203 |
-
'metakey' => 'profile_privacy',
|
1204 |
-
'type' => 'select',
|
1205 |
-
'label' => __( 'Profile Privacy', 'ultimate-member' ),
|
1206 |
-
'help' => __( 'Who can see your public profile?', 'ultimate-member' ),
|
1207 |
-
'required' => 0,
|
1208 |
-
'public' => 1,
|
1209 |
-
'editable' => 1,
|
1210 |
-
'default' => 'Everyone',
|
1211 |
-
'options' => $profile_privacy,
|
1212 |
-
'allowclear' => 0,
|
1213 |
-
'account_only' => true,
|
1214 |
-
'required_perm' => 'can_make_private_profile',
|
1215 |
-
),
|
1216 |
-
|
1217 |
-
'profile_noindex' => array(
|
1218 |
-
'title' => __( 'Avoid indexing my profile by search engines', 'ultimate-member' ),
|
1219 |
-
'metakey' => 'profile_noindex',
|
1220 |
-
'type' => 'select',
|
1221 |
-
'label' => __( 'Avoid indexing my profile by search engines', 'ultimate-member' ),
|
1222 |
-
'help' => __( 'Hide my profile for robots?', 'ultimate-member' ),
|
1223 |
-
'required' => 0,
|
1224 |
-
'public' => 1,
|
1225 |
-
'editable' => 1,
|
1226 |
-
'default' => UM()->roles()->um_user_can( 'profile_noindex' ) ? '1' : '0',
|
1227 |
-
'options' => array(
|
1228 |
-
'0' => __( 'No', 'ultimate-member' ),
|
1229 |
-
'1' => __( 'Yes', 'ultimate-member' ),
|
1230 |
-
),
|
1231 |
-
'allowclear' => 0,
|
1232 |
-
'account_only' => true,
|
1233 |
-
'required_perm' => 'can_make_private_profile',
|
1234 |
-
),
|
1235 |
-
|
1236 |
-
'hide_in_members' => array(
|
1237 |
-
'title' => __( 'Hide my profile from directory', 'ultimate-member' ),
|
1238 |
-
'metakey' => 'hide_in_members',
|
1239 |
-
'type' => 'radio',
|
1240 |
-
'label' => __( 'Hide my profile from directory', 'ultimate-member' ),
|
1241 |
-
'help' => __( 'Here you can hide yourself from appearing in public directory', 'ultimate-member' ),
|
1242 |
-
'required' => 0,
|
1243 |
-
'public' => 1,
|
1244 |
-
'editable' => 1,
|
1245 |
-
'default' => UM()->member_directory()->get_hide_in_members_default() ? 'Yes' : 'No',
|
1246 |
-
'options' => array(
|
1247 |
-
'No' => __( 'No', 'ultimate-member' ),
|
1248 |
-
'Yes' => __( 'Yes', 'ultimate-member' ),
|
1249 |
-
),
|
1250 |
-
'account_only' => true,
|
1251 |
-
'required_opt' => array( 'members_page', 1 ),
|
1252 |
-
),
|
1253 |
-
|
1254 |
-
'delete_account' => array(
|
1255 |
-
'title' => __( 'Delete Account', 'ultimate-member' ),
|
1256 |
-
'metakey' => 'delete_account',
|
1257 |
-
'type' => 'radio',
|
1258 |
-
'label' => __( 'Delete Account', 'ultimate-member'),
|
1259 |
-
'help' => __( 'If you confirm, everything related to your profile will be deleted permanently from the site', 'ultimate-member' ),
|
1260 |
-
'required' => 0,
|
1261 |
-
'public' => 1,
|
1262 |
-
'editable' => 1,
|
1263 |
-
'default' => __( 'No', 'ultimate-member' ),
|
1264 |
-
'options' => array(
|
1265 |
-
__( 'Yes', 'ultimate-member' ),
|
1266 |
-
__( 'No', 'ultimate-member' )
|
1267 |
-
),
|
1268 |
-
'account_only' => true,
|
1269 |
-
),
|
1270 |
-
|
1271 |
-
'single_user_password' => array(
|
1272 |
-
'title' => __( 'Password', 'ultimate-member' ),
|
1273 |
-
'metakey' => 'single_user_password',
|
1274 |
-
'type' => 'password',
|
1275 |
-
'label' => __( 'Password', 'ultimate-member' ),
|
1276 |
-
'required' => 1,
|
1277 |
-
'public' => 1,
|
1278 |
-
'editable' => 1,
|
1279 |
-
'account_only' => true,
|
1280 |
-
),
|
1281 |
-
|
1282 |
-
);
|
1283 |
-
|
1284 |
-
/**
|
1285 |
-
* UM hook
|
1286 |
-
*
|
1287 |
-
* @type filter
|
1288 |
-
* @title um_predefined_fields_hook
|
1289 |
-
* @description Extend Predefined Fields
|
1290 |
-
* @input_vars
|
1291 |
-
* [{"var":"$predefined_fields","type":"array","desc":"Predefined Fields"}]
|
1292 |
-
* @change_log
|
1293 |
-
* ["Since: 2.0"]
|
1294 |
-
* @usage add_filter( 'um_predefined_fields_hook', 'function_name', 10, 1 );
|
1295 |
-
* @example
|
1296 |
-
* <?php
|
1297 |
-
* add_filter( 'um_predefined_fields_hook', 'my_predefined_fields', 10, 1 );
|
1298 |
-
* function my_predefined_fields( $predefined_fields ) {
|
1299 |
-
* // your code here
|
1300 |
-
* return $predefined_fields;
|
1301 |
-
* }
|
1302 |
-
* ?>
|
1303 |
-
*/
|
1304 |
-
$this->predefined_fields = apply_filters( 'um_predefined_fields_hook', $this->predefined_fields );
|
1305 |
-
}
|
1306 |
-
|
1307 |
-
|
1308 |
-
/**
|
1309 |
-
* Custom Fields
|
1310 |
-
*/
|
1311 |
-
function set_custom_fields() {
|
1312 |
-
|
1313 |
-
if ( is_array( $this->saved_fields ) ) {
|
1314 |
-
|
1315 |
-
$this->custom_fields = $this->saved_fields;
|
1316 |
-
|
1317 |
-
} else {
|
1318 |
-
|
1319 |
-
$this->custom_fields = '';
|
1320 |
-
|
1321 |
-
}
|
1322 |
-
|
1323 |
-
$custom = $this->custom_fields;
|
1324 |
-
$predefined = $this->predefined_fields;
|
1325 |
-
|
1326 |
-
if ( is_array( $custom ) ){
|
1327 |
-
$this->all_user_fields = array_merge( $predefined, $custom );
|
1328 |
-
} else {
|
1329 |
-
$this->all_user_fields = $predefined;
|
1330 |
-
}
|
1331 |
-
|
1332 |
-
}
|
1333 |
-
|
1334 |
-
|
1335 |
-
/**
|
1336 |
-
* Get all fields without metakeys
|
1337 |
-
*
|
1338 |
-
* @since 2.0.56
|
1339 |
-
*
|
1340 |
-
* @return array
|
1341 |
-
*/
|
1342 |
-
function get_fields_without_metakey() {
|
1343 |
-
$fields_without_metakey = array(
|
1344 |
-
'block',
|
1345 |
-
'shortcode',
|
1346 |
-
'spacing',
|
1347 |
-
'divider',
|
1348 |
-
'group'
|
1349 |
-
);
|
1350 |
-
|
1351 |
-
|
1352 |
-
/**
|
1353 |
-
* UM hook
|
1354 |
-
*
|
1355 |
-
* @type filter
|
1356 |
-
* @title um_fields_without_metakey
|
1357 |
-
* @description Field Types without meta key
|
1358 |
-
* @input_vars
|
1359 |
-
* [{"var":"$types","type":"array","desc":"Field Types"}]
|
1360 |
-
* @change_log
|
1361 |
-
* ["Since: 2.0"]
|
1362 |
-
* @usage add_filter( 'um_fields_without_metakey', 'function_name', 10, 1 );
|
1363 |
-
* @example
|
1364 |
-
* <?php
|
1365 |
-
* add_filter( 'um_fields_without_metakey', 'my_fields_without_metakey', 10, 1 );
|
1366 |
-
* function my_fields_without_metakey( $types ) {
|
1367 |
-
* // your code here
|
1368 |
-
* return $types;
|
1369 |
-
* }
|
1370 |
-
* ?>
|
1371 |
-
*/
|
1372 |
-
return apply_filters( 'um_fields_without_metakey', $fields_without_metakey );
|
1373 |
-
}
|
1374 |
-
|
1375 |
-
|
1376 |
-
/**
|
1377 |
-
* May be used to show a dropdown, or source for user meta
|
1378 |
-
*
|
1379 |
-
* @param null $exclude_types
|
1380 |
-
* @param bool $show_all
|
1381 |
-
*
|
1382 |
-
* @return array
|
1383 |
-
*/
|
1384 |
-
function all_user_fields( $exclude_types = null, $show_all = false ) {
|
1385 |
-
|
1386 |
-
$fields_without_metakey = $this->get_fields_without_metakey();
|
1387 |
-
$fields_without_metakey = apply_filters( 'um_all_user_fields_without_metakey', $fields_without_metakey );
|
1388 |
-
|
1389 |
-
if ( ! $show_all ) {
|
1390 |
-
$this->fields_dropdown = array( 'image', 'file', 'password', 'rating' );
|
1391 |
-
$this->fields_dropdown = array_merge( $this->fields_dropdown, $fields_without_metakey );
|
1392 |
-
} else {
|
1393 |
-
$this->fields_dropdown = $fields_without_metakey;
|
1394 |
-
}
|
1395 |
-
|
1396 |
-
$custom = $this->custom_fields;
|
1397 |
-
$predefined = $this->predefined_fields;
|
1398 |
-
|
1399 |
-
if ( $exclude_types ) {
|
1400 |
-
$exclude_types = explode( ',', $exclude_types );
|
1401 |
-
}
|
1402 |
-
|
1403 |
-
$all = array( 0 => '' );
|
1404 |
-
|
1405 |
-
if ( is_array( $custom ) ) {
|
1406 |
-
$all = $all + array_merge( $predefined, $custom );
|
1407 |
-
} else {
|
1408 |
-
$all = $all + $predefined;
|
1409 |
-
}
|
1410 |
-
|
1411 |
-
foreach ( $all as $k => $arr ) {
|
1412 |
-
|
1413 |
-
if ( $k == 0 ) {
|
1414 |
-
unset( $all[ $k ] );
|
1415 |
-
}
|
1416 |
-
|
1417 |
-
if ( isset( $arr['title'] ) ) {
|
1418 |
-
$all[ $k ]['title'] = stripslashes( $arr['title'] );
|
1419 |
-
}
|
1420 |
-
|
1421 |
-
if ( $exclude_types && isset( $arr['type'] ) && in_array( $arr['type'], $exclude_types ) ) {
|
1422 |
-
unset( $all[ $k ] );
|
1423 |
-
}
|
1424 |
-
if ( isset( $arr['account_only'] ) || isset( $arr['private_use'] ) ) {
|
1425 |
-
if ( ! $show_all ) {
|
1426 |
-
unset( $all[ $k ] );
|
1427 |
-
}
|
1428 |
-
}
|
1429 |
-
if ( isset( $arr['type'] ) && in_array( $arr['type'], $this->fields_dropdown ) ) {
|
1430 |
-
unset( $all[ $k ] );
|
1431 |
-
}
|
1432 |
-
}
|
1433 |
-
|
1434 |
-
$all = UM()->fields()->array_sort_by_column( $all, 'title' );
|
1435 |
-
|
1436 |
-
return $all;
|
1437 |
-
}
|
1438 |
-
|
1439 |
-
|
1440 |
-
/**
|
1441 |
-
* Possible validation types for fields
|
1442 |
-
*
|
1443 |
-
* @return mixed
|
1444 |
-
*/
|
1445 |
-
function validation_types() {
|
1446 |
-
|
1447 |
-
$array[0] = __('None','ultimate-member');
|
1448 |
-
$array['alphabetic'] = __('Alphabetic value only','ultimate-member');
|
1449 |
-
$array['alpha_numeric'] = __('Alpha-numeric value','ultimate-member');
|
1450 |
-
$array['english'] = __('English letters only','ultimate-member');
|
1451 |
-
$array['facebook_url'] = __('Facebook URL','ultimate-member');
|
1452 |
-
$array['google_url'] = __('Google+ URL','ultimate-member');
|
1453 |
-
$array['instagram_url'] = __('Instagram URL','ultimate-member');
|
1454 |
-
$array['linkedin_url'] = __('LinkedIn URL','ultimate-member');
|
1455 |
-
$array['vk_url'] = __('VKontakte URL','ultimate-member');
|
1456 |
-
$array['lowercase'] = __('Lowercase only','ultimate-member');
|
1457 |
-
$array['numeric'] = __('Numeric value only','ultimate-member');
|
1458 |
-
$array['phone_number'] = __('Phone Number','ultimate-member');
|
1459 |
-
$array['skype'] = __('Skype ID','ultimate-member');
|
1460 |
-
$array['soundcloud'] = __( 'SoundCloud Profile', 'ultimate-member' );
|
1461 |
-
$array['twitter_url'] = __('Twitter URL','ultimate-member');
|
1462 |
-
$array['is_email'] = __('E-mail( Not Unique )','ultimate-member');
|
1463 |
-
$array['unique_email'] = __('Unique E-mail','ultimate-member');
|
1464 |
-
$array['unique_value'] = __('Unique Metakey value','ultimate-member');
|
1465 |
-
$array['unique_username'] = __('Unique Username','ultimate-member');
|
1466 |
-
$array['unique_username_or_email'] = __('Unique Username/E-mail','ultimate-member');
|
1467 |
-
$array['url'] = __('Website URL','ultimate-member');
|
1468 |
-
$array['youtube_url'] = __('YouTube Profile','ultimate-member');
|
1469 |
-
$array['telegram_url'] = __('Telegram URL','ultimate-member');
|
1470 |
-
$array['discord'] = __('Discord ID','ultimate-member');
|
1471 |
-
$array['custom'] = __('Custom Validation','ultimate-member');
|
1472 |
-
|
1473 |
-
/**
|
1474 |
-
* UM hook
|
1475 |
-
*
|
1476 |
-
* @type filter
|
1477 |
-
* @title um_admin_field_validation_hook
|
1478 |
-
* @description Extend validation types
|
1479 |
-
* @input_vars
|
1480 |
-
* [{"var":"$types","type":"array","desc":"Validation Types"}]
|
1481 |
-
* @change_log
|
1482 |
-
* ["Since: 2.0"]
|
1483 |
-
* @usage add_filter( 'um_admin_field_validation_hook', 'function_name', 10, 1 );
|
1484 |
-
* @example
|
1485 |
-
* <?php
|
1486 |
-
* add_filter( 'um_admin_field_validation_hook', 'my_admin_field_validation', 10, 1 );
|
1487 |
-
* function my_admin_field_validation( $types ) {
|
1488 |
-
* // your code here
|
1489 |
-
* return $types;
|
1490 |
-
* }
|
1491 |
-
* ?>
|
1492 |
-
*/
|
1493 |
-
$array = apply_filters( 'um_admin_field_validation_hook', $array );
|
1494 |
-
return $array;
|
1495 |
-
}
|
1496 |
-
|
1497 |
-
|
1498 |
-
/**
|
1499 |
-
* Get predefined options
|
1500 |
-
*
|
1501 |
-
* @param $data
|
1502 |
-
*
|
1503 |
-
* @return array|mixed|void
|
1504 |
-
*/
|
1505 |
-
function get( $data ) {
|
1506 |
-
switch ( $data ) {
|
1507 |
-
|
1508 |
-
case 'languages':
|
1509 |
-
$array = array(
|
1510 |
-
"aa" => __("Afar",'ultimate-member'),
|
1511 |
-
"ab" => __("Abkhazian",'ultimate-member'),
|
1512 |
-
"ae" => __("Avestan",'ultimate-member'),
|
1513 |
-
"af" => __("Afrikaans",'ultimate-member'),
|
1514 |
-
"ak" => __("Akan",'ultimate-member'),
|
1515 |
-
"am" => __("Amharic",'ultimate-member'),
|
1516 |
-
"an" => __("Aragonese",'ultimate-member'),
|
1517 |
-
"ar" => __("Arabic",'ultimate-member'),
|
1518 |
-
"as" => __("Assamese",'ultimate-member'),
|
1519 |
-
"av" => __("Avaric",'ultimate-member'),
|
1520 |
-
"ay" => __("Aymara",'ultimate-member'),
|
1521 |
-
"az" => __("Azerbaijani",'ultimate-member'),
|
1522 |
-
"ba" => __("Bashkir",'ultimate-member'),
|
1523 |
-
"be" => __("Belarusian",'ultimate-member'),
|
1524 |
-
"bg" => __("Bulgarian",'ultimate-member'),
|
1525 |
-
"bh" => __("Bihari",'ultimate-member'),
|
1526 |
-
"bi" => __("Bislama",'ultimate-member'),
|
1527 |
-
"bm" => __("Bambara",'ultimate-member'),
|
1528 |
-
"bn" => __("Bengali",'ultimate-member'),
|
1529 |
-
"bo" => __("Tibetan",'ultimate-member'),
|
1530 |
-
"br" => __("Breton",'ultimate-member'),
|
1531 |
-
"bs" => __("Bosnian",'ultimate-member'),
|
1532 |
-
"ca" => __("Catalan",'ultimate-member'),
|
1533 |
-
"ce" => __("Chechen",'ultimate-member'),
|
1534 |
-
"ch" => __("Chamorro",'ultimate-member'),
|
1535 |
-
"co" => __("Corsican",'ultimate-member'),
|
1536 |
-
"cr" => __("Cree",'ultimate-member'),
|
1537 |
-
"cs" => __("Czech",'ultimate-member'),
|
1538 |
-
"cu" => __("Church Slavic",'ultimate-member'),
|
1539 |
-
"cv" => __("Chuvash",'ultimate-member'),
|
1540 |
-
"cy" => __("Welsh",'ultimate-member'),
|
1541 |
-
"da" => __("Danish",'ultimate-member'),
|
1542 |
-
"de" => __("German",'ultimate-member'),
|
1543 |
-
"dv" => __("Divehi",'ultimate-member'),
|
1544 |
-
"dz" => __("Dzongkha",'ultimate-member'),
|
1545 |
-
"ee" => __("Ewe",'ultimate-member'),
|
1546 |
-
"el" => __("Greek",'ultimate-member'),
|
1547 |
-
"en" => __("English",'ultimate-member'),
|
1548 |
-
"eo" => __("Esperanto",'ultimate-member'),
|
1549 |
-
"es" => __("Spanish",'ultimate-member'),
|
1550 |
-
"et" => __("Estonian",'ultimate-member'),
|
1551 |
-
"eu" => __("Basque",'ultimate-member'),
|
1552 |
-
"fa" => __("Persian",'ultimate-member'),
|
1553 |
-
"ff" => __("Fulah",'ultimate-member'),
|
1554 |
-
"fi" => __("Finnish",'ultimate-member'),
|
1555 |
-
"fj" => __("Fijian",'ultimate-member'),
|
1556 |
-
"fo" => __("Faroese",'ultimate-member'),
|
1557 |
-
"fr" => __("French",'ultimate-member'),
|
1558 |
-
"fy" => __("Western Frisian",'ultimate-member'),
|
1559 |
-
"ga" => __("Irish",'ultimate-member'),
|
1560 |
-
"gd" => __("Scottish Gaelic",'ultimate-member'),
|
1561 |
-
"gl" => __("Galician",'ultimate-member'),
|
1562 |
-
"gn" => __("Guarani",'ultimate-member'),
|
1563 |
-
"gu" => __("Gujarati",'ultimate-member'),
|
1564 |
-
"gv" => __("Manx",'ultimate-member'),
|
1565 |
-
"ha" => __("Hausa",'ultimate-member'),
|
1566 |
-
"he" => __("Hebrew",'ultimate-member'),
|
1567 |
-
"hi" => __("Hindi",'ultimate-member'),
|
1568 |
-
"ho" => __("Hiri Motu",'ultimate-member'),
|
1569 |
-
"hr" => __("Croatian",'ultimate-member'),
|
1570 |
-
"ht" => __("Haitian",'ultimate-member'),
|
1571 |
-
"hu" => __("Hungarian",'ultimate-member'),
|
1572 |
-
"hy" => __("Armenian",'ultimate-member'),
|
1573 |
-
"hz" => __("Herero",'ultimate-member'),
|
1574 |
-
"ia" => __("Interlingua (International Auxiliary Language Association)",'ultimate-member'),
|
1575 |
-
"id" => __("Indonesian",'ultimate-member'),
|
1576 |
-
"ie" => __("Interlingue",'ultimate-member'),
|
1577 |
-
"ig" => __("Igbo",'ultimate-member'),
|
1578 |
-
"ii" => __("Sichuan Yi",'ultimate-member'),
|
1579 |
-
"ik" => __("Inupiaq",'ultimate-member'),
|
1580 |
-
"io" => __("Ido",'ultimate-member'),
|
1581 |
-
"is" => __("Icelandic",'ultimate-member'),
|
1582 |
-
"it" => __("Italian",'ultimate-member'),
|
1583 |
-
"iu" => __("Inuktitut",'ultimate-member'),
|
1584 |
-
"ja" => __("Japanese",'ultimate-member'),
|
1585 |
-
"jv" => __("Javanese",'ultimate-member'),
|
1586 |
-
"ka" => __("Kartuli",'ultimate-member'),
|
1587 |
-
"kg" => __("Kongo",'ultimate-member'),
|
1588 |
-
"ki" => __("Kikuyu",'ultimate-member'),
|
1589 |
-
"kj" => __("Kwanyama",'ultimate-member'),
|
1590 |
-
"kk" => __("Kazakh",'ultimate-member'),
|
1591 |
-
"kl" => __("Kalaallisut",'ultimate-member'),
|
1592 |
-
"km" => __("Khmer",'ultimate-member'),
|
1593 |
-
"kn" => __("Kannada",'ultimate-member'),
|
1594 |
-
"ko" => __("Korean",'ultimate-member'),
|
1595 |
-
"kr" => __("Kanuri",'ultimate-member'),
|
1596 |
-
"ks" => __("Kashmiri",'ultimate-member'),
|
1597 |
-
"ku" => __("Kurdish",'ultimate-member'),
|
1598 |
-
"kv" => __("Komi",'ultimate-member'),
|
1599 |
-
"kw" => __("Cornish",'ultimate-member'),
|
1600 |
-
"ky" => __("Kirghiz",'ultimate-member'),
|
1601 |
-
"la" => __("Latin",'ultimate-member'),
|
1602 |
-
"lb" => __("Luxembourgish",'ultimate-member'),
|
1603 |
-
"lg" => __("Ganda",'ultimate-member'),
|
1604 |
-
"li" => __("Limburgish",'ultimate-member'),
|
1605 |
-
"ln" => __("Lingala",'ultimate-member'),
|
1606 |
-
"lo" => __("Lao",'ultimate-member'),
|
1607 |
-
"lt" => __("Lithuanian",'ultimate-member'),
|
1608 |
-
"lu" => __("Luba-Katanga",'ultimate-member'),
|
1609 |
-
"lv" => __("Latvian",'ultimate-member'),
|
1610 |
-
"mg" => __("Malagasy",'ultimate-member'),
|
1611 |
-
"mh" => __("Marshallese",'ultimate-member'),
|
1612 |
-
"mi" => __("Maori",'ultimate-member'),
|
1613 |
-
"mk" => __("Macedonian",'ultimate-member'),
|
1614 |
-
"ml" => __("Malayalam",'ultimate-member'),
|
1615 |
-
"mn" => __("Mongolian",'ultimate-member'),
|
1616 |
-
"mr" => __("Marathi",'ultimate-member'),
|
1617 |
-
"ms" => __("Malay",'ultimate-member'),
|
1618 |
-
"mt" => __("Maltese",'ultimate-member'),
|
1619 |
-
"my" => __("Burmese",'ultimate-member'),
|
1620 |
-
"na" => __("Nauru",'ultimate-member'),
|
1621 |
-
"nb" => __("Norwegian Bokmal",'ultimate-member'),
|
1622 |
-
"nd" => __("North Ndebele",'ultimate-member'),
|
1623 |
-
"ne" => __("Nepali",'ultimate-member'),
|
1624 |
-
"ng" => __("Ndonga",'ultimate-member'),
|
1625 |
-
"nl" => __("Dutch",'ultimate-member'),
|
1626 |
-
"nn" => __("Norwegian Nynorsk",'ultimate-member'),
|
1627 |
-
"no" => __("Norwegian",'ultimate-member'),
|
1628 |
-
"nr" => __("South Ndebele",'ultimate-member'),
|
1629 |
-
"nv" => __("Navajo",'ultimate-member'),
|
1630 |
-
"ny" => __("Chichewa",'ultimate-member'),
|
1631 |
-
"oc" => __("Occitan",'ultimate-member'),
|
1632 |
-
"oj" => __("Ojibwa",'ultimate-member'),
|
1633 |
-
"om" => __("Oromo",'ultimate-member'),
|
1634 |
-
"or" => __("Oriya",'ultimate-member'),
|
1635 |
-
"os" => __("Ossetian",'ultimate-member'),
|
1636 |
-
"pa" => __("Panjabi",'ultimate-member'),
|
1637 |
-
"pi" => __("Pali",'ultimate-member'),
|
1638 |
-
"pl" => __("Polish",'ultimate-member'),
|
1639 |
-
"ps" => __("Pashto",'ultimate-member'),
|
1640 |
-
"pt" => __("Portuguese",'ultimate-member'),
|
1641 |
-
"qu" => __("Quechua",'ultimate-member'),
|
1642 |
-
"rm" => __("Raeto-Romance",'ultimate-member'),
|
1643 |
-
"rn" => __("Kirundi",'ultimate-member'),
|
1644 |
-
"ro" => __("Romanian",'ultimate-member'),
|
1645 |
-
"ru" => __("Russian",'ultimate-member'),
|
1646 |
-
"rw" => __("Kinyarwanda",'ultimate-member'),
|
1647 |
-
"sa" => __("Sanskrit",'ultimate-member'),
|
1648 |
-
"sc" => __("Sardinian",'ultimate-member'),
|
1649 |
-
"sd" => __("Sindhi",'ultimate-member'),
|
1650 |
-
"se" => __("Northern Sami",'ultimate-member'),
|
1651 |
-
"sg" => __("Sango",'ultimate-member'),
|
1652 |
-
"si" => __("Sinhala",'ultimate-member'),
|
1653 |
-
"sk" => __("Slovak",'ultimate-member'),
|
1654 |
-
"sl" => __("Slovenian",'ultimate-member'),
|
1655 |
-
"sm" => __("Samoan",'ultimate-member'),
|
1656 |
-
"sn" => __("Shona",'ultimate-member'),
|
1657 |
-
"so" => __("Somali",'ultimate-member'),
|
1658 |
-
"sq" => __("Albanian",'ultimate-member'),
|
1659 |
-
"sr" => __("Serbian",'ultimate-member'),
|
1660 |
-
"ss" => __("Swati",'ultimate-member'),
|
1661 |
-
"st" => __("Southern Sotho",'ultimate-member'),
|
1662 |
-
"su" => __("Sundanese",'ultimate-member'),
|
1663 |
-
"sv" => __("Swedish",'ultimate-member'),
|
1664 |
-
"sw" => __("Swahili",'ultimate-member'),
|
1665 |
-
"ta" => __("Tamil",'ultimate-member'),
|
1666 |
-
"te" => __("Telugu",'ultimate-member'),
|
1667 |
-
"tg" => __("Tajik",'ultimate-member'),
|
1668 |
-
"th" => __("Thai",'ultimate-member'),
|
1669 |
-
"ti" => __("Tigrinya",'ultimate-member'),
|
1670 |
-
"tk" => __("Turkmen",'ultimate-member'),
|
1671 |
-
"tl" => __("Tagalog",'ultimate-member'),
|
1672 |
-
"tn" => __("Tswana",'ultimate-member'),
|
1673 |
-
"to" => __("Tonga",'ultimate-member'),
|
1674 |
-
"tr" => __("Turkish",'ultimate-member'),
|
1675 |
-
"ts" => __("Tsonga",'ultimate-member'),
|
1676 |
-
"tt" => __("Tatar",'ultimate-member'),
|
1677 |
-
"tw" => __("Twi",'ultimate-member'),
|
1678 |
-
"ty" => __("Tahitian",'ultimate-member'),
|
1679 |
-
"ug" => __("Uighur",'ultimate-member'),
|
1680 |
-
"uk" => __("Ukrainian",'ultimate-member'),
|
1681 |
-
"ur" => __("Urdu",'ultimate-member'),
|
1682 |
-
"uz" => __("Uzbek",'ultimate-member'),
|
1683 |
-
"ve" => __("Venda",'ultimate-member'),
|
1684 |
-
"vi" => __("Vietnamese",'ultimate-member'),
|
1685 |
-
"vo" => __("Volapuk",'ultimate-member'),
|
1686 |
-
"wa" => __("Walloon",'ultimate-member'),
|
1687 |
-
"wo" => __("Wolof",'ultimate-member'),
|
1688 |
-
"xh" => __("Xhosa",'ultimate-member'),
|
1689 |
-
"yi" => __("Yiddish",'ultimate-member'),
|
1690 |
-
"yo" => __("Yoruba",'ultimate-member'),
|
1691 |
-
"za" => __("Zhuang",'ultimate-member'),
|
1692 |
-
"zh" => __("Chinese",'ultimate-member'),
|
1693 |
-
"zu" => __("Zulu",'ultimate-member')
|
1694 |
-
);
|
1695 |
-
break;
|
1696 |
-
|
1697 |
-
case 'countries':
|
1698 |
-
$array = array (
|
1699 |
-
'AF' => __('Afghanistan','ultimate-member'),
|
1700 |
-
'AX' => __('Åland Islands','ultimate-member'),
|
1701 |
-
'AL' => __('Albania','ultimate-member'),
|
1702 |
-
'DZ' => __('Algeria','ultimate-member'),
|
1703 |
-
'AS' => __('American Samoa','ultimate-member'),
|
1704 |
-
'AD' => __('Andorra','ultimate-member'),
|
1705 |
-
'AO' => __('Angola','ultimate-member'),
|
1706 |
-
'AI' => __('Anguilla','ultimate-member'),
|
1707 |
-
'AQ' => __('Antarctica','ultimate-member'),
|
1708 |
-
'AG' => __('Antigua and Barbuda','ultimate-member'),
|
1709 |
-
'AR' => __('Argentina','ultimate-member'),
|
1710 |
-
'AM' => __('Armenia','ultimate-member'),
|
1711 |
-
'AW' => __('Aruba','ultimate-member'),
|
1712 |
-
'AU' => __('Australia','ultimate-member'),
|
1713 |
-
'AT' => __('Austria','ultimate-member'),
|
1714 |
-
'AZ' => __('Azerbaijan','ultimate-member'),
|
1715 |
-
'BS' => __('Bahamas','ultimate-member'),
|
1716 |
-
'BH' => __('Bahrain','ultimate-member'),
|
1717 |
-
'BD' => __('Bangladesh','ultimate-member'),
|
1718 |
-
'BB' => __('Barbados','ultimate-member'),
|
1719 |
-
'BY' => __('Belarus','ultimate-member'),
|
1720 |
-
'BE' => __('Belgium','ultimate-member'),
|
1721 |
-
'BZ' => __('Belize','ultimate-member'),
|
1722 |
-
'BJ' => __('Benin','ultimate-member'),
|
1723 |
-
'BM' => __('Bermuda','ultimate-member'),
|
1724 |
-
'BT' => __('Bhutan','ultimate-member'),
|
1725 |
-
'BO' => __('Bolivia, Plurinational State of','ultimate-member'),
|
1726 |
-
'BA' => __('Bosnia and Herzegovina','ultimate-member'),
|
1727 |
-
'BW' => __('Botswana','ultimate-member'),
|
1728 |
-
'BV' => __('Bouvet Island','ultimate-member'),
|
1729 |
-
'BR' => __('Brazil','ultimate-member'),
|
1730 |
-
'IO' => __('British Indian Ocean Territory','ultimate-member'),
|
1731 |
-
'BN' => __('Brunei Darussalam','ultimate-member'),
|
1732 |
-
'BG' => __('Bulgaria','ultimate-member'),
|
1733 |
-
'BF' => __('Burkina Faso','ultimate-member'),
|
1734 |
-
'BI' => __('Burundi','ultimate-member'),
|
1735 |
-
'KH' => __('Cambodia','ultimate-member'),
|
1736 |
-
'CM' => __('Cameroon','ultimate-member'),
|
1737 |
-
'CA' => __('Canada','ultimate-member'),
|
1738 |
-
'CV' => __('Cape Verde','ultimate-member'),
|
1739 |
-
'KY' => __('Cayman Islands','ultimate-member'),
|
1740 |
-
'CF' => __('Central African Republic','ultimate-member'),
|
1741 |
-
'TD' => __('Chad','ultimate-member'),
|
1742 |
-
'CL' => __('Chile','ultimate-member'),
|
1743 |
-
'CN' => __('China','ultimate-member'),
|
1744 |
-
'CX' => __('Christmas Island','ultimate-member'),
|
1745 |
-
'CC' => __('Cocos (Keeling) Islands','ultimate-member'),
|
1746 |
-
'CO' => __('Colombia','ultimate-member'),
|
1747 |
-
'KM' => __('Comoros','ultimate-member'),
|
1748 |
-
'CG' => __('Congo','ultimate-member'),
|
1749 |
-
'CD' => __('Congo, the Democratic Republic of the','ultimate-member'),
|
1750 |
-
'CK' => __('Cook Islands','ultimate-member'),
|
1751 |
-
'CR' => __('Costa Rica','ultimate-member'),
|
1752 |
-
'CI' => __("Côte d'Ivoire",'ultimate-member'),
|
1753 |
-
'HR' => __('Croatia','ultimate-member'),
|
1754 |
-
'CU' => __('Cuba','ultimate-member'),
|
1755 |
-
'CY' => __('Cyprus','ultimate-member'),
|
1756 |
-
'CZ' => __('Czech Republic','ultimate-member'),
|
1757 |
-
'DK' => __('Denmark','ultimate-member'),
|
1758 |
-
'DJ' => __('Djibouti','ultimate-member'),
|
1759 |
-
'DM' => __('Dominica','ultimate-member'),
|
1760 |
-
'DO' => __('Dominican Republic','ultimate-member'),
|
1761 |
-
'EC' => __('Ecuador','ultimate-member'),
|
1762 |
-
'EG' => __('Egypt','ultimate-member'),
|
1763 |
-
'SV' => __('El Salvador','ultimate-member'),
|
1764 |
-
'GQ' => __('Equatorial Guinea','ultimate-member'),
|
1765 |
-
'ER' => __('Eritrea','ultimate-member'),
|
1766 |
-
'EE' => __('Estonia','ultimate-member'),
|
1767 |
-
'ET' => __('Ethiopia','ultimate-member'),
|
1768 |
-
'FK' => __('Falkland Islands (Malvinas)','ultimate-member'),
|
1769 |
-
'FO' => __('Faroe Islands','ultimate-member'),
|
1770 |
-
'FJ' => __('Fiji','ultimate-member'),
|
1771 |
-
'FI' => __('Finland','ultimate-member'),
|
1772 |
-
'FR' => __('France','ultimate-member'),
|
1773 |
-
'GF' => __('French Guiana','ultimate-member'),
|
1774 |
-
'PF' => __('French Polynesia','ultimate-member'),
|
1775 |
-
'TF' => __('French Southern Territories','ultimate-member'),
|
1776 |
-
'GA' => __('Gabon','ultimate-member'),
|
1777 |
-
'GM' => __('Gambia','ultimate-member'),
|
1778 |
-
'GE' => __('Sakartvelo','ultimate-member'),
|
1779 |
-
'DE' => __('Germany','ultimate-member'),
|
1780 |
-
'GH' => __('Ghana','ultimate-member'),
|
1781 |
-
'GI' => __('Gibraltar','ultimate-member'),
|
1782 |
-
'GR' => __('Greece','ultimate-member'),
|
1783 |
-
'GL' => __('Greenland','ultimate-member'),
|
1784 |
-
'GD' => __('Grenada','ultimate-member'),
|
1785 |
-
'GP' => __('Guadeloupe','ultimate-member'),
|
1786 |
-
'GU' => __('Guam','ultimate-member'),
|
1787 |
-
'GT' => __('Guatemala','ultimate-member'),
|
1788 |
-
'GG' => __('Guernsey','ultimate-member'),
|
1789 |
-
'GN' => __('Guinea','ultimate-member'),
|
1790 |
-
'GW' => __('Guinea-Bissau','ultimate-member'),
|
1791 |
-
'GY' => __('Guyana','ultimate-member'),
|
1792 |
-
'HT' => __('Haiti','ultimate-member'),
|
1793 |
-
'HM' => __('Heard Island and McDonald Islands','ultimate-member'),
|
1794 |
-
'VA' => __('Holy See (Vatican City State)','ultimate-member'),
|
1795 |
-
'HN' => __('Honduras','ultimate-member'),
|
1796 |
-
'HK' => __('Hong Kong','ultimate-member'),
|
1797 |
-
'HU' => __('Hungary','ultimate-member'),
|
1798 |
-
'IS' => __('Iceland','ultimate-member'),
|
1799 |
-
'IN' => __('India','ultimate-member'),
|
1800 |
-
'ID' => __('Indonesia','ultimate-member'),
|
1801 |
-
'IR' => __('Iran, Islamic Republic of','ultimate-member'),
|
1802 |
-
'IQ' => __('Iraq','ultimate-member'),
|
1803 |
-
'IE' => __('Ireland','ultimate-member'),
|
1804 |
-
'IM' => __('Isle of Man','ultimate-member'),
|
1805 |
-
'IL' => __('Israel','ultimate-member'),
|
1806 |
-
'IT' => __('Italy','ultimate-member'),
|
1807 |
-
'JM' => __('Jamaica','ultimate-member'),
|
1808 |
-
'JP' => __('Japan','ultimate-member'),
|
1809 |
-
'JE' => __('Jersey','ultimate-member'),
|
1810 |
-
'JO' => __('Jordan','ultimate-member'),
|
1811 |
-
'KZ' => __('Kazakhstan','ultimate-member'),
|
1812 |
-
'KE' => __('Kenya','ultimate-member'),
|
1813 |
-
'KI' => __('Kiribati','ultimate-member'),
|
1814 |
-
'KP' => __("Korea, Democratic People's Republic of",'ultimate-member'),
|
1815 |
-
'KR' => __('Korea, Republic of','ultimate-member'),
|
1816 |
-
'KW' => __('Kuwait','ultimate-member'),
|
1817 |
-
'KG' => __('Kyrgyzstan','ultimate-member'),
|
1818 |
-
'LA' => __("Lao People's Democratic Republic",'ultimate-member'),
|
1819 |
-
'LV' => __('Latvia','ultimate-member'),
|
1820 |
-
'LB' => __('Lebanon','ultimate-member'),
|
1821 |
-
'LS' => __('Lesotho','ultimate-member'),
|
1822 |
-
'LR' => __('Liberia','ultimate-member'),
|
1823 |
-
'LY' => __('Libyan Arab Jamahiriya','ultimate-member'),
|
1824 |
-
'LI' => __('Liechtenstein','ultimate-member'),
|
1825 |
-
'LT' => __('Lithuania','ultimate-member'),
|
1826 |
-
'LU' => __('Luxembourg','ultimate-member'),
|
1827 |
-
'MO' => __('Macao','ultimate-member'),
|
1828 |
-
'MK' => __('Macedonia, the former Yugoslav Republic of','ultimate-member'),
|
1829 |
-
'MG' => __('Madagascar','ultimate-member'),
|
1830 |
-
'MW' => __('Malawi','ultimate-member'),
|
1831 |
-
'MY' => __('Malaysia','ultimate-member'),
|
1832 |
-
'MV' => __('Maldives','ultimate-member'),
|
1833 |
-
'ML' => __('Mali','ultimate-member'),
|
1834 |
-
'MT' => __('Malta','ultimate-member'),
|
1835 |
-
'MH' => __('Marshall Islands','ultimate-member'),
|
1836 |
-
'MQ' => __('Martinique','ultimate-member'),
|
1837 |
-
'MR' => __('Mauritania','ultimate-member'),
|
1838 |
-
'MU' => __('Mauritius','ultimate-member'),
|
1839 |
-
'YT' => __('Mayotte','ultimate-member'),
|
1840 |
-
'MX' => __('Mexico','ultimate-member'),
|
1841 |
-
'FM' => __('Micronesia, Federated States of','ultimate-member'),
|
1842 |
-
'MD' => __('Moldova, Republic of','ultimate-member'),
|
1843 |
-
'MC' => __('Monaco','ultimate-member'),
|
1844 |
-
'MN' => __('Mongolia','ultimate-member'),
|
1845 |
-
'ME' => __('Montenegro','ultimate-member'),
|
1846 |
-
'MS' => __('Montserrat','ultimate-member'),
|
1847 |
-
'MA' => __('Morocco','ultimate-member'),
|
1848 |
-
'MZ' => __('Mozambique','ultimate-member'),
|
1849 |
-
'MM' => __('Myanmar','ultimate-member'),
|
1850 |
-
'NA' => __('Namibia','ultimate-member'),
|
1851 |
-
'NR' => __('Nauru','ultimate-member'),
|
1852 |
-
'NP' => __('Nepal','ultimate-member'),
|
1853 |
-
'NL' => __('Netherlands','ultimate-member'),
|
1854 |
-
'AN' => __('Netherlands Antilles','ultimate-member'),
|
1855 |
-
'NC' => __('New Caledonia','ultimate-member'),
|
1856 |
-
'NZ' => __('New Zealand','ultimate-member'),
|
1857 |
-
'NI' => __('Nicaragua','ultimate-member'),
|
1858 |
-
'NE' => __('Niger','ultimate-member'),
|
1859 |
-
'NG' => __('Nigeria','ultimate-member'),
|
1860 |
-
'NU' => __('Niue','ultimate-member'),
|
1861 |
-
'NF' => __('Norfolk Island','ultimate-member'),
|
1862 |
-
'MP' => __('Northern Mariana Islands','ultimate-member'),
|
1863 |
-
'NO' => __('Norway','ultimate-member'),
|
1864 |
-
'OM' => __('Oman','ultimate-member'),
|
1865 |
-
'PK' => __('Pakistan','ultimate-member'),
|
1866 |
-
'PW' => __('Palau','ultimate-member'),
|
1867 |
-
'PS' => __('Palestine','ultimate-member'),
|
1868 |
-
'PA' => __('Panama','ultimate-member'),
|
1869 |
-
'PG' => __('Papua New Guinea','ultimate-member'),
|
1870 |
-
'PY' => __('Paraguay','ultimate-member'),
|
1871 |
-
'PE' => __('Peru','ultimate-member'),
|
1872 |
-
'PH' => __('Philippines','ultimate-member'),
|
1873 |
-
'PN' => __('Pitcairn','ultimate-member'),
|
1874 |
-
'PL' => __('Poland','ultimate-member'),
|
1875 |
-
'PT' => __('Portugal','ultimate-member'),
|
1876 |
-
'PR' => __('Puerto Rico','ultimate-member'),
|
1877 |
-
'QA' => __('Qatar','ultimate-member'),
|
1878 |
-
'RE' => __('Réunion','ultimate-member'),
|
1879 |
-
'RO' => __('Romania','ultimate-member'),
|
1880 |
-
'RU' => __('Russian Federation','ultimate-member'),
|
1881 |
-
'RW' => __('Rwanda','ultimate-member'),
|
1882 |
-
'BL' => __('Saint Barthélemy','ultimate-member'),
|
1883 |
-
'SH' => __('Saint Helena','ultimate-member'),
|
1884 |
-
'KN' => __('Saint Kitts and Nevis','ultimate-member'),
|
1885 |
-
'LC' => __('Saint Lucia','ultimate-member'),
|
1886 |
-
'MF' => __('Saint Martin (French part)','ultimate-member'),
|
1887 |
-
'PM' => __('Saint Pierre and Miquelon','ultimate-member'),
|
1888 |
-
'VC' => __('Saint Vincent and the Grenadines','ultimate-member'),
|
1889 |
-
'WS' => __('Samoa','ultimate-member'),
|
1890 |
-
'SM' => __('San Marino','ultimate-member'),
|
1891 |
-
'ST' => __('Sao Tome and Principe','ultimate-member'),
|
1892 |
-
'SA' => __('Saudi Arabia','ultimate-member'),
|
1893 |
-
'SN' => __('Senegal','ultimate-member'),
|
1894 |
-
'RS' => __('Serbia','ultimate-member'),
|
1895 |
-
'SC' => __('Seychelles','ultimate-member'),
|
1896 |
-
'SL' => __('Sierra Leone','ultimate-member'),
|
1897 |
-
'SG' => __('Singapore','ultimate-member'),
|
1898 |
-
'SK' => __('Slovakia','ultimate-member'),
|
1899 |
-
'SI' => __('Slovenia','ultimate-member'),
|
1900 |
-
'SB' => __('Solomon Islands','ultimate-member'),
|
1901 |
-
'SO' => __('Somalia','ultimate-member'),
|
1902 |
-
'ZA' => __('South Africa','ultimate-member'),
|
1903 |
-
'GS' => __('South Georgia and the South Sandwich Islands','ultimate-member'),
|
1904 |
-
'SS' => __('South Sudan','ultimate-member'),
|
1905 |
-
'ES' => __('Spain','ultimate-member'),
|
1906 |
-
'LK' => __('Sri Lanka','ultimate-member'),
|
1907 |
-
'SD' => __('Sudan','ultimate-member'),
|
1908 |
-
'SR' => __('Suriname','ultimate-member'),
|
1909 |
-
'SJ' => __('Svalbard and Jan Mayen','ultimate-member'),
|
1910 |
-
'SZ' => __('Swaziland','ultimate-member'),
|
1911 |
-
'SE' => __('Sweden','ultimate-member'),
|
1912 |
-
'CH' => __('Switzerland','ultimate-member'),
|
1913 |
-
'SY' => __('Syrian Arab Republic','ultimate-member'),
|
1914 |
-
'TW' => __('Taiwan, Province of China','ultimate-member'),
|
1915 |
-
'TJ' => __('Tajikistan','ultimate-member'),
|
1916 |
-
'TZ' => __('Tanzania, United Republic of','ultimate-member'),
|
1917 |
-
'TH' => __('Thailand','ultimate-member'),
|
1918 |
-
'TL' => __('Timor-Leste','ultimate-member'),
|
1919 |
-
'TG' => __('Togo','ultimate-member'),
|
1920 |
-
'TK' => __('Tokelau','ultimate-member'),
|
1921 |
-
'TO' => __('Tonga','ultimate-member'),
|
1922 |
-
'TT' => __('Trinidad and Tobago','ultimate-member'),
|
1923 |
-
'TN' => __('Tunisia','ultimate-member'),
|
1924 |
-
'TR' => __('Turkey','ultimate-member'),
|
1925 |
-
'TM' => __('Turkmenistan','ultimate-member'),
|
1926 |
-
'TC' => __('Turks and Caicos Islands','ultimate-member'),
|
1927 |
-
'TV' => __('Tuvalu','ultimate-member'),
|
1928 |
-
'UG' => __('Uganda','ultimate-member'),
|
1929 |
-
'UA' => __('Ukraine','ultimate-member'),
|
1930 |
-
'AE' => __('United Arab Emirates','ultimate-member'),
|
1931 |
-
'GB' => __('United Kingdom','ultimate-member'),
|
1932 |
-
'US' => __('United States','ultimate-member'),
|
1933 |
-
'UM' => __('United States Minor Outlying Islands','ultimate-member'),
|
1934 |
-
'UY' => __('Uruguay','ultimate-member'),
|
1935 |
-
'UZ' => __('Uzbekistan','ultimate-member'),
|
1936 |
-
'VU' => __('Vanuatu','ultimate-member'),
|
1937 |
-
'VE' => __('Venezuela, Bolivarian Republic of','ultimate-member'),
|
1938 |
-
'VN' => __('Viet Nam','ultimate-member'),
|
1939 |
-
'VG' => __('Virgin Islands, British','ultimate-member'),
|
1940 |
-
'VI' => __('Virgin Islands, U.S.','ultimate-member'),
|
1941 |
-
'WF' => __('Wallis and Futuna','ultimate-member'),
|
1942 |
-
'EH' => __('Western Sahara','ultimate-member'),
|
1943 |
-
'YE' => __('Yemen','ultimate-member'),
|
1944 |
-
'ZM' => __('Zambia','ultimate-member'),
|
1945 |
-
'ZW' => __('Zimbabwe','ultimate-member'),
|
1946 |
-
);
|
1947 |
-
break;
|
1948 |
-
|
1949 |
-
}
|
1950 |
-
|
1951 |
-
/**
|
1952 |
-
* UM hook
|
1953 |
-
*
|
1954 |
-
* @type filter
|
1955 |
-
* @title um_{$data}_predefined_field_options
|
1956 |
-
* @description Extend Predefined Fields options. Where $data - field key.
|
1957 |
-
* @input_vars
|
1958 |
-
* [{"var":"$options","type":"array","desc":"Field's Options"}]
|
1959 |
-
* @change_log
|
1960 |
-
* ["Since: 2.0"]
|
1961 |
-
* @usage add_filter( 'um_{$data}_predefined_field_options', 'function_name', 10, 1 );
|
1962 |
-
* @example
|
1963 |
-
* <?php
|
1964 |
-
* add_filter( 'um_{$data}_predefined_field_options', 'my_predefined_field', 10, 1 );
|
1965 |
-
* function my_predefined_field( $options ) {
|
1966 |
-
* // your code here
|
1967 |
-
* return $options;
|
1968 |
-
* }
|
1969 |
-
* ?>
|
1970 |
-
*/
|
1971 |
-
$array = apply_filters( "um_{$data}_predefined_field_options", $array );
|
1972 |
-
return $array;
|
1973 |
-
}
|
1974 |
-
|
1975 |
-
}
|
1976 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\core;
|
3 |
+
|
4 |
+
// Exit if accessed directly
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
if ( ! class_exists( 'um\core\Builtin' ) ) {
|
8 |
+
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Builtin
|
12 |
+
* @package um\core
|
13 |
+
*/
|
14 |
+
class Builtin {
|
15 |
+
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var array
|
19 |
+
*/
|
20 |
+
public $predefined_fields = array();
|
21 |
+
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var array
|
25 |
+
*/
|
26 |
+
var $all_user_fields = array();
|
27 |
+
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @var array
|
31 |
+
*/
|
32 |
+
var $core_fields = array();
|
33 |
+
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Builtin constructor.
|
37 |
+
*/
|
38 |
+
function __construct() {
|
39 |
+
add_action( 'init', array( &$this, 'set_core_fields' ), 1 );
|
40 |
+
add_action( 'init', array( &$this, 'set_predefined_fields' ), 1 );
|
41 |
+
add_action( 'init', array( &$this, 'set_custom_fields' ), 1 );
|
42 |
+
$this->saved_fields = get_option( 'um_fields' );
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @return array
|
48 |
+
*/
|
49 |
+
function get_all_user_fields() {
|
50 |
+
return apply_filters( 'um_builtin_all_user_fields', $this->all_user_fields );
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Regular or multi-select/options
|
56 |
+
*
|
57 |
+
* @param $field
|
58 |
+
* @param $attrs
|
59 |
+
*
|
60 |
+
* @return bool
|
61 |
+
*/
|
62 |
+
function is_dropdown_field( $field, $attrs ) {
|
63 |
+
|
64 |
+
if ( isset( $attrs['options'] ) ) {
|
65 |
+
return true;
|
66 |
+
}
|
67 |
+
|
68 |
+
$fields = $this->all_user_fields;
|
69 |
+
|
70 |
+
if ( isset( $fields[ $field ]['options'] ) || ! empty( $fields[ $field ]['custom_dropdown_options_source'] ) ) {
|
71 |
+
return true;
|
72 |
+
}
|
73 |
+
|
74 |
+
return false;
|
75 |
+
}
|
76 |
+
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Get a field
|
80 |
+
*
|
81 |
+
* @param $field
|
82 |
+
*
|
83 |
+
* @return mixed|string
|
84 |
+
*/
|
85 |
+
function get_a_field( $field ) {
|
86 |
+
$fields = $this->all_user_fields;
|
87 |
+
if ( isset( $fields[ $field ] ) ) {
|
88 |
+
return $fields[ $field ];
|
89 |
+
}
|
90 |
+
return '';
|
91 |
+
}
|
92 |
+
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Get specific fields
|
96 |
+
*
|
97 |
+
* @param $fields
|
98 |
+
*
|
99 |
+
* @return array
|
100 |
+
*/
|
101 |
+
function get_specific_fields( $fields ) {
|
102 |
+
$fields = explode( ',', $fields );
|
103 |
+
$array = array();
|
104 |
+
foreach ( $fields as $field ) {
|
105 |
+
if ( isset( $this->predefined_fields[ $field ] ) ) {
|
106 |
+
$array[ $field ] = $this->predefined_fields[ $field ];
|
107 |
+
}
|
108 |
+
}
|
109 |
+
return $array;
|
110 |
+
}
|
111 |
+
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Get specific field
|
115 |
+
*
|
116 |
+
* @param $fields
|
117 |
+
*
|
118 |
+
* @return array|mixed
|
119 |
+
*/
|
120 |
+
function get_specific_field( $fields ) {
|
121 |
+
$fields = explode( ',', $fields );
|
122 |
+
$array = array();
|
123 |
+
foreach ( $fields as $field ) {
|
124 |
+
if ( isset( $this->predefined_fields[ $field ] ) ) {
|
125 |
+
$array = $this->predefined_fields[ $field ];
|
126 |
+
} elseif ( isset( $this->saved_fields[ $field ] ) ) {
|
127 |
+
$array = $this->saved_fields[ $field ];
|
128 |
+
}
|
129 |
+
}
|
130 |
+
return $array;
|
131 |
+
}
|
132 |
+
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Checks for a unique field error
|
136 |
+
*
|
137 |
+
* @param $key
|
138 |
+
*
|
139 |
+
* @return int|string
|
140 |
+
*/
|
141 |
+
function unique_field_err( $key ) {
|
142 |
+
if ( empty( $key ) ) {
|
143 |
+
return __( 'Please provide a meta key', 'ultimate-member' );
|
144 |
+
}
|
145 |
+
if ( isset( $this->core_fields[ $key ] ) ) {
|
146 |
+
return __( 'Your meta key is a reserved core field and cannot be used', 'ultimate-member' );
|
147 |
+
}
|
148 |
+
if ( isset( $this->predefined_fields[ $key ] ) ) {
|
149 |
+
return __( 'Your meta key is a predefined reserved key and cannot be used', 'ultimate-member' );
|
150 |
+
}
|
151 |
+
if ( isset( $this->saved_fields[ $key ] ) ) {
|
152 |
+
return __( 'Your meta key already exists in your fields list', 'ultimate-member' );
|
153 |
+
}
|
154 |
+
if ( ! UM()->validation()->safe_string( $key ) ) {
|
155 |
+
return __( 'Your meta key contains illegal characters. Please correct it.', 'ultimate-member' );
|
156 |
+
}
|
157 |
+
|
158 |
+
return 0;
|
159 |
+
}
|
160 |
+
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Check date range errors (start date)
|
164 |
+
*
|
165 |
+
* @param $date
|
166 |
+
*
|
167 |
+
* @return int|string
|
168 |
+
*/
|
169 |
+
function date_range_start_err( $date ) {
|
170 |
+
if ( empty( $date ) ) {
|
171 |
+
return __( 'Please provide a date range beginning', 'ultimate-member' );
|
172 |
+
}
|
173 |
+
if ( ! UM()->validation()->validate_date( $date ) ) {
|
174 |
+
return __( 'Please enter a valid start date in the date range', 'ultimate-member' );
|
175 |
+
}
|
176 |
+
|
177 |
+
return 0;
|
178 |
+
}
|
179 |
+
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Check date range errors (end date)
|
183 |
+
*
|
184 |
+
* @param $date
|
185 |
+
* @param $start_date
|
186 |
+
*
|
187 |
+
* @return int|string
|
188 |
+
*/
|
189 |
+
function date_range_end_err( $date, $start_date ) {
|
190 |
+
if ( empty( $date ) ) {
|
191 |
+
return __( 'Please provide a date range end', 'ultimate-member' );
|
192 |
+
}
|
193 |
+
if ( ! UM()->validation()->validate_date( $date ) ) {
|
194 |
+
return __( 'Please enter a valid end date in the date range', 'ultimate-member' );
|
195 |
+
}
|
196 |
+
if ( strtotime( $date ) <= strtotime( $start_date ) ) {
|
197 |
+
return __( 'The end of date range must be greater than the start of date range', 'ultimate-member' );
|
198 |
+
}
|
199 |
+
return 0;
|
200 |
+
}
|
201 |
+
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Get a core field attrs
|
205 |
+
*
|
206 |
+
* @param $type
|
207 |
+
*
|
208 |
+
* @return array|mixed
|
209 |
+
*/
|
210 |
+
function get_core_field_attrs( $type ) {
|
211 |
+
return ( isset( $this->core_fields[ $type ] ) ) ? $this->core_fields[ $type ] : array('');
|
212 |
+
}
|
213 |
+
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Core Fields
|
217 |
+
*/
|
218 |
+
function set_core_fields() {
|
219 |
+
|
220 |
+
$this->core_fields = array(
|
221 |
+
|
222 |
+
'row' => array(
|
223 |
+
'name' => 'Row',
|
224 |
+
'in_fields' => false,
|
225 |
+
'form_only' => true,
|
226 |
+
'conditional_support' => 0,
|
227 |
+
'icon' => 'um-faicon-pencil',
|
228 |
+
'col1' => array('_id','_background','_text_color','_padding','_margin','_border','_borderradius','_borderstyle','_bordercolor'),
|
229 |
+
'col2' => array('_heading','_heading_text','_heading_background_color','_heading_text_color','_icon','_icon_color','_css_class'),
|
230 |
+
),
|
231 |
+
|
232 |
+
'text' => array(
|
233 |
+
'name' => 'Text Box',
|
234 |
+
'col1' => array('_title','_metakey','_help','_default','_min_chars','_visibility'),
|
235 |
+
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate','_max_chars'),
|
236 |
+
'col3' => array('_required','_editable','_icon'),
|
237 |
+
'validate' => array(
|
238 |
+
'_title' => array(
|
239 |
+
'mode' => 'required',
|
240 |
+
'error' => __('You must provide a title','ultimate-member')
|
241 |
+
),
|
242 |
+
'_metakey' => array(
|
243 |
+
'mode' => 'unique',
|
244 |
+
),
|
245 |
+
)
|
246 |
+
),
|
247 |
+
|
248 |
+
'number' => array(
|
249 |
+
'name' => __('Number','ultimate-member'),
|
250 |
+
'col1' => array('_title','_metakey','_help','_default','_min','_visibility'),
|
251 |
+
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate','_max'),
|
252 |
+
'col3' => array('_required','_editable','_icon'),
|
253 |
+
'validate' => array(
|
254 |
+
'_title' => array(
|
255 |
+
'mode' => 'required',
|
256 |
+
'error' => __('You must provide a title','ultimate-member')
|
257 |
+
),
|
258 |
+
'_metakey' => array(
|
259 |
+
'mode' => 'unique',
|
260 |
+
),
|
261 |
+
)
|
262 |
+
),
|
263 |
+
|
264 |
+
'textarea' => array(
|
265 |
+
'name' => 'Textarea',
|
266 |
+
'col1' => array('_title','_metakey','_help','_height','_max_chars','_max_words','_visibility'),
|
267 |
+
'col2' => array('_label','_placeholder','_public','_roles','_default','_html'),
|
268 |
+
'col3' => array('_required','_editable','_icon'),
|
269 |
+
'validate' => array(
|
270 |
+
'_title' => array(
|
271 |
+
'mode' => 'required',
|
272 |
+
'error' => __('You must provide a title','ultimate-member')
|
273 |
+
),
|
274 |
+
'_metakey' => array(
|
275 |
+
'mode' => 'unique',
|
276 |
+
),
|
277 |
+
)
|
278 |
+
),
|
279 |
+
|
280 |
+
'select' => array(
|
281 |
+
'name' => 'Dropdown',
|
282 |
+
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
283 |
+
'col2' => array('_label','_placeholder','_public','_roles','_custom_dropdown_options_source','_parent_dropdown_relationship'),
|
284 |
+
'col3' => array('_required','_editable','_icon'),
|
285 |
+
'validate' => array(
|
286 |
+
'_title' => array(
|
287 |
+
'mode' => 'required',
|
288 |
+
'error' => __('You must provide a title','ultimate-member')
|
289 |
+
),
|
290 |
+
'_metakey' => array(
|
291 |
+
'mode' => 'unique',
|
292 |
+
),
|
293 |
+
'_options' => array(
|
294 |
+
'mode' => 'required',
|
295 |
+
'error' => __('You have not added any choices yet.','ultimate-member')
|
296 |
+
),
|
297 |
+
)
|
298 |
+
),
|
299 |
+
|
300 |
+
'multiselect' => array(
|
301 |
+
'name' => 'Multi-Select',
|
302 |
+
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
303 |
+
'col2' => array('_label','_placeholder','_public','_roles','_min_selections','_max_selections','_custom_dropdown_options_source'),
|
304 |
+
'col3' => array('_required','_editable','_icon'),
|
305 |
+
'validate' => array(
|
306 |
+
'_title' => array(
|
307 |
+
'mode' => 'required',
|
308 |
+
'error' => __('You must provide a title','ultimate-member')
|
309 |
+
),
|
310 |
+
'_metakey' => array(
|
311 |
+
'mode' => 'unique',
|
312 |
+
),
|
313 |
+
'_options' => array(
|
314 |
+
'mode' => 'required',
|
315 |
+
'error' => __('You have not added any choices yet.','ultimate-member')
|
316 |
+
),
|
317 |
+
)
|
318 |
+
),
|
319 |
+
|
320 |
+
'radio' => array(
|
321 |
+
'name' => 'Radio',
|
322 |
+
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
323 |
+
'col2' => array('_label','_public','_roles'),
|
324 |
+
'col3' => array('_required','_editable','_icon'),
|
325 |
+
'validate' => array(
|
326 |
+
'_title' => array(
|
327 |
+
'mode' => 'required',
|
328 |
+
'error' => __('You must provide a title','ultimate-member')
|
329 |
+
),
|
330 |
+
'_metakey' => array(
|
331 |
+
'mode' => 'unique',
|
332 |
+
),
|
333 |
+
'_options' => array(
|
334 |
+
'mode' => 'required',
|
335 |
+
'error' => __('You have not added any choices yet.','ultimate-member')
|
336 |
+
),
|
337 |
+
)
|
338 |
+
),
|
339 |
+
|
340 |
+
'checkbox' => array(
|
341 |
+
'name' => 'Checkbox',
|
342 |
+
'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
|
343 |
+
'col2' => array('_label','_public','_roles','_max_selections'),
|
344 |
+
'col3' => array('_required','_editable','_icon'),
|
345 |
+
'validate' => array(
|
346 |
+
'_title' => array(
|
347 |
+
'mode' => 'required',
|
348 |
+
'error' => __('You must provide a title','ultimate-member')
|
349 |
+
),
|
350 |
+
'_metakey' => array(
|
351 |
+
'mode' => 'unique',
|
352 |
+
),
|
353 |
+
'_options' => array(
|
354 |
+
'mode' => 'required',
|
355 |
+
'error' => __('You have not added any choices yet.','ultimate-member')
|
356 |
+
),
|
357 |
+
)
|
358 |
+
),
|
359 |
+
|
360 |
+
'url' => array(
|
361 |
+
'name' => 'URL',
|
362 |
+
'col1' => array('_title','_metakey','_help','_default','_url_text','_visibility'),
|
363 |
+
'col2' => array('_label','_placeholder','_url_target','_url_rel','_public','_roles','_validate','_custom_validate'),
|
364 |
+
'col3' => array('_required','_editable','_icon'),
|
365 |
+
'validate' => array(
|
366 |
+
'_title' => array(
|
367 |
+
'mode' => 'required',
|
368 |
+
'error' => __('You must provide a title','ultimate-member')
|
369 |
+
),
|
370 |
+
'_metakey' => array(
|
371 |
+
'mode' => 'unique',
|
372 |
+
),
|
373 |
+
)
|
374 |
+
),
|
375 |
+
|
376 |
+
'password' => array(
|
377 |
+
'name' => 'Password',
|
378 |
+
'col1' => array('_title','_metakey','_help','_min_chars','_max_chars','_visibility'),
|
379 |
+
'col2' => array('_label','_placeholder','_public','_roles','_force_good_pass','_force_confirm_pass','_label_confirm_pass'),
|
380 |
+
'col3' => array('_required','_editable','_icon'),
|
381 |
+
'validate' => array(
|
382 |
+
'_title' => array(
|
383 |
+
'mode' => 'required',
|
384 |
+
'error' => __('You must provide a title','ultimate-member')
|
385 |
+
),
|
386 |
+
'_metakey' => array(
|
387 |
+
'mode' => 'unique',
|
388 |
+
),
|
389 |
+
)
|
390 |
+
),
|
391 |
+
|
392 |
+
'image' => array(
|
393 |
+
'name' => 'Image Upload',
|
394 |
+
'col1' => array('_title','_metakey','_help','_allowed_types','_max_size','_crop','_visibility'),
|
395 |
+
'col2' => array('_label','_public','_roles','_upload_text','_upload_help_text','_button_text'),
|
396 |
+
'col3' => array('_required','_editable','_icon'),
|
397 |
+
'validate' => array(
|
398 |
+
'_title' => array(
|
399 |
+
'mode' => 'required',
|
400 |
+
'error' => __('You must provide a title','ultimate-member')
|
401 |
+
),
|
402 |
+
'_metakey' => array(
|
403 |
+
'mode' => 'unique',
|
404 |
+
),
|
405 |
+
'_max_size' => array(
|
406 |
+
'mode' => 'numeric',
|
407 |
+
'error' => __('Please enter a valid size','ultimate-member')
|
408 |
+
),
|
409 |
+
)
|
410 |
+
),
|
411 |
+
|
412 |
+
'file' => array(
|
413 |
+
'name' => 'File Upload',
|
414 |
+
'col1' => array('_title','_metakey','_help','_allowed_types','_max_size','_visibility'),
|
415 |
+
'col2' => array('_label','_public','_roles','_upload_text','_upload_help_text','_button_text'),
|
416 |
+
'col3' => array('_required','_editable','_icon'),
|
417 |
+
'validate' => array(
|
418 |
+
'_title' => array(
|
419 |
+
'mode' => 'required',
|
420 |
+
'error' => __('You must provide a title','ultimate-member')
|
421 |
+
),
|
422 |
+
'_metakey' => array(
|
423 |
+
'mode' => 'unique',
|
424 |
+
),
|
425 |
+
'_max_size' => array(
|
426 |
+
'mode' => 'numeric',
|
427 |
+
'error' => __( 'Please enter a valid size', 'ultimate-member' )
|
428 |
+
),
|
429 |
+
)
|
430 |
+
),
|
431 |
+
|
432 |
+
'date' => array(
|
433 |
+
'name' => 'Date Picker',
|
434 |
+
'col1' => array( '_title', '_metakey', '_help', '_default', '_range', '_years', '_years_x', '_range_start', '_range_end', '_visibility' ),
|
435 |
+
'col2' => array( '_label', '_placeholder', '_public', '_roles', '_format', '_format_custom', '_pretty_format', '_disabled_weekdays' ),
|
436 |
+
'col3' => array( '_required', '_editable', '_icon' ),
|
437 |
+
'validate' => array(
|
438 |
+
'_title' => array(
|
439 |
+
'mode' => 'required',
|
440 |
+
'error' => __( 'You must provide a title', 'ultimate-member' )
|
441 |
+
),
|
442 |
+
'_metakey' => array(
|
443 |
+
'mode' => 'unique',
|
444 |
+
),
|
445 |
+
'_years' => array(
|
446 |
+
'mode' => 'numeric',
|
447 |
+
'error' => __( 'Number of years is not valid', 'ultimate-member' )
|
448 |
+
),
|
449 |
+
'_range_start' => array(
|
450 |
+
'mode' => 'range-start',
|
451 |
+
),
|
452 |
+
'_range_end' => array(
|
453 |
+
'mode' => 'range-end',
|
454 |
+
),
|
455 |
+
)
|
456 |
+
),
|
457 |
+
|
458 |
+
'time' => array(
|
459 |
+
'name' => 'Time Picker',
|
460 |
+
'col1' => array('_title','_metakey','_help','_format','_visibility'),
|
461 |
+
'col2' => array('_label','_placeholder','_default','_public','_roles','_intervals'),
|
462 |
+
'col3' => array('_required','_editable','_icon'),
|
463 |
+
'validate' => array(
|
464 |
+
'_title' => array(
|
465 |
+
'mode' => 'required',
|
466 |
+
'error' => __( 'You must provide a title', 'ultimate-member' )
|
467 |
+
),
|
468 |
+
'_metakey' => array(
|
469 |
+
'mode' => 'unique',
|
470 |
+
),
|
471 |
+
)
|
472 |
+
),
|
473 |
+
|
474 |
+
'rating' => array(
|
475 |
+
'name' => 'Rating',
|
476 |
+
'col1' => array('_title','_metakey','_help','_visibility'),
|
477 |
+
'col2' => array('_label','_public','_roles','_number','_default'),
|
478 |
+
'col3' => array('_required','_editable','_icon'),
|
479 |
+
'validate' => array(
|
480 |
+
'_title' => array(
|
481 |
+
'mode' => 'required',
|
482 |
+
'error' => __('You must provide a title','ultimate-member')
|
483 |
+
),
|
484 |
+
'_metakey' => array(
|
485 |
+
'mode' => 'unique',
|
486 |
+
),
|
487 |
+
)
|
488 |
+
),
|
489 |
+
|
490 |
+
'block' => array(
|
491 |
+
'name' => 'Content Block',
|
492 |
+
'col1' => array('_title','_visibility'),
|
493 |
+
'col2' => array('_public','_roles'),
|
494 |
+
'col_full' => array('_content'),
|
495 |
+
'mce_content' => true,
|
496 |
+
'validate' => array(
|
497 |
+
'_title' => array(
|
498 |
+
'mode' => 'required',
|
499 |
+
'error' => __('You must provide a title','ultimate-member')
|
500 |
+
),
|
501 |
+
)
|
502 |
+
),
|
503 |
+
|
504 |
+
'shortcode' => array(
|
505 |
+
'name' => 'Shortcode',
|
506 |
+
'col1' => array('_title','_visibility'),
|
507 |
+
'col2' => array('_public','_roles'),
|
508 |
+
'col_full' => array('_content'),
|
509 |
+
'validate' => array(
|
510 |
+
'_title' => array(
|
511 |
+
'mode' => 'required',
|
512 |
+
'error' => __('You must provide a title','ultimate-member')
|
513 |
+
),
|
514 |
+
'_content' => array(
|
515 |
+
'mode' => 'required',
|
516 |
+
'error' => __('You must add a shortcode to the content area','ultimate-member')
|
517 |
+
),
|
518 |
+
)
|
519 |
+
),
|
520 |
+
|
521 |
+
'spacing' => array(
|
522 |
+
'name' => 'Spacing',
|
523 |
+
'col1' => array('_title','_visibility'),
|
524 |
+
'col2' => array('_spacing'),
|
525 |
+
'form_only' => true,
|
526 |
+
'validate' => array(
|
527 |
+
'_title' => array(
|
528 |
+
'mode' => 'required',
|
529 |
+
'error' => __('You must provide a title','ultimate-member')
|
530 |
+
),
|
531 |
+
)
|
532 |
+
),
|
533 |
+
|
534 |
+
'divider' => array(
|
535 |
+
'name' => 'Divider',
|
536 |
+
'col1' => array('_title','_width','_divider_text','_visibility'),
|
537 |
+
'col2' => array('_style','_color','_public','_roles'),
|
538 |
+
'form_only' => true,
|
539 |
+
'validate' => array(
|
540 |
+
'_title' => array(
|
541 |
+
'mode' => 'required',
|
542 |
+
'error' => __('You must provide a title','ultimate-member')
|
543 |
+
),
|
544 |
+
)
|
545 |
+
),
|
546 |
+
|
547 |
+
'googlemap' => array(
|
548 |
+
'name' => 'Google Map',
|
549 |
+
'col1' => array('_title','_metakey','_help','_visibility'),
|
550 |
+
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
551 |
+
'col3' => array('_required','_editable','_icon'),
|
552 |
+
'validate' => array(
|
553 |
+
'_title' => array(
|
554 |
+
'mode' => 'required',
|
555 |
+
'error' => __('You must provide a title','ultimate-member')
|
556 |
+
),
|
557 |
+
'_metakey' => array(
|
558 |
+
'mode' => 'unique',
|
559 |
+
),
|
560 |
+
)
|
561 |
+
),
|
562 |
+
|
563 |
+
'youtube_video' => array(
|
564 |
+
'name' => 'YouTube Video',
|
565 |
+
'col1' => array('_title','_metakey','_help','_visibility'),
|
566 |
+
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
567 |
+
'col3' => array('_required','_editable','_icon'),
|
568 |
+
'validate' => array(
|
569 |
+
'_title' => array(
|
570 |
+
'mode' => 'required',
|
571 |
+
'error' => __('You must provide a title','ultimate-member')
|
572 |
+
),
|
573 |
+
'_metakey' => array(
|
574 |
+
'mode' => 'unique',
|
575 |
+
),
|
576 |
+
)
|
577 |
+
),
|
578 |
+
|
579 |
+
'vimeo_video' => array(
|
580 |
+
'name' => 'Vimeo Video',
|
581 |
+
'col1' => array('_title','_metakey','_help','_visibility'),
|
582 |
+
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
583 |
+
'col3' => array('_required','_editable','_icon'),
|
584 |
+
'validate' => array(
|
585 |
+
'_title' => array(
|
586 |
+
'mode' => 'required',
|
587 |
+
'error' => __('You must provide a title','ultimate-member')
|
588 |
+
),
|
589 |
+
'_metakey' => array(
|
590 |
+
'mode' => 'unique',
|
591 |
+
),
|
592 |
+
)
|
593 |
+
),
|
594 |
+
|
595 |
+
'soundcloud_track' => array(
|
596 |
+
'name' => 'SoundCloud Track',
|
597 |
+
'col1' => array('_title','_metakey','_help','_visibility'),
|
598 |
+
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
|
599 |
+
'col3' => array('_required','_editable','_icon'),
|
600 |
+
'validate' => array(
|
601 |
+
'_title' => array(
|
602 |
+
'mode' => 'required',
|
603 |
+
'error' => __('You must provide a title','ultimate-member')
|
604 |
+
),
|
605 |
+
'_metakey' => array(
|
606 |
+
'mode' => 'unique',
|
607 |
+
),
|
608 |
+
)
|
609 |
+
),
|
610 |
+
|
611 |
+
/*'group' => array(
|
612 |
+
'name' => 'Field Group',
|
613 |
+
'col1' => array('_title','_max_entries'),
|
614 |
+
'col2' => array('_label','_public','_roles'),
|
615 |
+
'form_only' => true,
|
616 |
+
'validate' => array(
|
617 |
+
'_title' => array(
|
618 |
+
'mode' => 'required',
|
619 |
+
'error' => 'You must provide a title'
|
620 |
+
),
|
621 |
+
'_label' => array(
|
622 |
+
'mode' => 'required',
|
623 |
+
'error' => 'You must provide a label'
|
624 |
+
),
|
625 |
+
)
|
626 |
+
),*/
|
627 |
+
|
628 |
+
);
|
629 |
+
|
630 |
+
/**
|
631 |
+
* UM hook
|
632 |
+
*
|
633 |
+
* @type filter
|
634 |
+
* @title um_core_fields_hook
|
635 |
+
* @description UM Core Fields
|
636 |
+
* @input_vars
|
637 |
+
* [{"var":"$core_fields","type":"array","desc":"Core Fields"}]
|
638 |
+
* @change_log
|
639 |
+
* ["Since: 2.0"]
|
640 |
+
* @usage add_filter( 'um_core_fields_hook', 'function_name', 10, 1 );
|
641 |
+
* @example
|
642 |
+
* <?php
|
643 |
+
* add_filter( 'um_core_fields_hook', 'my_core_fields', 10, 1 );
|
644 |
+
* function my_core_fields( $core_fields ) {
|
645 |
+
* // your code here
|
646 |
+
* return $core_fields;
|
647 |
+
* }
|
648 |
+
* ?>
|
649 |
+
*/
|
650 |
+
$this->core_fields = apply_filters( 'um_core_fields_hook', $this->core_fields );
|
651 |
+
}
|
652 |
+
|
653 |
+
|
654 |
+
/**
|
655 |
+
* Predefined Fields
|
656 |
+
*/
|
657 |
+
function set_predefined_fields() {
|
658 |
+
global $wp_roles;
|
659 |
+
|
660 |
+
$um_roles = array();
|
661 |
+
if ( ! empty( $wp_roles->roles ) ) {
|
662 |
+
$role_keys = get_option( 'um_roles', array() );
|
663 |
+
if ( ! empty( $role_keys ) && is_array( $role_keys ) ) {
|
664 |
+
$role_keys = array_map( function( $item ) {
|
665 |
+
return 'um_' . $item;
|
666 |
+
}, $role_keys );
|
667 |
+
} else {
|
668 |
+
$role_keys = array();
|
669 |
+
}
|
670 |
+
|
671 |
+
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
672 |
+
$um_roles = UM()->roles()->get_roles( false, $exclude_roles );
|
673 |
+
}
|
674 |
+
|
675 |
+
/**
|
676 |
+
* UM hook
|
677 |
+
*
|
678 |
+
* @type filter
|
679 |
+
* @title um_profile_privacy_options
|
680 |
+
* @description Profile Privacy Options
|
681 |
+
* @input_vars
|
682 |
+
* [{"var":"$privacy_options","type":"array","desc":"Privacy Options"}]
|
683 |
+
* @change_log
|
684 |
+
* ["Since: 2.0"]
|
685 |
+
* @usage add_filter( 'um_profile_privacy_options', 'function_name', 10, 1 );
|
686 |
+
* @example
|
687 |
+
* <?php
|
688 |
+
* add_filter( 'um_profile_privacy_options', 'my_profile_privacy_options', 10, 1 );
|
689 |
+
* function my_profile_privacy_options( $privacy_options ) {
|
690 |
+
* // your code here
|
691 |
+
* return $privacy_options;
|
692 |
+
* }
|
693 |
+
* ?>
|
694 |
+
*/
|
695 |
+
$profile_privacy = apply_filters( 'um_profile_privacy_options', array(
|
696 |
+
'Everyone' => __( 'Everyone', 'ultimate-member' ),
|
697 |
+
'Only me' => __( 'Only me', 'ultimate-member' )
|
698 |
+
) );
|
699 |
+
|
700 |
+
/*
|
701 |
+
* it's important create key for array equals value of 'metakey'.
|
702 |
+
*
|
703 |
+
*/
|
704 |
+
|
705 |
+
$this->predefined_fields = array(
|
706 |
+
|
707 |
+
'user_login' => array(
|
708 |
+
'title' => __('Username','ultimate-member'),
|
709 |
+
'metakey' => 'user_login',
|
710 |
+
'type' => 'text',
|
711 |
+
'label' => __('Username','ultimate-member'),
|
712 |
+
'required' => 1,
|
713 |
+
'public' => 1,
|
714 |
+
'editable' => 0,
|
715 |
+
'validate' => 'unique_username',
|
716 |
+
'min_chars' => 3,
|
717 |
+
'max_chars' => 24
|
718 |
+
),
|
719 |
+
|
720 |
+
'username' => array(
|
721 |
+
'title' => __('Username or E-mail','ultimate-member'),
|
722 |
+
'metakey' => 'username',
|
723 |
+
'type' => 'text',
|
724 |
+
'label' => __('Username or E-mail','ultimate-member'),
|
725 |
+
'required' => 1,
|
726 |
+
'public' => 1,
|
727 |
+
'editable' => 0,
|
728 |
+
'validate' => 'unique_username_or_email',
|
729 |
+
),
|
730 |
+
|
731 |
+
'user_password' => array(
|
732 |
+
'title' => __('Password','ultimate-member'),
|
733 |
+
'metakey' => 'user_password',
|
734 |
+
'type' => 'password',
|
735 |
+
'label' => __('Password','ultimate-member'),
|
736 |
+
'required' => 1,
|
737 |
+
'public' => 1,
|
738 |
+
'editable' => 1,
|
739 |
+
'min_chars' => 8,
|
740 |
+
'max_chars' => 30,
|
741 |
+
'force_good_pass' => 1,
|
742 |
+
'force_confirm_pass' => 1,
|
743 |
+
'label_confirm_pass' => __('Confirm Password','ultimate-member')
|
744 |
+
),
|
745 |
+
|
746 |
+
'first_name' => array(
|
747 |
+
'title' => __('First Name','ultimate-member'),
|
748 |
+
'metakey' => 'first_name',
|
749 |
+
'type' => 'text',
|
750 |
+
'label' => __('First Name','ultimate-member'),
|
751 |
+
'required' => 0,
|
752 |
+
'public' => 1,
|
753 |
+
'editable' => 1,
|
754 |
+
),
|
755 |
+
|
756 |
+
'last_name' => array(
|
757 |
+
'title' => __('Last Name','ultimate-member'),
|
758 |
+
'metakey' => 'last_name',
|
759 |
+
'type' => 'text',
|
760 |
+
'label' => __('Last Name','ultimate-member'),
|
761 |
+
'required' => 0,
|
762 |
+
'public' => 1,
|
763 |
+
'editable' => 1,
|
764 |
+
),
|
765 |
+
|
766 |
+
'nickname' => array(
|
767 |
+
'title' => __('Nickname','ultimate-member'),
|
768 |
+
'metakey' => 'nickname',
|
769 |
+
'type' => 'text',
|
770 |
+
'label' => __('Nickname','ultimate-member'),
|
771 |
+
'required' => 0,
|
772 |
+
'public' => 1,
|
773 |
+
'editable' => 1,
|
774 |
+
),
|
775 |
+
|
776 |
+
'user_url' => array(
|
777 |
+
'title' => __('Website URL','ultimate-member'),
|
778 |
+
'metakey' => 'user_url',
|
779 |
+
'type' => 'url',
|
780 |
+
'label' => __('Website URL','ultimate-member'),
|
781 |
+
'required' => 1,
|
782 |
+
'public' => 1,
|
783 |
+
'editable' => 1,
|
784 |
+
'validate' => 'url'
|
785 |
+
),
|
786 |
+
|
787 |
+
'user_registered' => array(
|
788 |
+
'title' => __('Registration Date','ultimate-member'),
|
789 |
+
'metakey' => 'user_registered',
|
790 |
+
'type' => 'text',
|
791 |
+
'label' => __('Registration Date','ultimate-member'),
|
792 |
+
'required' => 0,
|
793 |
+
'public' => 1,
|
794 |
+
'editable' => 1,
|
795 |
+
'edit_forbidden' => 1,
|
796 |
+
),
|
797 |
+
|
798 |
+
'_um_last_login' => array(
|
799 |
+
'title' => __('Last Login','ultimate-member'),
|
800 |
+
'metakey' => '_um_last_login',
|
801 |
+
'type' => 'text',
|
802 |
+
'label' => __('Last Login','ultimate-member'),
|
803 |
+
'required' => 0,
|
804 |
+
'public' => 1,
|
805 |
+
'editable' => 1,
|
806 |
+
'edit_forbidden' => 1,
|
807 |
+
),
|
808 |
+
|
809 |
+
'user_email' => array(
|
810 |
+
'title' => __('E-mail Address','ultimate-member'),
|
811 |
+
'metakey' => 'user_email',
|
812 |
+
'type' => 'text',
|
813 |
+
'label' => __('E-mail Address','ultimate-member'),
|
814 |
+
'required' => 0,
|
815 |
+
'public' => 1,
|
816 |
+
'validate' => 'unique_email',
|
817 |
+
'autocomplete' => 'off'
|
818 |
+
),
|
819 |
+
|
820 |
+
'secondary_user_email' => array(
|
821 |
+
'title' => __('Secondary E-mail Address','ultimate-member'),
|
822 |
+
'metakey' => 'secondary_user_email',
|
823 |
+
'type' => 'text',
|
824 |
+
'label' => __('Secondary E-mail Address','ultimate-member'),
|
825 |
+
'required' => 0,
|
826 |
+
'public' => 1,
|
827 |
+
'editable' => 1,
|
828 |
+
'validate' => 'unique_email',
|
829 |
+
'autocomplete' => 'off'
|
830 |
+
),
|
831 |
+
|
832 |
+
'description' => array(
|
833 |
+
'title' => __('Biography','ultimate-member'),
|
834 |
+
'metakey' => 'description',
|
835 |
+
'type' => 'textarea',
|
836 |
+
'label' => __('Biography','ultimate-member'),
|
837 |
+
'html' => 0,
|
838 |
+
'required' => 0,
|
839 |
+
'public' => 1,
|
840 |
+
'editable' => 1,
|
841 |
+
'max_words' => 40,
|
842 |
+
'placeholder' => __('Enter a bit about yourself...','ultimate-member'),
|
843 |
+
),
|
844 |
+
|
845 |
+
'birth_date' => array(
|
846 |
+
'title' => __('Birth Date','ultimate-member'),
|
847 |
+
'metakey' => 'birth_date',
|
848 |
+
'type' => 'date',
|
849 |
+
'label' => __('Birth Date','ultimate-member'),
|
850 |
+
'required' => 0,
|
851 |
+
'public' => 1,
|
852 |
+
'editable' => 1,
|
853 |
+
'pretty_format' => 1,
|
854 |
+
'years' => 115,
|
855 |
+
'years_x' => 'past',
|
856 |
+
'icon' => 'um-faicon-calendar'
|
857 |
+
),
|
858 |
+
|
859 |
+
'gender' => array(
|
860 |
+
'title' => __('Gender','ultimate-member'),
|
861 |
+
'metakey' => 'gender',
|
862 |
+
'type' => 'radio',
|
863 |
+
'label' => __('Gender','ultimate-member'),
|
864 |
+
'required' => 0,
|
865 |
+
'public' => 1,
|
866 |
+
'editable' => 1,
|
867 |
+
'options' => array( __('Male','ultimate-member'), __('Female','ultimate-member') )
|
868 |
+
),
|
869 |
+
|
870 |
+
'country' => array(
|
871 |
+
'title' => __('Country','ultimate-member'),
|
872 |
+
'metakey' => 'country',
|
873 |
+
'type' => 'select',
|
874 |
+
'label' => __('Country','ultimate-member'),
|
875 |
+
'placeholder' => __('Choose a Country','ultimate-member'),
|
876 |
+
'required' => 0,
|
877 |
+
'public' => 1,
|
878 |
+
'editable' => 1,
|
879 |
+
'options' => $this->get('countries')
|
880 |
+
),
|
881 |
+
|
882 |
+
'facebook' => array(
|
883 |
+
'title' => __('Facebook','ultimate-member'),
|
884 |
+
'metakey' => 'facebook',
|
885 |
+
'type' => 'url',
|
886 |
+
'label' => __('Facebook','ultimate-member'),
|
887 |
+
'required' => 0,
|
888 |
+
'public' => 1,
|
889 |
+
'editable' => 1,
|
890 |
+
'url_target' => '_blank',
|
891 |
+
'url_rel' => 'nofollow',
|
892 |
+
'icon' => 'um-faicon-facebook',
|
893 |
+
'validate' => 'facebook_url',
|
894 |
+
'url_text' => 'Facebook',
|
895 |
+
'advanced' => 'social',
|
896 |
+
'color' => '#3B5999',
|
897 |
+
'match' => 'https://facebook.com/',
|
898 |
+
),
|
899 |
+
|
900 |
+
'twitter' => array(
|
901 |
+
'title' => __('Twitter','ultimate-member'),
|
902 |
+
'metakey' => 'twitter',
|
903 |
+
'type' => 'url',
|
904 |
+
'label' => __('Twitter','ultimate-member'),
|
905 |
+
'required' => 0,
|
906 |
+
'public' => 1,
|
907 |
+
'editable' => 1,
|
908 |
+
'url_target' => '_blank',
|
909 |
+
'url_rel' => 'nofollow',
|
910 |
+
'icon' => 'um-faicon-twitter',
|
911 |
+
'validate' => 'twitter_url',
|
912 |
+
'url_text' => 'Twitter',
|
913 |
+
'advanced' => 'social',
|
914 |
+
'color' => '#4099FF',
|
915 |
+
'match' => 'https://twitter.com/',
|
916 |
+
),
|
917 |
+
|
918 |
+
'linkedin' => array(
|
919 |
+
'title' => __('LinkedIn','ultimate-member'),
|
920 |
+
'metakey' => 'linkedin',
|
921 |
+
'type' => 'url',
|
922 |
+
'label' => __('LinkedIn','ultimate-member'),
|
923 |
+
'required' => 0,
|
924 |
+
'public' => 1,
|
925 |
+
'editable' => 1,
|
926 |
+
'url_target' => '_blank',
|
927 |
+
'url_rel' => 'nofollow',
|
928 |
+
'icon' => 'um-faicon-linkedin',
|
929 |
+
'validate' => 'linkedin_url',
|
930 |
+
'url_text' => 'LinkedIn',
|
931 |
+
'advanced' => 'social',
|
932 |
+
'color' => '#0976b4',
|
933 |
+
'match' => 'https://linkedin.com/',
|
934 |
+
),
|
935 |
+
|
936 |
+
'googleplus' => array(
|
937 |
+
'title' => __('Google+','ultimate-member'),
|
938 |
+
'metakey' => 'googleplus',
|
939 |
+
'type' => 'url',
|
940 |
+
'label' => __('Google+','ultimate-member'),
|
941 |
+
'required' => 0,
|
942 |
+
'public' => 1,
|
943 |
+
'editable' => 1,
|
944 |
+
'url_target' => '_blank',
|
945 |
+
'url_rel' => 'nofollow',
|
946 |
+
'icon' => 'um-faicon-google-plus',
|
947 |
+
'validate' => 'google_url',
|
948 |
+
'url_text' => 'Google+',
|
949 |
+
'advanced' => 'social',
|
950 |
+
'color' => '#dd4b39',
|
951 |
+
'match' => 'https://google.com/+',
|
952 |
+
),
|
953 |
+
|
954 |
+
'instagram' => array(
|
955 |
+
'title' => __('Instagram','ultimate-member'),
|
956 |
+
'metakey' => 'instagram',
|
957 |
+
'type' => 'url',
|
958 |
+
'label' => __('Instagram','ultimate-member'),
|
959 |
+
'required' => 0,
|
960 |
+
'public' => 1,
|
961 |
+
'editable' => 1,
|
962 |
+
'url_target' => '_blank',
|
963 |
+
'url_rel' => 'nofollow',
|
964 |
+
'icon' => 'um-faicon-instagram',
|
965 |
+
'validate' => 'instagram_url',
|
966 |
+
'url_text' => 'Instagram',
|
967 |
+
'advanced' => 'social',
|
968 |
+
'color' => 'radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%,#d6249f 60%,#285AEB 90%)',
|
969 |
+
'match' => 'https://instagram.com/',
|
970 |
+
),
|
971 |
+
|
972 |
+
'skype' => array(
|
973 |
+
'title' => __('Skype ID','ultimate-member'),
|
974 |
+
'metakey' => 'skype',
|
975 |
+
'type' => 'text',
|
976 |
+
'label' => __('Skype ID','ultimate-member'),
|
977 |
+
'required' => 0,
|
978 |
+
'public' => 1,
|
979 |
+
'editable' => 1,
|
980 |
+
'url_target' => '_blank',
|
981 |
+
'url_rel' => 'nofollow',
|
982 |
+
'icon' => 'um-faicon-skype',
|
983 |
+
'validate' => 'skype',
|
984 |
+
'url_text' => __( 'Join chat', 'ultimate-member' ),
|
985 |
+
),
|
986 |
+
|
987 |
+
'viber' => array(
|
988 |
+
'title' => __('Viber number','ultimate-member'),
|
989 |
+
'metakey' => 'viber',
|
990 |
+
'type' => 'text',
|
991 |
+
'label' => __('Viber number','ultimate-member'),
|
992 |
+
'required' => 0,
|
993 |
+
'public' => 1,
|
994 |
+
'editable' => 1,
|
995 |
+
'url_target' => '_blank',
|
996 |
+
'url_rel' => 'nofollow',
|
997 |
+
'icon' => 'um-icon-ios-telephone',
|
998 |
+
'validate' => 'phone_number',
|
999 |
+
),
|
1000 |
+
|
1001 |
+
'whatsapp' => array(
|
1002 |
+
'title' => __('WhatsApp number','ultimate-member'),
|
1003 |
+
'metakey' => 'whatsapp',
|
1004 |
+
'type' => 'text',
|
1005 |
+
'label' => __('WhatsApp number','ultimate-member'),
|
1006 |
+
'required' => 0,
|
1007 |
+
'public' => 1,
|
1008 |
+
'editable' => 1,
|
1009 |
+
'url_target' => '_blank',
|
1010 |
+
'url_rel' => 'nofollow',
|
1011 |
+
'icon' => 'um-icon-social-whatsapp',
|
1012 |
+
'validate' => 'phone_number',
|
1013 |
+
),
|
1014 |
+
|
1015 |
+
'telegram' => array(
|
1016 |
+
'title' => __('Telegram','ultimate-member'),
|
1017 |
+
'metakey' => 'telegram',
|
1018 |
+
'type' => 'url',
|
1019 |
+
'label' => __('Telegram','ultimate-member'),
|
1020 |
+
'required' => 0,
|
1021 |
+
'public' => 1,
|
1022 |
+
'editable' => 1,
|
1023 |
+
'url_target' => '_blank',
|
1024 |
+
'url_rel' => 'nofollow',
|
1025 |
+
'icon' => 'um-faicon-paper-plane',
|
1026 |
+
'validate' => 'telegram_url',
|
1027 |
+
'url_text' => 'Telegram',
|
1028 |
+
'match' => 'https://t.me/',
|
1029 |
+
),
|
1030 |
+
|
1031 |
+
'discord' => array(
|
1032 |
+
'title' => __('Discord','ultimate-member'),
|
1033 |
+
'metakey' => 'discord',
|
1034 |
+
'type' => 'text',
|
1035 |
+
'label' => __('Discord ID','ultimate-member'),
|
1036 |
+
'required' => 0,
|
1037 |
+
'public' => 1,
|
1038 |
+
'editable' => 1,
|
1039 |
+
'url_target' => '_blank',
|
1040 |
+
'url_rel' => 'nofollow',
|
1041 |
+
'validate' => 'discord',
|
1042 |
+
),
|
1043 |
+
|
1044 |
+
'youtube' => array(
|
1045 |
+
'title' => __('YouTube','ultimate-member'),
|
1046 |
+
'metakey' => 'youtube',
|
1047 |
+
'type' => 'url',
|
1048 |
+
'label' => __('YouTube','ultimate-member'),
|
1049 |
+
'required' => 0,
|
1050 |
+
'public' => 1,
|
1051 |
+
'editable' => 1,
|
1052 |
+
'url_target' => '_blank',
|
1053 |
+
'url_rel' => 'nofollow',
|
1054 |
+
'icon' => 'um-faicon-youtube',
|
1055 |
+
'validate' => 'youtube_url',
|
1056 |
+
'url_text' => 'YouTube',
|
1057 |
+
'advanced' => 'social',
|
1058 |
+
'color' => '#e52d27',
|
1059 |
+
'match' => 'https://youtube.com/',
|
1060 |
+
),
|
1061 |
+
|
1062 |
+
'soundcloud' => array(
|
1063 |
+
'title' => __( 'SoundCloud', 'ultimate-member' ),
|
1064 |
+
'metakey' => 'soundcloud',
|
1065 |
+
'type' => 'url',
|
1066 |
+
'label' => __( 'SoundCloud', 'ultimate-member' ),
|
1067 |
+
'required' => 0,
|
1068 |
+
'public' => 1,
|
1069 |
+
'editable' => 1,
|
1070 |
+
'url_target' => '_blank',
|
1071 |
+
'url_rel' => 'nofollow',
|
1072 |
+
'icon' => 'um-faicon-soundcloud',
|
1073 |
+
'validate' => 'soundcloud_url',
|
1074 |
+
'url_text' => 'SoundCloud',
|
1075 |
+
'advanced' => 'social',
|
1076 |
+
'color' => '#f50',
|
1077 |
+
'match' => 'https://soundcloud.com/',
|
1078 |
+
),
|
1079 |
+
|
1080 |
+
'vkontakte' => array(
|
1081 |
+
'title' => __('VKontakte','ultimate-member'),
|
1082 |
+
'metakey' => 'vkontakte',
|
1083 |
+
'type' => 'url',
|
1084 |
+
'label' => __('VKontakte','ultimate-member'),
|
1085 |
+
'required' => 0,
|
1086 |
+
'public' => 1,
|
1087 |
+
'editable' => 1,
|
1088 |
+
'url_target' => '_blank',
|
1089 |
+
'url_rel' => 'nofollow',
|
1090 |
+
'icon' => 'um-faicon-vk',
|
1091 |
+
'validate' => 'vk_url',
|
1092 |
+
'url_text' => 'VKontakte',
|
1093 |
+
'advanced' => 'social',
|
1094 |
+
'color' => '#2B587A',
|
1095 |
+
'match' => 'https://vk.com/',
|
1096 |
+
),
|
1097 |
+
|
1098 |
+
'role_select' => array(
|
1099 |
+
'title' => __('Roles (Dropdown)','ultimate-member'),
|
1100 |
+
'metakey' => 'role_select',
|
1101 |
+
'type' => 'select',
|
1102 |
+
'label' => __('Account Type','ultimate-member'),
|
1103 |
+
'placeholder' => 'Choose account type',
|
1104 |
+
'required' => 0,
|
1105 |
+
'public' => 1,
|
1106 |
+
'editable' => 1,
|
1107 |
+
'options' => $um_roles,
|
1108 |
+
),
|
1109 |
+
|
1110 |
+
'role_radio' => array(
|
1111 |
+
'title' => __('Roles (Radio)','ultimate-member'),
|
1112 |
+
'metakey' => 'role_radio',
|
1113 |
+
'type' => 'radio',
|
1114 |
+
'label' => __('Account Type','ultimate-member'),
|
1115 |
+
'required' => 0,
|
1116 |
+
'public' => 1,
|
1117 |
+
'editable' => 1,
|
1118 |
+
'options' => $um_roles,
|
1119 |
+
),
|
1120 |
+
|
1121 |
+
'languages' => array(
|
1122 |
+
'title' => __('Languages','ultimate-member'),
|
1123 |
+
'metakey' => 'languages',
|
1124 |
+
'type' => 'multiselect',
|
1125 |
+
'label' => __('Languages Spoken','ultimate-member'),
|
1126 |
+
'placeholder' => __('Select languages','ultimate-member'),
|
1127 |
+
'required' => 0,
|
1128 |
+
'public' => 1,
|
1129 |
+
'editable' => 1,
|
1130 |
+
'options' => $this->get('languages'),
|
1131 |
+
),
|
1132 |
+
|
1133 |
+
'phone_number' => array(
|
1134 |
+
'title' => __('Phone Number','ultimate-member'),
|
1135 |
+
'metakey' => 'phone_number',
|
1136 |
+
'type' => 'text',
|
1137 |
+
'label' => __('Phone Number','ultimate-member'),
|
1138 |
+
'required' => 0,
|
1139 |
+
'public' => 1,
|
1140 |
+
'editable' => 1,
|
1141 |
+
'validate' => 'phone_number',
|
1142 |
+
'icon' => 'um-faicon-phone',
|
1143 |
+
),
|
1144 |
+
|
1145 |
+
'mobile_number' => array(
|
1146 |
+
'title' => __('Mobile Number','ultimate-member'),
|
1147 |
+
'metakey' => 'mobile_number',
|
1148 |
+
'type' => 'text',
|
1149 |
+
'label' => __('Mobile Number','ultimate-member'),
|
1150 |
+
'required' => 0,
|
1151 |
+
'public' => 1,
|
1152 |
+
'editable' => 1,
|
1153 |
+
'validate' => 'phone_number',
|
1154 |
+
'icon' => 'um-faicon-mobile',
|
1155 |
+
),
|
1156 |
+
|
1157 |
+
// private use ( not public list )
|
1158 |
+
|
1159 |
+
'profile_photo' => array(
|
1160 |
+
'title' => __('Profile Photo','ultimate-member'),
|
1161 |
+
'metakey' => 'profile_photo',
|
1162 |
+
'type' => 'image',
|
1163 |
+
'label' => __('Change your profile photo','ultimate-member'),
|
1164 |
+
'upload_text' => __('Upload your photo here','ultimate-member'),
|
1165 |
+
'icon' => 'um-faicon-camera',
|
1166 |
+
'crop' => 1,
|
1167 |
+
'max_size' => ( UM()->options()->get('profile_photo_max_size') ) ? UM()->options()->get('profile_photo_max_size') : 999999999,
|
1168 |
+
'min_width' => str_replace('px','',UM()->options()->get('profile_photosize')),
|
1169 |
+
'min_height' => str_replace('px','',UM()->options()->get('profile_photosize')),
|
1170 |
+
'private_use' => true,
|
1171 |
+
),
|
1172 |
+
|
1173 |
+
'cover_photo' => array(
|
1174 |
+
'title' => __('Cover Photo','ultimate-member'),
|
1175 |
+
'metakey' => 'cover_photo',
|
1176 |
+
'type' => 'image',
|
1177 |
+
'label' => __('Change your cover photo','ultimate-member'),
|
1178 |
+
'upload_text' => __('Upload profile cover here','ultimate-member'),
|
1179 |
+
'icon' => 'um-faicon-picture-o',
|
1180 |
+
'crop' => 2,
|
1181 |
+
'max_size' => ( UM()->options()->get('cover_photo_max_size') ) ? UM()->options()->get('cover_photo_max_size') : 999999999,
|
1182 |
+
'modal_size' => 'large',
|
1183 |
+
'ratio' => str_replace(':1','',UM()->options()->get('profile_cover_ratio')),
|
1184 |
+
'min_width' => UM()->options()->get('cover_min_width'),
|
1185 |
+
'private_use' => true,
|
1186 |
+
),
|
1187 |
+
|
1188 |
+
'username_b' => array(
|
1189 |
+
'title' => __('Username or E-mail','ultimate-member'),
|
1190 |
+
'metakey' => 'username_b',
|
1191 |
+
'type' => 'text',
|
1192 |
+
'placeholder' => __('Enter your username or email','ultimate-member'),
|
1193 |
+
'required' => 1,
|
1194 |
+
'public' => 1,
|
1195 |
+
'editable' => 0,
|
1196 |
+
'private_use' => true,
|
1197 |
+
),
|
1198 |
+
|
1199 |
+
// account page use ( not public )
|
1200 |
+
|
1201 |
+
'profile_privacy' => array(
|
1202 |
+
'title' => __( 'Profile Privacy', 'ultimate-member' ),
|
1203 |
+
'metakey' => 'profile_privacy',
|
1204 |
+
'type' => 'select',
|
1205 |
+
'label' => __( 'Profile Privacy', 'ultimate-member' ),
|
1206 |
+
'help' => __( 'Who can see your public profile?', 'ultimate-member' ),
|
1207 |
+
'required' => 0,
|
1208 |
+
'public' => 1,
|
1209 |
+
'editable' => 1,
|
1210 |
+
'default' => 'Everyone',
|
1211 |
+
'options' => $profile_privacy,
|
1212 |
+
'allowclear' => 0,
|
1213 |
+
'account_only' => true,
|
1214 |
+
'required_perm' => 'can_make_private_profile',
|
1215 |
+
),
|
1216 |
+
|
1217 |
+
'profile_noindex' => array(
|
1218 |
+
'title' => __( 'Avoid indexing my profile by search engines', 'ultimate-member' ),
|
1219 |
+
'metakey' => 'profile_noindex',
|
1220 |
+
'type' => 'select',
|
1221 |
+
'label' => __( 'Avoid indexing my profile by search engines', 'ultimate-member' ),
|
1222 |
+
'help' => __( 'Hide my profile for robots?', 'ultimate-member' ),
|
1223 |
+
'required' => 0,
|
1224 |
+
'public' => 1,
|
1225 |
+
'editable' => 1,
|
1226 |
+
'default' => UM()->roles()->um_user_can( 'profile_noindex' ) ? '1' : '0',
|
1227 |
+
'options' => array(
|
1228 |
+
'0' => __( 'No', 'ultimate-member' ),
|
1229 |
+
'1' => __( 'Yes', 'ultimate-member' ),
|
1230 |
+
),
|
1231 |
+
'allowclear' => 0,
|
1232 |
+
'account_only' => true,
|
1233 |
+
'required_perm' => 'can_make_private_profile',
|
1234 |
+
),
|
1235 |
+
|
1236 |
+
'hide_in_members' => array(
|
1237 |
+
'title' => __( 'Hide my profile from directory', 'ultimate-member' ),
|
1238 |
+
'metakey' => 'hide_in_members',
|
1239 |
+
'type' => 'radio',
|
1240 |
+
'label' => __( 'Hide my profile from directory', 'ultimate-member' ),
|
1241 |
+
'help' => __( 'Here you can hide yourself from appearing in public directory', 'ultimate-member' ),
|
1242 |
+
'required' => 0,
|
1243 |
+
'public' => 1,
|
1244 |
+
'editable' => 1,
|
1245 |
+
'default' => UM()->member_directory()->get_hide_in_members_default() ? 'Yes' : 'No',
|
1246 |
+
'options' => array(
|
1247 |
+
'No' => __( 'No', 'ultimate-member' ),
|
1248 |
+
'Yes' => __( 'Yes', 'ultimate-member' ),
|
1249 |
+
),
|
1250 |
+
'account_only' => true,
|
1251 |
+
'required_opt' => array( 'members_page', 1 ),
|
1252 |
+
),
|
1253 |
+
|
1254 |
+
'delete_account' => array(
|
1255 |
+
'title' => __( 'Delete Account', 'ultimate-member' ),
|
1256 |
+
'metakey' => 'delete_account',
|
1257 |
+
'type' => 'radio',
|
1258 |
+
'label' => __( 'Delete Account', 'ultimate-member'),
|
1259 |
+
'help' => __( 'If you confirm, everything related to your profile will be deleted permanently from the site', 'ultimate-member' ),
|
1260 |
+
'required' => 0,
|
1261 |
+
'public' => 1,
|
1262 |
+
'editable' => 1,
|
1263 |
+
'default' => __( 'No', 'ultimate-member' ),
|
1264 |
+
'options' => array(
|
1265 |
+
__( 'Yes', 'ultimate-member' ),
|
1266 |
+
__( 'No', 'ultimate-member' )
|
1267 |
+
),
|
1268 |
+
'account_only' => true,
|
1269 |
+
),
|
1270 |
+
|
1271 |
+
'single_user_password' => array(
|
1272 |
+
'title' => __( 'Password', 'ultimate-member' ),
|
1273 |
+
'metakey' => 'single_user_password',
|
1274 |
+
'type' => 'password',
|
1275 |
+
'label' => __( 'Password', 'ultimate-member' ),
|
1276 |
+
'required' => 1,
|
1277 |
+
'public' => 1,
|
1278 |
+
'editable' => 1,
|
1279 |
+
'account_only' => true,
|
1280 |
+
),
|
1281 |
+
|
1282 |
+
);
|
1283 |
+
|
1284 |
+
/**
|
1285 |
+
* UM hook
|
1286 |
+
*
|
1287 |
+
* @type filter
|
1288 |
+
* @title um_predefined_fields_hook
|
1289 |
+
* @description Extend Predefined Fields
|
1290 |
+
* @input_vars
|
1291 |
+
* [{"var":"$predefined_fields","type":"array","desc":"Predefined Fields"}]
|
1292 |
+
* @change_log
|
1293 |
+
* ["Since: 2.0"]
|
1294 |
+
* @usage add_filter( 'um_predefined_fields_hook', 'function_name', 10, 1 );
|
1295 |
+
* @example
|
1296 |
+
* <?php
|
1297 |
+
* add_filter( 'um_predefined_fields_hook', 'my_predefined_fields', 10, 1 );
|
1298 |
+
* function my_predefined_fields( $predefined_fields ) {
|
1299 |
+
* // your code here
|
1300 |
+
* return $predefined_fields;
|
1301 |
+
* }
|
1302 |
+
* ?>
|
1303 |
+
*/
|
1304 |
+
$this->predefined_fields = apply_filters( 'um_predefined_fields_hook', $this->predefined_fields );
|
1305 |
+
}
|
1306 |
+
|
1307 |
+
|
1308 |
+
/**
|
1309 |
+
* Custom Fields
|
1310 |
+
*/
|
1311 |
+
function set_custom_fields() {
|
1312 |
+
|
1313 |
+
if ( is_array( $this->saved_fields ) ) {
|
1314 |
+
|
1315 |
+
$this->custom_fields = $this->saved_fields;
|
1316 |
+
|
1317 |
+
} else {
|
1318 |
+
|
1319 |
+
$this->custom_fields = '';
|
1320 |
+
|
1321 |
+
}
|
1322 |
+
|
1323 |
+
$custom = $this->custom_fields;
|
1324 |
+
$predefined = $this->predefined_fields;
|
1325 |
+
|
1326 |
+
if ( is_array( $custom ) ){
|
1327 |
+
$this->all_user_fields = array_merge( $predefined, $custom );
|
1328 |
+
} else {
|
1329 |
+
$this->all_user_fields = $predefined;
|
1330 |
+
}
|
1331 |
+
|
1332 |
+
}
|
1333 |
+
|
1334 |
+
|
1335 |
+
/**
|
1336 |
+
* Get all fields without metakeys
|
1337 |
+
*
|
1338 |
+
* @since 2.0.56
|
1339 |
+
*
|
1340 |
+
* @return array
|
1341 |
+
*/
|
1342 |
+
function get_fields_without_metakey() {
|
1343 |
+
$fields_without_metakey = array(
|
1344 |
+
'block',
|
1345 |
+
'shortcode',
|
1346 |
+
'spacing',
|
1347 |
+
'divider',
|
1348 |
+
'group'
|
1349 |
+
);
|
1350 |
+
|
1351 |
+
|
1352 |
+
/**
|
1353 |
+
* UM hook
|
1354 |
+
*
|
1355 |
+
* @type filter
|
1356 |
+
* @title um_fields_without_metakey
|
1357 |
+
* @description Field Types without meta key
|
1358 |
+
* @input_vars
|
1359 |
+
* [{"var":"$types","type":"array","desc":"Field Types"}]
|
1360 |
+
* @change_log
|
1361 |
+
* ["Since: 2.0"]
|
1362 |
+
* @usage add_filter( 'um_fields_without_metakey', 'function_name', 10, 1 );
|
1363 |
+
* @example
|
1364 |
+
* <?php
|
1365 |
+
* add_filter( 'um_fields_without_metakey', 'my_fields_without_metakey', 10, 1 );
|
1366 |
+
* function my_fields_without_metakey( $types ) {
|
1367 |
+
* // your code here
|
1368 |
+
* return $types;
|
1369 |
+
* }
|
1370 |
+
* ?>
|
1371 |
+
*/
|
1372 |
+
return apply_filters( 'um_fields_without_metakey', $fields_without_metakey );
|
1373 |
+
}
|
1374 |
+
|
1375 |
+
|
1376 |
+
/**
|
1377 |
+
* May be used to show a dropdown, or source for user meta
|
1378 |
+
*
|
1379 |
+
* @param null $exclude_types
|
1380 |
+
* @param bool $show_all
|
1381 |
+
*
|
1382 |
+
* @return array
|
1383 |
+
*/
|
1384 |
+
function all_user_fields( $exclude_types = null, $show_all = false ) {
|
1385 |
+
|
1386 |
+
$fields_without_metakey = $this->get_fields_without_metakey();
|
1387 |
+
$fields_without_metakey = apply_filters( 'um_all_user_fields_without_metakey', $fields_without_metakey );
|
1388 |
+
|
1389 |
+
if ( ! $show_all ) {
|
1390 |
+
$this->fields_dropdown = array( 'image', 'file', 'password', 'rating' );
|
1391 |
+
$this->fields_dropdown = array_merge( $this->fields_dropdown, $fields_without_metakey );
|
1392 |
+
} else {
|
1393 |
+
$this->fields_dropdown = $fields_without_metakey;
|
1394 |
+
}
|
1395 |
+
|
1396 |
+
$custom = $this->custom_fields;
|
1397 |
+
$predefined = $this->predefined_fields;
|
1398 |
+
|
1399 |
+
if ( $exclude_types ) {
|
1400 |
+
$exclude_types = explode( ',', $exclude_types );
|
1401 |
+
}
|
1402 |
+
|
1403 |
+
$all = array( 0 => '' );
|
1404 |
+
|
1405 |
+
if ( is_array( $custom ) ) {
|
1406 |
+
$all = $all + array_merge( $predefined, $custom );
|
1407 |
+
} else {
|
1408 |
+
$all = $all + $predefined;
|
1409 |
+
}
|
1410 |
+
|
1411 |
+
foreach ( $all as $k => $arr ) {
|
1412 |
+
|
1413 |
+
if ( $k == 0 ) {
|
1414 |
+
unset( $all[ $k ] );
|
1415 |
+
}
|
1416 |
+
|
1417 |
+
if ( isset( $arr['title'] ) ) {
|
1418 |
+
$all[ $k ]['title'] = stripslashes( $arr['title'] );
|
1419 |
+
}
|
1420 |
+
|
1421 |
+
if ( $exclude_types && isset( $arr['type'] ) && in_array( $arr['type'], $exclude_types ) ) {
|
1422 |
+
unset( $all[ $k ] );
|
1423 |
+
}
|
1424 |
+
if ( isset( $arr['account_only'] ) || isset( $arr['private_use'] ) ) {
|
1425 |
+
if ( ! $show_all ) {
|
1426 |
+
unset( $all[ $k ] );
|
1427 |
+
}
|
1428 |
+
}
|
1429 |
+
if ( isset( $arr['type'] ) && in_array( $arr['type'], $this->fields_dropdown ) ) {
|
1430 |
+
unset( $all[ $k ] );
|
1431 |
+
}
|
1432 |
+
}
|
1433 |
+
|
1434 |
+
$all = UM()->fields()->array_sort_by_column( $all, 'title' );
|
1435 |
+
|
1436 |
+
return $all;
|
1437 |
+
}
|
1438 |
+
|
1439 |
+
|
1440 |
+
/**
|
1441 |
+
* Possible validation types for fields
|
1442 |
+
*
|
1443 |
+
* @return mixed
|
1444 |
+
*/
|
1445 |
+
function validation_types() {
|
1446 |
+
|
1447 |
+
$array[0] = __('None','ultimate-member');
|
1448 |
+
$array['alphabetic'] = __('Alphabetic value only','ultimate-member');
|
1449 |
+
$array['alpha_numeric'] = __('Alpha-numeric value','ultimate-member');
|
1450 |
+
$array['english'] = __('English letters only','ultimate-member');
|
1451 |
+
$array['facebook_url'] = __('Facebook URL','ultimate-member');
|
1452 |
+
$array['google_url'] = __('Google+ URL','ultimate-member');
|
1453 |
+
$array['instagram_url'] = __('Instagram URL','ultimate-member');
|
1454 |
+
$array['linkedin_url'] = __('LinkedIn URL','ultimate-member');
|
1455 |
+
$array['vk_url'] = __('VKontakte URL','ultimate-member');
|
1456 |
+
$array['lowercase'] = __('Lowercase only','ultimate-member');
|
1457 |
+
$array['numeric'] = __('Numeric value only','ultimate-member');
|
1458 |
+
$array['phone_number'] = __('Phone Number','ultimate-member');
|
1459 |
+
$array['skype'] = __('Skype ID','ultimate-member');
|
1460 |
+
$array['soundcloud'] = __( 'SoundCloud Profile', 'ultimate-member' );
|
1461 |
+
$array['twitter_url'] = __('Twitter URL','ultimate-member');
|
1462 |
+
$array['is_email'] = __('E-mail( Not Unique )','ultimate-member');
|
1463 |
+
$array['unique_email'] = __('Unique E-mail','ultimate-member');
|
1464 |
+
$array['unique_value'] = __('Unique Metakey value','ultimate-member');
|
1465 |
+
$array['unique_username'] = __('Unique Username','ultimate-member');
|
1466 |
+
$array['unique_username_or_email'] = __('Unique Username/E-mail','ultimate-member');
|
1467 |
+
$array['url'] = __('Website URL','ultimate-member');
|
1468 |
+
$array['youtube_url'] = __('YouTube Profile','ultimate-member');
|
1469 |
+
$array['telegram_url'] = __('Telegram URL','ultimate-member');
|
1470 |
+
$array['discord'] = __('Discord ID','ultimate-member');
|
1471 |
+
$array['custom'] = __('Custom Validation','ultimate-member');
|
1472 |
+
|
1473 |
+
/**
|
1474 |
+
* UM hook
|
1475 |
+
*
|
1476 |
+
* @type filter
|
1477 |
+
* @title um_admin_field_validation_hook
|
1478 |
+
* @description Extend validation types
|
1479 |
+
* @input_vars
|
1480 |
+
* [{"var":"$types","type":"array","desc":"Validation Types"}]
|
1481 |
+
* @change_log
|
1482 |
+
* ["Since: 2.0"]
|
1483 |
+
* @usage add_filter( 'um_admin_field_validation_hook', 'function_name', 10, 1 );
|
1484 |
+
* @example
|
1485 |
+
* <?php
|
1486 |
+
* add_filter( 'um_admin_field_validation_hook', 'my_admin_field_validation', 10, 1 );
|
1487 |
+
* function my_admin_field_validation( $types ) {
|
1488 |
+
* // your code here
|
1489 |
+
* return $types;
|
1490 |
+
* }
|
1491 |
+
* ?>
|
1492 |
+
*/
|
1493 |
+
$array = apply_filters( 'um_admin_field_validation_hook', $array );
|
1494 |
+
return $array;
|
1495 |
+
}
|
1496 |
+
|
1497 |
+
|
1498 |
+
/**
|
1499 |
+
* Get predefined options
|
1500 |
+
*
|
1501 |
+
* @param $data
|
1502 |
+
*
|
1503 |
+
* @return array|mixed|void
|
1504 |
+
*/
|
1505 |
+
function get( $data ) {
|
1506 |
+
switch ( $data ) {
|
1507 |
+
|
1508 |
+
case 'languages':
|
1509 |
+
$array = array(
|
1510 |
+
"aa" => __("Afar",'ultimate-member'),
|
1511 |
+
"ab" => __("Abkhazian",'ultimate-member'),
|
1512 |
+
"ae" => __("Avestan",'ultimate-member'),
|
1513 |
+
"af" => __("Afrikaans",'ultimate-member'),
|
1514 |
+
"ak" => __("Akan",'ultimate-member'),
|
1515 |
+
"am" => __("Amharic",'ultimate-member'),
|
1516 |
+
"an" => __("Aragonese",'ultimate-member'),
|
1517 |
+
"ar" => __("Arabic",'ultimate-member'),
|
1518 |
+
"as" => __("Assamese",'ultimate-member'),
|
1519 |
+
"av" => __("Avaric",'ultimate-member'),
|
1520 |
+
"ay" => __("Aymara",'ultimate-member'),
|
1521 |
+
"az" => __("Azerbaijani",'ultimate-member'),
|
1522 |
+
"ba" => __("Bashkir",'ultimate-member'),
|
1523 |
+
"be" => __("Belarusian",'ultimate-member'),
|
1524 |
+
"bg" => __("Bulgarian",'ultimate-member'),
|
1525 |
+
"bh" => __("Bihari",'ultimate-member'),
|
1526 |
+
"bi" => __("Bislama",'ultimate-member'),
|
1527 |
+
"bm" => __("Bambara",'ultimate-member'),
|
1528 |
+
"bn" => __("Bengali",'ultimate-member'),
|
1529 |
+
"bo" => __("Tibetan",'ultimate-member'),
|
1530 |
+
"br" => __("Breton",'ultimate-member'),
|
1531 |
+
"bs" => __("Bosnian",'ultimate-member'),
|
1532 |
+
"ca" => __("Catalan",'ultimate-member'),
|
1533 |
+
"ce" => __("Chechen",'ultimate-member'),
|
1534 |
+
"ch" => __("Chamorro",'ultimate-member'),
|
1535 |
+
"co" => __("Corsican",'ultimate-member'),
|
1536 |
+
"cr" => __("Cree",'ultimate-member'),
|
1537 |
+
"cs" => __("Czech",'ultimate-member'),
|
1538 |
+
"cu" => __("Church Slavic",'ultimate-member'),
|
1539 |
+
"cv" => __("Chuvash",'ultimate-member'),
|
1540 |
+
"cy" => __("Welsh",'ultimate-member'),
|
1541 |
+
"da" => __("Danish",'ultimate-member'),
|
1542 |
+
"de" => __("German",'ultimate-member'),
|
1543 |
+
"dv" => __("Divehi",'ultimate-member'),
|
1544 |
+
"dz" => __("Dzongkha",'ultimate-member'),
|
1545 |
+
"ee" => __("Ewe",'ultimate-member'),
|
1546 |
+
"el" => __("Greek",'ultimate-member'),
|
1547 |
+
"en" => __("English",'ultimate-member'),
|
1548 |
+
"eo" => __("Esperanto",'ultimate-member'),
|
1549 |
+
"es" => __("Spanish",'ultimate-member'),
|
1550 |
+
"et" => __("Estonian",'ultimate-member'),
|
1551 |
+
"eu" => __("Basque",'ultimate-member'),
|
1552 |
+
"fa" => __("Persian",'ultimate-member'),
|
1553 |
+
"ff" => __("Fulah",'ultimate-member'),
|
1554 |
+
"fi" => __("Finnish",'ultimate-member'),
|
1555 |
+
"fj" => __("Fijian",'ultimate-member'),
|
1556 |
+
"fo" => __("Faroese",'ultimate-member'),
|
1557 |
+
"fr" => __("French",'ultimate-member'),
|
1558 |
+
"fy" => __("Western Frisian",'ultimate-member'),
|
1559 |
+
"ga" => __("Irish",'ultimate-member'),
|
1560 |
+
"gd" => __("Scottish Gaelic",'ultimate-member'),
|
1561 |
+
"gl" => __("Galician",'ultimate-member'),
|
1562 |
+
"gn" => __("Guarani",'ultimate-member'),
|
1563 |
+
"gu" => __("Gujarati",'ultimate-member'),
|
1564 |
+
"gv" => __("Manx",'ultimate-member'),
|
1565 |
+
"ha" => __("Hausa",'ultimate-member'),
|
1566 |
+
"he" => __("Hebrew",'ultimate-member'),
|
1567 |
+
"hi" => __("Hindi",'ultimate-member'),
|
1568 |
+
"ho" => __("Hiri Motu",'ultimate-member'),
|
1569 |
+
"hr" => __("Croatian",'ultimate-member'),
|
1570 |
+
"ht" => __("Haitian",'ultimate-member'),
|
1571 |
+
"hu" => __("Hungarian",'ultimate-member'),
|
1572 |
+
"hy" => __("Armenian",'ultimate-member'),
|
1573 |
+
"hz" => __("Herero",'ultimate-member'),
|
1574 |
+
"ia" => __("Interlingua (International Auxiliary Language Association)",'ultimate-member'),
|
1575 |
+
"id" => __("Indonesian",'ultimate-member'),
|
1576 |
+
"ie" => __("Interlingue",'ultimate-member'),
|
1577 |
+
"ig" => __("Igbo",'ultimate-member'),
|
1578 |
+
"ii" => __("Sichuan Yi",'ultimate-member'),
|
1579 |
+
"ik" => __("Inupiaq",'ultimate-member'),
|
1580 |
+
"io" => __("Ido",'ultimate-member'),
|
1581 |
+
"is" => __("Icelandic",'ultimate-member'),
|
1582 |
+
"it" => __("Italian",'ultimate-member'),
|
1583 |
+
"iu" => __("Inuktitut",'ultimate-member'),
|
1584 |
+
"ja" => __("Japanese",'ultimate-member'),
|
1585 |
+
"jv" => __("Javanese",'ultimate-member'),
|
1586 |
+
"ka" => __("Kartuli",'ultimate-member'),
|
1587 |
+
"kg" => __("Kongo",'ultimate-member'),
|
1588 |
+
"ki" => __("Kikuyu",'ultimate-member'),
|
1589 |
+
"kj" => __("Kwanyama",'ultimate-member'),
|
1590 |
+
"kk" => __("Kazakh",'ultimate-member'),
|
1591 |
+
"kl" => __("Kalaallisut",'ultimate-member'),
|
1592 |
+
"km" => __("Khmer",'ultimate-member'),
|
1593 |
+
"kn" => __("Kannada",'ultimate-member'),
|
1594 |
+
"ko" => __("Korean",'ultimate-member'),
|
1595 |
+
"kr" => __("Kanuri",'ultimate-member'),
|
1596 |
+
"ks" => __("Kashmiri",'ultimate-member'),
|
1597 |
+
"ku" => __("Kurdish",'ultimate-member'),
|
1598 |
+
"kv" => __("Komi",'ultimate-member'),
|
1599 |
+
"kw" => __("Cornish",'ultimate-member'),
|
1600 |
+
"ky" => __("Kirghiz",'ultimate-member'),
|
1601 |
+
"la" => __("Latin",'ultimate-member'),
|
1602 |
+
"lb" => __("Luxembourgish",'ultimate-member'),
|
1603 |
+
"lg" => __("Ganda",'ultimate-member'),
|
1604 |
+
"li" => __("Limburgish",'ultimate-member'),
|
1605 |
+
"ln" => __("Lingala",'ultimate-member'),
|
1606 |
+
"lo" => __("Lao",'ultimate-member'),
|
1607 |
+
"lt" => __("Lithuanian",'ultimate-member'),
|
1608 |
+
"lu" => __("Luba-Katanga",'ultimate-member'),
|
1609 |
+
"lv" => __("Latvian",'ultimate-member'),
|
1610 |
+
"mg" => __("Malagasy",'ultimate-member'),
|
1611 |
+
"mh" => __("Marshallese",'ultimate-member'),
|
1612 |
+
"mi" => __("Maori",'ultimate-member'),
|
1613 |
+
"mk" => __("Macedonian",'ultimate-member'),
|
1614 |
+
"ml" => __("Malayalam",'ultimate-member'),
|
1615 |
+
"mn" => __("Mongolian",'ultimate-member'),
|
1616 |
+
"mr" => __("Marathi",'ultimate-member'),
|
1617 |
+
"ms" => __("Malay",'ultimate-member'),
|
1618 |
+
"mt" => __("Maltese",'ultimate-member'),
|
1619 |
+
"my" => __("Burmese",'ultimate-member'),
|
1620 |
+
"na" => __("Nauru",'ultimate-member'),
|
1621 |
+
"nb" => __("Norwegian Bokmal",'ultimate-member'),
|
1622 |
+
"nd" => __("North Ndebele",'ultimate-member'),
|
1623 |
+
"ne" => __("Nepali",'ultimate-member'),
|
1624 |
+
"ng" => __("Ndonga",'ultimate-member'),
|
1625 |
+
"nl" => __("Dutch",'ultimate-member'),
|
1626 |
+
"nn" => __("Norwegian Nynorsk",'ultimate-member'),
|
1627 |
+
"no" => __("Norwegian",'ultimate-member'),
|
1628 |
+
"nr" => __("South Ndebele",'ultimate-member'),
|
1629 |
+
"nv" => __("Navajo",'ultimate-member'),
|
1630 |
+
"ny" => __("Chichewa",'ultimate-member'),
|
1631 |
+
"oc" => __("Occitan",'ultimate-member'),
|
1632 |
+
"oj" => __("Ojibwa",'ultimate-member'),
|
1633 |
+
"om" => __("Oromo",'ultimate-member'),
|
1634 |
+
"or" => __("Oriya",'ultimate-member'),
|
1635 |
+
"os" => __("Ossetian",'ultimate-member'),
|
1636 |
+
"pa" => __("Panjabi",'ultimate-member'),
|
1637 |
+
"pi" => __("Pali",'ultimate-member'),
|
1638 |
+
"pl" => __("Polish",'ultimate-member'),
|
1639 |
+
"ps" => __("Pashto",'ultimate-member'),
|
1640 |
+
"pt" => __("Portuguese",'ultimate-member'),
|
1641 |
+
"qu" => __("Quechua",'ultimate-member'),
|
1642 |
+
"rm" => __("Raeto-Romance",'ultimate-member'),
|
1643 |
+
"rn" => __("Kirundi",'ultimate-member'),
|
1644 |
+
"ro" => __("Romanian",'ultimate-member'),
|
1645 |
+
"ru" => __("Russian",'ultimate-member'),
|
1646 |
+
"rw" => __("Kinyarwanda",'ultimate-member'),
|
1647 |
+
"sa" => __("Sanskrit",'ultimate-member'),
|
1648 |
+
"sc" => __("Sardinian",'ultimate-member'),
|
1649 |
+
"sd" => __("Sindhi",'ultimate-member'),
|
1650 |
+
"se" => __("Northern Sami",'ultimate-member'),
|
1651 |
+
"sg" => __("Sango",'ultimate-member'),
|
1652 |
+
"si" => __("Sinhala",'ultimate-member'),
|
1653 |
+
"sk" => __("Slovak",'ultimate-member'),
|
1654 |
+
"sl" => __("Slovenian",'ultimate-member'),
|
1655 |
+
"sm" => __("Samoan",'ultimate-member'),
|
1656 |
+
"sn" => __("Shona",'ultimate-member'),
|
1657 |
+
"so" => __("Somali",'ultimate-member'),
|
1658 |
+
"sq" => __("Albanian",'ultimate-member'),
|
1659 |
+
"sr" => __("Serbian",'ultimate-member'),
|
1660 |
+
"ss" => __("Swati",'ultimate-member'),
|
1661 |
+
"st" => __("Southern Sotho",'ultimate-member'),
|
1662 |
+
"su" => __("Sundanese",'ultimate-member'),
|
1663 |
+
"sv" => __("Swedish",'ultimate-member'),
|
1664 |
+
"sw" => __("Swahili",'ultimate-member'),
|
1665 |
+
"ta" => __("Tamil",'ultimate-member'),
|
1666 |
+
"te" => __("Telugu",'ultimate-member'),
|
1667 |
+
"tg" => __("Tajik",'ultimate-member'),
|
1668 |
+
"th" => __("Thai",'ultimate-member'),
|
1669 |
+
"ti" => __("Tigrinya",'ultimate-member'),
|
1670 |
+
"tk" => __("Turkmen",'ultimate-member'),
|
1671 |
+
"tl" => __("Tagalog",'ultimate-member'),
|
1672 |
+
"tn" => __("Tswana",'ultimate-member'),
|
1673 |
+
"to" => __("Tonga",'ultimate-member'),
|
1674 |
+
"tr" => __("Turkish",'ultimate-member'),
|
1675 |
+
"ts" => __("Tsonga",'ultimate-member'),
|
1676 |
+
"tt" => __("Tatar",'ultimate-member'),
|
1677 |
+
"tw" => __("Twi",'ultimate-member'),
|
1678 |
+
"ty" => __("Tahitian",'ultimate-member'),
|
1679 |
+
"ug" => __("Uighur",'ultimate-member'),
|
1680 |
+
"uk" => __("Ukrainian",'ultimate-member'),
|
1681 |
+
"ur" => __("Urdu",'ultimate-member'),
|
1682 |
+
"uz" => __("Uzbek",'ultimate-member'),
|
1683 |
+
"ve" => __("Venda",'ultimate-member'),
|
1684 |
+
"vi" => __("Vietnamese",'ultimate-member'),
|
1685 |
+
"vo" => __("Volapuk",'ultimate-member'),
|
1686 |
+
"wa" => __("Walloon",'ultimate-member'),
|
1687 |
+
"wo" => __("Wolof",'ultimate-member'),
|
1688 |
+
"xh" => __("Xhosa",'ultimate-member'),
|
1689 |
+
"yi" => __("Yiddish",'ultimate-member'),
|
1690 |
+
"yo" => __("Yoruba",'ultimate-member'),
|
1691 |
+
"za" => __("Zhuang",'ultimate-member'),
|
1692 |
+
"zh" => __("Chinese",'ultimate-member'),
|
1693 |
+
"zu" => __("Zulu",'ultimate-member')
|
1694 |
+
);
|
1695 |
+
break;
|
1696 |
+
|
1697 |
+
case 'countries':
|
1698 |
+
$array = array (
|
1699 |
+
'AF' => __('Afghanistan','ultimate-member'),
|
1700 |
+
'AX' => __('Åland Islands','ultimate-member'),
|
1701 |
+
'AL' => __('Albania','ultimate-member'),
|
1702 |
+
'DZ' => __('Algeria','ultimate-member'),
|
1703 |
+
'AS' => __('American Samoa','ultimate-member'),
|
1704 |
+
'AD' => __('Andorra','ultimate-member'),
|
1705 |
+
'AO' => __('Angola','ultimate-member'),
|
1706 |
+
'AI' => __('Anguilla','ultimate-member'),
|
1707 |
+
'AQ' => __('Antarctica','ultimate-member'),
|
1708 |
+
'AG' => __('Antigua and Barbuda','ultimate-member'),
|
1709 |
+
'AR' => __('Argentina','ultimate-member'),
|
1710 |
+
'AM' => __('Armenia','ultimate-member'),
|
1711 |
+
'AW' => __('Aruba','ultimate-member'),
|
1712 |
+
'AU' => __('Australia','ultimate-member'),
|
1713 |
+
'AT' => __('Austria','ultimate-member'),
|
1714 |
+
'AZ' => __('Azerbaijan','ultimate-member'),
|
1715 |
+
'BS' => __('Bahamas','ultimate-member'),
|
1716 |
+
'BH' => __('Bahrain','ultimate-member'),
|
1717 |
+
'BD' => __('Bangladesh','ultimate-member'),
|
1718 |
+
'BB' => __('Barbados','ultimate-member'),
|
1719 |
+
'BY' => __('Belarus','ultimate-member'),
|
1720 |
+
'BE' => __('Belgium','ultimate-member'),
|
1721 |
+
'BZ' => __('Belize','ultimate-member'),
|
1722 |
+
'BJ' => __('Benin','ultimate-member'),
|
1723 |
+
'BM' => __('Bermuda','ultimate-member'),
|
1724 |
+
'BT' => __('Bhutan','ultimate-member'),
|
1725 |
+
'BO' => __('Bolivia, Plurinational State of','ultimate-member'),
|
1726 |
+
'BA' => __('Bosnia and Herzegovina','ultimate-member'),
|
1727 |
+
'BW' => __('Botswana','ultimate-member'),
|
1728 |
+
'BV' => __('Bouvet Island','ultimate-member'),
|
1729 |
+
'BR' => __('Brazil','ultimate-member'),
|
1730 |
+
'IO' => __('British Indian Ocean Territory','ultimate-member'),
|
1731 |
+
'BN' => __('Brunei Darussalam','ultimate-member'),
|
1732 |
+
'BG' => __('Bulgaria','ultimate-member'),
|
1733 |
+
'BF' => __('Burkina Faso','ultimate-member'),
|
1734 |
+
'BI' => __('Burundi','ultimate-member'),
|
1735 |
+
'KH' => __('Cambodia','ultimate-member'),
|
1736 |
+
'CM' => __('Cameroon','ultimate-member'),
|
1737 |
+
'CA' => __('Canada','ultimate-member'),
|
1738 |
+
'CV' => __('Cape Verde','ultimate-member'),
|
1739 |
+
'KY' => __('Cayman Islands','ultimate-member'),
|
1740 |
+
'CF' => __('Central African Republic','ultimate-member'),
|
1741 |
+
'TD' => __('Chad','ultimate-member'),
|
1742 |
+
'CL' => __('Chile','ultimate-member'),
|
1743 |
+
'CN' => __('China','ultimate-member'),
|
1744 |
+
'CX' => __('Christmas Island','ultimate-member'),
|
1745 |
+
'CC' => __('Cocos (Keeling) Islands','ultimate-member'),
|
1746 |
+
'CO' => __('Colombia','ultimate-member'),
|
1747 |
+
'KM' => __('Comoros','ultimate-member'),
|
1748 |
+
'CG' => __('Congo','ultimate-member'),
|
1749 |
+
'CD' => __('Congo, the Democratic Republic of the','ultimate-member'),
|
1750 |
+
'CK' => __('Cook Islands','ultimate-member'),
|
1751 |
+
'CR' => __('Costa Rica','ultimate-member'),
|
1752 |
+
'CI' => __("Côte d'Ivoire",'ultimate-member'),
|
1753 |
+
'HR' => __('Croatia','ultimate-member'),
|
1754 |
+
'CU' => __('Cuba','ultimate-member'),
|
1755 |
+
'CY' => __('Cyprus','ultimate-member'),
|
1756 |
+
'CZ' => __('Czech Republic','ultimate-member'),
|
1757 |
+
'DK' => __('Denmark','ultimate-member'),
|
1758 |
+
'DJ' => __('Djibouti','ultimate-member'),
|
1759 |
+
'DM' => __('Dominica','ultimate-member'),
|
1760 |
+
'DO' => __('Dominican Republic','ultimate-member'),
|
1761 |
+
'EC' => __('Ecuador','ultimate-member'),
|
1762 |
+
'EG' => __('Egypt','ultimate-member'),
|
1763 |
+
'SV' => __('El Salvador','ultimate-member'),
|
1764 |
+
'GQ' => __('Equatorial Guinea','ultimate-member'),
|
1765 |
+
'ER' => __('Eritrea','ultimate-member'),
|
1766 |
+
'EE' => __('Estonia','ultimate-member'),
|
1767 |
+
'ET' => __('Ethiopia','ultimate-member'),
|
1768 |
+
'FK' => __('Falkland Islands (Malvinas)','ultimate-member'),
|
1769 |
+
'FO' => __('Faroe Islands','ultimate-member'),
|
1770 |
+
'FJ' => __('Fiji','ultimate-member'),
|
1771 |
+
'FI' => __('Finland','ultimate-member'),
|
1772 |
+
'FR' => __('France','ultimate-member'),
|
1773 |
+
'GF' => __('French Guiana','ultimate-member'),
|
1774 |
+
'PF' => __('French Polynesia','ultimate-member'),
|
1775 |
+
'TF' => __('French Southern Territories','ultimate-member'),
|
1776 |
+
'GA' => __('Gabon','ultimate-member'),
|
1777 |
+
'GM' => __('Gambia','ultimate-member'),
|
1778 |
+
'GE' => __('Sakartvelo','ultimate-member'),
|
1779 |
+
'DE' => __('Germany','ultimate-member'),
|
1780 |
+
'GH' => __('Ghana','ultimate-member'),
|
1781 |
+
'GI' => __('Gibraltar','ultimate-member'),
|
1782 |
+
'GR' => __('Greece','ultimate-member'),
|
1783 |
+
'GL' => __('Greenland','ultimate-member'),
|
1784 |
+
'GD' => __('Grenada','ultimate-member'),
|
1785 |
+
'GP' => __('Guadeloupe','ultimate-member'),
|
1786 |
+
'GU' => __('Guam','ultimate-member'),
|
1787 |
+
'GT' => __('Guatemala','ultimate-member'),
|
1788 |
+
'GG' => __('Guernsey','ultimate-member'),
|
1789 |
+
'GN' => __('Guinea','ultimate-member'),
|
1790 |
+
'GW' => __('Guinea-Bissau','ultimate-member'),
|
1791 |
+
'GY' => __('Guyana','ultimate-member'),
|
1792 |
+
'HT' => __('Haiti','ultimate-member'),
|
1793 |
+
'HM' => __('Heard Island and McDonald Islands','ultimate-member'),
|
1794 |
+
'VA' => __('Holy See (Vatican City State)','ultimate-member'),
|
1795 |
+
'HN' => __('Honduras','ultimate-member'),
|
1796 |
+
'HK' => __('Hong Kong','ultimate-member'),
|
1797 |
+
'HU' => __('Hungary','ultimate-member'),
|
1798 |
+
'IS' => __('Iceland','ultimate-member'),
|
1799 |
+
'IN' => __('India','ultimate-member'),
|
1800 |
+
'ID' => __('Indonesia','ultimate-member'),
|
1801 |
+
'IR' => __('Iran, Islamic Republic of','ultimate-member'),
|
1802 |
+
'IQ' => __('Iraq','ultimate-member'),
|
1803 |
+
'IE' => __('Ireland','ultimate-member'),
|
1804 |
+
'IM' => __('Isle of Man','ultimate-member'),
|
1805 |
+
'IL' => __('Israel','ultimate-member'),
|
1806 |
+
'IT' => __('Italy','ultimate-member'),
|
1807 |
+
'JM' => __('Jamaica','ultimate-member'),
|
1808 |
+
'JP' => __('Japan','ultimate-member'),
|
1809 |
+
'JE' => __('Jersey','ultimate-member'),
|
1810 |
+
'JO' => __('Jordan','ultimate-member'),
|
1811 |
+
'KZ' => __('Kazakhstan','ultimate-member'),
|
1812 |
+
'KE' => __('Kenya','ultimate-member'),
|
1813 |
+
'KI' => __('Kiribati','ultimate-member'),
|
1814 |
+
'KP' => __("Korea, Democratic People's Republic of",'ultimate-member'),
|
1815 |
+
'KR' => __('Korea, Republic of','ultimate-member'),
|
1816 |
+
'KW' => __('Kuwait','ultimate-member'),
|
1817 |
+
'KG' => __('Kyrgyzstan','ultimate-member'),
|
1818 |
+
'LA' => __("Lao People's Democratic Republic",'ultimate-member'),
|
1819 |
+
'LV' => __('Latvia','ultimate-member'),
|
1820 |
+
'LB' => __('Lebanon','ultimate-member'),
|
1821 |
+
'LS' => __('Lesotho','ultimate-member'),
|
1822 |
+
'LR' => __('Liberia','ultimate-member'),
|
1823 |
+
'LY' => __('Libyan Arab Jamahiriya','ultimate-member'),
|
1824 |
+
'LI' => __('Liechtenstein','ultimate-member'),
|
1825 |
+
'LT' => __('Lithuania','ultimate-member'),
|
1826 |
+
'LU' => __('Luxembourg','ultimate-member'),
|
1827 |
+
'MO' => __('Macao','ultimate-member'),
|
1828 |
+
'MK' => __('Macedonia, the former Yugoslav Republic of','ultimate-member'),
|
1829 |
+
'MG' => __('Madagascar','ultimate-member'),
|
1830 |
+
'MW' => __('Malawi','ultimate-member'),
|
1831 |
+
'MY' => __('Malaysia','ultimate-member'),
|
1832 |
+
'MV' => __('Maldives','ultimate-member'),
|
1833 |
+
'ML' => __('Mali','ultimate-member'),
|
1834 |
+
'MT' => __('Malta','ultimate-member'),
|
1835 |
+
'MH' => __('Marshall Islands','ultimate-member'),
|
1836 |
+
'MQ' => __('Martinique','ultimate-member'),
|
1837 |
+
'MR' => __('Mauritania','ultimate-member'),
|
1838 |
+
'MU' => __('Mauritius','ultimate-member'),
|
1839 |
+
'YT' => __('Mayotte','ultimate-member'),
|
1840 |
+
'MX' => __('Mexico','ultimate-member'),
|
1841 |
+
'FM' => __('Micronesia, Federated States of','ultimate-member'),
|
1842 |
+
'MD' => __('Moldova, Republic of','ultimate-member'),
|
1843 |
+
'MC' => __('Monaco','ultimate-member'),
|
1844 |
+
'MN' => __('Mongolia','ultimate-member'),
|
1845 |
+
'ME' => __('Montenegro','ultimate-member'),
|
1846 |
+
'MS' => __('Montserrat','ultimate-member'),
|
1847 |
+
'MA' => __('Morocco','ultimate-member'),
|
1848 |
+
'MZ' => __('Mozambique','ultimate-member'),
|
1849 |
+
'MM' => __('Myanmar','ultimate-member'),
|
1850 |
+
'NA' => __('Namibia','ultimate-member'),
|
1851 |
+
'NR' => __('Nauru','ultimate-member'),
|
1852 |
+
'NP' => __('Nepal','ultimate-member'),
|
1853 |
+
'NL' => __('Netherlands','ultimate-member'),
|
1854 |
+
'AN' => __('Netherlands Antilles','ultimate-member'),
|
1855 |
+
'NC' => __('New Caledonia','ultimate-member'),
|
1856 |
+
'NZ' => __('New Zealand','ultimate-member'),
|
1857 |
+
'NI' => __('Nicaragua','ultimate-member'),
|
1858 |
+
'NE' => __('Niger','ultimate-member'),
|
1859 |
+
'NG' => __('Nigeria','ultimate-member'),
|
1860 |
+
'NU' => __('Niue','ultimate-member'),
|
1861 |
+
'NF' => __('Norfolk Island','ultimate-member'),
|
1862 |
+
'MP' => __('Northern Mariana Islands','ultimate-member'),
|
1863 |
+
'NO' => __('Norway','ultimate-member'),
|
1864 |
+
'OM' => __('Oman','ultimate-member'),
|
1865 |
+
'PK' => __('Pakistan','ultimate-member'),
|
1866 |
+
'PW' => __('Palau','ultimate-member'),
|
1867 |
+
'PS' => __('Palestine','ultimate-member'),
|
1868 |
+
'PA' => __('Panama','ultimate-member'),
|
1869 |
+
'PG' => __('Papua New Guinea','ultimate-member'),
|
1870 |
+
'PY' => __('Paraguay','ultimate-member'),
|
1871 |
+
'PE' => __('Peru','ultimate-member'),
|
1872 |
+
'PH' => __('Philippines','ultimate-member'),
|
1873 |
+
'PN' => __('Pitcairn','ultimate-member'),
|
1874 |
+
'PL' => __('Poland','ultimate-member'),
|
1875 |
+
'PT' => __('Portugal','ultimate-member'),
|
1876 |
+
'PR' => __('Puerto Rico','ultimate-member'),
|
1877 |
+
'QA' => __('Qatar','ultimate-member'),
|
1878 |
+
'RE' => __('Réunion','ultimate-member'),
|
1879 |
+
'RO' => __('Romania','ultimate-member'),
|
1880 |
+
'RU' => __('Russian Federation','ultimate-member'),
|
1881 |
+
'RW' => __('Rwanda','ultimate-member'),
|
1882 |
+
'BL' => __('Saint Barthélemy','ultimate-member'),
|
1883 |
+
'SH' => __('Saint Helena','ultimate-member'),
|
1884 |
+
'KN' => __('Saint Kitts and Nevis','ultimate-member'),
|
1885 |
+
'LC' => __('Saint Lucia','ultimate-member'),
|
1886 |
+
'MF' => __('Saint Martin (French part)','ultimate-member'),
|
1887 |
+
'PM' => __('Saint Pierre and Miquelon','ultimate-member'),
|
1888 |
+
'VC' => __('Saint Vincent and the Grenadines','ultimate-member'),
|
1889 |
+
'WS' => __('Samoa','ultimate-member'),
|
1890 |
+
'SM' => __('San Marino','ultimate-member'),
|
1891 |
+
'ST' => __('Sao Tome and Principe','ultimate-member'),
|
1892 |
+
'SA' => __('Saudi Arabia','ultimate-member'),
|
1893 |
+
'SN' => __('Senegal','ultimate-member'),
|
1894 |
+
'RS' => __('Serbia','ultimate-member'),
|
1895 |
+
'SC' => __('Seychelles','ultimate-member'),
|
1896 |
+
'SL' => __('Sierra Leone','ultimate-member'),
|
1897 |
+
'SG' => __('Singapore','ultimate-member'),
|
1898 |
+
'SK' => __('Slovakia','ultimate-member'),
|
1899 |
+
'SI' => __('Slovenia','ultimate-member'),
|
1900 |
+
'SB' => __('Solomon Islands','ultimate-member'),
|
1901 |
+
'SO' => __('Somalia','ultimate-member'),
|
1902 |
+
'ZA' => __('South Africa','ultimate-member'),
|
1903 |
+
'GS' => __('South Georgia and the South Sandwich Islands','ultimate-member'),
|
1904 |
+
'SS' => __('South Sudan','ultimate-member'),
|
1905 |
+
'ES' => __('Spain','ultimate-member'),
|
1906 |
+
'LK' => __('Sri Lanka','ultimate-member'),
|
1907 |
+
'SD' => __('Sudan','ultimate-member'),
|
1908 |
+
'SR' => __('Suriname','ultimate-member'),
|
1909 |
+
'SJ' => __('Svalbard and Jan Mayen','ultimate-member'),
|
1910 |
+
'SZ' => __('Swaziland','ultimate-member'),
|
1911 |
+
'SE' => __('Sweden','ultimate-member'),
|
1912 |
+
'CH' => __('Switzerland','ultimate-member'),
|
1913 |
+
'SY' => __('Syrian Arab Republic','ultimate-member'),
|
1914 |
+
'TW' => __('Taiwan, Province of China','ultimate-member'),
|
1915 |
+
'TJ' => __('Tajikistan','ultimate-member'),
|
1916 |
+
'TZ' => __('Tanzania, United Republic of','ultimate-member'),
|
1917 |
+
'TH' => __('Thailand','ultimate-member'),
|
1918 |
+
'TL' => __('Timor-Leste','ultimate-member'),
|
1919 |
+
'TG' => __('Togo','ultimate-member'),
|
1920 |
+
'TK' => __('Tokelau','ultimate-member'),
|
1921 |
+
'TO' => __('Tonga','ultimate-member'),
|
1922 |
+
'TT' => __('Trinidad and Tobago','ultimate-member'),
|
1923 |
+
'TN' => __('Tunisia','ultimate-member'),
|
1924 |
+
'TR' => __('Turkey','ultimate-member'),
|
1925 |
+
'TM' => __('Turkmenistan','ultimate-member'),
|
1926 |
+
'TC' => __('Turks and Caicos Islands','ultimate-member'),
|
1927 |
+
'TV' => __('Tuvalu','ultimate-member'),
|
1928 |
+
'UG' => __('Uganda','ultimate-member'),
|
1929 |
+
'UA' => __('Ukraine','ultimate-member'),
|
1930 |
+
'AE' => __('United Arab Emirates','ultimate-member'),
|
1931 |
+
'GB' => __('United Kingdom','ultimate-member'),
|
1932 |
+
'US' => __('United States','ultimate-member'),
|
1933 |
+
'UM' => __('United States Minor Outlying Islands','ultimate-member'),
|
1934 |
+
'UY' => __('Uruguay','ultimate-member'),
|
1935 |
+
'UZ' => __('Uzbekistan','ultimate-member'),
|
1936 |
+
'VU' => __('Vanuatu','ultimate-member'),
|
1937 |
+
'VE' => __('Venezuela, Bolivarian Republic of','ultimate-member'),
|
1938 |
+
'VN' => __('Viet Nam','ultimate-member'),
|
1939 |
+
'VG' => __('Virgin Islands, British','ultimate-member'),
|
1940 |
+
'VI' => __('Virgin Islands, U.S.','ultimate-member'),
|
1941 |
+
'WF' => __('Wallis and Futuna','ultimate-member'),
|
1942 |
+
'EH' => __('Western Sahara','ultimate-member'),
|
1943 |
+
'YE' => __('Yemen','ultimate-member'),
|
1944 |
+
'ZM' => __('Zambia','ultimate-member'),
|
1945 |
+
'ZW' => __('Zimbabwe','ultimate-member'),
|
1946 |
+
);
|
1947 |
+
break;
|
1948 |
+
|
1949 |
+
}
|
1950 |
+
|
1951 |
+
/**
|
1952 |
+
* UM hook
|
1953 |
+
*
|
1954 |
+
* @type filter
|
1955 |
+
* @title um_{$data}_predefined_field_options
|
1956 |
+
* @description Extend Predefined Fields options. Where $data - field key.
|
1957 |
+
* @input_vars
|
1958 |
+
* [{"var":"$options","type":"array","desc":"Field's Options"}]
|
1959 |
+
* @change_log
|
1960 |
+
* ["Since: 2.0"]
|
1961 |
+
* @usage add_filter( 'um_{$data}_predefined_field_options', 'function_name', 10, 1 );
|
1962 |
+
* @example
|
1963 |
+
* <?php
|
1964 |
+
* add_filter( 'um_{$data}_predefined_field_options', 'my_predefined_field', 10, 1 );
|
1965 |
+
* function my_predefined_field( $options ) {
|
1966 |
+
* // your code here
|
1967 |
+
* return $options;
|
1968 |
+
* }
|
1969 |
+
* ?>
|
1970 |
+
*/
|
1971 |
+
$array = apply_filters( "um_{$data}_predefined_field_options", $array );
|
1972 |
+
return $array;
|
1973 |
+
}
|
1974 |
+
|
1975 |
+
}
|
1976 |
+
}
|
includes/core/class-fields.php
CHANGED
@@ -1,4896 +1,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 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
unset( $fields[ $id ]['
|
164 |
-
unset( $fields[ $id ]['
|
165 |
-
unset( $fields[ $id ]['
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
*
|
177 |
-
*
|
178 |
-
* @param integer $
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
if ( array_key_exists( 'custom_dropdown_options_source', $args )
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
unset( $
|
258 |
-
unset( $
|
259 |
-
unset( $
|
260 |
-
unset( $
|
261 |
-
unset( $
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
$
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
$
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
$directory_sorting_fields =
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
$
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
$
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
$
|
428 |
-
|
429 |
-
$
|
430 |
-
|
431 |
-
$duplicate
|
432 |
-
|
433 |
-
$
|
434 |
-
|
435 |
-
$
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
if (
|
474 |
-
$output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
if (
|
480 |
-
$output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
481 |
-
}
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
if (
|
508 |
-
$output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
if (
|
514 |
-
$output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
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 |
-
if ( !
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
if ( UM()->mobile()->isMobile()
|
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 |
-
if (
|
701 |
-
$classes .= '
|
702 |
-
}
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
*
|
728 |
-
*
|
729 |
-
*
|
730 |
-
* @
|
731 |
-
*
|
732 |
-
* @
|
733 |
-
*
|
734 |
-
*
|
735 |
-
*
|
736 |
-
*
|
737 |
-
*
|
738 |
-
*
|
739 |
-
*
|
740 |
-
*
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
*
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
}
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
*
|
809 |
-
*
|
810 |
-
* @
|
811 |
-
*
|
812 |
-
* @
|
813 |
-
* @
|
814 |
-
*
|
815 |
-
*
|
816 |
-
*
|
817 |
-
*
|
818 |
-
*
|
819 |
-
*
|
820 |
-
*
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
*
|
825 |
-
*
|
826 |
-
*
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
*
|
831 |
-
*
|
832 |
-
* @
|
833 |
-
*
|
834 |
-
* @
|
835 |
-
* @
|
836 |
-
*
|
837 |
-
*
|
838 |
-
*
|
839 |
-
*
|
840 |
-
*
|
841 |
-
*
|
842 |
-
*
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
*
|
861 |
-
*
|
862 |
-
* @
|
863 |
-
*
|
864 |
-
* @
|
865 |
-
* @
|
866 |
-
*
|
867 |
-
*
|
868 |
-
*
|
869 |
-
*
|
870 |
-
*
|
871 |
-
*
|
872 |
-
*
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
*
|
887 |
-
*
|
888 |
-
*
|
889 |
-
* @
|
890 |
-
*
|
891 |
-
* @
|
892 |
-
*
|
893 |
-
*
|
894 |
-
*
|
895 |
-
*
|
896 |
-
*
|
897 |
-
*
|
898 |
-
*
|
899 |
-
*
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
*
|
904 |
-
*
|
905 |
-
*
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
*
|
910 |
-
*
|
911 |
-
* @
|
912 |
-
*
|
913 |
-
* @
|
914 |
-
* @
|
915 |
-
*
|
916 |
-
*
|
917 |
-
*
|
918 |
-
*
|
919 |
-
*
|
920 |
-
*
|
921 |
-
*
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
*
|
926 |
-
*
|
927 |
-
*
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
*
|
932 |
-
*
|
933 |
-
* @
|
934 |
-
*
|
935 |
-
* @
|
936 |
-
* @
|
937 |
-
*
|
938 |
-
*
|
939 |
-
*
|
940 |
-
*
|
941 |
-
*
|
942 |
-
*
|
943 |
-
*
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
*
|
960 |
-
*
|
961 |
-
* @
|
962 |
-
*
|
963 |
-
* @
|
964 |
-
* @
|
965 |
-
*
|
966 |
-
*
|
967 |
-
*
|
968 |
-
*
|
969 |
-
*
|
970 |
-
*
|
971 |
-
*
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
*
|
990 |
-
*
|
991 |
-
*
|
992 |
-
*
|
993 |
-
*
|
994 |
-
* @
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
*
|
1008 |
-
*
|
1009 |
-
*
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
*
|
1022 |
-
*
|
1023 |
-
*
|
1024 |
-
* @
|
1025 |
-
* @
|
1026 |
-
*
|
1027 |
-
*
|
1028 |
-
*
|
1029 |
-
*
|
1030 |
-
*
|
1031 |
-
*
|
1032 |
-
*
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
}
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
$
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
*
|
1092 |
-
*
|
1093 |
-
*
|
1094 |
-
* @
|
1095 |
-
*
|
1096 |
-
* @
|
1097 |
-
*
|
1098 |
-
*
|
1099 |
-
*
|
1100 |
-
*
|
1101 |
-
*
|
1102 |
-
*
|
1103 |
-
*
|
1104 |
-
*
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
*
|
1110 |
-
*
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
*
|
1116 |
-
*
|
1117 |
-
*
|
1118 |
-
* @
|
1119 |
-
*
|
1120 |
-
* @
|
1121 |
-
*
|
1122 |
-
*
|
1123 |
-
*
|
1124 |
-
*
|
1125 |
-
*
|
1126 |
-
*
|
1127 |
-
*
|
1128 |
-
*
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
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 |
-
if ( !
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
*
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
*
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
*
|
1425 |
-
*
|
1426 |
-
* @
|
1427 |
-
*
|
1428 |
-
* @
|
1429 |
-
* @
|
1430 |
-
*
|
1431 |
-
*
|
1432 |
-
*
|
1433 |
-
*
|
1434 |
-
*
|
1435 |
-
*
|
1436 |
-
*
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
*
|
1479 |
-
*
|
1480 |
-
*
|
1481 |
-
* @
|
1482 |
-
* @
|
1483 |
-
*
|
1484 |
-
*
|
1485 |
-
*
|
1486 |
-
*
|
1487 |
-
*
|
1488 |
-
*
|
1489 |
-
*
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
$array[
|
1520 |
-
}
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
if ( ! isset( $array['
|
1525 |
-
$array['
|
1526 |
-
}
|
1527 |
-
if ( ! isset( $array['
|
1528 |
-
$array['
|
1529 |
-
}
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
$array['
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
$array['
|
1548 |
-
}
|
1549 |
-
|
1550 |
-
$
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
case '
|
1563 |
-
|
1564 |
-
$array['disabled'] = '';
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
$array['
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
$array['input'] = '
|
1577 |
-
|
1578 |
-
break;
|
1579 |
-
|
1580 |
-
case '
|
1581 |
-
|
1582 |
-
$array['
|
1583 |
-
|
1584 |
-
break;
|
1585 |
-
|
1586 |
-
case '
|
1587 |
-
|
1588 |
-
$array['
|
1589 |
-
|
1590 |
-
break;
|
1591 |
-
|
1592 |
-
case '
|
1593 |
-
|
1594 |
-
$array['input'] = 'text';
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
case 'M
|
1608 |
-
$js_format = 'mmm
|
1609 |
-
break;
|
1610 |
-
case 'F
|
1611 |
-
$js_format = 'mmmm
|
1612 |
-
break;
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
}
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
if ( ! isset( $array['
|
1624 |
-
$array['
|
1625 |
-
}
|
1626 |
-
if ( ! isset( $array['
|
1627 |
-
$array['
|
1628 |
-
}
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
$array['
|
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 |
-
$array['
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
case '
|
1694 |
-
$js_format = '
|
1695 |
-
break;
|
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 |
-
if ( isset( $array['
|
1739 |
-
$array['
|
1740 |
-
} else {
|
1741 |
-
$array['
|
1742 |
-
}
|
1743 |
-
|
1744 |
-
if ( isset( $array['
|
1745 |
-
$array['
|
1746 |
-
} else {
|
1747 |
-
$array['
|
1748 |
-
}
|
1749 |
-
|
1750 |
-
if (
|
1751 |
-
$array['
|
1752 |
-
}
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
$array['
|
1766 |
-
}
|
1767 |
-
|
1768 |
-
|
1769 |
-
$array['crop_data'] =
|
1770 |
-
}
|
1771 |
-
|
1772 |
-
|
1773 |
-
$array['
|
1774 |
-
}
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
$array['
|
1780 |
-
}
|
1781 |
-
|
1782 |
-
if (
|
1783 |
-
$array['
|
1784 |
-
}
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
$array['
|
1820 |
-
}
|
1821 |
-
if ( ! isset( $array['
|
1822 |
-
$array['
|
1823 |
-
}
|
1824 |
-
if ( ! isset( $array['
|
1825 |
-
$array['
|
1826 |
-
}
|
1827 |
-
if ( ! isset( $array['
|
1828 |
-
$array['
|
1829 |
-
}
|
1830 |
-
if ( ! isset( $array['
|
1831 |
-
$array['
|
1832 |
-
}
|
1833 |
-
if (
|
1834 |
-
$array['
|
1835 |
-
}
|
1836 |
-
if ( ! isset( $array['
|
1837 |
-
$array['
|
1838 |
-
}
|
1839 |
-
if (
|
1840 |
-
$array['
|
1841 |
-
}
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
$array['
|
1855 |
-
}
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
$array['
|
1861 |
-
}
|
1862 |
-
if ( ! isset( $array['
|
1863 |
-
$array['
|
1864 |
-
}
|
1865 |
-
if ( ! isset( $array['
|
1866 |
-
$array['
|
1867 |
-
}
|
1868 |
-
if ( ! isset( $array['
|
1869 |
-
$array['
|
1870 |
-
}
|
1871 |
-
if ( ! isset( $array['
|
1872 |
-
$array['
|
1873 |
-
}
|
1874 |
-
if (
|
1875 |
-
$array['
|
1876 |
-
}
|
1877 |
-
if ( ! isset( $array['
|
1878 |
-
$array['
|
1879 |
-
}
|
1880 |
-
if (
|
1881 |
-
$array['
|
1882 |
-
}
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
*
|
1916 |
-
*
|
1917 |
-
*
|
1918 |
-
* @
|
1919 |
-
* @
|
1920 |
-
*
|
1921 |
-
*
|
1922 |
-
*
|
1923 |
-
*
|
1924 |
-
*
|
1925 |
-
*
|
1926 |
-
*
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
*
|
1948 |
-
*
|
1949 |
-
*
|
1950 |
-
* @
|
1951 |
-
* @
|
1952 |
-
*
|
1953 |
-
*
|
1954 |
-
*
|
1955 |
-
*
|
1956 |
-
*
|
1957 |
-
*
|
1958 |
-
*
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
*
|
1988 |
-
*
|
1989 |
-
* @
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
* @var string $
|
2012 |
-
* @var
|
2013 |
-
* @var
|
2014 |
-
* @var string $
|
2015 |
-
* @var string $
|
2016 |
-
* @var
|
2017 |
-
* @var
|
2018 |
-
* @var
|
2019 |
-
* @var
|
2020 |
-
* @var
|
2021 |
-
* @var
|
2022 |
-
* @var string $
|
2023 |
-
* @var
|
2024 |
-
* @var
|
2025 |
-
* @var string $
|
2026 |
-
* @var
|
2027 |
-
* @var
|
2028 |
-
* @var string $
|
2029 |
-
* @var string $
|
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 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
|
2075 |
-
|
2076 |
-
|
2077 |
-
|
2078 |
-
|
2079 |
-
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
}
|
2096 |
-
|
2097 |
-
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
|
2115 |
-
|
2116 |
-
|
2117 |
-
|
2118 |
-
|
2119 |
-
|
2120 |
-
|
2121 |
-
|
2122 |
-
|
2123 |
-
|
2124 |
-
|
2125 |
-
|
2126 |
-
|
2127 |
-
|
2128 |
-
|
2129 |
-
|
2130 |
-
|
2131 |
-
|
2132 |
-
|
2133 |
-
|
2134 |
-
|
2135 |
-
|
2136 |
-
|
2137 |
-
|
2138 |
-
}
|
2139 |
-
|
2140 |
-
|
2141 |
-
|
2142 |
-
|
2143 |
-
|
2144 |
-
|
2145 |
-
|
2146 |
-
|
2147 |
-
|
2148 |
-
|
2149 |
-
|
2150 |
-
|
2151 |
-
|
2152 |
-
|
2153 |
-
*
|
2154 |
-
*
|
2155 |
-
*
|
2156 |
-
* @
|
2157 |
-
* @
|
2158 |
-
*
|
2159 |
-
*
|
2160 |
-
*
|
2161 |
-
*
|
2162 |
-
*
|
2163 |
-
*
|
2164 |
-
*
|
2165 |
-
|
2166 |
-
|
2167 |
-
|
2168 |
-
|
2169 |
-
|
2170 |
-
|
2171 |
-
|
2172 |
-
|
2173 |
-
|
2174 |
-
|
2175 |
-
case '
|
2176 |
-
case '
|
2177 |
-
$
|
2178 |
-
$
|
2179 |
-
break;
|
2180 |
-
|
2181 |
-
|
2182 |
-
|
2183 |
-
|
2184 |
-
|
2185 |
-
|
2186 |
-
|
2187 |
-
|
2188 |
-
|
2189 |
-
|
2190 |
-
|
2191 |
-
|
2192 |
-
*
|
2193 |
-
*
|
2194 |
-
*
|
2195 |
-
* @
|
2196 |
-
*
|
2197 |
-
* @
|
2198 |
-
*
|
2199 |
-
*
|
2200 |
-
*
|
2201 |
-
*
|
2202 |
-
*
|
2203 |
-
*
|
2204 |
-
*
|
2205 |
-
*
|
2206 |
-
|
2207 |
-
|
2208 |
-
|
2209 |
-
|
2210 |
-
|
2211 |
-
|
2212 |
-
|
2213 |
-
|
2214 |
-
|
2215 |
-
|
2216 |
-
|
2217 |
-
|
2218 |
-
|
2219 |
-
|
2220 |
-
|
2221 |
-
|
2222 |
-
|
2223 |
-
|
2224 |
-
*
|
2225 |
-
*
|
2226 |
-
* @
|
2227 |
-
*
|
2228 |
-
* @
|
2229 |
-
* @
|
2230 |
-
*
|
2231 |
-
*
|
2232 |
-
*
|
2233 |
-
*
|
2234 |
-
*
|
2235 |
-
*
|
2236 |
-
*
|
2237 |
-
|
2238 |
-
|
2239 |
-
|
2240 |
-
|
2241 |
-
|
2242 |
-
|
2243 |
-
|
2244 |
-
|
2245 |
-
|
2246 |
-
|
2247 |
-
|
2248 |
-
|
2249 |
-
|
2250 |
-
|
2251 |
-
|
2252 |
-
|
2253 |
-
|
2254 |
-
$output .= '<div
|
2255 |
-
|
2256 |
-
if (
|
2257 |
-
|
2258 |
-
|
2259 |
-
|
2260 |
-
|
2261 |
-
|
2262 |
-
|
2263 |
-
|
2264 |
-
|
2265 |
-
|
2266 |
-
|
2267 |
-
|
2268 |
-
|
2269 |
-
|
2270 |
-
|
2271 |
-
|
2272 |
-
|
2273 |
-
|
2274 |
-
|
2275 |
-
|
2276 |
-
$output .= $this->
|
2277 |
-
}
|
2278 |
-
|
2279 |
-
$
|
2280 |
-
|
2281 |
-
|
2282 |
-
|
2283 |
-
|
2284 |
-
|
2285 |
-
$output .= '
|
2286 |
-
|
2287 |
-
|
2288 |
-
|
2289 |
-
|
2290 |
-
|
2291 |
-
$output .= '<div
|
2292 |
-
|
2293 |
-
if (
|
2294 |
-
|
2295 |
-
|
2296 |
-
|
2297 |
-
|
2298 |
-
|
2299 |
-
|
2300 |
-
|
2301 |
-
|
2302 |
-
|
2303 |
-
|
2304 |
-
|
2305 |
-
|
2306 |
-
|
2307 |
-
|
2308 |
-
|
2309 |
-
|
2310 |
-
|
2311 |
-
|
2312 |
-
|
2313 |
-
$output .= $this->
|
2314 |
-
}
|
2315 |
-
|
2316 |
-
$
|
2317 |
-
|
2318 |
-
|
2319 |
-
|
2320 |
-
|
2321 |
-
|
2322 |
-
$output .= '
|
2323 |
-
|
2324 |
-
|
2325 |
-
|
2326 |
-
|
2327 |
-
|
2328 |
-
$output .= '<div
|
2329 |
-
|
2330 |
-
if (
|
2331 |
-
|
2332 |
-
|
2333 |
-
|
2334 |
-
|
2335 |
-
|
2336 |
-
$
|
2337 |
-
|
2338 |
-
$
|
2339 |
-
|
2340 |
-
|
2341 |
-
|
2342 |
-
|
2343 |
-
|
2344 |
-
|
2345 |
-
|
2346 |
-
|
2347 |
-
|
2348 |
-
|
2349 |
-
|
2350 |
-
|
2351 |
-
|
2352 |
-
|
2353 |
-
|
2354 |
-
$
|
2355 |
-
|
2356 |
-
|
2357 |
-
|
2358 |
-
|
2359 |
-
|
2360 |
-
$
|
2361 |
-
|
2362 |
-
|
2363 |
-
|
2364 |
-
|
2365 |
-
|
2366 |
-
|
2367 |
-
|
2368 |
-
|
2369 |
-
|
2370 |
-
|
2371 |
-
|
2372 |
-
$output .= '<div
|
2373 |
-
|
2374 |
-
if (
|
2375 |
-
|
2376 |
-
|
2377 |
-
|
2378 |
-
|
2379 |
-
|
2380 |
-
|
2381 |
-
|
2382 |
-
|
2383 |
-
|
2384 |
-
|
2385 |
-
|
2386 |
-
|
2387 |
-
|
2388 |
-
|
2389 |
-
|
2390 |
-
$
|
2391 |
-
|
2392 |
-
|
2393 |
-
|
2394 |
-
|
2395 |
-
|
2396 |
-
|
2397 |
-
|
2398 |
-
|
2399 |
-
|
2400 |
-
|
2401 |
-
|
2402 |
-
|
2403 |
-
|
2404 |
-
$output .= '<div
|
2405 |
-
|
2406 |
-
if (
|
2407 |
-
|
2408 |
-
|
2409 |
-
|
2410 |
-
|
2411 |
-
|
2412 |
-
|
2413 |
-
|
2414 |
-
|
2415 |
-
|
2416 |
-
|
2417 |
-
|
2418 |
-
|
2419 |
-
|
2420 |
-
|
2421 |
-
|
2422 |
-
$
|
2423 |
-
|
2424 |
-
|
2425 |
-
|
2426 |
-
|
2427 |
-
|
2428 |
-
|
2429 |
-
|
2430 |
-
|
2431 |
-
|
2432 |
-
|
2433 |
-
|
2434 |
-
|
2435 |
-
|
2436 |
-
|
2437 |
-
|
2438 |
-
|
2439 |
-
|
2440 |
-
|
2441 |
-
|
2442 |
-
|
2443 |
-
|
2444 |
-
|
2445 |
-
|
2446 |
-
|
2447 |
-
|
2448 |
-
|
2449 |
-
|
2450 |
-
$
|
2451 |
-
|
2452 |
-
|
2453 |
-
|
2454 |
-
|
2455 |
-
|
2456 |
-
|
2457 |
-
|
2458 |
-
|
2459 |
-
|
2460 |
-
|
2461 |
-
|
2462 |
-
|
2463 |
-
$
|
2464 |
-
|
2465 |
-
|
2466 |
-
|
2467 |
-
|
2468 |
-
|
2469 |
-
|
2470 |
-
|
2471 |
-
|
2472 |
-
|
2473 |
-
|
2474 |
-
|
2475 |
-
|
2476 |
-
|
2477 |
-
|
2478 |
-
|
2479 |
-
|
2480 |
-
|
2481 |
-
|
2482 |
-
|
2483 |
-
|
2484 |
-
|
2485 |
-
|
2486 |
-
|
2487 |
-
|
2488 |
-
$
|
2489 |
-
|
2490 |
-
|
2491 |
-
|
2492 |
-
|
2493 |
-
|
2494 |
-
$
|
2495 |
-
}
|
2496 |
-
|
2497 |
-
|
2498 |
-
|
2499 |
-
|
2500 |
-
|
2501 |
-
|
2502 |
-
|
2503 |
-
|
2504 |
-
|
2505 |
-
|
2506 |
-
|
2507 |
-
|
2508 |
-
|
2509 |
-
|
2510 |
-
|
2511 |
-
$
|
2512 |
-
|
2513 |
-
|
2514 |
-
|
2515 |
-
|
2516 |
-
|
2517 |
-
|
2518 |
-
|
2519 |
-
|
2520 |
-
|
2521 |
-
|
2522 |
-
|
2523 |
-
|
2524 |
-
|
2525 |
-
|
2526 |
-
|
2527 |
-
|
2528 |
-
$output .= '<div
|
2529 |
-
|
2530 |
-
if (
|
2531 |
-
|
2532 |
-
|
2533 |
-
|
2534 |
-
|
2535 |
-
|
2536 |
-
|
2537 |
-
|
2538 |
-
|
2539 |
-
|
2540 |
-
|
2541 |
-
|
2542 |
-
|
2543 |
-
|
2544 |
-
|
2545 |
-
|
2546 |
-
$
|
2547 |
-
|
2548 |
-
|
2549 |
-
|
2550 |
-
|
2551 |
-
|
2552 |
-
$output .= '
|
2553 |
-
|
2554 |
-
|
2555 |
-
|
2556 |
-
|
2557 |
-
|
2558 |
-
$output .= '<div
|
2559 |
-
|
2560 |
-
if (
|
2561 |
-
|
2562 |
-
|
2563 |
-
|
2564 |
-
|
2565 |
-
|
2566 |
-
|
2567 |
-
|
2568 |
-
|
2569 |
-
|
2570 |
-
|
2571 |
-
|
2572 |
-
|
2573 |
-
|
2574 |
-
|
2575 |
-
|
2576 |
-
$
|
2577 |
-
|
2578 |
-
|
2579 |
-
|
2580 |
-
|
2581 |
-
|
2582 |
-
$output .= '
|
2583 |
-
|
2584 |
-
|
2585 |
-
|
2586 |
-
|
2587 |
-
|
2588 |
-
$output .= '<div
|
2589 |
-
|
2590 |
-
if (
|
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 |
-
$output .= '<div
|
2623 |
-
|
2624 |
-
if ( isset( $data['
|
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 |
-
$output .= $this->
|
2681 |
-
}
|
2682 |
-
|
2683 |
-
|
2684 |
-
|
2685 |
-
|
2686 |
-
$output .= $this->
|
2687 |
-
}
|
2688 |
-
|
2689 |
-
$
|
2690 |
-
|
2691 |
-
|
2692 |
-
|
2693 |
-
|
2694 |
-
|
2695 |
-
|
2696 |
-
|
2697 |
-
|
2698 |
-
|
2699 |
-
|
2700 |
-
$output .= '<div
|
2701 |
-
|
2702 |
-
|
2703 |
-
|
2704 |
-
|
2705 |
-
|
2706 |
-
|
2707 |
-
|
2708 |
-
|
2709 |
-
|
2710 |
-
|
2711 |
-
$
|
2712 |
-
|
2713 |
-
|
2714 |
-
|
2715 |
-
|
2716 |
-
|
2717 |
-
$output .= '
|
2718 |
-
|
2719 |
-
|
2720 |
-
|
2721 |
-
|
2722 |
-
|
2723 |
-
|
2724 |
-
|
2725 |
-
|
2726 |
-
|
2727 |
-
|
2728 |
-
|
2729 |
-
|
2730 |
-
|
2731 |
-
|
2732 |
-
|
2733 |
-
|
2734 |
-
|
2735 |
-
|
2736 |
-
|
2737 |
-
$output .= '<
|
2738 |
-
if (
|
2739 |
-
$
|
2740 |
-
}
|
2741 |
-
|
2742 |
-
|
2743 |
-
|
2744 |
-
if (
|
2745 |
-
|
2746 |
-
|
2747 |
-
|
2748 |
-
|
2749 |
-
|
2750 |
-
|
2751 |
-
|
2752 |
-
if (
|
2753 |
-
$
|
2754 |
-
} else {
|
2755 |
-
$
|
2756 |
-
}
|
2757 |
-
|
2758 |
-
|
2759 |
-
|
2760 |
-
|
2761 |
-
|
2762 |
-
|
2763 |
-
$
|
2764 |
-
}
|
2765 |
-
|
2766 |
-
|
2767 |
-
|
2768 |
-
|
2769 |
-
|
2770 |
-
|
2771 |
-
|
2772 |
-
|
2773 |
-
|
2774 |
-
|
2775 |
-
|
2776 |
-
|
2777 |
-
|
2778 |
-
|
2779 |
-
|
2780 |
-
|
2781 |
-
|
2782 |
-
|
2783 |
-
|
2784 |
-
|
2785 |
-
|
2786 |
-
|
2787 |
-
|
2788 |
-
|
2789 |
-
|
2790 |
-
|
2791 |
-
|
2792 |
-
|
2793 |
-
|
2794 |
-
|
2795 |
-
|
2796 |
-
|
2797 |
-
|
2798 |
-
|
2799 |
-
|
2800 |
-
|
2801 |
-
|
2802 |
-
|
2803 |
-
|
2804 |
-
|
2805 |
-
|
2806 |
-
|
2807 |
-
|
2808 |
-
|
2809 |
-
|
2810 |
-
|
2811 |
-
|
2812 |
-
|
2813 |
-
$output .=
|
2814 |
-
}
|
2815 |
-
|
2816 |
-
|
2817 |
-
|
2818 |
-
|
2819 |
-
|
2820 |
-
|
2821 |
-
$output .= '
|
2822 |
-
|
2823 |
-
|
2824 |
-
|
2825 |
-
|
2826 |
-
|
2827 |
-
$output .= '<div
|
2828 |
-
|
2829 |
-
|
2830 |
-
|
2831 |
-
|
2832 |
-
|
2833 |
-
|
2834 |
-
|
2835 |
-
|
2836 |
-
|
2837 |
-
|
2838 |
-
|
2839 |
-
|
2840 |
-
|
2841 |
-
|
2842 |
-
|
2843 |
-
|
2844 |
-
|
2845 |
-
|
2846 |
-
|
2847 |
-
|
2848 |
-
|
2849 |
-
|
2850 |
-
|
2851 |
-
|
2852 |
-
|
2853 |
-
|
2854 |
-
|
2855 |
-
$
|
2856 |
-
|
2857 |
-
|
2858 |
-
|
2859 |
-
|
2860 |
-
|
2861 |
-
|
2862 |
-
|
2863 |
-
|
2864 |
-
|
2865 |
-
|
2866 |
-
|
2867 |
-
|
2868 |
-
|
2869 |
-
|
2870 |
-
|
2871 |
-
|
2872 |
-
|
2873 |
-
|
2874 |
-
|
2875 |
-
}
|
2876 |
-
|
2877 |
-
|
2878 |
-
|
2879 |
-
|
2880 |
-
|
2881 |
-
|
2882 |
-
|
2883 |
-
|
2884 |
-
|
2885 |
-
|
2886 |
-
|
2887 |
-
|
2888 |
-
|
2889 |
-
|
2890 |
-
|
2891 |
-
|
2892 |
-
|
2893 |
-
|
2894 |
-
|
2895 |
-
|
2896 |
-
|
2897 |
-
|
2898 |
-
|
2899 |
-
|
2900 |
-
|
2901 |
-
|
2902 |
-
|
2903 |
-
|
2904 |
-
|
2905 |
-
|
2906 |
-
|
2907 |
-
|
2908 |
-
|
2909 |
-
|
2910 |
-
|
2911 |
-
|
2912 |
-
|
2913 |
-
|
2914 |
-
|
2915 |
-
|
2916 |
-
|
2917 |
-
|
2918 |
-
|
2919 |
-
|
2920 |
-
$output .=
|
2921 |
-
}
|
2922 |
-
|
2923 |
-
|
2924 |
-
|
2925 |
-
|
2926 |
-
|
2927 |
-
|
2928 |
-
|
2929 |
-
|
2930 |
-
|
2931 |
-
|
2932 |
-
|
2933 |
-
|
2934 |
-
|
2935 |
-
|
2936 |
-
|
2937 |
-
if ( isset( $data['
|
2938 |
-
$
|
2939 |
-
}
|
2940 |
-
|
2941 |
-
|
2942 |
-
|
2943 |
-
|
2944 |
-
|
2945 |
-
|
2946 |
-
|
2947 |
-
$
|
2948 |
-
$
|
2949 |
-
|
2950 |
-
|
2951 |
-
|
2952 |
-
|
2953 |
-
|
2954 |
-
|
2955 |
-
|
2956 |
-
|
2957 |
-
|
2958 |
-
|
2959 |
-
|
2960 |
-
|
2961 |
-
|
2962 |
-
|
2963 |
-
|
2964 |
-
|
2965 |
-
|
2966 |
-
|
2967 |
-
|
2968 |
-
|
2969 |
-
*
|
2970 |
-
*
|
2971 |
-
* @
|
2972 |
-
*
|
2973 |
-
* @
|
2974 |
-
* @
|
2975 |
-
*
|
2976 |
-
*
|
2977 |
-
*
|
2978 |
-
*
|
2979 |
-
*
|
2980 |
-
*
|
2981 |
-
*
|
2982 |
-
|
2983 |
-
|
2984 |
-
|
2985 |
-
|
2986 |
-
|
2987 |
-
|
2988 |
-
|
2989 |
-
|
2990 |
-
|
2991 |
-
|
2992 |
-
|
2993 |
-
|
2994 |
-
|
2995 |
-
|
2996 |
-
|
2997 |
-
|
2998 |
-
|
2999 |
-
|
3000 |
-
|
3001 |
-
|
3002 |
-
|
3003 |
-
|
3004 |
-
|
3005 |
-
|
3006 |
-
|
3007 |
-
|
3008 |
-
|
3009 |
-
|
3010 |
-
|
3011 |
-
|
3012 |
-
|
3013 |
-
|
3014 |
-
|
3015 |
-
|
3016 |
-
|
3017 |
-
|
3018 |
-
|
3019 |
-
|
3020 |
-
|
3021 |
-
*
|
3022 |
-
*
|
3023 |
-
* @
|
3024 |
-
*
|
3025 |
-
* @
|
3026 |
-
* @
|
3027 |
-
*
|
3028 |
-
*
|
3029 |
-
*
|
3030 |
-
*
|
3031 |
-
*
|
3032 |
-
*
|
3033 |
-
*
|
3034 |
-
|
3035 |
-
|
3036 |
-
|
3037 |
-
|
3038 |
-
|
3039 |
-
*
|
3040 |
-
|
3041 |
-
|
3042 |
-
|
3043 |
-
|
3044 |
-
|
3045 |
-
*
|
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 |
-
if ( isset( $options ) ) {
|
3102 |
-
|
3103 |
-
|
3104 |
-
|
3105 |
-
|
3106 |
-
|
3107 |
-
|
3108 |
-
|
3109 |
-
*
|
3110 |
-
*
|
3111 |
-
* @
|
3112 |
-
*
|
3113 |
-
* @
|
3114 |
-
* @
|
3115 |
-
*
|
3116 |
-
*
|
3117 |
-
*
|
3118 |
-
*
|
3119 |
-
*
|
3120 |
-
*
|
3121 |
-
*
|
3122 |
-
|
3123 |
-
|
3124 |
-
|
3125 |
-
*
|
3126 |
-
*
|
3127 |
-
*
|
3128 |
-
|
3129 |
-
|
3130 |
-
|
3131 |
-
*
|
3132 |
-
*
|
3133 |
-
*
|
3134 |
-
* @
|
3135 |
-
* @
|
3136 |
-
*
|
3137 |
-
*
|
3138 |
-
*
|
3139 |
-
*
|
3140 |
-
*
|
3141 |
-
*
|
3142 |
-
*
|
3143 |
-
|
3144 |
-
|
3145 |
-
|
3146 |
-
|
3147 |
-
|
3148 |
-
|
3149 |
-
|
3150 |
-
|
3151 |
-
|
3152 |
-
|
3153 |
-
|
3154 |
-
|
3155 |
-
|
3156 |
-
|
3157 |
-
|
3158 |
-
|
3159 |
-
*
|
3160 |
-
*
|
3161 |
-
|
3162 |
-
|
3163 |
-
|
3164 |
-
|
3165 |
-
|
3166 |
-
|
3167 |
-
|
3168 |
-
|
3169 |
-
|
3170 |
-
|
3171 |
-
if ( ! empty( $
|
3172 |
-
$
|
3173 |
-
}
|
3174 |
-
|
3175 |
-
$
|
3176 |
-
|
3177 |
-
$
|
3178 |
-
|
3179 |
-
|
3180 |
-
|
3181 |
-
|
3182 |
-
|
3183 |
-
|
3184 |
-
|
3185 |
-
|
3186 |
-
|
3187 |
-
|
3188 |
-
|
3189 |
-
|
3190 |
-
|
3191 |
-
|
3192 |
-
|
3193 |
-
|
3194 |
-
|
3195 |
-
if (
|
3196 |
-
|
3197 |
-
$
|
3198 |
-
|
3199 |
-
|
3200 |
-
|
3201 |
-
|
3202 |
-
|
3203 |
-
|
3204 |
-
|
3205 |
-
|
3206 |
-
|
3207 |
-
|
3208 |
-
|
3209 |
-
|
3210 |
-
|
3211 |
-
|
3212 |
-
|
3213 |
-
|
3214 |
-
|
3215 |
-
|
3216 |
-
|
3217 |
-
|
3218 |
-
|
3219 |
-
|
3220 |
-
|
3221 |
-
|
3222 |
-
$
|
3223 |
-
|
3224 |
-
|
3225 |
-
|
3226 |
-
|
3227 |
-
|
3228 |
-
|
3229 |
-
|
3230 |
-
|
3231 |
-
|
3232 |
-
|
3233 |
-
|
3234 |
-
|
3235 |
-
|
3236 |
-
|
3237 |
-
|
3238 |
-
$
|
3239 |
-
|
3240 |
-
|
3241 |
-
|
3242 |
-
|
3243 |
-
|
3244 |
-
|
3245 |
-
|
3246 |
-
|
3247 |
-
|
3248 |
-
if ( isset( $data['
|
3249 |
-
$
|
3250 |
-
}
|
3251 |
-
|
3252 |
-
|
3253 |
-
|
3254 |
-
|
3255 |
-
|
3256 |
-
|
3257 |
-
|
3258 |
-
|
3259 |
-
|
3260 |
-
|
3261 |
-
|
3262 |
-
*
|
3263 |
-
*
|
3264 |
-
* @
|
3265 |
-
*
|
3266 |
-
* @
|
3267 |
-
* @
|
3268 |
-
*
|
3269 |
-
*
|
3270 |
-
*
|
3271 |
-
*
|
3272 |
-
*
|
3273 |
-
*
|
3274 |
-
*
|
3275 |
-
|
3276 |
-
|
3277 |
-
|
3278 |
-
|
3279 |
-
|
3280 |
-
|
3281 |
-
|
3282 |
-
|
3283 |
-
|
3284 |
-
|
3285 |
-
|
3286 |
-
|
3287 |
-
|
3288 |
-
|
3289 |
-
|
3290 |
-
|
3291 |
-
|
3292 |
-
|
3293 |
-
|
3294 |
-
|
3295 |
-
|
3296 |
-
|
3297 |
-
|
3298 |
-
|
3299 |
-
|
3300 |
-
|
3301 |
-
|
3302 |
-
*
|
3303 |
-
*
|
3304 |
-
* @
|
3305 |
-
*
|
3306 |
-
* @
|
3307 |
-
* @
|
3308 |
-
*
|
3309 |
-
*
|
3310 |
-
*
|
3311 |
-
*
|
3312 |
-
*
|
3313 |
-
*
|
3314 |
-
*
|
3315 |
-
|
3316 |
-
|
3317 |
-
|
3318 |
-
*
|
3319 |
-
*
|
3320 |
-
*
|
3321 |
-
|
3322 |
-
|
3323 |
-
|
3324 |
-
*
|
3325 |
-
*
|
3326 |
-
*
|
3327 |
-
* @
|
3328 |
-
* @
|
3329 |
-
*
|
3330 |
-
*
|
3331 |
-
*
|
3332 |
-
*
|
3333 |
-
*
|
3334 |
-
*
|
3335 |
-
*
|
3336 |
-
|
3337 |
-
|
3338 |
-
|
3339 |
-
*
|
3340 |
-
*
|
3341 |
-
*
|
3342 |
-
|
3343 |
-
|
3344 |
-
|
3345 |
-
*
|
3346 |
-
*
|
3347 |
-
* @
|
3348 |
-
*
|
3349 |
-
* @
|
3350 |
-
* @
|
3351 |
-
*
|
3352 |
-
*
|
3353 |
-
*
|
3354 |
-
*
|
3355 |
-
*
|
3356 |
-
*
|
3357 |
-
*
|
3358 |
-
|
3359 |
-
|
3360 |
-
|
3361 |
-
|
3362 |
-
|
3363 |
-
|
3364 |
-
|
3365 |
-
|
3366 |
-
|
3367 |
-
|
3368 |
-
|
3369 |
-
*
|
3370 |
-
*
|
3371 |
-
|
3372 |
-
|
3373 |
-
|
3374 |
-
|
3375 |
-
|
3376 |
-
|
3377 |
-
|
3378 |
-
|
3379 |
-
|
3380 |
-
|
3381 |
-
|
3382 |
-
|
3383 |
-
|
3384 |
-
|
3385 |
-
|
3386 |
-
|
3387 |
-
|
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 |
-
|
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 |
-
$output .= '<div
|
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 |
-
if( $
|
3522 |
-
|
3523 |
-
$
|
3524 |
-
|
3525 |
-
|
3526 |
-
|
3527 |
-
if
|
3528 |
-
$
|
3529 |
-
|
3530 |
-
|
3531 |
-
|
3532 |
-
|
3533 |
-
if (
|
3534 |
-
$
|
3535 |
-
|
3536 |
-
|
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 |
-
|
3566 |
-
|
3567 |
-
|
3568 |
-
|
3569 |
-
|
3570 |
-
|
3571 |
-
|
3572 |
-
|
3573 |
-
}
|
3574 |
-
}
|
3575 |
-
|
3576 |
-
$
|
3577 |
-
|
3578 |
-
|
3579 |
-
|
3580 |
-
|
3581 |
-
|
3582 |
-
|
3583 |
-
|
3584 |
-
|
3585 |
-
|
3586 |
-
$
|
3587 |
-
|
3588 |
-
|
3589 |
-
|
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 |
-
$output .= '<div
|
3645 |
-
|
3646 |
-
|
3647 |
-
|
3648 |
-
|
3649 |
-
|
3650 |
-
|
3651 |
-
|
3652 |
-
|
3653 |
-
|
3654 |
-
|
3655 |
-
|
3656 |
-
|
3657 |
-
|
3658 |
-
|
3659 |
-
|
3660 |
-
if ( $
|
3661 |
-
$
|
3662 |
-
|
3663 |
-
|
3664 |
-
|
3665 |
-
|
3666 |
-
|
3667 |
-
|
3668 |
-
|
3669 |
-
|
3670 |
-
|
3671 |
-
|
3672 |
-
|
3673 |
-
|
3674 |
-
$
|
3675 |
-
|
3676 |
-
|
3677 |
-
|
3678 |
-
$output .= '<
|
3679 |
-
|
3680 |
-
|
3681 |
-
|
3682 |
-
|
3683 |
-
|
3684 |
-
$output .= '
|
3685 |
-
|
3686 |
-
if (
|
3687 |
-
$output .=
|
3688 |
-
}
|
3689 |
-
|
3690 |
-
|
3691 |
-
|
3692 |
-
|
3693 |
-
|
3694 |
-
|
3695 |
-
|
3696 |
-
|
3697 |
-
|
3698 |
-
|
3699 |
-
*
|
3700 |
-
*
|
3701 |
-
*
|
3702 |
-
*
|
3703 |
-
* @
|
3704 |
-
*
|
3705 |
-
*
|
3706 |
-
*
|
3707 |
-
*
|
3708 |
-
*
|
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 |
-
|
3734 |
-
|
3735 |
-
|
3736 |
-
$
|
3737 |
-
|
3738 |
-
|
3739 |
-
|
3740 |
-
|
3741 |
-
|
3742 |
-
|
3743 |
-
|
3744 |
-
|
3745 |
-
|
3746 |
-
|
3747 |
-
$
|
3748 |
-
|
3749 |
-
|
3750 |
-
|
3751 |
-
|
3752 |
-
|
3753 |
-
|
3754 |
-
|
3755 |
-
|
3756 |
-
|
3757 |
-
|
3758 |
-
|
3759 |
-
|
3760 |
-
$
|
3761 |
-
|
3762 |
-
|
3763 |
-
|
3764 |
-
|
3765 |
-
|
3766 |
-
|
3767 |
-
|
3768 |
-
|
3769 |
-
|
3770 |
-
|
3771 |
-
$output .= '
|
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 |
-
return
|
3826 |
-
}
|
3827 |
-
|
3828 |
-
|
3829 |
-
|
3830 |
-
|
3831 |
-
|
3832 |
-
|
3833 |
-
|
3834 |
-
|
3835 |
-
|
3836 |
-
|
3837 |
-
|
3838 |
-
|
3839 |
-
|
3840 |
-
|
3841 |
-
|
3842 |
-
|
3843 |
-
|
3844 |
-
|
3845 |
-
|
3846 |
-
|
3847 |
-
|
3848 |
-
|
3849 |
-
|
3850 |
-
|
3851 |
-
|
3852 |
-
|
3853 |
-
|
3854 |
-
|
3855 |
-
|
3856 |
-
|
3857 |
-
|
3858 |
-
|
3859 |
-
|
3860 |
-
|
3861 |
-
|
3862 |
-
|
3863 |
-
*
|
3864 |
-
|
3865 |
-
|
3866 |
-
|
3867 |
-
|
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 |
-
$this->
|
3990 |
-
|
3991 |
-
|
3992 |
-
|
3993 |
-
|
3994 |
-
|
3995 |
-
|
3996 |
-
|
3997 |
-
|
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 |
-
|
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 |
-
|
4079 |
-
$
|
4080 |
-
|
4081 |
-
|
4082 |
-
|
4083 |
-
|
4084 |
-
|
4085 |
-
|
4086 |
-
|
4087 |
-
|
4088 |
-
|
4089 |
-
|
4090 |
-
$
|
4091 |
-
|
4092 |
-
|
4093 |
-
|
4094 |
-
|
4095 |
-
|
4096 |
-
|
4097 |
-
|
4098 |
-
|
4099 |
-
$
|
4100 |
-
|
4101 |
-
|
4102 |
-
|
4103 |
-
|
4104 |
-
|
4105 |
-
|
4106 |
-
|
4107 |
-
|
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 |
-
|
4140 |
-
|
4141 |
-
|
4142 |
-
|
4143 |
-
|
4144 |
-
|
4145 |
-
|
4146 |
-
|
4147 |
-
|
4148 |
-
|
4149 |
-
|
4150 |
-
|
4151 |
-
|
4152 |
-
|
4153 |
-
* @var $
|
4154 |
-
* @var $
|
4155 |
-
* @var $
|
4156 |
-
* @var $
|
4157 |
-
* @var $
|
4158 |
-
* @var $
|
4159 |
-
|
4160 |
-
|
4161 |
-
|
4162 |
-
|
4163 |
-
|
4164 |
-
|
4165 |
-
|
4166 |
-
|
4167 |
-
|
4168 |
-
|
4169 |
-
|
4170 |
-
|
4171 |
-
|
4172 |
-
|
4173 |
-
|
4174 |
-
|
4175 |
-
|
4176 |
-
|
4177 |
-
|
4178 |
-
|
4179 |
-
|
4180 |
-
if (
|
4181 |
-
|
4182 |
-
|
4183 |
-
|
4184 |
-
|
4185 |
-
|
4186 |
-
|
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 |
-
|
4244 |
-
|
4245 |
-
|
4246 |
-
|
4247 |
-
|
4248 |
-
|
4249 |
-
|
4250 |
-
|
4251 |
-
*
|
4252 |
-
*
|
4253 |
-
*
|
4254 |
-
* @
|
4255 |
-
*
|
4256 |
-
* @
|
4257 |
-
*
|
4258 |
-
*
|
4259 |
-
*
|
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 |
-
$output
|
4303 |
-
}
|
4304 |
-
|
4305 |
-
|
4306 |
-
|
4307 |
-
|
4308 |
-
|
4309 |
-
|
4310 |
-
|
4311 |
-
|
4312 |
-
|
4313 |
-
|
4314 |
-
|
4315 |
-
|
4316 |
-
$
|
4317 |
-
|
4318 |
-
|
4319 |
-
|
4320 |
-
|
4321 |
-
|
4322 |
-
|
4323 |
-
|
4324 |
-
|
4325 |
-
|
4326 |
-
|
4327 |
-
|
4328 |
-
|
4329 |
-
|
4330 |
-
|
4331 |
-
|
4332 |
-
|
4333 |
-
|
4334 |
-
|
4335 |
-
|
4336 |
-
|
4337 |
-
|
4338 |
-
|
4339 |
-
|
4340 |
-
|
4341 |
-
|
4342 |
-
|
4343 |
-
$output .= '
|
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 |
-
$this->
|
4473 |
-
|
4474 |
-
|
4475 |
-
|
4476 |
-
|
4477 |
-
|
4478 |
-
|
4479 |
-
|
4480 |
-
|
4481 |
-
|
4482 |
-
|
4483 |
-
if (
|
4484 |
-
$
|
4485 |
-
} else {
|
4486 |
-
$
|
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 |
-
|
4564 |
-
|
4565 |
-
|
4566 |
-
|
4567 |
-
|
4568 |
-
|
4569 |
-
|
4570 |
-
|
4571 |
-
|
4572 |
-
|
4573 |
-
|
4574 |
-
|
4575 |
-
|
4576 |
-
|
4577 |
-
|
4578 |
-
|
4579 |
-
|
4580 |
-
|
4581 |
-
|
4582 |
-
|
4583 |
-
|
4584 |
-
|
4585 |
-
|
4586 |
-
|
4587 |
-
|
4588 |
-
|
4589 |
-
|
4590 |
-
|
4591 |
-
|
4592 |
-
|
4593 |
-
|
4594 |
-
|
4595 |
-
|
4596 |
-
|
4597 |
-
|
4598 |
-
|
4599 |
-
|
4600 |
-
|
4601 |
-
|
4602 |
-
|
4603 |
-
|
4604 |
-
|
4605 |
-
|
4606 |
-
|
4607 |
-
|
4608 |
-
|
4609 |
-
|
4610 |
-
|
4611 |
-
|
4612 |
-
|
4613 |
-
|
4614 |
-
|
4615 |
-
|
4616 |
-
|
4617 |
-
|
4618 |
-
|
4619 |
-
|
4620 |
-
|
4621 |
-
|
4622 |
-
|
4623 |
-
|
4624 |
-
|
4625 |
-
|
4626 |
-
|
4627 |
-
|
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 |
-
if ( $
|
4688 |
-
$
|
4689 |
-
}
|
4690 |
-
|
4691 |
-
|
4692 |
-
|
4693 |
-
if ( $
|
4694 |
-
$
|
4695 |
-
}
|
4696 |
-
if ( $
|
4697 |
-
$
|
4698 |
-
}
|
4699 |
-
if ( $
|
4700 |
-
$
|
4701 |
-
}
|
4702 |
-
if ( $
|
4703 |
-
$
|
4704 |
-
|
4705 |
-
|
4706 |
-
|
4707 |
-
|
4708 |
-
if ( $
|
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 |
-
* @var $
|
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 |
-
$html_atts
|
4892 |
-
|
4893 |
-
|
4894 |
-
|
4895 |
-
|
4896 |
-
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
unset( $directory_search_filters[ $id ] );
|
312 |
+
update_post_meta( $directory_id, '_um_search_filters', $directory_search_filters );
|
313 |
+
|
314 |
+
// display in tagline
|
315 |
+
$directory_reveal_fields = get_post_meta( $directory_id, '_um_reveal_fields', true );
|
316 |
+
$directory_reveal_fields = array_values( array_diff( $directory_reveal_fields, array( $id ) ) );
|
317 |
+
update_post_meta( $directory_id, '_um_reveal_fields', $directory_reveal_fields );
|
318 |
+
|
319 |
+
// extra user information section
|
320 |
+
$directory_tagline_fields = get_post_meta( $directory_id, '_um_tagline_fields', true );
|
321 |
+
$directory_tagline_fields = array_values( array_diff( $directory_tagline_fields, array( $id ) ) );
|
322 |
+
update_post_meta( $directory_id, '_um_tagline_fields', $directory_tagline_fields );
|
323 |
+
|
324 |
+
// Custom fields selected in "Choose field(s) to enable in sorting"
|
325 |
+
$directory_sorting_fields = get_post_meta( $directory_id, '_um_sorting_fields', true );
|
326 |
+
foreach ( $directory_sorting_fields as $key => $sorting_data ) {
|
327 |
+
if ( is_array( $sorting_data ) && array_key_exists( $id, $sorting_data ) ) {
|
328 |
+
unset( $directory_sorting_fields[ $key ] );
|
329 |
+
}
|
330 |
+
}
|
331 |
+
$directory_sorting_fields = array_values( $directory_sorting_fields );
|
332 |
+
update_post_meta( $directory_id, '_um_sorting_fields', $directory_sorting_fields );
|
333 |
+
|
334 |
+
// If "Default sort users by" = "Other (Custom Field)" is selected when delete this custom field and set default sorting
|
335 |
+
$directory_sortby_custom = get_post_meta( $directory_id, '_um_sortby_custom', true );
|
336 |
+
if ( $directory_sortby_custom === $id ) {
|
337 |
+
$directory_sortby = get_post_meta( $directory_id, '_um_sortby', true );
|
338 |
+
if ( 'other' === $directory_sortby ) {
|
339 |
+
update_post_meta( $directory_id, '_um_sortby', 'user_registered_desc' );
|
340 |
+
}
|
341 |
+
update_post_meta( $directory_id, '_um_sortby_custom', '' );
|
342 |
+
update_post_meta( $directory_id, '_um_sortby_custom_label', '' );
|
343 |
+
}
|
344 |
+
}
|
345 |
+
|
346 |
+
}
|
347 |
+
}
|
348 |
+
|
349 |
+
|
350 |
+
/**
|
351 |
+
* Quickly adds a field from custom fields
|
352 |
+
*
|
353 |
+
* @param integer $global_id
|
354 |
+
* @param integer $form_id
|
355 |
+
* @param array $position
|
356 |
+
*/
|
357 |
+
function add_field_from_list( $global_id, $form_id, $position = array() ) {
|
358 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
359 |
+
$field_scope = UM()->builtin()->saved_fields;
|
360 |
+
|
361 |
+
if ( ! isset( $fields[ $global_id ] ) ) {
|
362 |
+
|
363 |
+
$count = 1;
|
364 |
+
if ( ! empty( $fields ) ) {
|
365 |
+
$count = count( $fields ) + 1;
|
366 |
+
}
|
367 |
+
|
368 |
+
$fields[ $global_id ] = $field_scope[ $global_id ];
|
369 |
+
$fields[ $global_id ]['position'] = $count;
|
370 |
+
|
371 |
+
// set position
|
372 |
+
if ( $position ) {
|
373 |
+
foreach ( $position as $key => $val) {
|
374 |
+
$fields[ $global_id ][ $key ] = $val;
|
375 |
+
}
|
376 |
+
}
|
377 |
+
|
378 |
+
// add field to form
|
379 |
+
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
380 |
+
|
381 |
+
}
|
382 |
+
}
|
383 |
+
|
384 |
+
|
385 |
+
/**
|
386 |
+
* Quickly adds a field from pre-defined fields
|
387 |
+
*
|
388 |
+
* @param integer $global_id
|
389 |
+
* @param integer $form_id
|
390 |
+
* @param array $position
|
391 |
+
*/
|
392 |
+
function add_field_from_predefined( $global_id, $form_id, $position = array() ) {
|
393 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
394 |
+
$field_scope = UM()->builtin()->predefined_fields;
|
395 |
+
|
396 |
+
if ( ! isset( $fields[ $global_id ] ) ) {
|
397 |
+
|
398 |
+
$count = 1;
|
399 |
+
if ( ! empty( $fields ) ) {
|
400 |
+
$count = count( $fields ) + 1;
|
401 |
+
}
|
402 |
+
|
403 |
+
$fields[ $global_id ] = $field_scope[ $global_id ];
|
404 |
+
$fields[ $global_id ]['position'] = $count;
|
405 |
+
|
406 |
+
// set position
|
407 |
+
if ( $position ) {
|
408 |
+
foreach ( $position as $key => $val ) {
|
409 |
+
$fields[ $global_id ][ $key ] = $val;
|
410 |
+
}
|
411 |
+
}
|
412 |
+
|
413 |
+
// add field to form
|
414 |
+
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
415 |
+
}
|
416 |
+
}
|
417 |
+
|
418 |
+
|
419 |
+
/**
|
420 |
+
* Duplicates a frield by meta key
|
421 |
+
*
|
422 |
+
* @param integer $id
|
423 |
+
* @param integer $form_id
|
424 |
+
*/
|
425 |
+
function duplicate_field( $id, $form_id ) {
|
426 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
|
427 |
+
$all_fields = UM()->builtin()->saved_fields;
|
428 |
+
|
429 |
+
$inc = count( $fields ) + 1;
|
430 |
+
|
431 |
+
$duplicate = $fields[ $id ];
|
432 |
+
|
433 |
+
$new_metakey = $id . "_" . $inc;
|
434 |
+
$new_title = $fields[ $id ]['title'] . " #" . $inc;
|
435 |
+
$new_position = $inc;
|
436 |
+
|
437 |
+
$duplicate['title'] = $new_title;
|
438 |
+
$duplicate['metakey'] = $new_metakey;
|
439 |
+
$duplicate['position'] = $new_position;
|
440 |
+
|
441 |
+
$fields[ $new_metakey ] = $duplicate;
|
442 |
+
$all_fields[ $new_metakey ] = $duplicate;
|
443 |
+
|
444 |
+
// not global attributes
|
445 |
+
unset( $all_fields[ $new_metakey ]['in_row'] );
|
446 |
+
unset( $all_fields[ $new_metakey ]['in_sub_row'] );
|
447 |
+
unset( $all_fields[ $new_metakey ]['in_column'] );
|
448 |
+
unset( $all_fields[ $new_metakey ]['in_group'] );
|
449 |
+
unset( $all_fields[ $new_metakey ]['position'] );
|
450 |
+
|
451 |
+
|
452 |
+
do_action( 'um_add_new_field', $new_metakey, $duplicate );
|
453 |
+
|
454 |
+
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
|
455 |
+
update_option( 'um_fields', $all_fields );
|
456 |
+
}
|
457 |
+
|
458 |
+
|
459 |
+
/**
|
460 |
+
* Print field error
|
461 |
+
*
|
462 |
+
* @param string $text
|
463 |
+
* @param bool $force_show
|
464 |
+
*
|
465 |
+
* @return string
|
466 |
+
*/
|
467 |
+
function field_error( $text, $force_show = false ) {
|
468 |
+
|
469 |
+
if ( empty( $text ) ) {
|
470 |
+
return '';
|
471 |
+
}
|
472 |
+
|
473 |
+
if ( $force_show ) {
|
474 |
+
$output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
475 |
+
return $output;
|
476 |
+
}
|
477 |
+
|
478 |
+
|
479 |
+
if ( isset( $this->set_id ) && UM()->form()->processing == $this->set_id ) {
|
480 |
+
$output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
481 |
+
} else {
|
482 |
+
$output = '';
|
483 |
+
}
|
484 |
+
|
485 |
+
if ( ! UM()->form()->processing ) {
|
486 |
+
$output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
487 |
+
}
|
488 |
+
|
489 |
+
return $output;
|
490 |
+
}
|
491 |
+
|
492 |
+
|
493 |
+
/**
|
494 |
+
* Print field notice
|
495 |
+
*
|
496 |
+
* @param string $text
|
497 |
+
* @param bool $force_show
|
498 |
+
*
|
499 |
+
* @return string
|
500 |
+
*/
|
501 |
+
function field_notice( $text, $force_show = false ) {
|
502 |
+
|
503 |
+
if ( empty( $text ) ) {
|
504 |
+
return '';
|
505 |
+
}
|
506 |
+
|
507 |
+
if ( $force_show ) {
|
508 |
+
$output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
509 |
+
return $output;
|
510 |
+
}
|
511 |
+
|
512 |
+
|
513 |
+
if ( isset( $this->set_id ) && UM()->form()->processing == $this->set_id ) {
|
514 |
+
$output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
515 |
+
} else {
|
516 |
+
$output = '';
|
517 |
+
}
|
518 |
+
|
519 |
+
if ( ! UM()->form()->processing ) {
|
520 |
+
$output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . esc_attr( $text ) . '</div>';
|
521 |
+
}
|
522 |
+
|
523 |
+
return $output;
|
524 |
+
}
|
525 |
+
|
526 |
+
|
527 |
+
/**
|
528 |
+
* Checks if field has a server-side error
|
529 |
+
*
|
530 |
+
* @param string $key
|
531 |
+
*
|
532 |
+
* @return boolean
|
533 |
+
*/
|
534 |
+
function is_error( $key ) {
|
535 |
+
return UM()->form()->has_error( $key );
|
536 |
+
}
|
537 |
+
|
538 |
+
/**
|
539 |
+
* Checks if field has a notice
|
540 |
+
*
|
541 |
+
* @param string $key
|
542 |
+
*
|
543 |
+
* @return boolean
|
544 |
+
*/
|
545 |
+
function is_notice( $key ) {
|
546 |
+
return UM()->form()->has_notice( $key );
|
547 |
+
}
|
548 |
+
|
549 |
+
|
550 |
+
/**
|
551 |
+
* Returns field error
|
552 |
+
*
|
553 |
+
* @param string $key
|
554 |
+
*
|
555 |
+
* @return string
|
556 |
+
*/
|
557 |
+
function show_error( $key ) {
|
558 |
+
return UM()->form()->errors[ $key ];
|
559 |
+
}
|
560 |
+
|
561 |
+
/**
|
562 |
+
* Returns field notices
|
563 |
+
*
|
564 |
+
* @param string $key
|
565 |
+
*
|
566 |
+
* @return string
|
567 |
+
*/
|
568 |
+
function show_notice( $key ) {
|
569 |
+
return UM()->form()->notices[ $key ];
|
570 |
+
}
|
571 |
+
|
572 |
+
|
573 |
+
/**
|
574 |
+
* Display field label
|
575 |
+
*
|
576 |
+
* @param string $label
|
577 |
+
* @param string $key
|
578 |
+
* @param array $data
|
579 |
+
*
|
580 |
+
* @return string
|
581 |
+
*/
|
582 |
+
function field_label( $label, $key, $data ) {
|
583 |
+
$output = null;
|
584 |
+
$output .= '<div class="um-field-label">';
|
585 |
+
|
586 |
+
if ( isset( $data['icon'] ) && $data['icon'] != '' && isset( $this->field_icons ) && $this->field_icons != 'off' && ( $this->field_icons == 'label' || $this->viewing == true ) ) {
|
587 |
+
$output .= '<div class="um-field-label-icon"><i class="' . esc_attr( $data['icon'] ) . '" aria-label="' . esc_attr( $label ) . '"></i></div>';
|
588 |
+
}
|
589 |
+
|
590 |
+
if ( $this->viewing == true ) {
|
591 |
+
/**
|
592 |
+
* UM hook
|
593 |
+
*
|
594 |
+
* @type filter
|
595 |
+
* @title um_view_label_{$key}
|
596 |
+
* @description Change field label on view by field $key
|
597 |
+
* @input_vars
|
598 |
+
* [{"var":"$label","type":"string","desc":"Field Label"}]
|
599 |
+
* @change_log
|
600 |
+
* ["Since: 2.0"]
|
601 |
+
* @usage add_filter( 'um_view_label_{$key}', 'function_name', 10, 1 );
|
602 |
+
* @example
|
603 |
+
* <?php
|
604 |
+
* add_filter( 'um_view_label_{$key}', 'my_view_label', 10, 1 );
|
605 |
+
* function my_view_label( $label ) {
|
606 |
+
* // your code here
|
607 |
+
* return $label;
|
608 |
+
* }
|
609 |
+
* ?>
|
610 |
+
*/
|
611 |
+
$label = apply_filters( "um_view_label_{$key}", $label );
|
612 |
+
} else {
|
613 |
+
/**
|
614 |
+
* UM hook
|
615 |
+
*
|
616 |
+
* @type filter
|
617 |
+
* @title um_edit_label_{$key}
|
618 |
+
* @description Change field label on edit by field $key
|
619 |
+
* @input_vars
|
620 |
+
* [{"var":"$label","type":"string","desc":"Field Label"}]
|
621 |
+
* @change_log
|
622 |
+
* ["Since: 2.0"]
|
623 |
+
* @usage add_filter( 'um_edit_label_{$key}', 'function_name', 10, 1 );
|
624 |
+
* @example
|
625 |
+
* <?php
|
626 |
+
* add_filter( 'um_edit_label_{$key}', 'my_edit_label', 10, 1 );
|
627 |
+
* function my_edit_label( $label ) {
|
628 |
+
* // your code here
|
629 |
+
* return $label;
|
630 |
+
* }
|
631 |
+
* ?>
|
632 |
+
*/
|
633 |
+
$label = apply_filters( "um_edit_label_{$key}", $label );
|
634 |
+
/**
|
635 |
+
* UM hook
|
636 |
+
*
|
637 |
+
* @type filter
|
638 |
+
* @title um_edit_label_all_fields
|
639 |
+
* @description Change field label on view by field $key
|
640 |
+
* @input_vars
|
641 |
+
* [{"var":"$label","type":"string","desc":"Field Label"},
|
642 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
643 |
+
* @change_log
|
644 |
+
* ["Since: 2.0"]
|
645 |
+
* @usage add_filter( 'um_edit_label_all_fields', 'function_name', 10, 2 );
|
646 |
+
* @example
|
647 |
+
* <?php
|
648 |
+
* add_filter( 'um_edit_label_all_fields', 'my_edit_label_all_fields', 10, 2 );
|
649 |
+
* function my_edit_label_all_fields( $label, $data ) {
|
650 |
+
* // your code here
|
651 |
+
* return $label;
|
652 |
+
* }
|
653 |
+
* ?>
|
654 |
+
*/
|
655 |
+
$label = apply_filters( 'um_edit_label_all_fields', $label, $data );
|
656 |
+
}
|
657 |
+
|
658 |
+
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
659 |
+
$for_attr = '';
|
660 |
+
if ( ! in_array( $data['type'], $fields_without_metakey ) ) {
|
661 |
+
$for_attr = ' for="' . esc_attr( $key . UM()->form()->form_suffix ) . '"';
|
662 |
+
}
|
663 |
+
|
664 |
+
$output .= '<label' . $for_attr . '>' . __( $label, 'ultimate-member' ) . '</label>';
|
665 |
+
|
666 |
+
if ( ! empty( $data['help'] ) && $this->viewing == false && ! strstr( $key, 'confirm_user_pass' ) ) {
|
667 |
+
|
668 |
+
if ( ! UM()->mobile()->isMobile() ) {
|
669 |
+
if ( ! isset( $this->disable_tooltips ) ) {
|
670 |
+
$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>';
|
671 |
+
}
|
672 |
+
}
|
673 |
+
|
674 |
+
if ( UM()->mobile()->isMobile() || isset( $this->disable_tooltips ) ) {
|
675 |
+
$output .= '<span class="um-tip-text">' . __( $data['help'], 'ultimate-member' ) . '</span>';
|
676 |
+
}
|
677 |
+
|
678 |
+
}
|
679 |
+
|
680 |
+
$output .= '<div class="um-clear"></div></div>';
|
681 |
+
|
682 |
+
return $output;
|
683 |
+
}
|
684 |
+
|
685 |
+
|
686 |
+
/**
|
687 |
+
* Output field classes
|
688 |
+
*
|
689 |
+
* @param string $key
|
690 |
+
* @param array $data
|
691 |
+
* @param string $add
|
692 |
+
*
|
693 |
+
* @return string
|
694 |
+
*/
|
695 |
+
function get_class( $key, $data, $add = null ) {
|
696 |
+
$classes = null;
|
697 |
+
|
698 |
+
$classes .= 'um-form-field ';
|
699 |
+
|
700 |
+
if ( $this->is_error( $key ) ) {
|
701 |
+
$classes .= 'um-error ';
|
702 |
+
} else {
|
703 |
+
$classes .= 'valid ';
|
704 |
+
}
|
705 |
+
|
706 |
+
if ( ! isset( $data['required'] ) ) {
|
707 |
+
$classes .= 'not-required ';
|
708 |
+
}
|
709 |
+
|
710 |
+
if ( $data['type'] == 'date' ) {
|
711 |
+
$classes .= 'um-datepicker ';
|
712 |
+
}
|
713 |
+
|
714 |
+
if ( $data['type'] == 'time' ) {
|
715 |
+
$classes .= 'um-timepicker ';
|
716 |
+
}
|
717 |
+
|
718 |
+
if ( ! empty( $data['icon'] ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
719 |
+
$classes .= 'um-iconed ';
|
720 |
+
}
|
721 |
+
|
722 |
+
if ( $add ) {
|
723 |
+
$classes .= $add . ' ';
|
724 |
+
}
|
725 |
+
|
726 |
+
/**
|
727 |
+
* UM hook
|
728 |
+
*
|
729 |
+
* @type filter
|
730 |
+
* @title um_extend_field_classes
|
731 |
+
* @description Change field classes
|
732 |
+
* @input_vars
|
733 |
+
* [{"var":"$classes","type":"string","desc":"Field Classes"},
|
734 |
+
* {"var":"$key","type":"string","desc":"Field Key"},
|
735 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
736 |
+
* @change_log
|
737 |
+
* ["Since: 2.0"]
|
738 |
+
* @usage add_filter( 'um_extend_field_classes', 'function_name', 10, 3 );
|
739 |
+
* @example
|
740 |
+
* <?php
|
741 |
+
* add_filter( 'um_extend_field_classes', 'my_extend_field_classes', 10, 3 );
|
742 |
+
* function my_extend_field_classes( $classes, $key, $data ) {
|
743 |
+
* // your code here
|
744 |
+
* return $classes;
|
745 |
+
* }
|
746 |
+
* ?>
|
747 |
+
*/
|
748 |
+
$classes = apply_filters( 'um_extend_field_classes', $classes, $key, $data );
|
749 |
+
|
750 |
+
return $classes;
|
751 |
+
}
|
752 |
+
|
753 |
+
|
754 |
+
/**
|
755 |
+
* Gets field value
|
756 |
+
*
|
757 |
+
* @param string $key
|
758 |
+
* @param boolean $default
|
759 |
+
* @param array $data
|
760 |
+
*
|
761 |
+
* @return mixed
|
762 |
+
*/
|
763 |
+
function field_value( $key, $default = false, $data = null ) {
|
764 |
+
// preview in backend
|
765 |
+
if ( isset( UM()->user()->preview ) && UM()->user()->preview ) {
|
766 |
+
if ( $this->set_mode == 'login' || $this->set_mode == 'register' ) {
|
767 |
+
return '';
|
768 |
+
} else {
|
769 |
+
$val = um_user( $key );
|
770 |
+
if ( ! empty( $val ) ) {
|
771 |
+
return $val;
|
772 |
+
} else {
|
773 |
+
return '';
|
774 |
+
}
|
775 |
+
}
|
776 |
+
}
|
777 |
+
|
778 |
+
if ( isset( $_SESSION ) && isset( $_SESSION['um_social_profile'][ $key ] ) && isset( $this->set_mode ) && $this->set_mode == 'register' ) {
|
779 |
+
return $_SESSION['um_social_profile'][ $key ];
|
780 |
+
}
|
781 |
+
|
782 |
+
$type = ( isset( $data['type'] ) ) ? $data['type'] : '';
|
783 |
+
|
784 |
+
// normal state
|
785 |
+
if ( isset( UM()->form()->post_form[ $key ] ) ) {
|
786 |
+
//show empty value for password fields
|
787 |
+
if ( strstr( $key, 'user_pass' ) && $this->set_mode != 'password' ) {
|
788 |
+
return '';
|
789 |
+
}
|
790 |
+
|
791 |
+
if ( 'profile' === $this->set_mode ) {
|
792 |
+
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 ) ) {
|
793 |
+
return '';
|
794 |
+
}
|
795 |
+
}
|
796 |
+
|
797 |
+
return stripslashes_deep( UM()->form()->post_form[ $key ] );
|
798 |
+
|
799 |
+
} elseif ( um_user( $key ) && $this->editing == true ) {
|
800 |
+
|
801 |
+
//show empty value for password fields
|
802 |
+
if ( strstr( $key, 'user_pass' ) || $type == 'password' ) {
|
803 |
+
return '';
|
804 |
+
}
|
805 |
+
|
806 |
+
$value = um_user( $key );
|
807 |
+
/**
|
808 |
+
* UM hook
|
809 |
+
*
|
810 |
+
* @type filter
|
811 |
+
* @title um_edit_{$key}_field_value
|
812 |
+
* @description Change field value on edit by field $key
|
813 |
+
* @input_vars
|
814 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
815 |
+
* {"var":"$key","type":"string","desc":"Field Key"}]
|
816 |
+
* @change_log
|
817 |
+
* ["Since: 2.0"]
|
818 |
+
* @usage add_filter( 'um_edit_{$key}_field_value', 'function_name', 10, 2 );
|
819 |
+
* @example
|
820 |
+
* <?php
|
821 |
+
* add_filter( 'um_edit_{$key}_field_value', 'my_edit_field_value', 10, 2 );
|
822 |
+
* function my_edit_field_value( $value, $key ) {
|
823 |
+
* // your code here
|
824 |
+
* return $value;
|
825 |
+
* }
|
826 |
+
* ?>
|
827 |
+
*/
|
828 |
+
$value = apply_filters( "um_edit_{$key}_field_value", $value, $key );
|
829 |
+
/**
|
830 |
+
* UM hook
|
831 |
+
*
|
832 |
+
* @type filter
|
833 |
+
* @title um_edit_{$type}_field_value
|
834 |
+
* @description Change field value on edit by field $type
|
835 |
+
* @input_vars
|
836 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
837 |
+
* {"var":"$key","type":"string","desc":"Field Key"}]
|
838 |
+
* @change_log
|
839 |
+
* ["Since: 2.0"]
|
840 |
+
* @usage add_filter( 'um_edit_{$type}_field_value', 'function_name', 10, 2 );
|
841 |
+
* @example
|
842 |
+
* <?php
|
843 |
+
* add_filter( 'um_edit_{$type}_field_value', 'my_edit_field_value', 10, 2 );
|
844 |
+
* function my_edit_field_value( $value, $key ) {
|
845 |
+
* // your code here
|
846 |
+
* return $value;
|
847 |
+
* }
|
848 |
+
* ?>
|
849 |
+
*/
|
850 |
+
$value = apply_filters( "um_edit_{$type}_field_value", $value, $key );
|
851 |
+
|
852 |
+
} elseif ( ( um_user( $key ) || isset( $data['show_anyway'] ) ) && $this->viewing == true ) {
|
853 |
+
|
854 |
+
return um_filtered_value( $key, $data );
|
855 |
+
|
856 |
+
} elseif ( isset( UM()->user()->profile[ $key ] ) ) {
|
857 |
+
|
858 |
+
$value = UM()->user()->profile[ $key ];
|
859 |
+
/**
|
860 |
+
* UM hook
|
861 |
+
*
|
862 |
+
* @type filter
|
863 |
+
* @title um_edit_{$key}_field_value
|
864 |
+
* @description Change field value on edit by field $key
|
865 |
+
* @input_vars
|
866 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
867 |
+
* {"var":"$key","type":"string","desc":"Field Key"}]
|
868 |
+
* @change_log
|
869 |
+
* ["Since: 2.0"]
|
870 |
+
* @usage add_filter( 'um_edit_{$key}_field_value', 'function_name', 10, 2 );
|
871 |
+
* @example
|
872 |
+
* <?php
|
873 |
+
* add_filter( 'um_edit_{$key}_field_value', 'my_edit_field_value', 10, 2 );
|
874 |
+
* function my_edit_field_value( $value, $key ) {
|
875 |
+
* // your code here
|
876 |
+
* return $value;
|
877 |
+
* }
|
878 |
+
* ?>
|
879 |
+
*/
|
880 |
+
$value = apply_filters( "um_edit_{$key}_field_value", $value, $key );
|
881 |
+
$value = maybe_unserialize( $value );
|
882 |
+
|
883 |
+
} elseif ( $default ) {
|
884 |
+
|
885 |
+
/**
|
886 |
+
* UM hook
|
887 |
+
*
|
888 |
+
* @type filter
|
889 |
+
* @title um_field_default_value
|
890 |
+
* @description Change field default value
|
891 |
+
* @input_vars
|
892 |
+
* [{"var":"$default","type":"string","desc":"Field Default Value"},
|
893 |
+
* {"var":"$data","type":"array","desc":"Field Data"},
|
894 |
+
* {"var":"$type","type":"string","desc":"Field Type"}]
|
895 |
+
* @change_log
|
896 |
+
* ["Since: 2.0"]
|
897 |
+
* @usage add_filter( 'um_field_default_value', 'function_name', 10, 2 );
|
898 |
+
* @example
|
899 |
+
* <?php
|
900 |
+
* add_filter( 'um_field_default_value', 'my_field_default_value', 10, 2 );
|
901 |
+
* function my_field_default_value( $default, $data, $type ) {
|
902 |
+
* // your code here
|
903 |
+
* return $default;
|
904 |
+
* }
|
905 |
+
* ?>
|
906 |
+
*/
|
907 |
+
$default = apply_filters( 'um_field_default_value', $default, $data, $type );
|
908 |
+
/**
|
909 |
+
* UM hook
|
910 |
+
*
|
911 |
+
* @type filter
|
912 |
+
* @title um_field_{$key}_default_value
|
913 |
+
* @description Change field default value by $key
|
914 |
+
* @input_vars
|
915 |
+
* [{"var":"$default","type":"string","desc":"Field Default Value"},
|
916 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
917 |
+
* @change_log
|
918 |
+
* ["Since: 2.0"]
|
919 |
+
* @usage add_filter( 'um_field_{$key}_default_value', 'function_name', 10, 2 );
|
920 |
+
* @example
|
921 |
+
* <?php
|
922 |
+
* add_filter( 'um_field_{$key}_default_value', 'my_field_default_value', 10, 2 );
|
923 |
+
* function my_field_default_value( $default, $data ) {
|
924 |
+
* // your code here
|
925 |
+
* return $default;
|
926 |
+
* }
|
927 |
+
* ?>
|
928 |
+
*/
|
929 |
+
$default = apply_filters( "um_field_{$key}_default_value", $default, $data );
|
930 |
+
/**
|
931 |
+
* UM hook
|
932 |
+
*
|
933 |
+
* @type filter
|
934 |
+
* @title um_field_{$type}_default_value
|
935 |
+
* @description Change field default value by $type
|
936 |
+
* @input_vars
|
937 |
+
* [{"var":"$default","type":"string","desc":"Field Default Value"},
|
938 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
939 |
+
* @change_log
|
940 |
+
* ["Since: 2.0"]
|
941 |
+
* @usage add_filter( 'um_field_{$type}_default_value', 'function_name', 10, 2 );
|
942 |
+
* @example
|
943 |
+
* <?php
|
944 |
+
* add_filter( 'um_field_{$type}_default_value', 'my_field_default_value', 10, 2 );
|
945 |
+
* function my_field_default_value( $default, $data ) {
|
946 |
+
* // your code here
|
947 |
+
* return $default;
|
948 |
+
* }
|
949 |
+
* ?>
|
950 |
+
*/
|
951 |
+
$default = apply_filters( "um_field_{$type}_default_value", $default, $data );
|
952 |
+
|
953 |
+
}
|
954 |
+
|
955 |
+
// Default Value for Registration Form and Profile Form editing
|
956 |
+
if ( ! isset( $value ) && ( $this->set_mode == 'register' || $this->editing == true ) ) {
|
957 |
+
|
958 |
+
/**
|
959 |
+
* UM hook
|
960 |
+
*
|
961 |
+
* @type filter
|
962 |
+
* @title um_edit_{$key}_field_value
|
963 |
+
* @description Change field value on edit by field $key
|
964 |
+
* @input_vars
|
965 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
966 |
+
* {"var":"$key","type":"string","desc":"Field Key"}]
|
967 |
+
* @change_log
|
968 |
+
* ["Since: 2.0"]
|
969 |
+
* @usage add_filter( 'um_edit_{$key}_field_value', 'function_name', 10, 2 );
|
970 |
+
* @example
|
971 |
+
* <?php
|
972 |
+
* add_filter( 'um_edit_{$key}_field_value', 'my_edit_field_value', 10, 2 );
|
973 |
+
* function my_edit_field_value( $value, $key ) {
|
974 |
+
* // your code here
|
975 |
+
* return $value;
|
976 |
+
* }
|
977 |
+
* ?>
|
978 |
+
*/
|
979 |
+
$value = apply_filters( "um_edit_{$key}_field_value", $default, $key );
|
980 |
+
|
981 |
+
} elseif ( isset( $value ) && is_array( $value ) && ! count( $value ) ) {
|
982 |
+
$value = '';
|
983 |
+
} elseif ( ! isset( $value ) ) {
|
984 |
+
$value = '';
|
985 |
+
}
|
986 |
+
|
987 |
+
|
988 |
+
/**
|
989 |
+
* UM hook
|
990 |
+
*
|
991 |
+
* @type filter
|
992 |
+
* @title um_field_value
|
993 |
+
* @description Change field value
|
994 |
+
* @input_vars
|
995 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
996 |
+
* {"var":"$key","type":"string","desc":"Field Key"},,
|
997 |
+
* {"var":"$type","type":"string","desc":"Field Type"}
|
998 |
+
* {"var":"$default","type":"string","desc":"Field Default Value"},
|
999 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
1000 |
+
* @usage add_filter( 'um_field_value', 'function_name', 10, 5 );
|
1001 |
+
*/
|
1002 |
+
return apply_filters( 'um_field_value', $value, $default, $key, $type, $data );
|
1003 |
+
}
|
1004 |
+
|
1005 |
+
|
1006 |
+
/**
|
1007 |
+
* Checks if an option is selected
|
1008 |
+
*
|
1009 |
+
* is used by Select, Multiselect and Checkbox fields
|
1010 |
+
*
|
1011 |
+
* @param string $key
|
1012 |
+
* @param string $value
|
1013 |
+
* @param array $data
|
1014 |
+
*
|
1015 |
+
* @return boolean
|
1016 |
+
*/
|
1017 |
+
function is_selected( $key, $value, $data ) {
|
1018 |
+
global $wpdb;
|
1019 |
+
|
1020 |
+
/**
|
1021 |
+
* UM hook
|
1022 |
+
*
|
1023 |
+
* @type filter
|
1024 |
+
* @title um_is_selected_filter_key
|
1025 |
+
* @description Change is selected filter key
|
1026 |
+
* @input_vars
|
1027 |
+
* [{"var":"$key","type":"string","desc":"Selected filter key"}]
|
1028 |
+
* @change_log
|
1029 |
+
* ["Since: 2.0"]
|
1030 |
+
* @usage add_filter( 'um_is_selected_filter_key', 'function_name', 10, 1 );
|
1031 |
+
* @example
|
1032 |
+
* <?php
|
1033 |
+
* add_filter( 'um_is_selected_filter_key', 'my_selected_filter_key', 10, 1 );
|
1034 |
+
* function my_selected_filter_key( $key ) {
|
1035 |
+
* // your code here
|
1036 |
+
* return $key;
|
1037 |
+
* }
|
1038 |
+
* ?>
|
1039 |
+
*/
|
1040 |
+
$key = apply_filters( 'um_is_selected_filter_key', $key );
|
1041 |
+
|
1042 |
+
if ( isset( UM()->form()->post_form[ $key ] ) ) {
|
1043 |
+
|
1044 |
+
if ( is_array( UM()->form()->post_form[ $key ] ) ) {
|
1045 |
+
|
1046 |
+
if ( in_array( $value, UM()->form()->post_form[ $key ] ) ) {
|
1047 |
+
return true;
|
1048 |
+
}
|
1049 |
+
|
1050 |
+
$stripslashed = array_map( 'stripslashes', UM()->form()->post_form[ $key ] );
|
1051 |
+
if ( in_array( $value, $stripslashed ) ) {
|
1052 |
+
return true;
|
1053 |
+
}
|
1054 |
+
|
1055 |
+
if ( in_array( html_entity_decode( $value ), UM()->form()->post_form[ $key ] ) ) {
|
1056 |
+
return true;
|
1057 |
+
}
|
1058 |
+
} else {
|
1059 |
+
|
1060 |
+
if ( $value == UM()->form()->post_form[ $key ] ) {
|
1061 |
+
return true;
|
1062 |
+
}
|
1063 |
+
|
1064 |
+
}
|
1065 |
+
|
1066 |
+
} else {
|
1067 |
+
|
1068 |
+
$field_value = um_user( $key );
|
1069 |
+
if ( ! $field_value ) {
|
1070 |
+
$field_value = 0;
|
1071 |
+
}
|
1072 |
+
|
1073 |
+
if ( $field_value == 0 && $value == '0' ) {
|
1074 |
+
$value = (int) $value;
|
1075 |
+
}
|
1076 |
+
|
1077 |
+
if ( strstr( $key, 'role_' ) || $key == 'role' ) {
|
1078 |
+
$field_value = strtolower( UM()->roles()->get_editable_priority_user_role( um_user( 'ID' ) ) );
|
1079 |
+
|
1080 |
+
$role_keys = get_option( 'um_roles', array() );
|
1081 |
+
|
1082 |
+
if ( ! empty( $role_keys ) ) {
|
1083 |
+
if ( in_array( $field_value, $role_keys ) ) {
|
1084 |
+
$field_value = 'um_' . $field_value;
|
1085 |
+
}
|
1086 |
+
}
|
1087 |
+
}
|
1088 |
+
|
1089 |
+
|
1090 |
+
/**
|
1091 |
+
* UM hook
|
1092 |
+
*
|
1093 |
+
* @type filter
|
1094 |
+
* @title um_is_selected_filter_value
|
1095 |
+
* @description Change is selected filter value
|
1096 |
+
* @input_vars
|
1097 |
+
* [{"var":"$value","type":"string","desc":"Selected filter value"},
|
1098 |
+
* {"var":"$key","type":"string","desc":"Selected filter key"},
|
1099 |
+
* {"var":"$value","type":"string","desc":"Selected filter value"}]
|
1100 |
+
* @change_log
|
1101 |
+
* ["Since: 2.0"]
|
1102 |
+
* @usage add_filter( 'um_is_selected_filter_value', 'function_name', 10, 2 );
|
1103 |
+
* @example
|
1104 |
+
* <?php
|
1105 |
+
* add_filter( 'um_is_selected_filter_value', 'my_selected_filter_value', 10, 2 );
|
1106 |
+
* function my_selected_filter_value( $value, $key ) {
|
1107 |
+
* // your code here
|
1108 |
+
* return $field_value;
|
1109 |
+
* }
|
1110 |
+
* ?>
|
1111 |
+
*/
|
1112 |
+
$field_value = apply_filters( 'um_is_selected_filter_value', $field_value, $key, $value );
|
1113 |
+
|
1114 |
+
/**
|
1115 |
+
* UM hook
|
1116 |
+
*
|
1117 |
+
* @type filter
|
1118 |
+
* @title um_is_selected_filter_data
|
1119 |
+
* @description Change is selected filter data
|
1120 |
+
* @input_vars
|
1121 |
+
* [{"var":"$data","type":"array","desc":"Selected filter value"},
|
1122 |
+
* {"var":"$key","type":"string","desc":"Selected filter key"},
|
1123 |
+
* {"var":"$value","type":"string","desc":"Selected filter value"}]
|
1124 |
+
* @change_log
|
1125 |
+
* ["Since: 2.0"]
|
1126 |
+
* @usage add_filter( 'um_is_selected_filter_data', 'function_name', 10, 3 );
|
1127 |
+
* @example
|
1128 |
+
* <?php
|
1129 |
+
* add_filter( 'um_is_selected_filter_data', 'my_selected_filter_data', 10, 3 );
|
1130 |
+
* function my_selected_filter_data( $data, $key, $value ) {
|
1131 |
+
* // your code here
|
1132 |
+
* return $data;
|
1133 |
+
* }
|
1134 |
+
* ?>
|
1135 |
+
*/
|
1136 |
+
$data = apply_filters( 'um_is_selected_filter_data', $data, $key, $field_value );
|
1137 |
+
|
1138 |
+
if ( ! $this->editing || 'custom' == $this->set_mode ) {
|
1139 |
+
// show default on register screen if there is default
|
1140 |
+
if ( isset( $data['default'] ) ) {
|
1141 |
+
|
1142 |
+
if ( ! is_array( $data['default'] ) && $data['default'] === $value ) {
|
1143 |
+
return true;
|
1144 |
+
}
|
1145 |
+
|
1146 |
+
if ( is_array( $data['default'] ) && in_array( $value, $data['default'] ) ) {
|
1147 |
+
return true;
|
1148 |
+
}
|
1149 |
+
|
1150 |
+
if ( is_array( $data['default'] ) && array_intersect( $data['options'], $data['default'] ) ) {
|
1151 |
+
return true;
|
1152 |
+
}
|
1153 |
+
|
1154 |
+
// default value with comma
|
1155 |
+
if ( is_string( $data['default'] ) && strstr( $data['default'], ',' ) ) {
|
1156 |
+
$choices = array_map( 'trim', explode( ',', $data['default'] ) );
|
1157 |
+
if ( in_array( $value, $choices ) ) {
|
1158 |
+
return true;
|
1159 |
+
}
|
1160 |
+
}
|
1161 |
+
|
1162 |
+
}
|
1163 |
+
} else {
|
1164 |
+
|
1165 |
+
if ( $field_value && is_array( $field_value ) && ( in_array( $value, $field_value ) || in_array( html_entity_decode( $value ), $field_value ) ) ) {
|
1166 |
+
return true;
|
1167 |
+
}
|
1168 |
+
|
1169 |
+
if ( $field_value == 0 && ! is_array( $field_value ) && $field_value === $value ) {
|
1170 |
+
return true;
|
1171 |
+
}
|
1172 |
+
|
1173 |
+
if ( $field_value && ! is_array( $field_value ) && $field_value == $value ) {
|
1174 |
+
return true;
|
1175 |
+
}
|
1176 |
+
|
1177 |
+
if ( $field_value && ! is_array( $field_value ) && html_entity_decode( $field_value ) == html_entity_decode( $value ) ) {
|
1178 |
+
return true;
|
1179 |
+
}
|
1180 |
+
|
1181 |
+
// show default on edit screen if there isn't meta row in usermeta table
|
1182 |
+
$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 ) );
|
1183 |
+
if ( ! isset( $direct_db_value ) && isset( $data['default'] ) ) {
|
1184 |
+
if ( ! is_array( $data['default'] ) && strstr( $data['default'], ', ' ) ) {
|
1185 |
+
$data['default'] = explode( ', ', $data['default'] );
|
1186 |
+
}
|
1187 |
+
|
1188 |
+
if ( ! is_array( $data['default'] ) && $data['default'] === $value ) {
|
1189 |
+
return true;
|
1190 |
+
}
|
1191 |
+
|
1192 |
+
if ( is_array( $data['default'] ) && in_array( $value, $data['default'] ) ) {
|
1193 |
+
return true;
|
1194 |
+
}
|
1195 |
+
}
|
1196 |
+
}
|
1197 |
+
|
1198 |
+
}
|
1199 |
+
|
1200 |
+
return false;
|
1201 |
+
}
|
1202 |
+
|
1203 |
+
|
1204 |
+
/**
|
1205 |
+
* Checks if a radio button is selected
|
1206 |
+
*
|
1207 |
+
* @param string $key
|
1208 |
+
* @param string $value
|
1209 |
+
* @param array $data
|
1210 |
+
*
|
1211 |
+
* @return boolean
|
1212 |
+
*/
|
1213 |
+
function is_radio_checked( $key, $value, $data ) {
|
1214 |
+
global $wpdb;
|
1215 |
+
|
1216 |
+
if ( isset( UM()->form()->post_form[ $key ] ) ) {
|
1217 |
+
if ( is_array( UM()->form()->post_form[ $key ] ) && in_array( $value, UM()->form()->post_form[ $key ] ) ) {
|
1218 |
+
return true;
|
1219 |
+
} elseif ( $value == UM()->form()->post_form[ $key ] ) {
|
1220 |
+
return true;
|
1221 |
+
}
|
1222 |
+
} else {
|
1223 |
+
|
1224 |
+
if ( $this->editing && 'custom' !== $this->set_mode ) {
|
1225 |
+
if ( um_user( $key ) ) {
|
1226 |
+
|
1227 |
+
$um_user_value = um_user( $key );
|
1228 |
+
|
1229 |
+
if ( strstr( $key, 'role_' ) || $key == 'role' ) {
|
1230 |
+
$um_user_value = strtolower( UM()->roles()->get_editable_priority_user_role( um_user( 'ID' ) ) );
|
1231 |
+
|
1232 |
+
$role_keys = get_option( 'um_roles', array() );
|
1233 |
+
|
1234 |
+
if ( ! empty( $role_keys ) ) {
|
1235 |
+
if ( in_array( $um_user_value, $role_keys ) ) {
|
1236 |
+
$um_user_value = 'um_' . $um_user_value;
|
1237 |
+
}
|
1238 |
+
}
|
1239 |
+
}
|
1240 |
+
|
1241 |
+
if ( $um_user_value == $value ) {
|
1242 |
+
return true;
|
1243 |
+
}
|
1244 |
+
|
1245 |
+
if ( is_array( $um_user_value ) && in_array( $value, $um_user_value ) ) {
|
1246 |
+
return true;
|
1247 |
+
}
|
1248 |
+
|
1249 |
+
if ( is_array( $um_user_value ) ) {
|
1250 |
+
foreach ( $um_user_value as $u ) {
|
1251 |
+
if ( $u == html_entity_decode( $value ) ) {
|
1252 |
+
return true;
|
1253 |
+
}
|
1254 |
+
}
|
1255 |
+
}
|
1256 |
+
} else {
|
1257 |
+
|
1258 |
+
// show default on edit screen if there isn't meta row in usermeta table
|
1259 |
+
$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 ) );
|
1260 |
+
if ( ! isset( $direct_db_value ) && isset( $data['default'] ) && $data['default'] == $value ) {
|
1261 |
+
return true;
|
1262 |
+
}
|
1263 |
+
|
1264 |
+
}
|
1265 |
+
} else {
|
1266 |
+
if ( isset( $data['default'] ) && $data['default'] == $value ) {
|
1267 |
+
return true;
|
1268 |
+
}
|
1269 |
+
}
|
1270 |
+
}
|
1271 |
+
|
1272 |
+
return false;
|
1273 |
+
}
|
1274 |
+
|
1275 |
+
|
1276 |
+
/**
|
1277 |
+
* Get field icon
|
1278 |
+
*
|
1279 |
+
* @param string $key
|
1280 |
+
*
|
1281 |
+
* @return string
|
1282 |
+
*/
|
1283 |
+
function get_field_icon( $key ) {
|
1284 |
+
$fields = UM()->builtin()->all_user_fields;
|
1285 |
+
if ( isset( $fields[ $key ]['icon'] ) ) {
|
1286 |
+
return $fields[ $key ]['icon'];
|
1287 |
+
}
|
1288 |
+
|
1289 |
+
return '';
|
1290 |
+
}
|
1291 |
+
|
1292 |
+
|
1293 |
+
/**
|
1294 |
+
* Gets selected option value from a callback function
|
1295 |
+
*
|
1296 |
+
* @param string $value
|
1297 |
+
* @param array $data
|
1298 |
+
* @param string $type
|
1299 |
+
*
|
1300 |
+
* @return string
|
1301 |
+
*/
|
1302 |
+
function get_option_value_from_callback( $value, $data, $type ) {
|
1303 |
+
|
1304 |
+
if ( in_array( $type, array( 'select', 'multiselect' ) ) && ! empty( $data['custom_dropdown_options_source'] ) ) {
|
1305 |
+
|
1306 |
+
$has_custom_source = apply_filters( "um_has_dropdown_options_source__{$data['metakey']}", false );
|
1307 |
+
|
1308 |
+
if ( $has_custom_source ) {
|
1309 |
+
|
1310 |
+
$opts = apply_filters( "um_get_field__{$data['metakey']}", array() );
|
1311 |
+
$arr_options = $opts['options'];
|
1312 |
+
|
1313 |
+
} elseif ( function_exists( $data['custom_dropdown_options_source'] ) ) {
|
1314 |
+
if ( isset( $data['parent_dropdown_relationship'] ) ) {
|
1315 |
+
$_POST['parent_option_name'] = $data['parent_dropdown_relationship'];
|
1316 |
+
$_POST['parent_option'] = um_user( $data['parent_dropdown_relationship'] );
|
1317 |
+
|
1318 |
+
$arr_options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
1319 |
+
} else {
|
1320 |
+
$arr_options = call_user_func( $data['custom_dropdown_options_source'] );
|
1321 |
+
}
|
1322 |
+
}
|
1323 |
+
|
1324 |
+
if ( $has_custom_source || function_exists( $data['custom_dropdown_options_source'] ) ) {
|
1325 |
+
if ( $type == 'select' ) {
|
1326 |
+
if ( ! empty( $arr_options[ $value ] ) ) {
|
1327 |
+
return $arr_options[ $value ];
|
1328 |
+
} elseif ( ! empty( $data['default'] ) && empty( $arr_options[ $value ] ) ) {
|
1329 |
+
return $arr_options[ $data['default'] ];
|
1330 |
+
} else {
|
1331 |
+
return '';
|
1332 |
+
}
|
1333 |
+
} elseif ( $type == 'multiselect' ) {
|
1334 |
+
|
1335 |
+
if ( is_array( $value ) ) {
|
1336 |
+
$values = $value;
|
1337 |
+
} else {
|
1338 |
+
$values = explode( ', ', $value );
|
1339 |
+
}
|
1340 |
+
|
1341 |
+
$arr_paired_options = array();
|
1342 |
+
|
1343 |
+
foreach ( $values as $option ) {
|
1344 |
+
if ( isset( $arr_options[ $option ] ) ) {
|
1345 |
+
$arr_paired_options[] = $arr_options[ $option ];
|
1346 |
+
}
|
1347 |
+
}
|
1348 |
+
|
1349 |
+
return implode( ', ', $arr_paired_options );
|
1350 |
+
}
|
1351 |
+
}
|
1352 |
+
|
1353 |
+
|
1354 |
+
}
|
1355 |
+
|
1356 |
+
return $value;
|
1357 |
+
}
|
1358 |
+
|
1359 |
+
|
1360 |
+
/**
|
1361 |
+
* Get select options from a callback function
|
1362 |
+
*
|
1363 |
+
* @param array $data
|
1364 |
+
* @param string $type
|
1365 |
+
*
|
1366 |
+
* @return array $arr_options
|
1367 |
+
*/
|
1368 |
+
function get_options_from_callback( $data, $type ) {
|
1369 |
+
$arr_options = array();
|
1370 |
+
|
1371 |
+
if ( in_array( $type, array( 'select', 'multiselect' ) ) && ! empty( $data['custom_dropdown_options_source'] ) ) {
|
1372 |
+
|
1373 |
+
if ( function_exists( $data['custom_dropdown_options_source'] ) ) {
|
1374 |
+
if ( isset( $data['parent_dropdown_relationship'] ) ) {
|
1375 |
+
$arr_options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
1376 |
+
} else {
|
1377 |
+
$arr_options = call_user_func( $data['custom_dropdown_options_source'] );
|
1378 |
+
}
|
1379 |
+
}
|
1380 |
+
|
1381 |
+
}
|
1382 |
+
|
1383 |
+
return $arr_options;
|
1384 |
+
}
|
1385 |
+
|
1386 |
+
|
1387 |
+
/**
|
1388 |
+
* Get field type
|
1389 |
+
*
|
1390 |
+
* @param string $key
|
1391 |
+
*
|
1392 |
+
* @return string
|
1393 |
+
*/
|
1394 |
+
function get_field_type( $key ) {
|
1395 |
+
$fields = UM()->builtin()->all_user_fields;
|
1396 |
+
if ( isset( $fields[ $key ]['type'] ) ) {
|
1397 |
+
return $fields[ $key ]['type'];
|
1398 |
+
}
|
1399 |
+
|
1400 |
+
return '';
|
1401 |
+
}
|
1402 |
+
|
1403 |
+
|
1404 |
+
/**
|
1405 |
+
* Get field label
|
1406 |
+
*
|
1407 |
+
* @param string $key
|
1408 |
+
*
|
1409 |
+
* @return string
|
1410 |
+
*/
|
1411 |
+
function get_label( $key ) {
|
1412 |
+
$label = '';
|
1413 |
+
|
1414 |
+
$fields = UM()->builtin()->all_user_fields;
|
1415 |
+
if ( isset( $fields[ $key ]['label'] ) ) {
|
1416 |
+
$label = stripslashes( $fields[ $key ]['label'] );
|
1417 |
+
}
|
1418 |
+
|
1419 |
+
if ( empty( $label ) && isset( $fields[ $key ]['title'] ) ) {
|
1420 |
+
$label = stripslashes( $fields[ $key ]['title'] );
|
1421 |
+
}
|
1422 |
+
|
1423 |
+
/**
|
1424 |
+
* UM hook
|
1425 |
+
*
|
1426 |
+
* @type filter
|
1427 |
+
* @title um_change_field_label
|
1428 |
+
* @description Change Field Label
|
1429 |
+
* @input_vars
|
1430 |
+
* [{"var":"$label","type":"string","desc":"Field Label"},
|
1431 |
+
* {"var":"$key","type":"string","desc":"Field Key"}]
|
1432 |
+
* @change_log
|
1433 |
+
* ["Since: 2.0.30"]
|
1434 |
+
* @usage add_filter( 'um_change_field_label', 'function_name', 10, 2 );
|
1435 |
+
* @example
|
1436 |
+
* <?php
|
1437 |
+
* add_filter( 'um_change_field_label', 'my_change_field_label', 10, 2 );
|
1438 |
+
* function my_form_fields( $label, $key ) {
|
1439 |
+
* // your code here
|
1440 |
+
* return $label;
|
1441 |
+
* }
|
1442 |
+
* ?>
|
1443 |
+
*/
|
1444 |
+
$label = apply_filters( 'um_change_field_label', $label, $key );
|
1445 |
+
|
1446 |
+
$label = sprintf( __( '%s', 'ultimate-member' ), $label );
|
1447 |
+
return $label;
|
1448 |
+
}
|
1449 |
+
|
1450 |
+
|
1451 |
+
/**
|
1452 |
+
* Get field title
|
1453 |
+
*
|
1454 |
+
* @param string $key
|
1455 |
+
*
|
1456 |
+
* @return string
|
1457 |
+
*/
|
1458 |
+
function get_field_title( $key ) {
|
1459 |
+
$fields = UM()->builtin()->all_user_fields;
|
1460 |
+
if ( isset( $fields[ $key ]['title'] ) ) {
|
1461 |
+
return $fields[ $key ]['title'];
|
1462 |
+
}
|
1463 |
+
if ( isset( $fields[ $key ]['label'] ) ) {
|
1464 |
+
return $fields[ $key ]['label'];
|
1465 |
+
}
|
1466 |
+
|
1467 |
+
return __( 'Custom Field', 'ultimate-member' );
|
1468 |
+
}
|
1469 |
+
|
1470 |
+
|
1471 |
+
/**
|
1472 |
+
* Get form fields
|
1473 |
+
*
|
1474 |
+
* @return array
|
1475 |
+
*/
|
1476 |
+
function get_fields() {
|
1477 |
+
/**
|
1478 |
+
* UM hook
|
1479 |
+
*
|
1480 |
+
* @type filter
|
1481 |
+
* @title um_get_form_fields
|
1482 |
+
* @description Extend form fields
|
1483 |
+
* @input_vars
|
1484 |
+
* [{"var":"$fields","type":"array","desc":"Selected filter value"}]
|
1485 |
+
* @change_log
|
1486 |
+
* ["Since: 2.0"]
|
1487 |
+
* @usage add_filter( 'um_get_form_fields', 'function_name', 10, 1 );
|
1488 |
+
* @example
|
1489 |
+
* <?php
|
1490 |
+
* add_filter( 'um_get_form_fields', 'my_form_fields', 10, 1 );
|
1491 |
+
* function my_form_fields( $fields ) {
|
1492 |
+
* // your code here
|
1493 |
+
* return $fields;
|
1494 |
+
* }
|
1495 |
+
* ?>
|
1496 |
+
*/
|
1497 |
+
$this->fields = apply_filters( 'um_get_form_fields', array() );
|
1498 |
+
return $this->fields;
|
1499 |
+
}
|
1500 |
+
|
1501 |
+
|
1502 |
+
/**
|
1503 |
+
* Get specific field
|
1504 |
+
*
|
1505 |
+
* @param $key
|
1506 |
+
*
|
1507 |
+
* @return mixed
|
1508 |
+
* @throws \Exception
|
1509 |
+
*/
|
1510 |
+
function get_field( $key ) {
|
1511 |
+
$fields = $this->get_fields();
|
1512 |
+
|
1513 |
+
if ( isset( $fields ) && is_array( $fields ) && isset( $fields[ $key ] ) ) {
|
1514 |
+
$array = $fields[ $key ];
|
1515 |
+
} else {
|
1516 |
+
if ( ! isset( UM()->builtin()->predefined_fields[ $key ] ) && ! isset( UM()->builtin()->all_user_fields[ $key ] ) ) {
|
1517 |
+
return '';
|
1518 |
+
}
|
1519 |
+
$array = ( isset( UM()->builtin()->predefined_fields[ $key ] ) ) ? UM()->builtin()->predefined_fields[ $key ] : UM()->builtin()->all_user_fields[ $key ];
|
1520 |
+
}
|
1521 |
+
|
1522 |
+
$array['classes'] = null;
|
1523 |
+
|
1524 |
+
if ( ! isset( $array['placeholder'] ) ) {
|
1525 |
+
$array['placeholder'] = null;
|
1526 |
+
}
|
1527 |
+
if ( ! isset( $array['required'] ) ) {
|
1528 |
+
$array['required'] = null;
|
1529 |
+
}
|
1530 |
+
if ( ! isset( $array['validate'] ) ) {
|
1531 |
+
$array['validate'] = null;
|
1532 |
+
}
|
1533 |
+
if ( ! isset( $array['default'] ) ) {
|
1534 |
+
$array['default'] = null;
|
1535 |
+
}
|
1536 |
+
|
1537 |
+
if ( isset( $array['conditions'] ) && is_array( $array['conditions'] ) && ! $this->viewing ) {
|
1538 |
+
$array['conditional'] = '';
|
1539 |
+
|
1540 |
+
foreach ( $array['conditions'] as $cond_id => $cond ) {
|
1541 |
+
$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] ) . '"';
|
1542 |
+
}
|
1543 |
+
|
1544 |
+
$array['classes'] .= ' um-is-conditional';
|
1545 |
+
|
1546 |
+
} else {
|
1547 |
+
$array['conditional'] = null;
|
1548 |
+
}
|
1549 |
+
|
1550 |
+
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
1551 |
+
|
1552 |
+
if ( ! in_array( $array['type'], $fields_without_metakey ) ) {
|
1553 |
+
$array['classes'] .= ' um-field-' . esc_attr( $key );
|
1554 |
+
}
|
1555 |
+
$array['classes'] .= ' um-field-' . esc_attr( $array['type'] );
|
1556 |
+
$array['classes'] .= ' um-field-type_' . esc_attr( $array['type'] );
|
1557 |
+
|
1558 |
+
switch ( $array['type'] ) {
|
1559 |
+
|
1560 |
+
case 'googlemap':
|
1561 |
+
case 'youtube_video':
|
1562 |
+
case 'vimeo_video':
|
1563 |
+
case 'soundcloud_track':
|
1564 |
+
$array['disabled'] = '';
|
1565 |
+
$array['input'] = 'text';
|
1566 |
+
break;
|
1567 |
+
|
1568 |
+
case 'text':
|
1569 |
+
|
1570 |
+
$array['disabled'] = '';
|
1571 |
+
|
1572 |
+
if ( $key == 'user_login' && isset( $this->set_mode ) && $this->set_mode == 'account' ) {
|
1573 |
+
$array['disabled'] = 'disabled="disabled"';
|
1574 |
+
}
|
1575 |
+
|
1576 |
+
$array['input'] = 'text';
|
1577 |
+
|
1578 |
+
break;
|
1579 |
+
|
1580 |
+
case 'password':
|
1581 |
+
|
1582 |
+
$array['input'] = 'password';
|
1583 |
+
|
1584 |
+
break;
|
1585 |
+
|
1586 |
+
case 'number':
|
1587 |
+
|
1588 |
+
$array['disabled'] = '';
|
1589 |
+
|
1590 |
+
break;
|
1591 |
+
|
1592 |
+
case 'url':
|
1593 |
+
|
1594 |
+
$array['input'] = 'text';
|
1595 |
+
|
1596 |
+
break;
|
1597 |
+
|
1598 |
+
case 'date':
|
1599 |
+
|
1600 |
+
$array['input'] = 'text';
|
1601 |
+
|
1602 |
+
if ( ! isset( $array['format'] ) ) {
|
1603 |
+
$array['format'] = 'j M Y';
|
1604 |
+
}
|
1605 |
+
|
1606 |
+
switch ( $array['format'] ) {
|
1607 |
+
case 'j M Y':
|
1608 |
+
$js_format = 'd mmm yyyy';
|
1609 |
+
break;
|
1610 |
+
case 'j F Y':
|
1611 |
+
$js_format = 'd mmmm yyyy';
|
1612 |
+
break;
|
1613 |
+
case 'M j Y':
|
1614 |
+
$js_format = 'mmm d yyyy';
|
1615 |
+
break;
|
1616 |
+
case 'F j Y':
|
1617 |
+
$js_format = 'mmmm d yyyy';
|
1618 |
+
break;
|
1619 |
+
}
|
1620 |
+
|
1621 |
+
$array['js_format'] = $js_format;
|
1622 |
+
|
1623 |
+
if ( ! isset( $array['range'] ) ) {
|
1624 |
+
$array['range'] = 'years';
|
1625 |
+
}
|
1626 |
+
if ( ! isset( $array['years'] ) ) {
|
1627 |
+
$array['years'] = 100;
|
1628 |
+
}
|
1629 |
+
if ( ! isset( $array['years_x'] ) ) {
|
1630 |
+
$array['years_x'] = 'past';
|
1631 |
+
}
|
1632 |
+
if ( ! isset( $array['disabled_weekdays'] ) ) {
|
1633 |
+
$array['disabled_weekdays'] = '';
|
1634 |
+
}
|
1635 |
+
|
1636 |
+
if ( ! empty( $array['disabled_weekdays'] ) ) {
|
1637 |
+
$array['disabled_weekdays'] = '[' . implode( ',', $array['disabled_weekdays'] ) . ']';
|
1638 |
+
}
|
1639 |
+
|
1640 |
+
// When date range is strictly defined
|
1641 |
+
if ( $array['range'] == 'date_range' ) {
|
1642 |
+
|
1643 |
+
$array['date_min'] = str_replace( '/', ',', $array['range_start'] );
|
1644 |
+
$array['date_max'] = str_replace( '/', ',', $array['range_end'] );
|
1645 |
+
|
1646 |
+
} else {
|
1647 |
+
|
1648 |
+
if ( $array['years_x'] == 'past' ) {
|
1649 |
+
|
1650 |
+
$date = new \DateTime( date( 'Y-n-d' ) );
|
1651 |
+
$past = $date->modify( '-' . $array['years'] . ' years' );
|
1652 |
+
$past = $date->format( 'Y,n,d' );
|
1653 |
+
|
1654 |
+
$array['date_min'] = $past;
|
1655 |
+
$array['date_max'] = date( 'Y,n,d' );
|
1656 |
+
|
1657 |
+
} elseif ( $array['years_x'] == 'future' ) {
|
1658 |
+
|
1659 |
+
$date = new \DateTime( date( 'Y-n-d' ) );
|
1660 |
+
$future = $date->modify( '+' . $array['years'] . ' years' );
|
1661 |
+
$future = $date->format( 'Y,n,d' );
|
1662 |
+
|
1663 |
+
$array['date_min'] = date( 'Y,n,d' );
|
1664 |
+
$array['date_max'] = $future;
|
1665 |
+
|
1666 |
+
} else {
|
1667 |
+
|
1668 |
+
$date = new \DateTime( date( 'Y-n-d' ) );
|
1669 |
+
$date_f = new \DateTime( date( 'Y-n-d' ) );
|
1670 |
+
$past = $date->modify( '-' . ( $array['years'] / 2 ) . ' years' );
|
1671 |
+
$past = $date->format( 'Y,n,d' );
|
1672 |
+
$future = $date_f->modify( '+' . ( $array['years'] / 2 ) . ' years' );
|
1673 |
+
$future = $date_f->format( 'Y,n,d' );
|
1674 |
+
|
1675 |
+
$array['date_min'] = $past;
|
1676 |
+
$array['date_max'] = $future;
|
1677 |
+
|
1678 |
+
}
|
1679 |
+
|
1680 |
+
}
|
1681 |
+
|
1682 |
+
break;
|
1683 |
+
|
1684 |
+
case 'time':
|
1685 |
+
|
1686 |
+
$array['input'] = 'text';
|
1687 |
+
|
1688 |
+
if ( ! isset( $array['format'] ) ) {
|
1689 |
+
$array['format'] = 'g:i a';
|
1690 |
+
}
|
1691 |
+
|
1692 |
+
switch ( $array['format'] ) {
|
1693 |
+
case 'g:i a':
|
1694 |
+
$js_format = 'h:i a';
|
1695 |
+
break;
|
1696 |
+
case 'g:i A':
|
1697 |
+
$js_format = 'h:i A';
|
1698 |
+
break;
|
1699 |
+
case 'H:i':
|
1700 |
+
$js_format = 'HH:i';
|
1701 |
+
break;
|
1702 |
+
}
|
1703 |
+
|
1704 |
+
$array['js_format'] = $js_format;
|
1705 |
+
|
1706 |
+
if ( ! isset( $array['intervals'] ) ) {
|
1707 |
+
$array['intervals'] = 60;
|
1708 |
+
}
|
1709 |
+
|
1710 |
+
break;
|
1711 |
+
|
1712 |
+
case 'textarea':
|
1713 |
+
|
1714 |
+
if ( ! isset( $array['height'] ) ) {
|
1715 |
+
$array['height'] = '100px';
|
1716 |
+
}
|
1717 |
+
|
1718 |
+
break;
|
1719 |
+
|
1720 |
+
case 'rating':
|
1721 |
+
|
1722 |
+
if ( ! isset( $array['number'] ) ) {
|
1723 |
+
$array['number'] = 5;
|
1724 |
+
}
|
1725 |
+
|
1726 |
+
break;
|
1727 |
+
|
1728 |
+
case 'spacing':
|
1729 |
+
|
1730 |
+
if ( ! isset( $array['spacing'] ) ) {
|
1731 |
+
$array['spacing'] = '20px';
|
1732 |
+
}
|
1733 |
+
|
1734 |
+
break;
|
1735 |
+
|
1736 |
+
case 'divider':
|
1737 |
+
|
1738 |
+
if ( isset( $array['width'] ) ) {
|
1739 |
+
$array['borderwidth'] = $array['width'];
|
1740 |
+
} else {
|
1741 |
+
$array['borderwidth'] = 4;
|
1742 |
+
}
|
1743 |
+
|
1744 |
+
if ( isset( $array['color'] ) ) {
|
1745 |
+
$array['bordercolor'] = $array['color'];
|
1746 |
+
} else {
|
1747 |
+
$array['bordercolor'] = '#eee';
|
1748 |
+
}
|
1749 |
+
|
1750 |
+
if ( isset( $array['style'] ) ) {
|
1751 |
+
$array['borderstyle'] = $array['style'];
|
1752 |
+
} else {
|
1753 |
+
$array['borderstyle'] = 'solid';
|
1754 |
+
}
|
1755 |
+
|
1756 |
+
if ( ! isset( $array['divider_text'] ) ) {
|
1757 |
+
$array['divider_text'] = '';
|
1758 |
+
}
|
1759 |
+
|
1760 |
+
break;
|
1761 |
+
|
1762 |
+
case 'image':
|
1763 |
+
|
1764 |
+
if ( ! isset( $array['crop'] ) ) {
|
1765 |
+
$array['crop'] = 0;
|
1766 |
+
}
|
1767 |
+
|
1768 |
+
if ( $array['crop'] == 0 ) {
|
1769 |
+
$array['crop_data'] = 0;
|
1770 |
+
} elseif ( $array['crop'] == 1 ) {
|
1771 |
+
$array['crop_data'] = 'square';
|
1772 |
+
} elseif ( $array['crop'] == 2 ) {
|
1773 |
+
$array['crop_data'] = 'cover';
|
1774 |
+
} else {
|
1775 |
+
$array['crop_data'] = 'user';
|
1776 |
+
}
|
1777 |
+
|
1778 |
+
if ( ! isset( $array['modal_size'] ) ) {
|
1779 |
+
$array['modal_size'] = 'normal';
|
1780 |
+
}
|
1781 |
+
|
1782 |
+
if ( $array['crop'] > 0 ) {
|
1783 |
+
$array['crop_class'] = 'crop';
|
1784 |
+
} else {
|
1785 |
+
$array['crop_class'] = '';
|
1786 |
+
}
|
1787 |
+
|
1788 |
+
if ( ! isset( $array['ratio'] ) ) {
|
1789 |
+
$array['ratio'] = 1.0;
|
1790 |
+
}
|
1791 |
+
|
1792 |
+
if ( ! isset( $array['min_width'] ) ) {
|
1793 |
+
$array['min_width'] = '';
|
1794 |
+
}
|
1795 |
+
if ( ! isset( $array['min_height'] ) ) {
|
1796 |
+
$array['min_height'] = '';
|
1797 |
+
}
|
1798 |
+
|
1799 |
+
if ( $array['min_width'] == '' && $array['crop'] == 1 ) {
|
1800 |
+
$array['min_width'] = 600;
|
1801 |
+
}
|
1802 |
+
if ( $array['min_height'] == '' && $array['crop'] == 1 ) {
|
1803 |
+
$array['min_height'] = 600;
|
1804 |
+
}
|
1805 |
+
|
1806 |
+
if ( $array['min_width'] == '' && $array['crop'] == 3 ) {
|
1807 |
+
$array['min_width'] = 600;
|
1808 |
+
}
|
1809 |
+
if ( $array['min_height'] == '' && $array['crop'] == 3 ) {
|
1810 |
+
$array['min_height'] = 600;
|
1811 |
+
}
|
1812 |
+
|
1813 |
+
if ( ! isset( $array['invalid_image'] ) ) {
|
1814 |
+
$array['invalid_image'] = __( 'Please upload a valid image!', 'ultimate-member' );
|
1815 |
+
}
|
1816 |
+
if ( ! isset( $array['allowed_types'] ) ) {
|
1817 |
+
$array['allowed_types'] = 'gif,jpg,jpeg,png';
|
1818 |
+
} else {
|
1819 |
+
$array['allowed_types'] = implode( ',', $array['allowed_types'] );
|
1820 |
+
}
|
1821 |
+
if ( ! isset( $array['upload_text'] ) ) {
|
1822 |
+
$array['upload_text'] = '';
|
1823 |
+
}
|
1824 |
+
if ( ! isset( $array['button_text'] ) ) {
|
1825 |
+
$array['button_text'] = __( 'Upload', 'ultimate-member' );
|
1826 |
+
}
|
1827 |
+
if ( ! isset( $array['extension_error'] ) ) {
|
1828 |
+
$array['extension_error'] = __( 'Sorry this is not a valid image.', 'ultimate-member' );
|
1829 |
+
}
|
1830 |
+
if ( ! isset( $array['max_size_error'] ) ) {
|
1831 |
+
$array['max_size_error'] = __( 'This image is too large!', 'ultimate-member' );
|
1832 |
+
}
|
1833 |
+
if ( ! isset( $array['min_size_error'] ) ) {
|
1834 |
+
$array['min_size_error'] = __( 'This image is too small!', 'ultimate-member' );
|
1835 |
+
}
|
1836 |
+
if ( ! isset( $array['max_files_error'] ) ) {
|
1837 |
+
$array['max_files_error'] = __( 'You can only upload one image', 'ultimate-member' );
|
1838 |
+
}
|
1839 |
+
if ( empty( $array['max_size'] ) ) {
|
1840 |
+
$array['max_size'] = 999999999;
|
1841 |
+
}
|
1842 |
+
if ( ! isset( $array['upload_help_text'] ) ) {
|
1843 |
+
$array['upload_help_text'] = '';
|
1844 |
+
}
|
1845 |
+
if ( ! isset( $array['icon'] ) ) {
|
1846 |
+
$array['icon'] = '';
|
1847 |
+
}
|
1848 |
+
|
1849 |
+
break;
|
1850 |
+
|
1851 |
+
case 'file':
|
1852 |
+
|
1853 |
+
if ( ! isset( $array['modal_size'] ) ) {
|
1854 |
+
$array['modal_size'] = 'normal';
|
1855 |
+
}
|
1856 |
+
|
1857 |
+
if ( ! isset( $array['allowed_types'] ) ) {
|
1858 |
+
$array['allowed_types'] = 'pdf,txt';
|
1859 |
+
} else {
|
1860 |
+
$array['allowed_types'] = implode( ',', $array['allowed_types'] );
|
1861 |
+
}
|
1862 |
+
if ( ! isset( $array['upload_text'] ) ) {
|
1863 |
+
$array['upload_text'] = '';
|
1864 |
+
}
|
1865 |
+
if ( ! isset( $array['button_text'] ) ) {
|
1866 |
+
$array['button_text'] = __( 'Upload', 'ultimate-member' );
|
1867 |
+
}
|
1868 |
+
if ( ! isset( $array['extension_error'] ) ) {
|
1869 |
+
$array['extension_error'] = __( 'Sorry this is not a valid file.', 'ultimate-member' );
|
1870 |
+
}
|
1871 |
+
if ( ! isset( $array['max_size_error'] ) ) {
|
1872 |
+
$array['max_size_error'] = __( 'This file is too large!', 'ultimate-member' );
|
1873 |
+
}
|
1874 |
+
if ( ! isset( $array['min_size_error'] ) ) {
|
1875 |
+
$array['min_size_error'] = __( 'This file is too small!', 'ultimate-member' );
|
1876 |
+
}
|
1877 |
+
if ( ! isset( $array['max_files_error'] ) ) {
|
1878 |
+
$array['max_files_error'] = __( 'You can only upload one file', 'ultimate-member' );
|
1879 |
+
}
|
1880 |
+
if ( empty( $array['max_size'] ) ) {
|
1881 |
+
$array['max_size'] = 999999999;
|
1882 |
+
}
|
1883 |
+
if ( ! isset( $array['upload_help_text'] ) ) {
|
1884 |
+
$array['upload_help_text'] = '';
|
1885 |
+
}
|
1886 |
+
if ( ! isset( $array['icon'] ) ) {
|
1887 |
+
$array['icon'] = '';
|
1888 |
+
}
|
1889 |
+
|
1890 |
+
break;
|
1891 |
+
|
1892 |
+
case 'select':
|
1893 |
+
|
1894 |
+
break;
|
1895 |
+
|
1896 |
+
case 'multiselect':
|
1897 |
+
|
1898 |
+
break;
|
1899 |
+
|
1900 |
+
case 'group':
|
1901 |
+
|
1902 |
+
if ( ! isset( $array['max_entries'] ) ) {
|
1903 |
+
$array['max_entries'] = 0;
|
1904 |
+
}
|
1905 |
+
|
1906 |
+
break;
|
1907 |
+
|
1908 |
+
}
|
1909 |
+
|
1910 |
+
if ( ! isset( $array['visibility'] ) ) {
|
1911 |
+
$array['visibility'] = 'all';
|
1912 |
+
}
|
1913 |
+
|
1914 |
+
/**
|
1915 |
+
* UM hook
|
1916 |
+
*
|
1917 |
+
* @type filter
|
1918 |
+
* @title um_get_field__{$key}
|
1919 |
+
* @description Extend field data by field $key
|
1920 |
+
* @input_vars
|
1921 |
+
* [{"var":"$data","type":"array","desc":"Field Data"}]
|
1922 |
+
* @change_log
|
1923 |
+
* ["Since: 2.0"]
|
1924 |
+
* @usage add_filter( 'um_get_field__{$key}', 'function_name', 10, 1 );
|
1925 |
+
* @example
|
1926 |
+
* <?php
|
1927 |
+
* add_filter( 'um_get_field__{$key}', 'my_get_field', 10, 1 );
|
1928 |
+
* function my_get_field( $data ) {
|
1929 |
+
* // your code here
|
1930 |
+
* return $data;
|
1931 |
+
* }
|
1932 |
+
* ?>
|
1933 |
+
*/
|
1934 |
+
$array = apply_filters( "um_get_field__{$key}", $array );
|
1935 |
+
|
1936 |
+
return $array;
|
1937 |
+
}
|
1938 |
+
|
1939 |
+
|
1940 |
+
/**
|
1941 |
+
* @param $option_value
|
1942 |
+
*
|
1943 |
+
* @return mixed|void
|
1944 |
+
*/
|
1945 |
+
function filter_field_non_utf8_value( $option_value ) {
|
1946 |
+
/**
|
1947 |
+
* UM hook
|
1948 |
+
*
|
1949 |
+
* @type filter
|
1950 |
+
* @title um_field_non_utf8_value
|
1951 |
+
* @description Change dropdown option text
|
1952 |
+
* @input_vars
|
1953 |
+
* [{"var":"$value","type":"string","desc":"Option Value"}]
|
1954 |
+
* @change_log
|
1955 |
+
* ["Since: 2.0"]
|
1956 |
+
* @usage add_filter( 'um_field_non_utf8_value', 'function_name', 10, 1 );
|
1957 |
+
* @example
|
1958 |
+
* <?php
|
1959 |
+
* add_filter( 'um_field_non_utf8_value', 'my_field_non_utf8_value', 10, 1 );
|
1960 |
+
* function my_field_non_utf8_value( $value ) {
|
1961 |
+
* // your code here
|
1962 |
+
* return $value;
|
1963 |
+
* }
|
1964 |
+
* ?>
|
1965 |
+
*/
|
1966 |
+
return apply_filters( 'um_field_non_utf8_value', $option_value );
|
1967 |
+
}
|
1968 |
+
|
1969 |
+
|
1970 |
+
/**
|
1971 |
+
* Getting the fields that need to be disabled in edit mode (profile)
|
1972 |
+
*
|
1973 |
+
* @param bool $_um_profile_id
|
1974 |
+
*
|
1975 |
+
* @return array
|
1976 |
+
*/
|
1977 |
+
function get_restricted_fields_for_edit( $_um_profile_id = false ) {
|
1978 |
+
// fields that need to be disabled in edit mode (profile)
|
1979 |
+
$arr_restricted_fields = array( 'user_email', 'username', 'user_login', 'user_password', '_um_last_login' );
|
1980 |
+
$arr_restricted_fields = apply_filters( 'um_user_profile_restricted_edit_fields', $arr_restricted_fields, $_um_profile_id );
|
1981 |
+
|
1982 |
+
return $arr_restricted_fields;
|
1983 |
+
}
|
1984 |
+
|
1985 |
+
|
1986 |
+
/**
|
1987 |
+
* Gets a field in 'input mode'
|
1988 |
+
*
|
1989 |
+
* @param string $key
|
1990 |
+
* @param array $data
|
1991 |
+
* @param bool $rule
|
1992 |
+
* @param array $args
|
1993 |
+
*
|
1994 |
+
* @return string|null
|
1995 |
+
* @throws \Exception
|
1996 |
+
*/
|
1997 |
+
function edit_field( $key, $data, $rule = false, $args = array() ) {
|
1998 |
+
global $_um_profile_id;
|
1999 |
+
|
2000 |
+
$output = '';
|
2001 |
+
$disabled = '';
|
2002 |
+
if ( empty( $_um_profile_id ) ) {
|
2003 |
+
$_um_profile_id = um_user( 'ID' );
|
2004 |
+
}
|
2005 |
+
|
2006 |
+
// get whole field data
|
2007 |
+
if ( isset( $data ) && is_array( $data ) ) {
|
2008 |
+
$data = $this->get_field( $key );
|
2009 |
+
if ( is_array( $data ) ) {
|
2010 |
+
/**
|
2011 |
+
* @var string $in_row
|
2012 |
+
* @var boolean $in_sub_row
|
2013 |
+
* @var boolean $in_column
|
2014 |
+
* @var string $type
|
2015 |
+
* @var string $metakey
|
2016 |
+
* @var int $position
|
2017 |
+
* @var string $title
|
2018 |
+
* @var string $help
|
2019 |
+
* @var array $options
|
2020 |
+
* @var string $visibility
|
2021 |
+
* @var string $label
|
2022 |
+
* @var string $placeholder
|
2023 |
+
* @var boolean $public
|
2024 |
+
* @var boolean $editable
|
2025 |
+
* @var string $icon
|
2026 |
+
* @var boolean $in_group
|
2027 |
+
* @var boolean $required
|
2028 |
+
* @var string $validate
|
2029 |
+
* @var string $default
|
2030 |
+
* @var string $conditional
|
2031 |
+
* @var string $input
|
2032 |
+
* @var string $js_format
|
2033 |
+
* @var string $date_max
|
2034 |
+
* @var string $date_min
|
2035 |
+
* @var string $disabled_weekdays
|
2036 |
+
* @var string $years_x
|
2037 |
+
* @var string $years
|
2038 |
+
* @var string $range
|
2039 |
+
* @var string $intervals
|
2040 |
+
* @var string $height
|
2041 |
+
* @var string $spacing
|
2042 |
+
* @var string $borderwidth
|
2043 |
+
* @var string $borderstyle
|
2044 |
+
* @var string $bordercolor
|
2045 |
+
* @var string $divider_text
|
2046 |
+
* @var string $crop_class
|
2047 |
+
* @var string $crop_data
|
2048 |
+
* @var string $modal_size
|
2049 |
+
* @var string $ratio
|
2050 |
+
* @var string $min_width
|
2051 |
+
* @var string $min_height
|
2052 |
+
* @var string $button_text
|
2053 |
+
* @var string $max_size
|
2054 |
+
* @var string $max_size_error
|
2055 |
+
* @var string $extension_error
|
2056 |
+
* @var string $allowed_types
|
2057 |
+
* @var string $upload_text
|
2058 |
+
* @var string $max_files_error
|
2059 |
+
* @var string $upload_help_text
|
2060 |
+
* @var string $min_size_error
|
2061 |
+
* @var string $filter
|
2062 |
+
* @var string $content
|
2063 |
+
* @var string $max_entries
|
2064 |
+
*/
|
2065 |
+
extract( $data );
|
2066 |
+
}
|
2067 |
+
}
|
2068 |
+
|
2069 |
+
if ( ! isset( $data['type'] ) ) {
|
2070 |
+
return '';
|
2071 |
+
}
|
2072 |
+
|
2073 |
+
if ( isset( $data['in_group'] ) && $data['in_group'] != '' && $rule != 'group' ) {
|
2074 |
+
return '';
|
2075 |
+
}
|
2076 |
+
|
2077 |
+
// forbidden in edit mode? 'edit_forbidden' - it's field attribute predefined in the field data in code
|
2078 |
+
if ( isset( $data['edit_forbidden'] ) ) {
|
2079 |
+
return '';
|
2080 |
+
}
|
2081 |
+
|
2082 |
+
// required option? 'required_opt' - it's field attribute predefined in the field data in code
|
2083 |
+
if ( isset( $data['required_opt'] ) ) {
|
2084 |
+
$opt = $data['required_opt'];
|
2085 |
+
if ( UM()->options()->get( $opt[0] ) != $opt[1] ) {
|
2086 |
+
return '';
|
2087 |
+
}
|
2088 |
+
}
|
2089 |
+
|
2090 |
+
// required user permission 'required_perm' - it's field attribute predefined in the field data in code
|
2091 |
+
if ( isset( $data['required_perm'] ) ) {
|
2092 |
+
if ( ! UM()->roles()->um_user_can( $data['required_perm'] ) ) {
|
2093 |
+
return '';
|
2094 |
+
}
|
2095 |
+
}
|
2096 |
+
|
2097 |
+
// fields that need to be disabled in edit mode (profile) (email, username, etc.)
|
2098 |
+
$arr_restricted_fields = $this->get_restricted_fields_for_edit( $_um_profile_id );
|
2099 |
+
if ( in_array( $key, $arr_restricted_fields ) && $this->editing == true && $this->set_mode == 'profile' ) {
|
2100 |
+
return '';
|
2101 |
+
}
|
2102 |
+
|
2103 |
+
|
2104 |
+
if ( $visibility == 'view' && $this->set_mode != 'register' ) {
|
2105 |
+
return '';
|
2106 |
+
}
|
2107 |
+
|
2108 |
+
if ( ! um_can_view_field( $data ) ) {
|
2109 |
+
return '';
|
2110 |
+
}
|
2111 |
+
|
2112 |
+
um_fetch_user( $_um_profile_id );
|
2113 |
+
|
2114 |
+
// Stop return empty values build field attributes:
|
2115 |
+
|
2116 |
+
if ( $visibility == 'view' && $this->set_mode == 'register' ) {
|
2117 |
+
|
2118 |
+
um_fetch_user( get_current_user_id() );
|
2119 |
+
if ( ! um_user( 'can_edit_everyone' ) ) {
|
2120 |
+
$disabled = ' disabled="disabled" ';
|
2121 |
+
}
|
2122 |
+
|
2123 |
+
um_fetch_user( $_um_profile_id );
|
2124 |
+
if ( isset( $data['public'] ) && $data['public'] == '-2' && $data['roles'] ) {
|
2125 |
+
$current_user_roles = um_user( 'roles' );
|
2126 |
+
if ( ! empty( $current_user_roles ) && count( array_intersect( $current_user_roles, $data['roles'] ) ) > 0 ) {
|
2127 |
+
$disabled = '';
|
2128 |
+
}
|
2129 |
+
}
|
2130 |
+
}
|
2131 |
+
|
2132 |
+
if ( ! empty( $this->editing ) && $this->set_mode == 'profile' ) {
|
2133 |
+
if ( ! UM()->roles()->um_user_can( 'can_edit_everyone' ) ) {
|
2134 |
+
if ( isset( $data['editable'] ) && $data['editable'] == 0 ) {
|
2135 |
+
$disabled = ' disabled="disabled" ';
|
2136 |
+
}
|
2137 |
+
}
|
2138 |
+
}
|
2139 |
+
|
2140 |
+
$disabled = apply_filters( 'um_is_field_disabled', $disabled, $data );
|
2141 |
+
|
2142 |
+
if ( ! isset( $data['autocomplete'] ) ) {
|
2143 |
+
$autocomplete = 'off';
|
2144 |
+
}
|
2145 |
+
|
2146 |
+
if ( isset( $data['classes'] ) ) {
|
2147 |
+
$classes = explode( " ", $data['classes'] );
|
2148 |
+
}
|
2149 |
+
|
2150 |
+
um_fetch_user( $_um_profile_id );
|
2151 |
+
|
2152 |
+
/**
|
2153 |
+
* UM hook
|
2154 |
+
*
|
2155 |
+
* @type filter
|
2156 |
+
* @title um_hook_for_field_{$type}
|
2157 |
+
* @description Change field type
|
2158 |
+
* @input_vars
|
2159 |
+
* [{"var":"$type","type":"string","desc":"Field Type"}]
|
2160 |
+
* @change_log
|
2161 |
+
* ["Since: 2.0"]
|
2162 |
+
* @usage add_filter( 'um_hook_for_field_{$type}', 'function_name', 10, 1 );
|
2163 |
+
* @example
|
2164 |
+
* <?php
|
2165 |
+
* add_filter( 'um_hook_for_field_{$type}', 'my_field_type', 10, 1 );
|
2166 |
+
* function my_get_field( $type ) {
|
2167 |
+
* // your code here
|
2168 |
+
* return $type;
|
2169 |
+
* }
|
2170 |
+
* ?>
|
2171 |
+
*/
|
2172 |
+
$type = apply_filters( "um_hook_for_field_{$type}", $type );
|
2173 |
+
switch ( $type ) {
|
2174 |
+
|
2175 |
+
case 'textarea':
|
2176 |
+
case 'multiselect':
|
2177 |
+
$field_id = $field_name = $key;
|
2178 |
+
$field_value = $this->field_value( $key, $default, $data );
|
2179 |
+
break;
|
2180 |
+
|
2181 |
+
case 'select':
|
2182 |
+
case 'radio':
|
2183 |
+
$form_key = str_replace( array( 'role_select', 'role_radio' ), 'role', $key );
|
2184 |
+
$field_id = $form_key;
|
2185 |
+
break;
|
2186 |
+
default:
|
2187 |
+
$field_id = '';
|
2188 |
+
break;
|
2189 |
+
}
|
2190 |
+
|
2191 |
+
/**
|
2192 |
+
* UM hook
|
2193 |
+
*
|
2194 |
+
* @type filter
|
2195 |
+
* @title um_completeness_field_id
|
2196 |
+
* @description use for change core id not allowed duplicate
|
2197 |
+
* @input_vars
|
2198 |
+
* [{"var":"$field_id","type":"string","desc":"Field id"},
|
2199 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
2200 |
+
* {"var":"$args","type":"array","desc":"Optional field arguments"}]
|
2201 |
+
* @change_log
|
2202 |
+
* ["Since: 2.0.13"]
|
2203 |
+
* @usage add_filter( 'um_completeness_field_id', 'function_name', 10, 3 );
|
2204 |
+
* @example
|
2205 |
+
* <?php
|
2206 |
+
* add_filter( 'um_completeness_field_id', 'function_name', 10, 3 );
|
2207 |
+
* function function_name( $field_id, $data, $args ) {
|
2208 |
+
* // your code here
|
2209 |
+
* return $field_id;
|
2210 |
+
* }
|
2211 |
+
* ?>
|
2212 |
+
*/
|
2213 |
+
$field_id = apply_filters( 'um_completeness_field_id', $field_id, $data, $args );
|
2214 |
+
|
2215 |
+
|
2216 |
+
/* Begin by field type */
|
2217 |
+
switch ( $type ) {
|
2218 |
+
|
2219 |
+
/* Default: Integration */
|
2220 |
+
default:
|
2221 |
+
$mode = ( isset( $this->set_mode ) ) ? $this->set_mode : 'no_mode';
|
2222 |
+
|
2223 |
+
/**
|
2224 |
+
* UM hook
|
2225 |
+
*
|
2226 |
+
* @type filter
|
2227 |
+
* @title um_edit_field_{$mode}_{$type}
|
2228 |
+
* @description Change field html by $mode and field $type
|
2229 |
+
* @input_vars
|
2230 |
+
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
2231 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
2232 |
+
* @change_log
|
2233 |
+
* ["Since: 2.0"]
|
2234 |
+
* @usage add_filter( 'um_edit_field_{$mode}_{$type}', 'function_name', 10, 2 );
|
2235 |
+
* @example
|
2236 |
+
* <?php
|
2237 |
+
* add_filter( 'um_edit_field_{$mode}_{$type}', 'my_edit_field_html', 10, 2 );
|
2238 |
+
* function my_edit_field_html( $output, $data ) {
|
2239 |
+
* // your code here
|
2240 |
+
* return $output;
|
2241 |
+
* }
|
2242 |
+
* ?>
|
2243 |
+
*/
|
2244 |
+
|
2245 |
+
$output .= apply_filters( "um_edit_field_{$mode}_{$type}", $output, $data );
|
2246 |
+
break;
|
2247 |
+
|
2248 |
+
/* Other fields */
|
2249 |
+
case 'googlemap':
|
2250 |
+
case 'youtube_video':
|
2251 |
+
case 'vimeo_video':
|
2252 |
+
case 'soundcloud_track':
|
2253 |
+
|
2254 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2255 |
+
|
2256 |
+
if ( isset( $data['label'] ) ) {
|
2257 |
+
$output .= $this->field_label( $label, $key, $data );
|
2258 |
+
}
|
2259 |
+
|
2260 |
+
$output .= '<div class="um-field-area">';
|
2261 |
+
|
2262 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2263 |
+
|
2264 |
+
$output .= '<div class="um-field-icon"><i class="' . $icon . '"></i></div>';
|
2265 |
+
|
2266 |
+
}
|
2267 |
+
|
2268 |
+
$field_name = $key . UM()->form()->form_suffix;
|
2269 |
+
$field_value = htmlspecialchars( $this->field_value( $key, $default, $data ) );
|
2270 |
+
|
2271 |
+
$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 ) . '" />
|
2272 |
+
|
2273 |
+
</div>';
|
2274 |
+
|
2275 |
+
if ( ! empty( $disabled ) ) {
|
2276 |
+
$output .= $this->disabled_hidden_field( $field_name, $field_value );
|
2277 |
+
}
|
2278 |
+
|
2279 |
+
if ( $this->is_error( $key ) ) {
|
2280 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2281 |
+
}else if ( $this->is_notice( $key ) ) {
|
2282 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2283 |
+
}
|
2284 |
+
|
2285 |
+
$output .= '</div>';
|
2286 |
+
break;
|
2287 |
+
|
2288 |
+
/* Text */
|
2289 |
+
case 'text':
|
2290 |
+
|
2291 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2292 |
+
|
2293 |
+
if ( isset( $data['label'] ) ) {
|
2294 |
+
$output .= $this->field_label( $label, $key, $data );
|
2295 |
+
}
|
2296 |
+
|
2297 |
+
$output .= '<div class="um-field-area">';
|
2298 |
+
|
2299 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2300 |
+
|
2301 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2302 |
+
|
2303 |
+
}
|
2304 |
+
|
2305 |
+
$field_name = $key . UM()->form()->form_suffix;
|
2306 |
+
$field_value = htmlspecialchars( $this->field_value( $key, $default, $data ) );
|
2307 |
+
|
2308 |
+
$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 ) . '" />
|
2309 |
+
|
2310 |
+
</div>';
|
2311 |
+
|
2312 |
+
if ( ! empty( $disabled ) ) {
|
2313 |
+
$output .= $this->disabled_hidden_field( $field_name, $field_value );
|
2314 |
+
}
|
2315 |
+
|
2316 |
+
if ( $this->is_error( $key ) ) {
|
2317 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2318 |
+
}else if ( $this->is_notice( $key ) ) {
|
2319 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2320 |
+
}
|
2321 |
+
|
2322 |
+
$output .= '</div>';
|
2323 |
+
break;
|
2324 |
+
|
2325 |
+
/* Number */
|
2326 |
+
case 'number':
|
2327 |
+
|
2328 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2329 |
+
|
2330 |
+
if ( isset( $data['label'] ) ) {
|
2331 |
+
$output .= $this->field_label( $label, $key, $data );
|
2332 |
+
}
|
2333 |
+
|
2334 |
+
$output .= '<div class="um-field-area">';
|
2335 |
+
|
2336 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2337 |
+
|
2338 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2339 |
+
|
2340 |
+
}
|
2341 |
+
|
2342 |
+
$number_limit = '';
|
2343 |
+
if ( isset( $min ) ) {
|
2344 |
+
$number_limit .= ' min="' . esc_attr( $min ) . '" ';
|
2345 |
+
}
|
2346 |
+
if ( isset( $max ) ) {
|
2347 |
+
$number_limit .= ' max="' . esc_attr( $max ) . '" ';
|
2348 |
+
}
|
2349 |
+
|
2350 |
+
$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 . ' />
|
2351 |
+
|
2352 |
+
</div>';
|
2353 |
+
|
2354 |
+
if ( $this->is_error( $key ) ) {
|
2355 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2356 |
+
}else if ( $this->is_notice( $key ) ) {
|
2357 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2358 |
+
}
|
2359 |
+
|
2360 |
+
$output .= '</div>';
|
2361 |
+
break;
|
2362 |
+
|
2363 |
+
/* Password */
|
2364 |
+
case 'password':
|
2365 |
+
|
2366 |
+
$original_key = $key;
|
2367 |
+
|
2368 |
+
if ( $key == 'single_user_password' ) {
|
2369 |
+
|
2370 |
+
$key = $original_key;
|
2371 |
+
|
2372 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2373 |
+
|
2374 |
+
if ( isset( $data['label'] ) ) {
|
2375 |
+
$output .= $this->field_label( $label, $key, $data );
|
2376 |
+
}
|
2377 |
+
|
2378 |
+
$output .= '<div class="um-field-area">';
|
2379 |
+
|
2380 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2381 |
+
|
2382 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2383 |
+
|
2384 |
+
}
|
2385 |
+
|
2386 |
+
$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 ) . '" />
|
2387 |
+
|
2388 |
+
</div>';
|
2389 |
+
|
2390 |
+
if ( $this->is_error( $key ) ) {
|
2391 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2392 |
+
}else if ( $this->is_notice( $key ) ) {
|
2393 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2394 |
+
}
|
2395 |
+
|
2396 |
+
$output .= '</div>';
|
2397 |
+
|
2398 |
+
} else {
|
2399 |
+
|
2400 |
+
if ( UM()->account()->current_password_is_required( 'password' ) &&
|
2401 |
+
( $this->set_mode == 'account' || um_is_core_page( 'account' ) ) ) {
|
2402 |
+
|
2403 |
+
$key = 'current_' . $original_key;
|
2404 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2405 |
+
|
2406 |
+
if ( isset( $data['label'] ) ) {
|
2407 |
+
$output .= $this->field_label( __( 'Current Password', 'ultimate-member' ), $key, $data );
|
2408 |
+
}
|
2409 |
+
|
2410 |
+
$output .= '<div class="um-field-area">';
|
2411 |
+
|
2412 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field') {
|
2413 |
+
|
2414 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2415 |
+
|
2416 |
+
}
|
2417 |
+
|
2418 |
+
$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 ) . '" />
|
2419 |
+
|
2420 |
+
</div>';
|
2421 |
+
|
2422 |
+
if ( $this->is_error( $key ) ) {
|
2423 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2424 |
+
} elseif ( $this->is_notice( $key ) ) {
|
2425 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2426 |
+
}
|
2427 |
+
|
2428 |
+
$output .= '</div>';
|
2429 |
+
|
2430 |
+
}
|
2431 |
+
|
2432 |
+
$key = $original_key;
|
2433 |
+
|
2434 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2435 |
+
|
2436 |
+
if ( $this->set_mode == 'account' && um_is_core_page( 'account' ) || $this->set_mode == 'password' && um_is_core_page( 'password-reset' ) ) {
|
2437 |
+
|
2438 |
+
$output .= $this->field_label( __( 'New Password', 'ultimate-member' ), $key, $data );
|
2439 |
+
|
2440 |
+
} elseif ( isset( $data['label'] ) ) {
|
2441 |
+
|
2442 |
+
$output .= $this->field_label( $label, $key, $data );
|
2443 |
+
|
2444 |
+
}
|
2445 |
+
|
2446 |
+
$output .= '<div class="um-field-area">';
|
2447 |
+
|
2448 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field') {
|
2449 |
+
|
2450 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2451 |
+
|
2452 |
+
}
|
2453 |
+
|
2454 |
+
$name = $key . UM()->form()->form_suffix;
|
2455 |
+
if ( $this->set_mode == 'password' && um_is_core_page( 'password-reset' ) ) {
|
2456 |
+
$name = $key;
|
2457 |
+
}
|
2458 |
+
|
2459 |
+
$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 ) . '" />
|
2460 |
+
|
2461 |
+
</div>';
|
2462 |
+
|
2463 |
+
if ( $this->is_error( $key ) ) {
|
2464 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2465 |
+
} elseif ( $this->is_notice( $key ) ) {
|
2466 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2467 |
+
}
|
2468 |
+
|
2469 |
+
$output .= '</div>';
|
2470 |
+
|
2471 |
+
if ( $this->set_mode != 'login' && isset( $data['force_confirm_pass'] ) && $data['force_confirm_pass'] == 1 ) {
|
2472 |
+
|
2473 |
+
$key = 'confirm_' . $original_key;
|
2474 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2475 |
+
|
2476 |
+
if ( ! empty( $data['label_confirm_pass'] ) ) {
|
2477 |
+
$label_confirm_pass = __( $data['label_confirm_pass'], 'ultimate-member' );
|
2478 |
+
$output .= $this->field_label( $label_confirm_pass, $key, $data );
|
2479 |
+
} elseif ( isset( $data['label'] ) ) {
|
2480 |
+
$data['label'] = __( $data['label'], 'ultimate-member' );
|
2481 |
+
$output .= $this->field_label( sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] ), $key, $data );
|
2482 |
+
}
|
2483 |
+
|
2484 |
+
$output .= '<div class="um-field-area">';
|
2485 |
+
|
2486 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2487 |
+
|
2488 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2489 |
+
|
2490 |
+
}
|
2491 |
+
|
2492 |
+
$name = $key . UM()->form()->form_suffix;
|
2493 |
+
if ( $this->set_mode == 'password' && um_is_core_page( 'password-reset' ) ) {
|
2494 |
+
$name = $key;
|
2495 |
+
}
|
2496 |
+
|
2497 |
+
if ( ! empty( $label_confirm_pass ) ) {
|
2498 |
+
$placeholder = $label_confirm_pass;
|
2499 |
+
} elseif( ! empty( $placeholder ) && ! isset( $data['label'] ) ) {
|
2500 |
+
$placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $placeholder );
|
2501 |
+
} elseif( isset( $data['label'] ) ) {
|
2502 |
+
$placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] );
|
2503 |
+
}
|
2504 |
+
|
2505 |
+
|
2506 |
+
$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 ) . '" />';
|
2507 |
+
|
2508 |
+
|
2509 |
+
$output .= '</div>';
|
2510 |
+
|
2511 |
+
if ( $this->is_error( $key ) ) {
|
2512 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2513 |
+
}else if ( $this->is_notice( $key ) ) {
|
2514 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2515 |
+
}
|
2516 |
+
|
2517 |
+
$output .= '</div>';
|
2518 |
+
|
2519 |
+
}
|
2520 |
+
|
2521 |
+
}
|
2522 |
+
|
2523 |
+
break;
|
2524 |
+
|
2525 |
+
/* URL */
|
2526 |
+
case 'url':
|
2527 |
+
|
2528 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2529 |
+
|
2530 |
+
if ( isset( $data['label'] ) ) {
|
2531 |
+
$output .= $this->field_label( $label, $key, $data );
|
2532 |
+
}
|
2533 |
+
|
2534 |
+
$output .= '<div class="um-field-area">';
|
2535 |
+
|
2536 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2537 |
+
|
2538 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2539 |
+
|
2540 |
+
}
|
2541 |
+
|
2542 |
+
$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 ) . '" />
|
2543 |
+
|
2544 |
+
</div>';
|
2545 |
+
|
2546 |
+
if ( $this->is_error( $key ) ) {
|
2547 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2548 |
+
}else if ( $this->is_notice( $key ) ) {
|
2549 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2550 |
+
}
|
2551 |
+
|
2552 |
+
$output .= '</div>';
|
2553 |
+
break;
|
2554 |
+
|
2555 |
+
/* Date */
|
2556 |
+
case 'date':
|
2557 |
+
|
2558 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2559 |
+
|
2560 |
+
if (isset( $data['label'] )) {
|
2561 |
+
$output .= $this->field_label( $label, $key, $data );
|
2562 |
+
}
|
2563 |
+
|
2564 |
+
$output .= '<div class="um-field-area">';
|
2565 |
+
|
2566 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2567 |
+
|
2568 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2569 |
+
|
2570 |
+
}
|
2571 |
+
|
2572 |
+
$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 ) . '" />
|
2573 |
+
|
2574 |
+
</div>';
|
2575 |
+
|
2576 |
+
if ( $this->is_error( $key ) ) {
|
2577 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2578 |
+
}else if ( $this->is_notice( $key ) ) {
|
2579 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2580 |
+
}
|
2581 |
+
|
2582 |
+
$output .= '</div>';
|
2583 |
+
break;
|
2584 |
+
|
2585 |
+
/* Time */
|
2586 |
+
case 'time':
|
2587 |
+
|
2588 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2589 |
+
|
2590 |
+
if (isset( $data['label'] )) {
|
2591 |
+
$output .= $this->field_label( $label, $key, $data );
|
2592 |
+
}
|
2593 |
+
|
2594 |
+
$output .= '<div class="um-field-area">';
|
2595 |
+
|
2596 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2597 |
+
|
2598 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2599 |
+
|
2600 |
+
}
|
2601 |
+
|
2602 |
+
$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 ) . '" />
|
2603 |
+
|
2604 |
+
</div>';
|
2605 |
+
|
2606 |
+
if ( $this->is_error( $key ) ) {
|
2607 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2608 |
+
}else if ( $this->is_notice( $key ) ) {
|
2609 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2610 |
+
}
|
2611 |
+
|
2612 |
+
$output .= '</div>';
|
2613 |
+
break;
|
2614 |
+
|
2615 |
+
/* Row */
|
2616 |
+
case 'row':
|
2617 |
+
$output .= '';
|
2618 |
+
break;
|
2619 |
+
|
2620 |
+
/* Textarea */
|
2621 |
+
case 'textarea':
|
2622 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2623 |
+
|
2624 |
+
if ( isset( $data['label'] ) ) {
|
2625 |
+
$output .= $this->field_label( $label, $key, $data );
|
2626 |
+
}
|
2627 |
+
|
2628 |
+
$output .= '<div class="um-field-area">';
|
2629 |
+
|
2630 |
+
if ( isset( $data['html'] ) && $data['html'] != 0 && $key != "description" ) {
|
2631 |
+
|
2632 |
+
$textarea_settings = array(
|
2633 |
+
'media_buttons' => false,
|
2634 |
+
'wpautop' => false,
|
2635 |
+
'editor_class' => $this->get_class( $key, $data ),
|
2636 |
+
'editor_height' => $height,
|
2637 |
+
'tinymce' => array(
|
2638 |
+
'toolbar1' => 'formatselect,bullist,numlist,bold,italic,underline,forecolor,blockquote,hr,removeformat,link,unlink,undo,redo',
|
2639 |
+
'toolbar2' => '',
|
2640 |
+
)
|
2641 |
+
);
|
2642 |
+
|
2643 |
+
if ( ! empty( $disabled ) ) {
|
2644 |
+
$textarea_settings['tinymce']['readonly'] = true;
|
2645 |
+
}
|
2646 |
+
|
2647 |
+
/**
|
2648 |
+
* UM hook
|
2649 |
+
*
|
2650 |
+
* @type filter
|
2651 |
+
* @title um_form_fields_textarea_settings
|
2652 |
+
* @description Change WP Editor options for textarea init
|
2653 |
+
* @input_vars
|
2654 |
+
* [{"var":"$textarea_settings","type":"array","desc":"WP Editor settings"}]
|
2655 |
+
* @change_log
|
2656 |
+
* ["Since: 2.0"]
|
2657 |
+
* @usage add_filter( 'um_form_fields_textarea_settings', 'function_name', 10, 1 );
|
2658 |
+
* @example
|
2659 |
+
* <?php
|
2660 |
+
* add_filter( 'um_form_fields_textarea_settings', 'my_textarea_settings', 10, 1 );
|
2661 |
+
* function my_edit_field_html( $textarea_settings ) {
|
2662 |
+
* // your code here
|
2663 |
+
* return $textarea_settings;
|
2664 |
+
* }
|
2665 |
+
* ?>
|
2666 |
+
*/
|
2667 |
+
$textarea_settings = apply_filters( 'um_form_fields_textarea_settings', $textarea_settings );
|
2668 |
+
|
2669 |
+
// turn on the output buffer
|
2670 |
+
ob_start();
|
2671 |
+
|
2672 |
+
// echo the editor to the buffer
|
2673 |
+
wp_editor( $field_value, $key, $textarea_settings );
|
2674 |
+
|
2675 |
+
// add the contents of the buffer to the output variable
|
2676 |
+
$output .= ob_get_clean();
|
2677 |
+
$output .= '<br /><span class="description">' . $placeholder . '</span>';
|
2678 |
+
} else {
|
2679 |
+
$textarea_field_value = ! empty( $data['html'] ) ? $field_value : strip_tags( $field_value );
|
2680 |
+
$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>';
|
2681 |
+
}
|
2682 |
+
|
2683 |
+
$output .= '</div>';
|
2684 |
+
|
2685 |
+
if ( ! empty( $disabled ) ) {
|
2686 |
+
$output .= $this->disabled_hidden_field( $field_name, $field_value );
|
2687 |
+
}
|
2688 |
+
|
2689 |
+
if ( $this->is_error( $key ) ) {
|
2690 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2691 |
+
}else if ( $this->is_notice( $key ) ) {
|
2692 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2693 |
+
}
|
2694 |
+
|
2695 |
+
$output .= '</div>';
|
2696 |
+
break;
|
2697 |
+
|
2698 |
+
/* Rating */
|
2699 |
+
case 'rating':
|
2700 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2701 |
+
|
2702 |
+
if ( isset( $data['label'] ) ) {
|
2703 |
+
$output .= $this->field_label( $label, $key, $data );
|
2704 |
+
}
|
2705 |
+
|
2706 |
+
$output .= '<div class="um-field-area">';
|
2707 |
+
|
2708 |
+
$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>';
|
2709 |
+
$output .= '</div>';
|
2710 |
+
|
2711 |
+
if ( $this->is_error( $key ) ) {
|
2712 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2713 |
+
} elseif ( $this->is_notice( $key ) ) {
|
2714 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2715 |
+
}
|
2716 |
+
|
2717 |
+
$output .= '</div>';
|
2718 |
+
|
2719 |
+
break;
|
2720 |
+
|
2721 |
+
/* Gap/Space */
|
2722 |
+
case 'spacing':
|
2723 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data, array( 'height' => $spacing ) ) . '></div>';
|
2724 |
+
break;
|
2725 |
+
|
2726 |
+
/* A line divider */
|
2727 |
+
case 'divider':
|
2728 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data, array( 'border-bottom' => $borderwidth . 'px ' . $borderstyle . ' ' . $bordercolor ) ) . '>';
|
2729 |
+
if ( $divider_text ) {
|
2730 |
+
$output .= '<div class="um-field-divider-text"><span>' . esc_html( $divider_text ) . '</span></div>';
|
2731 |
+
}
|
2732 |
+
$output .= '</div>';
|
2733 |
+
break;
|
2734 |
+
|
2735 |
+
/* Single Image Upload */
|
2736 |
+
case 'image':
|
2737 |
+
$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' ) ) . '">';
|
2738 |
+
if ( in_array( $key, array( 'profile_photo', 'cover_photo' ) ) ) {
|
2739 |
+
$field_value = '';
|
2740 |
+
} else {
|
2741 |
+
$field_value = $this->field_value( $key, $default, $data );
|
2742 |
+
}
|
2743 |
+
$output .= '<input type="hidden" name="' . esc_attr( $key . UM()->form()->form_suffix ) . '" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '" value="' . $field_value . '" />';
|
2744 |
+
if ( isset( $data['label'] ) ) {
|
2745 |
+
$output .= $this->field_label( $label, $key, $data );
|
2746 |
+
}
|
2747 |
+
$modal_label = ( isset( $data['label'] ) ) ? $data['label'] : __( 'Upload Photo', 'ultimate-member' );
|
2748 |
+
$output .= '<div class="um-field-area" style="text-align: center;">';
|
2749 |
+
|
2750 |
+
if ( ! empty( $field_value ) && $field_value != 'empty_file' ) {
|
2751 |
+
if ( ! in_array( $key, array( 'profile_photo', 'cover_photo' ) ) ) {
|
2752 |
+
if ( isset( $this->set_mode ) && 'register' == $this->set_mode ) {
|
2753 |
+
$image_info = get_transient("um_{$field_value}");
|
2754 |
+
} else {
|
2755 |
+
$image_info = um_user( $data['metakey']."_metadata" );
|
2756 |
+
}
|
2757 |
+
|
2758 |
+
if ( ( isset( $this->set_mode ) && $this->set_mode == 'register' ) || file_exists( UM()->uploader()->get_core_temp_dir() . DIRECTORY_SEPARATOR . $field_value ) ) {
|
2759 |
+
$imgValue = UM()->uploader()->get_core_temp_url() . "/" . $this->field_value( $key, $default, $data );
|
2760 |
+
} else {
|
2761 |
+
$imgValue = UM()->files()->get_download_link( $this->set_id, $key, um_user( 'ID' ) );
|
2762 |
+
}
|
2763 |
+
$img = '<img src="' . $imgValue . '" alt="" />';
|
2764 |
+
} else {
|
2765 |
+
$img = '';
|
2766 |
+
}
|
2767 |
+
$output .= '<div class="um-single-image-preview show ' . $crop_class . '" data-crop="' . $crop_data . '" data-key="' . $key . '">';
|
2768 |
+
if ( empty( $disabled ) ) {
|
2769 |
+
$output .= '<a href="javascript:void(0);" class="cancel"><i class="um-icon-close"></i></a>';
|
2770 |
+
}
|
2771 |
+
$output .= $img;
|
2772 |
+
$output .= '</div>';
|
2773 |
+
if ( empty( $disabled ) ) {
|
2774 |
+
$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>';
|
2775 |
+
}
|
2776 |
+
|
2777 |
+
|
2778 |
+
} else {
|
2779 |
+
$output .= '<div class="um-single-image-preview ' . $crop_class . '" data-crop="' . $crop_data . '" data-key="' . $key . '">';
|
2780 |
+
if ( empty( $disabled ) ) {
|
2781 |
+
$output .= '<a href="javascript:void(0);" class="cancel"><i class="um-icon-close"></i></a>';
|
2782 |
+
}
|
2783 |
+
$output .= '<img src="" alt="" /><div class="um-clear"></div></div>';
|
2784 |
+
if ( empty( $disabled ) ) {
|
2785 |
+
$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>';
|
2786 |
+
}
|
2787 |
+
|
2788 |
+
}
|
2789 |
+
$output .= '</div>';
|
2790 |
+
/* modal hidden */
|
2791 |
+
if ( empty( $disabled ) ) {
|
2792 |
+
$output .= '<div class="um-modal-hidden-content">';
|
2793 |
+
$output .= '<div class="um-modal-header"> ' . $modal_label . '</div>';
|
2794 |
+
$output .= '<div class="um-modal-body">';
|
2795 |
+
if ( isset( $this->set_id ) ) {
|
2796 |
+
$set_id = $this->set_id;
|
2797 |
+
$set_mode = $this->set_mode;
|
2798 |
+
} else {
|
2799 |
+
$set_id = 0;
|
2800 |
+
$set_mode = '';
|
2801 |
+
}
|
2802 |
+
$nonce = wp_create_nonce( 'um_upload_nonce-' . $this->timestamp );
|
2803 |
+
$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>';
|
2804 |
+
$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>';
|
2805 |
+
$output .= '<div class="um-modal-footer">
|
2806 |
+
<div class="um-modal-right">
|
2807 |
+
<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>
|
2808 |
+
<a href="javascript:void(0);" class="um-modal-btn alt" data-action="um_remove_modal"> ' . __( 'Cancel', 'ultimate-member' ) . '</a>
|
2809 |
+
</div>
|
2810 |
+
<div class="um-clear"></div>
|
2811 |
+
</div>';
|
2812 |
+
$output .= '</div>';
|
2813 |
+
$output .= '</div>';
|
2814 |
+
}
|
2815 |
+
/* end */
|
2816 |
+
if ( $this->is_error( $key ) ) {
|
2817 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2818 |
+
}else if ( $this->is_notice( $key ) ) {
|
2819 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2820 |
+
}
|
2821 |
+
$output .= '</div>';
|
2822 |
+
|
2823 |
+
break;
|
2824 |
+
|
2825 |
+
/* Single File Upload */
|
2826 |
+
case 'file':
|
2827 |
+
$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' ) ) . '">';
|
2828 |
+
$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 ) . '" />';
|
2829 |
+
if ( isset( $data['label'] ) ) {
|
2830 |
+
$output .= $this->field_label( $label, $key, $data );
|
2831 |
+
}
|
2832 |
+
$modal_label = ( isset( $data['label'] ) ) ? $data['label'] : __( 'Upload File', 'ultimate-member' );
|
2833 |
+
$output .= '<div class="um-field-area" style="text-align: center;">';
|
2834 |
+
|
2835 |
+
$file_field_value = $this->field_value( $key, $default, $data );
|
2836 |
+
|
2837 |
+
if ( ! empty( $file_field_value ) && 'empty_file' !== $file_field_value ) {
|
2838 |
+
$file_type = wp_check_filetype( $file_field_value );
|
2839 |
+
|
2840 |
+
if ( um_is_temp_file( $file_field_value ) ) {
|
2841 |
+
$file_info = get_transient( "um_{$file_field_value}" );
|
2842 |
+
} else {
|
2843 |
+
$file_info = um_user( $data['metakey'] . "_metadata" );
|
2844 |
+
}
|
2845 |
+
|
2846 |
+
$file_field_name = $file_field_value;
|
2847 |
+
if ( ! empty( $file_info['original_name'] ) ) {
|
2848 |
+
$file_field_name = $file_info['original_name'];
|
2849 |
+
}
|
2850 |
+
|
2851 |
+
if ( ( isset( $this->set_mode ) && 'register' == $this->set_mode ) || file_exists( UM()->uploader()->get_core_temp_dir() . DIRECTORY_SEPARATOR . $file_field_value ) ) {
|
2852 |
+
$file_url = UM()->uploader()->get_core_temp_url() . DIRECTORY_SEPARATOR . $file_field_value;
|
2853 |
+
$file_dir = UM()->uploader()->get_core_temp_dir() . DIRECTORY_SEPARATOR . $file_field_value;
|
2854 |
+
} else {
|
2855 |
+
$file_url = UM()->files()->get_download_link( $this->set_id, $key, um_user( 'ID' ) );
|
2856 |
+
$file_dir = UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $this->field_value( $key, $default, $data );
|
2857 |
+
}
|
2858 |
+
|
2859 |
+
//multisite fix for old customers
|
2860 |
+
if ( ! file_exists( $file_dir ) && is_multisite() ) {
|
2861 |
+
$file_dir = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $file_dir );
|
2862 |
+
}
|
2863 |
+
|
2864 |
+
if ( file_exists( $file_dir ) ) {
|
2865 |
+
$output .= "<div class=\"um-single-file-preview show\" data-key=\"{$key}\">";
|
2866 |
+
if ( empty( $disabled ) ) {
|
2867 |
+
$output .= "<a href=\"#\" class=\"cancel\"><i class=\"um-icon-close\"></i></a>";
|
2868 |
+
}
|
2869 |
+
$output .= "<div class=\"um-single-fileinfo\">
|
2870 |
+
<a href=\"{$file_url}\" target=\"_blank\">
|
2871 |
+
<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>
|
2872 |
+
<span class=\"filename\">{$file_field_name}</span>
|
2873 |
+
</a>
|
2874 |
+
</div></div>";
|
2875 |
+
} else {
|
2876 |
+
$output .= "<div class=\"um-single-file-preview show\" data-key=\"{$key}\">" . __('This file has been removed.','ultimate-member') . "</div>";
|
2877 |
+
}
|
2878 |
+
|
2879 |
+
if ( empty( $disabled ) ) {
|
2880 |
+
$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>";
|
2881 |
+
}
|
2882 |
+
} else {
|
2883 |
+
$output .= "<div class=\"um-single-file-preview\" data-key=\"{$key}\"></div>";
|
2884 |
+
if ( empty( $disabled ) ) {
|
2885 |
+
$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>";
|
2886 |
+
}
|
2887 |
+
}
|
2888 |
+
$output .= '</div>';
|
2889 |
+
/* modal hidden */
|
2890 |
+
if ( empty( $disabled ) ) {
|
2891 |
+
$output .= '<div class="um-modal-hidden-content">';
|
2892 |
+
$output .= '<div class="um-modal-header"> ' . $modal_label . '</div>';
|
2893 |
+
$output .= '<div class="um-modal-body">';
|
2894 |
+
if ( isset( $this->set_id ) ) {
|
2895 |
+
$set_id = $this->set_id;
|
2896 |
+
$set_mode = $this->set_mode;
|
2897 |
+
} else {
|
2898 |
+
$set_id = 0;
|
2899 |
+
$set_mode = '';
|
2900 |
+
}
|
2901 |
+
$output .= '<div class="um-single-file-preview">
|
2902 |
+
<a href="javascript:void(0);" class="cancel"><i class="um-icon-close"></i></a>
|
2903 |
+
<div class="um-single-fileinfo">
|
2904 |
+
<a href="" target="_blank">
|
2905 |
+
<span class="icon"><i></i></span>
|
2906 |
+
<span class="filename"></span>
|
2907 |
+
</a>
|
2908 |
+
</div>
|
2909 |
+
</div>';
|
2910 |
+
$nonce = wp_create_nonce( 'um_upload_nonce-' . $this->timestamp );
|
2911 |
+
$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>';
|
2912 |
+
$output .= '<div class="um-modal-footer">
|
2913 |
+
<div class="um-modal-right">
|
2914 |
+
<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>
|
2915 |
+
<a href="javascript:void(0);" class="um-modal-btn alt" data-action="um_remove_modal"> ' . __( 'Cancel', 'ultimate-member' ) . '</a>
|
2916 |
+
</div>
|
2917 |
+
<div class="um-clear"></div>
|
2918 |
+
</div>';
|
2919 |
+
$output .= '</div>';
|
2920 |
+
$output .= '</div>';
|
2921 |
+
}
|
2922 |
+
/* end */
|
2923 |
+
if ( $this->is_error( $key ) ) {
|
2924 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
2925 |
+
}else if ( $this->is_notice( $key ) ) {
|
2926 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
2927 |
+
}
|
2928 |
+
$output .= '</div>';
|
2929 |
+
|
2930 |
+
break;
|
2931 |
+
|
2932 |
+
/* Select dropdown */
|
2933 |
+
case 'select':
|
2934 |
+
|
2935 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
2936 |
+
|
2937 |
+
if ( isset( $data['allowclear'] ) && $data['allowclear'] == 0 ) {
|
2938 |
+
$class = 'um-s2';
|
2939 |
+
} else {
|
2940 |
+
$class = 'um-s1';
|
2941 |
+
}
|
2942 |
+
|
2943 |
+
if ( isset( $data['label'] ) ) {
|
2944 |
+
$output .= $this->field_label( $label, $key, $data );
|
2945 |
+
}
|
2946 |
+
|
2947 |
+
$output .= '<div class="um-field-area ' . ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ? 'um-field-area-has-icon' : '' ) . ' ">';
|
2948 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
|
2949 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
2950 |
+
}
|
2951 |
+
|
2952 |
+
$options = array();
|
2953 |
+
$has_parent_option = false;
|
2954 |
+
$disabled_by_parent_option = '';
|
2955 |
+
$atts_ajax = '';
|
2956 |
+
$select_original_option_value = '';
|
2957 |
+
|
2958 |
+
if ( isset( $data[ 'options' ] ) && is_array( $data[ 'options' ] ) ) {
|
2959 |
+
$options = $data[ 'options' ];
|
2960 |
+
}
|
2961 |
+
|
2962 |
+
if ( ! empty( $data['parent_dropdown_relationship'] ) && ! UM()->user()->preview ) {
|
2963 |
+
|
2964 |
+
$disabled_by_parent_option = 'disabled = disabled';
|
2965 |
+
|
2966 |
+
$has_parent_option = true;
|
2967 |
+
|
2968 |
+
/**
|
2969 |
+
* UM hook
|
2970 |
+
*
|
2971 |
+
* @type filter
|
2972 |
+
* @title um_custom_dropdown_options_parent__{$form_key}
|
2973 |
+
* @description Change parent dropdown relationship by $form_key
|
2974 |
+
* @input_vars
|
2975 |
+
* [{"var":"$parent","type":"string","desc":"Parent dropdown relationship"},
|
2976 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
2977 |
+
* @change_log
|
2978 |
+
* ["Since: 2.0"]
|
2979 |
+
* @usage add_filter( 'um_custom_dropdown_options_parent__{$form_key}', 'function_name', 10, 2 );
|
2980 |
+
* @example
|
2981 |
+
* <?php
|
2982 |
+
* add_filter( 'um_custom_dropdown_options_parent__{$form_key}', 'my_custom_dropdown_options_parent', 10, 2 );
|
2983 |
+
* function my_custom_dropdown_options_parent( $parent, $data ) {
|
2984 |
+
* // your code here
|
2985 |
+
* return $parent;
|
2986 |
+
* }
|
2987 |
+
* ?>
|
2988 |
+
*/
|
2989 |
+
$parent_dropdown_relationship = apply_filters( "um_custom_dropdown_options_parent__{$form_key}", $data['parent_dropdown_relationship'], $data );
|
2990 |
+
$atts_ajax .= " data-um-parent='{$parent_dropdown_relationship}' ";
|
2991 |
+
|
2992 |
+
if ( ! empty( $data['custom_dropdown_options_source'] ) && $has_parent_option && function_exists( $data['custom_dropdown_options_source'] ) &&
|
2993 |
+
um_user( $data['parent_dropdown_relationship'] )
|
2994 |
+
) {
|
2995 |
+
$options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
2996 |
+
|
2997 |
+
$disabled_by_parent_option = '';
|
2998 |
+
if ( um_user( $form_key ) ) {
|
2999 |
+
$select_original_option_value = " data-um-original-value='" . um_user( $form_key ) . "' ";
|
3000 |
+
}
|
3001 |
+
}
|
3002 |
+
}
|
3003 |
+
|
3004 |
+
// Child dropdown option selected
|
3005 |
+
if ( isset( UM()->form()->post_form[ $form_key ] ) ) {
|
3006 |
+
$select_original_option_value = " data-um-original-value='" . esc_attr( UM()->form()->post_form[ $form_key ] ) . "' ";
|
3007 |
+
}
|
3008 |
+
|
3009 |
+
// Child dropdown
|
3010 |
+
if ( $has_parent_option ) {
|
3011 |
+
|
3012 |
+
if ( ! empty( $data['custom_dropdown_options_source'] ) && $has_parent_option &&
|
3013 |
+
function_exists( $data['custom_dropdown_options_source'] ) && isset( UM()->form()->post_form[ $form_key ] ) ) {
|
3014 |
+
$options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
3015 |
+
}
|
3016 |
+
}
|
3017 |
+
|
3018 |
+
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
|
3019 |
+
|
3020 |
+
/**
|
3021 |
+
* UM hook
|
3022 |
+
*
|
3023 |
+
* @type filter
|
3024 |
+
* @title um_custom_dropdown_options_source__{$form_key}
|
3025 |
+
* @description Change custom dropdown options source by $form_key
|
3026 |
+
* @input_vars
|
3027 |
+
* [{"var":"$source","type":"string","desc":"Dropdown options source"},
|
3028 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3029 |
+
* @change_log
|
3030 |
+
* ["Since: 2.0"]
|
3031 |
+
* @usage add_filter( 'um_custom_dropdown_options_source__{$form_key}', 'function_name', 10, 2 );
|
3032 |
+
* @example
|
3033 |
+
* <?php
|
3034 |
+
* add_filter( 'um_custom_dropdown_options_source__{$form_key}', 'my_custom_dropdown_options_source', 10, 2 );
|
3035 |
+
* function my_custom_dropdown_options_source( $source, $data ) {
|
3036 |
+
* // your code here
|
3037 |
+
* return $source;
|
3038 |
+
* }
|
3039 |
+
* ?>
|
3040 |
+
*/
|
3041 |
+
$ajax_source = apply_filters( "um_custom_dropdown_options_source__{$form_key}", $data['custom_dropdown_options_source'], $data );
|
3042 |
+
$atts_ajax .= ' data-um-ajax-source="' . esc_attr( $ajax_source ) . '" ';
|
3043 |
+
|
3044 |
+
/**
|
3045 |
+
* UM hook
|
3046 |
+
*
|
3047 |
+
* @type filter
|
3048 |
+
* @title um_custom_dropdown_options_source_url__{$form_key}
|
3049 |
+
* @description Change custom dropdown options source URL by $form_key
|
3050 |
+
* @input_vars
|
3051 |
+
* [{"var":"$url","type":"string","desc":"Dropdown options source URL"},
|
3052 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3053 |
+
* @change_log
|
3054 |
+
* ["Since: 2.0"]
|
3055 |
+
* @usage add_filter( 'um_custom_dropdown_options_source_url__{$form_key}', 'function_name', 10, 2 );
|
3056 |
+
* @example
|
3057 |
+
* <?php
|
3058 |
+
* add_filter( 'um_custom_dropdown_options_source_url__{$form_key}', 'my_custom_dropdown_options_source_url', 10, 2 );
|
3059 |
+
* function my_custom_dropdown_options_source( $url, $data ) {
|
3060 |
+
* // your code here
|
3061 |
+
* return $url;
|
3062 |
+
* }
|
3063 |
+
* ?>
|
3064 |
+
*/
|
3065 |
+
// todo maybe deprecate
|
3066 |
+
// $ajax_source_url = apply_filters( "um_custom_dropdown_options_source_url__{$form_key}", admin_url( 'admin-ajax.php' ), $data );
|
3067 |
+
// $atts_ajax .= ' data-um-ajax-url="' . esc_url( $ajax_source_url ) . '" ';
|
3068 |
+
|
3069 |
+
}
|
3070 |
+
|
3071 |
+
/**
|
3072 |
+
* UM hook
|
3073 |
+
*
|
3074 |
+
* @type filter
|
3075 |
+
* @title um_fields_options_enable_pairs__{$key}
|
3076 |
+
* @description Enable options pairs by field $key
|
3077 |
+
* @input_vars
|
3078 |
+
* [{"var":"$options_pairs","type":"string","desc":"Enable pairs"}]
|
3079 |
+
* @change_log
|
3080 |
+
* ["Since: 2.0"]
|
3081 |
+
* @usage add_filter( 'um_fields_options_enable_pairs__{$key}', 'function_name', 10, 1 );
|
3082 |
+
* @example
|
3083 |
+
* <?php
|
3084 |
+
* add_filter( 'um_fields_options_enable_pairs__{$key}', 'my_fields_options_enable_pairs', 10, 1 );
|
3085 |
+
* function my_fields_options_enable_pairs( $options_pairs ) {
|
3086 |
+
* // your code here
|
3087 |
+
* return $options_pairs;
|
3088 |
+
* }
|
3089 |
+
* ?>
|
3090 |
+
*/
|
3091 |
+
$enable_options_pair = apply_filters( "um_fields_options_enable_pairs__{$key}", false );
|
3092 |
+
|
3093 |
+
if ( ! $has_parent_option ) {
|
3094 |
+
if ( isset( $options ) && $options == 'builtin' ) {
|
3095 |
+
$options = UM()->builtin()->get ( $filter );
|
3096 |
+
}
|
3097 |
+
|
3098 |
+
// 'country'
|
3099 |
+
if ( $key === 'country' && empty( $options ) ) {
|
3100 |
+
$options = UM()->builtin()->get( 'countries' );
|
3101 |
+
} else if ( empty( $options ) && isset( $data['options'] ) ) {
|
3102 |
+
$options = $data['options'];
|
3103 |
+
}
|
3104 |
+
|
3105 |
+
$options = apply_filters( 'um_selectbox_options', $options, $key );
|
3106 |
+
|
3107 |
+
if ( isset( $options ) ) {
|
3108 |
+
/**
|
3109 |
+
* UM hook
|
3110 |
+
*
|
3111 |
+
* @type filter
|
3112 |
+
* @title um_select_dropdown_dynamic_options
|
3113 |
+
* @description Extend dropdown dynamic options
|
3114 |
+
* @input_vars
|
3115 |
+
* [{"var":"$options","type":"array","desc":"Dynamic options"},
|
3116 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3117 |
+
* @change_log
|
3118 |
+
* ["Since: 2.0"]
|
3119 |
+
* @usage add_filter( 'um_select_dropdown_dynamic_options', 'function_name', 10, 2 );
|
3120 |
+
* @example
|
3121 |
+
* <?php
|
3122 |
+
* add_filter( 'um_select_dropdown_dynamic_options', 'my_select_dropdown_dynamic_options', 10, 2 );
|
3123 |
+
* function my_select_dropdown_dynamic_options( $options, $data ) {
|
3124 |
+
* // your code here
|
3125 |
+
* return $options;
|
3126 |
+
* }
|
3127 |
+
* ?>
|
3128 |
+
*/
|
3129 |
+
$options = apply_filters( 'um_select_dropdown_dynamic_options', $options, $data );
|
3130 |
+
/**
|
3131 |
+
* UM hook
|
3132 |
+
*
|
3133 |
+
* @type filter
|
3134 |
+
* @title um_select_dropdown_dynamic_options_{$key}
|
3135 |
+
* @description Extend dropdown dynamic options by field $key
|
3136 |
+
* @input_vars
|
3137 |
+
* [{"var":"$options","type":"array","desc":"Dynamic options"}]
|
3138 |
+
* @change_log
|
3139 |
+
* ["Since: 2.0"]
|
3140 |
+
* @usage add_filter( 'um_select_dropdown_dynamic_options_{$key}', 'function_name', 10, 1 );
|
3141 |
+
* @example
|
3142 |
+
* <?php
|
3143 |
+
* add_filter( 'um_select_dropdown_dynamic_options_{$key}', 'my_select_dropdown_dynamic_options', 10, 1 );
|
3144 |
+
* function my_select_dropdown_dynamic_options( $options ) {
|
3145 |
+
* // your code here
|
3146 |
+
* return $options;
|
3147 |
+
* }
|
3148 |
+
* ?>
|
3149 |
+
*/
|
3150 |
+
$options = apply_filters( "um_select_dropdown_dynamic_options_{$key}", $options );
|
3151 |
+
}
|
3152 |
+
}
|
3153 |
+
|
3154 |
+
if ( $form_key === 'role' ) {
|
3155 |
+
$options = $this->get_available_roles( $form_key, $options );
|
3156 |
+
}
|
3157 |
+
|
3158 |
+
/**
|
3159 |
+
* UM hook
|
3160 |
+
*
|
3161 |
+
* @type filter
|
3162 |
+
* @title um_select_option_value
|
3163 |
+
* @description Enable options pair by field $data
|
3164 |
+
* @input_vars
|
3165 |
+
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
3166 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3167 |
+
*/
|
3168 |
+
$options_pair = apply_filters( 'um_select_options_pair', null, $data );
|
3169 |
+
|
3170 |
+
// switch options pair for custom options from a callback function
|
3171 |
+
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
|
3172 |
+
$options_pair = true;
|
3173 |
+
}
|
3174 |
+
|
3175 |
+
$field_value = '';
|
3176 |
+
|
3177 |
+
if ( ! empty( $placeholder ) && is_string( $placeholder ) ) {
|
3178 |
+
$placeholder = strip_tags( $placeholder );
|
3179 |
+
}
|
3180 |
+
|
3181 |
+
$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 . '>';
|
3182 |
+
|
3183 |
+
$output .= '<option value=""></option>';
|
3184 |
+
|
3185 |
+
// add options
|
3186 |
+
if ( ! empty( $options ) ) {
|
3187 |
+
foreach ( $options as $k => $v ) {
|
3188 |
+
|
3189 |
+
$v = rtrim( $v );
|
3190 |
+
|
3191 |
+
$option_value = $v;
|
3192 |
+
$um_field_checkbox_item_title = $v;
|
3193 |
+
|
3194 |
+
|
3195 |
+
if ( ! is_numeric( $k ) && in_array( $form_key, array( 'role' ) ) ||
|
3196 |
+
( $this->set_mode == 'account' || um_is_core_page( 'account' ) ) ) {
|
3197 |
+
$option_value = $k;
|
3198 |
+
$um_field_checkbox_item_title = $v;
|
3199 |
+
}
|
3200 |
+
|
3201 |
+
if ( isset( $options_pair ) ) {
|
3202 |
+
$option_value = $k;
|
3203 |
+
$um_field_checkbox_item_title = $v;
|
3204 |
+
}
|
3205 |
+
|
3206 |
+
$option_value = $this->filter_field_non_utf8_value( $option_value );
|
3207 |
+
|
3208 |
+
$output .= '<option value="' . $option_value . '" ';
|
3209 |
+
|
3210 |
+
if ( $this->is_selected( $form_key, $option_value, $data ) ) {
|
3211 |
+
$output .= 'selected';
|
3212 |
+
$field_value = $option_value;
|
3213 |
+
} elseif ( ! isset( $options_pair ) && $this->is_selected( $form_key, $v, $data ) ) {
|
3214 |
+
$output .= 'selected';
|
3215 |
+
$field_value = $v;
|
3216 |
+
}
|
3217 |
+
|
3218 |
+
$output .= '>' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</option>';
|
3219 |
+
}
|
3220 |
+
}
|
3221 |
+
|
3222 |
+
if ( ! empty( $disabled ) ) {
|
3223 |
+
$output .= $this->disabled_hidden_field( $form_key, $field_value );
|
3224 |
+
}
|
3225 |
+
|
3226 |
+
$output .= '</select>';
|
3227 |
+
|
3228 |
+
$output .= '</div>';
|
3229 |
+
|
3230 |
+
|
3231 |
+
if ( $this->is_error( $form_key ) ) {
|
3232 |
+
$output .= $this->field_error( $this->show_error( $form_key ) );
|
3233 |
+
} elseif ( $this->is_notice( $form_key ) ) {
|
3234 |
+
$output .= $this->field_notice( $this->show_notice( $form_key ) );
|
3235 |
+
}
|
3236 |
+
|
3237 |
+
|
3238 |
+
$output .= '</div>';
|
3239 |
+
break;
|
3240 |
+
|
3241 |
+
/* Multi-Select dropdown */
|
3242 |
+
case 'multiselect':
|
3243 |
+
|
3244 |
+
$max_selections = ( isset( $max_selections ) ) ? absint( $max_selections ) : 0;
|
3245 |
+
|
3246 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
3247 |
+
|
3248 |
+
if ( isset( $data['allowclear'] ) && $data['allowclear'] == 0 ) {
|
3249 |
+
$class = 'um-s2';
|
3250 |
+
} else {
|
3251 |
+
$class = 'um-s1';
|
3252 |
+
}
|
3253 |
+
|
3254 |
+
if ( isset( $data['label'] ) ) {
|
3255 |
+
$output .= $this->field_label( $label, $key, $data );
|
3256 |
+
}
|
3257 |
+
|
3258 |
+
$field_icon = false;
|
3259 |
+
$field_icon_output = '';
|
3260 |
+
|
3261 |
+
/**
|
3262 |
+
* UM hook
|
3263 |
+
*
|
3264 |
+
* @type filter
|
3265 |
+
* @title um_multiselect_option_value
|
3266 |
+
* @description Change multiselect keyword data
|
3267 |
+
* @input_vars
|
3268 |
+
* [{"var":"$keyword","type":"int","desc":"Option Value"},
|
3269 |
+
* {"var":"$type","type":"string","desc":"Field Type"}]
|
3270 |
+
* @change_log
|
3271 |
+
* ["Since: 2.0"]
|
3272 |
+
* @usage add_filter( 'um_multiselect_option_value', 'function_name', 10, 2 );
|
3273 |
+
* @example
|
3274 |
+
* <?php
|
3275 |
+
* add_filter( 'um_multiselect_option_value', 'my_multiselect_option_value', 10, 2 );
|
3276 |
+
* function my_multiselect_option_value( $keyword, $type ) {
|
3277 |
+
* // your code here
|
3278 |
+
* return $keyword;
|
3279 |
+
* }
|
3280 |
+
* ?>
|
3281 |
+
*/
|
3282 |
+
$use_keyword = apply_filters( 'um_multiselect_option_value', 0, $data['type'] );
|
3283 |
+
|
3284 |
+
$output .= '<div class="um-field-area ' . (! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field' ? 'um-field-area-has-icon' : '' ) . ' ">';
|
3285 |
+
if ( ! empty( $icon ) && isset( $this->field_icons ) && $this->field_icons == 'field') {
|
3286 |
+
$output .= '<div class="um-field-icon"><i class="' . esc_attr( $icon ) . '"></i></div>';
|
3287 |
+
}
|
3288 |
+
|
3289 |
+
$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 ) . '">';
|
3290 |
+
|
3291 |
+
|
3292 |
+
if ( isset( $options ) && $options == 'builtin' ) {
|
3293 |
+
$options = UM()->builtin()->get( $filter );
|
3294 |
+
}
|
3295 |
+
|
3296 |
+
if ( ! isset( $options ) ) {
|
3297 |
+
$options = UM()->builtin()->get( 'countries' );
|
3298 |
+
}
|
3299 |
+
|
3300 |
+
if ( isset( $options ) ) {
|
3301 |
+
/**
|
3302 |
+
* UM hook
|
3303 |
+
*
|
3304 |
+
* @type filter
|
3305 |
+
* @title um_multiselect_options
|
3306 |
+
* @description Extend multiselect options
|
3307 |
+
* @input_vars
|
3308 |
+
* [{"var":"$options","type":"array","desc":"Multiselect Options"},
|
3309 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3310 |
+
* @change_log
|
3311 |
+
* ["Since: 2.0"]
|
3312 |
+
* @usage add_filter( 'um_multiselect_options', 'function_name', 10, 2 );
|
3313 |
+
* @example
|
3314 |
+
* <?php
|
3315 |
+
* add_filter( 'um_multiselect_options', 'my_multiselect_options', 10, 2 );
|
3316 |
+
* function my_multiselect_options( $options, $data ) {
|
3317 |
+
* // your code here
|
3318 |
+
* return $options;
|
3319 |
+
* }
|
3320 |
+
* ?>
|
3321 |
+
*/
|
3322 |
+
$options = apply_filters( 'um_multiselect_options', $options, $data );
|
3323 |
+
/**
|
3324 |
+
* UM hook
|
3325 |
+
*
|
3326 |
+
* @type filter
|
3327 |
+
* @title um_multiselect_options_{$key}
|
3328 |
+
* @description Extend multiselect options by field $key
|
3329 |
+
* @input_vars
|
3330 |
+
* [{"var":"$options","type":"array","desc":"Multiselect Options"}]
|
3331 |
+
* @change_log
|
3332 |
+
* ["Since: 2.0"]
|
3333 |
+
* @usage add_filter( 'um_multiselect_options_{$key}', 'function_name', 10, 1 );
|
3334 |
+
* @example
|
3335 |
+
* <?php
|
3336 |
+
* add_filter( 'um_multiselect_options_{$key}', 'my_multiselect_options', 10, 1 );
|
3337 |
+
* function my_multiselect_options( $options ) {
|
3338 |
+
* // your code here
|
3339 |
+
* return $options;
|
3340 |
+
* }
|
3341 |
+
* ?>
|
3342 |
+
*/
|
3343 |
+
$options = apply_filters( "um_multiselect_options_{$key}", $options );
|
3344 |
+
/**
|
3345 |
+
* UM hook
|
3346 |
+
*
|
3347 |
+
* @type filter
|
3348 |
+
* @title um_multiselect_options_{$type}
|
3349 |
+
* @description Extend multiselect options by field $type
|
3350 |
+
* @input_vars
|
3351 |
+
* [{"var":"$options","type":"array","desc":"Multiselect Options"},
|
3352 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3353 |
+
* @change_log
|
3354 |
+
* ["Since: 2.0"]
|
3355 |
+
* @usage add_filter( 'um_multiselect_options_{$type}', 'function_name', 10, 2 );
|
3356 |
+
* @example
|
3357 |
+
* <?php
|
3358 |
+
* add_filter( 'um_multiselect_options_{$type}', 'my_multiselect_options', 10, 2 );
|
3359 |
+
* function my_multiselect_option_value( $options, $data ) {
|
3360 |
+
* // your code here
|
3361 |
+
* return $options;
|
3362 |
+
* }
|
3363 |
+
* ?>
|
3364 |
+
*/
|
3365 |
+
$options = apply_filters( "um_multiselect_options_{$data['type']}", $options, $data );
|
3366 |
+
}
|
3367 |
+
|
3368 |
+
/**
|
3369 |
+
* UM hook
|
3370 |
+
*
|
3371 |
+
* @type filter
|
3372 |
+
* @title um_select_option_value
|
3373 |
+
* @description Enable options pair by field $data
|
3374 |
+
* @input_vars
|
3375 |
+
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
3376 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3377 |
+
*/
|
3378 |
+
$use_keyword = apply_filters( 'um_select_options_pair', null, $data );
|
3379 |
+
|
3380 |
+
// switch options pair for custom options from a callback function
|
3381 |
+
if ( ! empty( $data['custom_dropdown_options_source'] ) ) {
|
3382 |
+
$use_keyword = true;
|
3383 |
+
}
|
3384 |
+
|
3385 |
+
// add an empty option!
|
3386 |
+
$output .= '<option value=""></option>';
|
3387 |
+
|
3388 |
+
$arr_selected = array();
|
3389 |
+
// add options
|
3390 |
+
if ( ! empty( $options ) && is_array( $options ) ) {
|
3391 |
+
foreach ( $options as $k => $v ) {
|
3392 |
+
|
3393 |
+
$v = rtrim( $v );
|
3394 |
+
|
3395 |
+
$um_field_checkbox_item_title = $v;
|
3396 |
+
$opt_value = $v;
|
3397 |
+
|
3398 |
+
if ( $use_keyword ) {
|
3399 |
+
$um_field_checkbox_item_title = $v;
|
3400 |
+
$opt_value = $k;
|
3401 |
+
}
|
3402 |
+
|
3403 |
+
$opt_value = $this->filter_field_non_utf8_value( $opt_value );
|
3404 |
+
|
3405 |
+
$output .= '<option value="' . $opt_value . '" ';
|
3406 |
+
if ( $this->is_selected( $key, $opt_value, $data ) ) {
|
3407 |
+
|
3408 |
+
$output .= 'selected';
|
3409 |
+
$arr_selected[ $opt_value ] = $opt_value;
|
3410 |
+
}
|
3411 |
+
|
3412 |
+
$output .= '>' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</option>';
|
3413 |
+
|
3414 |
+
}
|
3415 |
+
}
|
3416 |
+
|
3417 |
+
$output .= '</select>';
|
3418 |
+
|
3419 |
+
if ( ! empty( $disabled ) && ! empty( $arr_selected ) ) {
|
3420 |
+
foreach ( $arr_selected as $item ) {
|
3421 |
+
$output .= $this->disabled_hidden_field( $key . '[]', $item );
|
3422 |
+
}
|
3423 |
+
}
|
3424 |
+
|
3425 |
+
$output .= '</div>';
|
3426 |
+
|
3427 |
+
|
3428 |
+
if ( $this->is_error( $key ) ) {
|
3429 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
3430 |
+
}else if ( $this->is_notice( $key ) ) {
|
3431 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
3432 |
+
}
|
3433 |
+
|
3434 |
+
$output .= '</div>';
|
3435 |
+
break;
|
3436 |
+
|
3437 |
+
/* Radio */
|
3438 |
+
case 'radio':
|
3439 |
+
|
3440 |
+
if ( isset( $options ) ) {
|
3441 |
+
/**
|
3442 |
+
* UM hook
|
3443 |
+
*
|
3444 |
+
* @type filter
|
3445 |
+
* @title um_radio_field_options
|
3446 |
+
* @description Extend radio field options
|
3447 |
+
* @input_vars
|
3448 |
+
* [{"var":"$options","type":"array","desc":"Radio Field Options"},
|
3449 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3450 |
+
* @change_log
|
3451 |
+
* ["Since: 2.0"]
|
3452 |
+
* @usage add_filter( 'um_radio_field_options', 'function_name', 10, 2 );
|
3453 |
+
* @example
|
3454 |
+
* <?php
|
3455 |
+
* add_filter( 'um_radio_field_options', 'my_radio_field_options', 10, 2 );
|
3456 |
+
* function my_radio_field_options( $options, $data ) {
|
3457 |
+
* // your code here
|
3458 |
+
* return $options;
|
3459 |
+
* }
|
3460 |
+
* ?>
|
3461 |
+
*/
|
3462 |
+
$options = apply_filters( 'um_radio_field_options', $options, $data );
|
3463 |
+
/**
|
3464 |
+
* UM hook
|
3465 |
+
*
|
3466 |
+
* @type filter
|
3467 |
+
* @title um_radio_field_options_{$key}
|
3468 |
+
* @description Extend radio field options by field $key
|
3469 |
+
* @input_vars
|
3470 |
+
* [{"var":"$options","type":"array","desc":"Radio field Options"}]
|
3471 |
+
* @change_log
|
3472 |
+
* ["Since: 2.0"]
|
3473 |
+
* @usage add_filter( 'um_radio_field_options_{$key}', 'function_name', 10, 1 );
|
3474 |
+
* @example
|
3475 |
+
* <?php
|
3476 |
+
* add_filter( 'um_radio_field_options_{$key}', 'my_radio_field_options', 10, 1 );
|
3477 |
+
* function my_radio_field_options( $options ) {
|
3478 |
+
* // your code here
|
3479 |
+
* return $options;
|
3480 |
+
* }
|
3481 |
+
* ?>
|
3482 |
+
*/
|
3483 |
+
$options = apply_filters( "um_radio_field_options_{$key}", $options );
|
3484 |
+
}
|
3485 |
+
|
3486 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
3487 |
+
|
3488 |
+
if ( isset( $data['label'] ) ) {
|
3489 |
+
$output .= $this->field_label( $label, $key, $data );
|
3490 |
+
}
|
3491 |
+
|
3492 |
+
$output .= '<div class="um-field-area">';
|
3493 |
+
|
3494 |
+
$options = $this->get_available_roles( $form_key, $options );
|
3495 |
+
|
3496 |
+
// add options
|
3497 |
+
$i = 0;
|
3498 |
+
$field_value = array();
|
3499 |
+
|
3500 |
+
/**
|
3501 |
+
* UM hook
|
3502 |
+
*
|
3503 |
+
* @type filter
|
3504 |
+
* @title um_radio_option_value
|
3505 |
+
* @description Enable options pair by field $data
|
3506 |
+
* @input_vars
|
3507 |
+
* [{"var":"$options_pair","type":"null","desc":"Enable pairs"},
|
3508 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3509 |
+
*/
|
3510 |
+
$options_pair = apply_filters( "um_radio_options_pair__{$key}", false, $data );
|
3511 |
+
|
3512 |
+
|
3513 |
+
if ( ! empty( $options ) ) {
|
3514 |
+
foreach ( $options as $k => $v ) {
|
3515 |
+
|
3516 |
+
$v = rtrim( $v );
|
3517 |
+
|
3518 |
+
$um_field_checkbox_item_title = $v;
|
3519 |
+
$option_value = $v;
|
3520 |
+
|
3521 |
+
if ( ! is_numeric( $k ) && in_array( $form_key, array( 'role' ) ) ||
|
3522 |
+
( $this->set_mode == 'account' || um_is_core_page( 'account' ) ) ) {
|
3523 |
+
$um_field_checkbox_item_title = $v;
|
3524 |
+
$option_value = $k;
|
3525 |
+
}
|
3526 |
+
|
3527 |
+
if( $options_pair ){
|
3528 |
+
$um_field_checkbox_item_title = $v;
|
3529 |
+
$option_value = $k;
|
3530 |
+
}
|
3531 |
+
|
3532 |
+
$i++;
|
3533 |
+
if ($i % 2 == 0) {
|
3534 |
+
$col_class = 'right';
|
3535 |
+
} else {
|
3536 |
+
$col_class = '';
|
3537 |
+
}
|
3538 |
+
|
3539 |
+
if ( $this->is_radio_checked( $key, $option_value, $data ) ) {
|
3540 |
+
$active = 'active';
|
3541 |
+
$class = "um-icon-android-radio-button-on";
|
3542 |
+
} else {
|
3543 |
+
$active = '';
|
3544 |
+
$class = "um-icon-android-radio-button-off";
|
3545 |
+
}
|
3546 |
+
|
3547 |
+
|
3548 |
+
if ( isset( $data['editable'] ) && $data['editable'] == 0 ) {
|
3549 |
+
$col_class .= " um-field-radio-state-disabled";
|
3550 |
+
}
|
3551 |
+
|
3552 |
+
$output .= '<label class="um-field-radio ' . esc_attr( $active ) . ' um-field-half ' . esc_attr( $col_class ) . '">';
|
3553 |
+
|
3554 |
+
$option_value = $this->filter_field_non_utf8_value( $option_value );
|
3555 |
+
|
3556 |
+
$output .= '<input ' . $disabled . ' type="radio" name="' . ( ( $form_key == 'role' ) ? esc_attr( $form_key ) : esc_attr( $form_key ) . '[]' ) . '" value="' . $option_value . '" ';
|
3557 |
+
|
3558 |
+
if ( $this->is_radio_checked( $key, $option_value, $data ) ) {
|
3559 |
+
$output .= 'checked';
|
3560 |
+
$field_value[ $key ] = $option_value;
|
3561 |
+
}
|
3562 |
+
|
3563 |
+
$output .= ' />';
|
3564 |
+
|
3565 |
+
$output .= '<span class="um-field-radio-state"><i class="' . esc_attr( $class ) . '"></i></span>';
|
3566 |
+
$output .= '<span class="um-field-radio-option">' . esc_html__( $um_field_checkbox_item_title, 'ultimate-member' ) . '</span>';
|
3567 |
+
$output .= '</label>';
|
3568 |
+
|
3569 |
+
if ( $i % 2 == 0 ) {
|
3570 |
+
$output .= '<div class="um-clear"></div>';
|
3571 |
+
}
|
3572 |
+
|
3573 |
+
}
|
3574 |
+
}
|
3575 |
+
|
3576 |
+
if ( ! empty( $disabled ) ) {
|
3577 |
+
foreach ( $field_value as $item ) {
|
3578 |
+
$output .= $this->disabled_hidden_field( $form_key, $item );
|
3579 |
+
}
|
3580 |
+
}
|
3581 |
+
|
3582 |
+
$output .= '<div class="um-clear"></div>';
|
3583 |
+
|
3584 |
+
$output .= '</div>';
|
3585 |
+
|
3586 |
+
if ( $this->is_error( $key ) ) {
|
3587 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
3588 |
+
}else if ( $this->is_notice( $key ) ) {
|
3589 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
3590 |
+
}
|
3591 |
+
|
3592 |
+
$output .= '</div>';
|
3593 |
+
break;
|
3594 |
+
|
3595 |
+
/* Checkbox */
|
3596 |
+
case 'checkbox':
|
3597 |
+
|
3598 |
+
if ( isset( $options ) ) {
|
3599 |
+
/**
|
3600 |
+
* UM hook
|
3601 |
+
*
|
3602 |
+
* @type filter
|
3603 |
+
* @title um_checkbox_field_options
|
3604 |
+
* @description Extend checkbox options
|
3605 |
+
* @input_vars
|
3606 |
+
* [{"var":"$options","type":"array","desc":"Checkbox Options"},
|
3607 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3608 |
+
* @change_log
|
3609 |
+
* ["Since: 2.0"]
|
3610 |
+
* @usage add_filter( 'um_checkbox_field_options', 'function_name', 10, 2 );
|
3611 |
+
* @example
|
3612 |
+
* <?php
|
3613 |
+
* add_filter( 'um_checkbox_field_options', 'my_checkbox_options', 10, 2 );
|
3614 |
+
* function my_checkbox_options( $options, $data ) {
|
3615 |
+
* // your code here
|
3616 |
+
* return $options;
|
3617 |
+
* }
|
3618 |
+
* ?>
|
3619 |
+
*/
|
3620 |
+
$options = apply_filters( 'um_checkbox_field_options', $options, $data );
|
3621 |
+
/**
|
3622 |
+
* UM hook
|
3623 |
+
*
|
3624 |
+
* @type filter
|
3625 |
+
* @title um_checkbox_field_options_{$key}
|
3626 |
+
* @description Extend checkbox options by field $key
|
3627 |
+
* @input_vars
|
3628 |
+
* [{"var":"$options","type":"array","desc":"Checkbox Options"}]
|
3629 |
+
* @change_log
|
3630 |
+
* ["Since: 2.0"]
|
3631 |
+
* @usage add_filter( 'um_checkbox_field_options_{$key}', 'function_name', 10, 1 );
|
3632 |
+
* @example
|
3633 |
+
* <?php
|
3634 |
+
* add_filter( 'um_checkbox_field_options_{$key}', 'my_checkbox_options', 10, 1 );
|
3635 |
+
* function my_checkbox_options( $options ) {
|
3636 |
+
* // your code here
|
3637 |
+
* return $options;
|
3638 |
+
* }
|
3639 |
+
* ?>
|
3640 |
+
*/
|
3641 |
+
$options = apply_filters( "um_checkbox_field_options_{$key}", $options );
|
3642 |
+
}
|
3643 |
+
|
3644 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
3645 |
+
|
3646 |
+
if ( isset( $data['label'] ) ) {
|
3647 |
+
$output .= $this->field_label( $label, $key, $data );
|
3648 |
+
}
|
3649 |
+
|
3650 |
+
$output .= '<div class="um-field-area">';
|
3651 |
+
|
3652 |
+
// add options
|
3653 |
+
$i = 0;
|
3654 |
+
|
3655 |
+
foreach ( $options as $k => $v ) {
|
3656 |
+
|
3657 |
+
$v = rtrim( $v );
|
3658 |
+
|
3659 |
+
$i++;
|
3660 |
+
if ( $i % 2 == 0 ) {
|
3661 |
+
$col_class = 'right';
|
3662 |
+
} else {
|
3663 |
+
$col_class = '';
|
3664 |
+
}
|
3665 |
+
|
3666 |
+
if ( $this->is_selected( $key, $v, $data ) ) {
|
3667 |
+
$active = 'active';
|
3668 |
+
$class = "um-icon-android-checkbox-outline";
|
3669 |
+
} else {
|
3670 |
+
$active = '';
|
3671 |
+
$class = "um-icon-android-checkbox-outline-blank";
|
3672 |
+
}
|
3673 |
+
|
3674 |
+
if ( isset( $data['editable'] ) && $data['editable'] == 0 ) {
|
3675 |
+
$col_class .= " um-field-radio-state-disabled";
|
3676 |
+
}
|
3677 |
+
|
3678 |
+
$output .= '<label class="um-field-checkbox ' . esc_attr( $active ) . ' um-field-half ' . esc_attr( $col_class ) . '">';
|
3679 |
+
|
3680 |
+
$um_field_checkbox_item_title = $v;
|
3681 |
+
|
3682 |
+
$v = $this->filter_field_non_utf8_value( $v );
|
3683 |
+
|
3684 |
+
$output .= '<input ' . $disabled . ' type="checkbox" name="' . esc_attr( $key ) . '[]" value="' . strip_tags( $v ) . '" ';
|
3685 |
+
|
3686 |
+
if ( $this->is_selected( $key, $v, $data ) ) {
|
3687 |
+
$output .= 'checked';
|
3688 |
+
}
|
3689 |
+
|
3690 |
+
$output .= ' />';
|
3691 |
+
|
3692 |
+
if ( ! empty( $disabled ) && $this->is_selected( $key, $v, $data ) ) {
|
3693 |
+
$output .= $this->disabled_hidden_field( $key . '[]', strip_tags( $v ) );
|
3694 |
+
}
|
3695 |
+
|
3696 |
+
|
3697 |
+
$output .= '<span class="um-field-checkbox-state"><i class="' . esc_attr( $class ) . '"></i></span>';
|
3698 |
+
/**
|
3699 |
+
* UM hook
|
3700 |
+
*
|
3701 |
+
* @type filter
|
3702 |
+
* @title um_field_checkbox_item_title
|
3703 |
+
* @description Change Checkbox item title
|
3704 |
+
* @input_vars
|
3705 |
+
* [{"var":"$checkbox_item_title","type":"array","desc":"Item Title"},
|
3706 |
+
* {"var":"$key","type":"string","desc":"Field Key"},
|
3707 |
+
* {"var":"$value","type":"string","desc":"Field Value"},
|
3708 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
3709 |
+
* @change_log
|
3710 |
+
* ["Since: 2.0"]
|
3711 |
+
* @usage add_filter( 'um_field_checkbox_item_title', 'function_name', 10, 4 );
|
3712 |
+
* @example
|
3713 |
+
* <?php
|
3714 |
+
* add_filter( 'um_field_checkbox_item_title', 'my_checkbox_item_title', 10, 4 );
|
3715 |
+
* function my_checkbox_item_title( $checkbox_item_title, $key, $value, $data ) {
|
3716 |
+
* // your code here
|
3717 |
+
* return $checkbox_item_title;
|
3718 |
+
* }
|
3719 |
+
* ?>
|
3720 |
+
*/
|
3721 |
+
$um_field_checkbox_item_title = apply_filters( 'um_field_checkbox_item_title', $um_field_checkbox_item_title, $key, $v, $data );
|
3722 |
+
$output .= '<span class="um-field-checkbox-option">' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</span>';
|
3723 |
+
$output .= '</label>';
|
3724 |
+
|
3725 |
+
if ( $i % 2 == 0 ) {
|
3726 |
+
$output .= '<div class="um-clear"></div>';
|
3727 |
+
}
|
3728 |
+
|
3729 |
+
}
|
3730 |
+
|
3731 |
+
$output .= '<div class="um-clear"></div>';
|
3732 |
+
|
3733 |
+
$output .= '</div>';
|
3734 |
+
|
3735 |
+
|
3736 |
+
if ( $this->is_error( $key ) ) {
|
3737 |
+
$output .= $this->field_error( $this->show_error( $key ) );
|
3738 |
+
}else if ( $this->is_notice( $key ) ) {
|
3739 |
+
$output .= $this->field_notice( $this->show_notice( $key ) );
|
3740 |
+
}
|
3741 |
+
|
3742 |
+
$output .= '</div>';
|
3743 |
+
break;
|
3744 |
+
|
3745 |
+
/* HTML */
|
3746 |
+
case 'block':
|
3747 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '</div>';
|
3748 |
+
break;
|
3749 |
+
|
3750 |
+
/* Shortcode */
|
3751 |
+
case 'shortcode':
|
3752 |
+
|
3753 |
+
$content = str_replace( '{profile_id}', um_profile_id(), $content );
|
3754 |
+
if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
|
3755 |
+
$content = do_shortcode( $content );
|
3756 |
+
} else {
|
3757 |
+
$content = apply_shortcodes( $content );
|
3758 |
+
}
|
3759 |
+
|
3760 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '</div>';
|
3761 |
+
break;
|
3762 |
+
|
3763 |
+
/* Unlimited Group */
|
3764 |
+
case 'group':
|
3765 |
+
|
3766 |
+
$fields = $this->get_fields_in_group( $key );
|
3767 |
+
if ( ! empty( $fields ) ) {
|
3768 |
+
|
3769 |
+
$output .= '<div class="um-field-group" data-max_entries="' . $max_entries . '">
|
3770 |
+
<div class="um-field-group-head"><i class="um-icon-plus"></i>' . esc_html__( $label, 'ultimate-member' ) . '</div>';
|
3771 |
+
$output .= '<div class="um-field-group-body"><a href="javascript:void(0);" class="um-field-group-cancel"><i class="um-icon-close"></i></a>';
|
3772 |
+
|
3773 |
+
foreach ( $fields as $subkey => $subdata ) {
|
3774 |
+
$output .= $this->edit_field( $subkey, $subdata, 'group' );
|
3775 |
+
}
|
3776 |
+
|
3777 |
+
$output .= '</div>';
|
3778 |
+
$output .= '</div>';
|
3779 |
+
|
3780 |
+
}
|
3781 |
+
|
3782 |
+
break;
|
3783 |
+
|
3784 |
+
}
|
3785 |
+
|
3786 |
+
// Custom filter for field output
|
3787 |
+
if ( isset( $this->set_mode ) ) {
|
3788 |
+
/**
|
3789 |
+
* UM hook
|
3790 |
+
*
|
3791 |
+
* @type filter
|
3792 |
+
* @title um_{$key}_form_edit_field
|
3793 |
+
* @description Change field HTML on edit mode by field $key
|
3794 |
+
* @input_vars
|
3795 |
+
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
3796 |
+
* {"var":"$mode","type":"string","desc":"Fields Mode"}]
|
3797 |
+
* @change_log
|
3798 |
+
* ["Since: 2.0"]
|
3799 |
+
* @usage add_filter( 'um_{$key}_form_edit_field', 'function_name', 10, 2 );
|
3800 |
+
* @example
|
3801 |
+
* <?php
|
3802 |
+
* add_filter( 'um_{$key}_form_edit_field', 'my_form_edit_field', 10, 2 );
|
3803 |
+
* function my_form_edit_field( $output, $mode ) {
|
3804 |
+
* // your code here
|
3805 |
+
* return $output;
|
3806 |
+
* }
|
3807 |
+
* ?>
|
3808 |
+
*/
|
3809 |
+
$output = apply_filters( "um_{$key}_form_edit_field", $output, $this->set_mode );
|
3810 |
+
}
|
3811 |
+
|
3812 |
+
return $output;
|
3813 |
+
}
|
3814 |
+
|
3815 |
+
|
3816 |
+
/**
|
3817 |
+
* Filter for user roles
|
3818 |
+
*
|
3819 |
+
* @param $form_key
|
3820 |
+
* @param array $options
|
3821 |
+
* @return array
|
3822 |
+
*/
|
3823 |
+
function get_available_roles( $form_key, $options = array() ) {
|
3824 |
+
if ( $form_key != 'role' ) {
|
3825 |
+
return $options;
|
3826 |
+
}
|
3827 |
+
|
3828 |
+
// role field
|
3829 |
+
global $wp_roles;
|
3830 |
+
$role_keys = array_map( function( $item ) {
|
3831 |
+
return 'um_' . $item;
|
3832 |
+
}, get_option( 'um_roles', array() ) );
|
3833 |
+
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
3834 |
+
|
3835 |
+
$roles = UM()->roles()->get_roles( false, $exclude_roles );
|
3836 |
+
|
3837 |
+
if ( ! empty( $options ) ) {
|
3838 |
+
|
3839 |
+
$roles = array_map( function( $item ) {
|
3840 |
+
return html_entity_decode( $item, ENT_QUOTES );
|
3841 |
+
}, $roles );
|
3842 |
+
|
3843 |
+
//fix when customers change options for role (radio/dropdown) fields
|
3844 |
+
$intersected_options = array();
|
3845 |
+
foreach ( $options as $key => $title ) {
|
3846 |
+
if ( false !== $search_key = array_search( $title, $roles ) ) {
|
3847 |
+
$intersected_options[ $search_key ] = $title;
|
3848 |
+
} elseif ( isset( $roles[ $key ] ) ) {
|
3849 |
+
$intersected_options[ $key ] = $title;
|
3850 |
+
}
|
3851 |
+
}
|
3852 |
+
|
3853 |
+
$options = $intersected_options;
|
3854 |
+
} else {
|
3855 |
+
$options = $roles;
|
3856 |
+
}
|
3857 |
+
|
3858 |
+
return $options;
|
3859 |
+
}
|
3860 |
+
|
3861 |
+
|
3862 |
+
/**
|
3863 |
+
* Sorts columns array
|
3864 |
+
*
|
3865 |
+
* @param array $arr
|
3866 |
+
* @param string $col
|
3867 |
+
* @param string $dir
|
3868 |
+
*
|
3869 |
+
* @return array $arr
|
3870 |
+
*/
|
3871 |
+
function array_sort_by_column( $arr, $col, $dir = SORT_ASC ) {
|
3872 |
+
$sort_col = array();
|
3873 |
+
foreach ( $arr as $key => $row ) {
|
3874 |
+
if ( $key == 'form_id' ) {
|
3875 |
+
unset( $arr['form_id'] );
|
3876 |
+
continue;
|
3877 |
+
}
|
3878 |
+
|
3879 |
+
if ( isset( $row[ $col ] ) ) {
|
3880 |
+
$sort_col[ $key ] = $row[ $col ];
|
3881 |
+
} else {
|
3882 |
+
unset( $arr[ $key ] );
|
3883 |
+
}
|
3884 |
+
}
|
3885 |
+
|
3886 |
+
array_multisort( $sort_col, $dir, $arr );
|
3887 |
+
|
3888 |
+
return $arr;
|
3889 |
+
}
|
3890 |
+
|
3891 |
+
|
3892 |
+
/**
|
3893 |
+
* Get fields in row
|
3894 |
+
*
|
3895 |
+
* @param int $row_id
|
3896 |
+
*
|
3897 |
+
* @return string
|
3898 |
+
*/
|
3899 |
+
function get_fields_by_row( $row_id ) {
|
3900 |
+
if ( ! isset( $this->get_fields ) ) {
|
3901 |
+
return '';
|
3902 |
+
}
|
3903 |
+
|
3904 |
+
foreach ( $this->get_fields as $key => $array ) {
|
3905 |
+
if ( ! isset( $array['in_row'] ) || ( isset( $array['in_row'] ) && $array['in_row'] == $row_id ) ) {
|
3906 |
+
$results[ $key ] = $array;
|
3907 |
+
}
|
3908 |
+
}
|
3909 |
+
|
3910 |
+
return ( isset ( $results ) ) ? $results : '';
|
3911 |
+
}
|
3912 |
+
|
3913 |
+
|
3914 |
+
/**
|
3915 |
+
* Get fields by sub row
|
3916 |
+
*
|
3917 |
+
* @param string $row_fields
|
3918 |
+
* @param integer $subrow_id
|
3919 |
+
*
|
3920 |
+
* @return mixed
|
3921 |
+
*/
|
3922 |
+
function get_fields_in_subrow( $row_fields, $subrow_id ) {
|
3923 |
+
if ( ! is_array( $row_fields ) ) {
|
3924 |
+
return '';
|
3925 |
+
}
|
3926 |
+
foreach ( $row_fields as $key => $array ) {
|
3927 |
+
if ( ! isset( $array['in_sub_row'] ) || ( isset( $array['in_sub_row'] ) && $array['in_sub_row'] == $subrow_id ) ) {
|
3928 |
+
$results[ $key ] = $array;
|
3929 |
+
}
|
3930 |
+
}
|
3931 |
+
|
3932 |
+
return ( isset ( $results ) ) ? $results : '';
|
3933 |
+
}
|
3934 |
+
|
3935 |
+
|
3936 |
+
/**
|
3937 |
+
* Get fields in group
|
3938 |
+
*
|
3939 |
+
* @param integer $group_id
|
3940 |
+
*
|
3941 |
+
* @return mixed
|
3942 |
+
*/
|
3943 |
+
function get_fields_in_group( $group_id ) {
|
3944 |
+
foreach ( $this->get_fields as $key => $array ) {
|
3945 |
+
if ( isset( $array['in_group'] ) && $array['in_group'] == $group_id ) {
|
3946 |
+
$results[ $key ] = $array;
|
3947 |
+
}
|
3948 |
+
}
|
3949 |
+
|
3950 |
+
return ( isset ( $results ) ) ? $results : '';
|
3951 |
+
}
|
3952 |
+
|
3953 |
+
|
3954 |
+
/**
|
3955 |
+
* Get fields in column
|
3956 |
+
*
|
3957 |
+
* @param array $fields
|
3958 |
+
* @param integer $col_number
|
3959 |
+
*
|
3960 |
+
* @return mixed
|
3961 |
+
*/
|
3962 |
+
function get_fields_in_column( $fields, $col_number ) {
|
3963 |
+
foreach ( $fields as $key => $array ) {
|
3964 |
+
if ( isset( $array['in_column'] ) && $array['in_column'] == $col_number ) {
|
3965 |
+
$results[ $key ] = $array;
|
3966 |
+
}
|
3967 |
+
}
|
3968 |
+
|
3969 |
+
return ( isset ( $results ) ) ? $results : '';
|
3970 |
+
}
|
3971 |
+
|
3972 |
+
|
3973 |
+
/**
|
3974 |
+
* Display fields
|
3975 |
+
*
|
3976 |
+
* @param string $mode
|
3977 |
+
* @param array $args
|
3978 |
+
*
|
3979 |
+
* @return string|null
|
3980 |
+
* @throws \Exception
|
3981 |
+
*/
|
3982 |
+
function display( $mode, $args ) {
|
3983 |
+
$output = null;
|
3984 |
+
|
3985 |
+
$this->global_args = $args;
|
3986 |
+
|
3987 |
+
UM()->form()->form_suffix = '-' . $this->global_args['form_id'];
|
3988 |
+
|
3989 |
+
$this->set_mode = $mode;
|
3990 |
+
|
3991 |
+
if ( 'profile' === $mode ) {
|
3992 |
+
UM()->form()->nonce = wp_create_nonce( 'um-profile-nonce' . UM()->user()->target_id );
|
3993 |
+
}
|
3994 |
+
|
3995 |
+
$this->set_id = $this->global_args['form_id'];
|
3996 |
+
|
3997 |
+
$this->field_icons = ( isset( $this->global_args['icons'] ) ) ? $this->global_args['icons'] : 'label';
|
3998 |
+
|
3999 |
+
// start output here
|
4000 |
+
$this->get_fields = $this->get_fields();
|
4001 |
+
|
4002 |
+
if ( ! empty( $this->get_fields ) ) {
|
4003 |
+
|
4004 |
+
// find rows
|
4005 |
+
foreach ( $this->get_fields as $key => $array ) {
|
4006 |
+
if ( $array['type'] == 'row' ) {
|
4007 |
+
$this->rows[ $key ] = $array;
|
4008 |
+
unset( $this->get_fields[ $key ] ); // not needed anymore
|
4009 |
+
}
|
4010 |
+
}
|
4011 |
+
|
4012 |
+
// rows fallback
|
4013 |
+
if ( ! isset( $this->rows ) ) {
|
4014 |
+
$this->rows = array(
|
4015 |
+
'_um_row_1' => array(
|
4016 |
+
'type' => 'row',
|
4017 |
+
'id' => '_um_row_1',
|
4018 |
+
'sub_rows' => 1,
|
4019 |
+
'cols' => 1,
|
4020 |
+
),
|
4021 |
+
);
|
4022 |
+
}
|
4023 |
+
|
4024 |
+
// master rows
|
4025 |
+
foreach ( $this->rows as $row_id => $row_array ) {
|
4026 |
+
|
4027 |
+
$row_fields = $this->get_fields_by_row( $row_id );
|
4028 |
+
if ( $row_fields ) {
|
4029 |
+
|
4030 |
+
$output .= $this->new_row_output( $row_id, $row_array );
|
4031 |
+
|
4032 |
+
$sub_rows = ( isset( $row_array['sub_rows'] ) ) ? $row_array['sub_rows'] : 1;
|
4033 |
+
for ( $c = 0; $c < $sub_rows; $c++ ) {
|
4034 |
+
|
4035 |
+
// cols
|
4036 |
+
$cols = isset( $row_array['cols'] ) ? $row_array['cols'] : 1;
|
4037 |
+
if ( is_numeric( $cols ) ) {
|
4038 |
+
$cols_num = (int) $cols;
|
4039 |
+
} else {
|
4040 |
+
if ( strstr( $cols, ':' ) ) {
|
4041 |
+
$col_split = explode( ':', $cols );
|
4042 |
+
} else {
|
4043 |
+
$col_split = array( $cols );
|
4044 |
+
}
|
4045 |
+
$cols_num = $col_split[ $c ];
|
4046 |
+
}
|
4047 |
+
|
4048 |
+
// sub row fields
|
4049 |
+
$subrow_fields = null;
|
4050 |
+
$subrow_fields = $this->get_fields_in_subrow( $row_fields, $c );
|
4051 |
+
|
4052 |
+
if ( is_array( $subrow_fields ) ) {
|
4053 |
+
|
4054 |
+
$subrow_fields = $this->array_sort_by_column( $subrow_fields, 'position' );
|
4055 |
+
|
4056 |
+
if ( $cols_num == 1 ) {
|
4057 |
+
|
4058 |
+
$output .= '<div class="um-col-1">';
|
4059 |
+
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4060 |
+
if ( $col1_fields ) {
|
4061 |
+
foreach ( $col1_fields as $key => $data ) {
|
4062 |
+
$output .= $this->edit_field( $key, $data );
|
4063 |
+
}
|
4064 |
+
}
|
4065 |
+
$output .= '</div>';
|
4066 |
+
|
4067 |
+
} else if ($cols_num == 2) {
|
4068 |
+
|
4069 |
+
$output .= '<div class="um-col-121">';
|
4070 |
+
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4071 |
+
if ( $col1_fields ) {
|
4072 |
+
foreach ( $col1_fields as $key => $data ) {
|
4073 |
+
$output .= $this->edit_field( $key, $data );
|
4074 |
+
}
|
4075 |
+
}
|
4076 |
+
$output .= '</div>';
|
4077 |
+
|
4078 |
+
$output .= '<div class="um-col-122">';
|
4079 |
+
$col2_fields = $this->get_fields_in_column( $subrow_fields, 2 );
|
4080 |
+
if ( $col2_fields ) {
|
4081 |
+
foreach ( $col2_fields as $key => $data ) {
|
4082 |
+
$output .= $this->edit_field( $key, $data );
|
4083 |
+
}
|
4084 |
+
}
|
4085 |
+
$output .= '</div><div class="um-clear"></div>';
|
4086 |
+
|
4087 |
+
} else {
|
4088 |
+
|
4089 |
+
$output .= '<div class="um-col-131">';
|
4090 |
+
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4091 |
+
if ( $col1_fields ) {
|
4092 |
+
foreach ( $col1_fields as $key => $data ) {
|
4093 |
+
$output .= $this->edit_field( $key, $data );
|
4094 |
+
}
|
4095 |
+
}
|
4096 |
+
$output .= '</div>';
|
4097 |
+
|
4098 |
+
$output .= '<div class="um-col-132">';
|
4099 |
+
$col2_fields = $this->get_fields_in_column( $subrow_fields, 2 );
|
4100 |
+
if ( $col2_fields ) {
|
4101 |
+
foreach ( $col2_fields as $key => $data ) {
|
4102 |
+
$output .= $this->edit_field( $key, $data );
|
4103 |
+
}
|
4104 |
+
}
|
4105 |
+
$output .= '</div>';
|
4106 |
+
|
4107 |
+
$output .= '<div class="um-col-133">';
|
4108 |
+
$col3_fields = $this->get_fields_in_column( $subrow_fields, 3 );
|
4109 |
+
if ( $col3_fields ) {
|
4110 |
+
foreach ( $col3_fields as $key => $data ) {
|
4111 |
+
$output .= $this->edit_field( $key, $data );
|
4112 |
+
}
|
4113 |
+
}
|
4114 |
+
$output .= '</div><div class="um-clear"></div>';
|
4115 |
+
|
4116 |
+
}
|
4117 |
+
|
4118 |
+
}
|
4119 |
+
|
4120 |
+
}
|
4121 |
+
|
4122 |
+
$output .= '</div>';
|
4123 |
+
|
4124 |
+
}
|
4125 |
+
|
4126 |
+
}
|
4127 |
+
|
4128 |
+
}
|
4129 |
+
|
4130 |
+
return $output;
|
4131 |
+
}
|
4132 |
+
|
4133 |
+
|
4134 |
+
/**
|
4135 |
+
* Gets a field in `view mode`
|
4136 |
+
*
|
4137 |
+
* @param string $key
|
4138 |
+
* @param array $data
|
4139 |
+
* @param bool $rule
|
4140 |
+
*
|
4141 |
+
* @return string|null
|
4142 |
+
* @throws \Exception
|
4143 |
+
*/
|
4144 |
+
function view_field( $key, $data, $rule = false ) {
|
4145 |
+
$output = '';
|
4146 |
+
|
4147 |
+
// get whole field data
|
4148 |
+
if ( is_array( $data ) ) {
|
4149 |
+
$data = $this->get_field( $key );
|
4150 |
+
|
4151 |
+
if ( is_array( $data ) ) {
|
4152 |
+
/**
|
4153 |
+
* @var $visibility
|
4154 |
+
* @var $type
|
4155 |
+
* @var $default
|
4156 |
+
* @var $classes
|
4157 |
+
* @var $conditional
|
4158 |
+
* @var $content
|
4159 |
+
* @var $divider_text
|
4160 |
+
* @var $spacing
|
4161 |
+
* @var $borderwidth
|
4162 |
+
* @var $borderstyle
|
4163 |
+
* @var $bordercolor
|
4164 |
+
* @var $label
|
4165 |
+
*/
|
4166 |
+
extract( $data );
|
4167 |
+
}
|
4168 |
+
}
|
4169 |
+
|
4170 |
+
//hide if empty type
|
4171 |
+
if ( ! isset( $data['type'] ) ) {
|
4172 |
+
return '';
|
4173 |
+
}
|
4174 |
+
|
4175 |
+
if ( isset( $data['in_group'] ) && $data['in_group'] != '' && $rule != 'group' ) {
|
4176 |
+
return '';
|
4177 |
+
}
|
4178 |
+
|
4179 |
+
//invisible on profile page
|
4180 |
+
if ( $visibility == 'edit' || $type == 'password' ) {
|
4181 |
+
return '';
|
4182 |
+
}
|
4183 |
+
|
4184 |
+
//hide if empty
|
4185 |
+
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
4186 |
+
if ( ! in_array( $type, $fields_without_metakey ) ) {
|
4187 |
+
$_field_value = $this->field_value( $key, $default, $data );
|
4188 |
+
|
4189 |
+
if ( ! isset( $_field_value ) || $_field_value == '' ) {
|
4190 |
+
return '';
|
4191 |
+
}
|
4192 |
+
}
|
4193 |
+
|
4194 |
+
if ( ! um_can_view_field( $data ) ) {
|
4195 |
+
return '';
|
4196 |
+
}
|
4197 |
+
|
4198 |
+
// disable these fields in profile view only
|
4199 |
+
if ( in_array( $key, array( 'user_password' ) ) && $this->set_mode == 'profile' ) {
|
4200 |
+
return '';
|
4201 |
+
}
|
4202 |
+
|
4203 |
+
if ( ! um_field_conditions_are_met( $data ) ) {
|
4204 |
+
return '';
|
4205 |
+
}
|
4206 |
+
|
4207 |
+
|
4208 |
+
if ( isset( $data['classes'] ) ) {
|
4209 |
+
$classes = explode( " ", $data['classes'] );
|
4210 |
+
}
|
4211 |
+
|
4212 |
+
switch ( $type ) {
|
4213 |
+
|
4214 |
+
/* Default */
|
4215 |
+
default:
|
4216 |
+
|
4217 |
+
$_field_value = $this->field_value( $key, $default, $data );
|
4218 |
+
|
4219 |
+
if ( ! in_array( $type, $fields_without_metakey ) && ( ! isset( $_field_value ) || $_field_value == '' ) ) {
|
4220 |
+
$output = '';
|
4221 |
+
} else {
|
4222 |
+
|
4223 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
4224 |
+
|
4225 |
+
if ( isset( $data['label'] ) || ! empty( $data['icon'] ) ) {
|
4226 |
+
|
4227 |
+
if ( ! isset( $data['label'] ) ) {
|
4228 |
+
$data['label'] = '';
|
4229 |
+
}
|
4230 |
+
|
4231 |
+
$output .= $this->field_label( $data['label'], $key, $data );
|
4232 |
+
}
|
4233 |
+
|
4234 |
+
$res = $this->field_value( $key, $default, $data );
|
4235 |
+
|
4236 |
+
if ( ! empty( $res ) ) {
|
4237 |
+
$res = stripslashes( $res );
|
4238 |
+
}
|
4239 |
+
if ( 'description' === $data['metakey'] ) {
|
4240 |
+
if ( UM()->options()->get( 'profile_show_html_bio' ) ) {
|
4241 |
+
$res = make_clickable( wpautop( wp_kses_post( $res ) ) );
|
4242 |
+
} else {
|
4243 |
+
$res = esc_html( $res );
|
4244 |
+
}
|
4245 |
+
|
4246 |
+
$res = nl2br( $res );
|
4247 |
+
}
|
4248 |
+
|
4249 |
+
$data['is_view_field'] = true;
|
4250 |
+
/**
|
4251 |
+
* UM hook
|
4252 |
+
*
|
4253 |
+
* @type filter
|
4254 |
+
* @title um_view_field
|
4255 |
+
* @description Change field HTML on view mode
|
4256 |
+
* @input_vars
|
4257 |
+
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
4258 |
+
* {"var":"$data","type":"string","desc":"Field Data"},
|
4259 |
+
* {"var":"$type","type":"string","desc":"Field Type"}]
|
4260 |
+
* @change_log
|
4261 |
+
* ["Since: 2.0"]
|
4262 |
+
* @usage add_filter( 'um_view_field', 'function_name', 10, 3 );
|
4263 |
+
* @example
|
4264 |
+
* <?php
|
4265 |
+
* add_filter( 'um_view_field', 'my_view_field', 10, 3 );
|
4266 |
+
* function my_form_edit_field( $output, $data, $type ) {
|
4267 |
+
* // your code here
|
4268 |
+
* return $output;
|
4269 |
+
* }
|
4270 |
+
* ?>
|
4271 |
+
*/
|
4272 |
+
$res = apply_filters( 'um_view_field', $res, $data, $type );
|
4273 |
+
/**
|
4274 |
+
* UM hook
|
4275 |
+
*
|
4276 |
+
* @type filter
|
4277 |
+
* @title um_view_field_value_{$type}
|
4278 |
+
* @description Change field HTML on view mode by field type
|
4279 |
+
* @input_vars
|
4280 |
+
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
4281 |
+
* {"var":"$data","type":"string","desc":"Field Data"}]
|
4282 |
+
* @change_log
|
4283 |
+
* ["Since: 2.0"]
|
4284 |
+
* @usage add_filter( 'um_view_field_value_{$type}', 'function_name', 10, 2 );
|
4285 |
+
* @example
|
4286 |
+
* <?php
|
4287 |
+
* add_filter( 'um_view_field_value_{$type}', 'my_view_field', 10, 2 );
|
4288 |
+
* function my_form_edit_field( $output, $data ) {
|
4289 |
+
* // your code here
|
4290 |
+
* return $output;
|
4291 |
+
* }
|
4292 |
+
* ?>
|
4293 |
+
*/
|
4294 |
+
$res = apply_filters( "um_view_field_value_{$type}", $res, $data );
|
4295 |
+
|
4296 |
+
$id_attr = '';
|
4297 |
+
if ( ! in_array( $type, $fields_without_metakey ) ) {
|
4298 |
+
$id_attr = ' id="' . esc_attr( $key . UM()->form()->form_suffix ) . '"';
|
4299 |
+
}
|
4300 |
+
|
4301 |
+
if ( empty( $res ) ) {
|
4302 |
+
$output = '';
|
4303 |
+
} else {
|
4304 |
+
$output .= '<div class="um-field-area">';
|
4305 |
+
$output .= '<div class="um-field-value"' . $id_attr . '>' . $res . '</div>';
|
4306 |
+
$output .= '</div>';
|
4307 |
+
|
4308 |
+
$output .= '</div>';
|
4309 |
+
}
|
4310 |
+
}
|
4311 |
+
|
4312 |
+
break;
|
4313 |
+
|
4314 |
+
/* HTML */
|
4315 |
+
case 'block':
|
4316 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '</div>';
|
4317 |
+
break;
|
4318 |
+
|
4319 |
+
/* Shortcode */
|
4320 |
+
case 'shortcode':
|
4321 |
+
|
4322 |
+
$content = str_replace( '{profile_id}', um_profile_id(), $content );
|
4323 |
+
if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
|
4324 |
+
$content = do_shortcode( $content );
|
4325 |
+
} else {
|
4326 |
+
$content = apply_shortcodes( $content );
|
4327 |
+
}
|
4328 |
+
|
4329 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>' . $content . '</div>';
|
4330 |
+
break;
|
4331 |
+
|
4332 |
+
/* Gap/Space */
|
4333 |
+
case 'spacing':
|
4334 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data, array( 'height' => $spacing ) ) . '></div>';
|
4335 |
+
break;
|
4336 |
+
|
4337 |
+
/* A line divider */
|
4338 |
+
case 'divider':
|
4339 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data, array( 'border-bottom' => $borderwidth . 'px ' . $borderstyle . ' ' . $bordercolor ) ) . '>';
|
4340 |
+
if ( $divider_text ) {
|
4341 |
+
$output .= '<div class="um-field-divider-text"><span>' . $divider_text . '</span></div>';
|
4342 |
+
}
|
4343 |
+
$output .= '</div>';
|
4344 |
+
break;
|
4345 |
+
|
4346 |
+
/* Rating */
|
4347 |
+
case 'rating':
|
4348 |
+
|
4349 |
+
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
|
4350 |
+
|
4351 |
+
if ( isset( $data['label'] ) || ! empty( $data['icon'] ) ) {
|
4352 |
+
$output .= $this->field_label( $label, $key, $data );
|
4353 |
+
}
|
4354 |
+
|
4355 |
+
ob_start(); ?>
|
4356 |
+
|
4357 |
+
<div class="um-field-area">
|
4358 |
+
<div class="um-field-value">
|
4359 |
+
<div class="um-rating-readonly um-raty" id="<?php echo esc_attr( $key ) ?>"
|
4360 |
+
data-key="<?php echo esc_attr( $key ) ?>" data-number="<?php echo esc_attr( $data['number'] ) ?>"
|
4361 |
+
data-score="<?php echo $this->field_value( $key, $default, $data ) ?>"></div>
|
4362 |
+
</div>
|
4363 |
+
</div>
|
4364 |
+
|
4365 |
+
<?php $output .= ob_get_clean();
|
4366 |
+
$output .= '</div>';
|
4367 |
+
|
4368 |
+
break;
|
4369 |
+
|
4370 |
+
}
|
4371 |
+
|
4372 |
+
// Custom filter for field output
|
4373 |
+
if ( isset( $this->set_mode ) ) {
|
4374 |
+
/**
|
4375 |
+
* UM hook
|
4376 |
+
*
|
4377 |
+
* @type filter
|
4378 |
+
* @title um_{$key}_form_show_field
|
4379 |
+
* @description Change field HTML by field $key
|
4380 |
+
* @input_vars
|
4381 |
+
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
4382 |
+
* {"var":"$mode","type":"string","desc":"Form Mode"}]
|
4383 |
+
* @change_log
|
4384 |
+
* ["Since: 2.0"]
|
4385 |
+
* @usage add_filter( 'um_{$key}_form_show_field', 'function_name', 10, 2 );
|
4386 |
+
* @example
|
4387 |
+
* <?php
|
4388 |
+
* add_filter( 'um_{$key}_form_show_field', 'my_form_show_field', 10, 2 );
|
4389 |
+
* function my_form_show_field( $output, $mode ) {
|
4390 |
+
* // your code here
|
4391 |
+
* return $output;
|
4392 |
+
* }
|
4393 |
+
* ?>
|
4394 |
+
*/
|
4395 |
+
$output = apply_filters( "um_{$key}_form_show_field", $output, $this->set_mode );
|
4396 |
+
/**
|
4397 |
+
* UM hook
|
4398 |
+
*
|
4399 |
+
* @type filter
|
4400 |
+
* @title um_{$type}_form_show_field
|
4401 |
+
* @description Change field HTML by field $type
|
4402 |
+
* @input_vars
|
4403 |
+
* [{"var":"$output","type":"string","desc":"Field HTML"},
|
4404 |
+
* {"var":"$mode","type":"string","desc":"Form Mode"}]
|
4405 |
+
* @change_log
|
4406 |
+
* ["Since: 2.0"]
|
4407 |
+
* @usage add_filter( 'um_{$type}_form_show_field', 'function_name', 10, 2 );
|
4408 |
+
* @example
|
4409 |
+
* <?php
|
4410 |
+
* add_filter( 'um_{$type}_form_show_field', 'my_form_show_field', 10, 2 );
|
4411 |
+
* function my_form_show_field( $output, $mode ) {
|
4412 |
+
* // your code here
|
4413 |
+
* return $output;
|
4414 |
+
* }
|
4415 |
+
* ?>
|
4416 |
+
*/
|
4417 |
+
$output = apply_filters( "um_{$type}_form_show_field", $output, $this->set_mode );
|
4418 |
+
}
|
4419 |
+
|
4420 |
+
return $output;
|
4421 |
+
}
|
4422 |
+
|
4423 |
+
|
4424 |
+
/**
|
4425 |
+
* Filter field data
|
4426 |
+
*
|
4427 |
+
* @param array $data
|
4428 |
+
*
|
4429 |
+
* @return array
|
4430 |
+
*/
|
4431 |
+
function view_field_output( $data ) {
|
4432 |
+
/**
|
4433 |
+
* UM hook
|
4434 |
+
*
|
4435 |
+
* @type filter
|
4436 |
+
* @title um_view_field_output_{$type}
|
4437 |
+
* @description Change field data output by $type
|
4438 |
+
* @input_vars
|
4439 |
+
* [{"var":"$data","type":"array","desc":"Field Data"}]
|
4440 |
+
* @change_log
|
4441 |
+
* ["Since: 2.0"]
|
4442 |
+
* @usage add_filter( 'um_view_field_output_{$type}', 'function_name', 10, 1 );
|
4443 |
+
* @example
|
4444 |
+
* <?php
|
4445 |
+
* add_filter( 'um_view_field_output_{$type}', 'my_view_field_output', 10, 1 );
|
4446 |
+
* function my_view_field_output( $data ) {
|
4447 |
+
* // your code here
|
4448 |
+
* return $data;
|
4449 |
+
* }
|
4450 |
+
* ?>
|
4451 |
+
*/
|
4452 |
+
return apply_filters( "um_view_field_output_" . $data['type'], $data );
|
4453 |
+
}
|
4454 |
+
|
4455 |
+
|
4456 |
+
/**
|
4457 |
+
* Display fields ( view mode )
|
4458 |
+
*
|
4459 |
+
* @param string $mode
|
4460 |
+
* @param array $args
|
4461 |
+
*
|
4462 |
+
* @return string|null
|
4463 |
+
* @throws \Exception
|
4464 |
+
*/
|
4465 |
+
function display_view( $mode, $args ) {
|
4466 |
+
$output = null;
|
4467 |
+
|
4468 |
+
$this->global_args = $args;
|
4469 |
+
|
4470 |
+
UM()->form()->form_suffix = '-' . $this->global_args['form_id'];
|
4471 |
+
|
4472 |
+
$this->set_mode = $mode;
|
4473 |
+
$this->set_id = $this->global_args['form_id'];
|
4474 |
+
|
4475 |
+
$this->field_icons = ( isset( $this->global_args['icons'] ) ) ? $this->global_args['icons'] : 'label';
|
4476 |
+
|
4477 |
+
// start output here
|
4478 |
+
$this->get_fields = $this->get_fields();
|
4479 |
+
|
4480 |
+
if ( UM()->options()->get( 'profile_empty_text' ) ) {
|
4481 |
+
|
4482 |
+
$emo = UM()->options()->get( 'profile_empty_text_emo' );
|
4483 |
+
if ( $emo ) {
|
4484 |
+
$emo = '<i class="um-faicon-frown-o"></i>';
|
4485 |
+
} else {
|
4486 |
+
$emo = false;
|
4487 |
+
}
|
4488 |
+
|
4489 |
+
if ( um_is_myprofile() ) {
|
4490 |
+
$output .= '<p class="um-profile-note">' . $emo . '<span>' . sprintf( __( 'Your profile is looking a little empty. Why not <a href="%s">add</a> some information!', 'ultimate-member' ), esc_url( um_edit_profile_url() ) ) . '</span></p>';
|
4491 |
+
} else {
|
4492 |
+
$output .= '<p class="um-profile-note">' . $emo . '<span>' . __( 'This user has not added any information to their profile yet.', 'ultimate-member' ) . '</span></p>';
|
4493 |
+
}
|
4494 |
+
}
|
4495 |
+
|
4496 |
+
if ( ! empty( $this->get_fields ) ) {
|
4497 |
+
|
4498 |
+
// find rows
|
4499 |
+
foreach ( $this->get_fields as $key => $array ) {
|
4500 |
+
if ( $array['type'] == 'row' ) {
|
4501 |
+
$this->rows[ $key ] = $array;
|
4502 |
+
unset( $this->get_fields[ $key ] ); // not needed anymore
|
4503 |
+
}
|
4504 |
+
}
|
4505 |
+
|
4506 |
+
// rows fallback
|
4507 |
+
if ( ! isset( $this->rows ) ) {
|
4508 |
+
$this->rows = array(
|
4509 |
+
'_um_row_1' => array(
|
4510 |
+
'type' => 'row',
|
4511 |
+
'id' => '_um_row_1',
|
4512 |
+
'sub_rows' => 1,
|
4513 |
+
'cols' => 1,
|
4514 |
+
),
|
4515 |
+
);
|
4516 |
+
}
|
4517 |
+
|
4518 |
+
// master rows
|
4519 |
+
foreach ( $this->rows as $row_id => $row_array ) {
|
4520 |
+
|
4521 |
+
$row_fields = $this->get_fields_by_row( $row_id );
|
4522 |
+
|
4523 |
+
if ( $row_fields ) {
|
4524 |
+
|
4525 |
+
$output .= $this->new_row_output( $row_id, $row_array );
|
4526 |
+
|
4527 |
+
$sub_rows = ( isset( $row_array['sub_rows'] ) ) ? $row_array['sub_rows'] : 1;
|
4528 |
+
for ( $c = 0; $c < $sub_rows; $c++ ) {
|
4529 |
+
|
4530 |
+
// cols
|
4531 |
+
$cols = isset( $row_array['cols'] ) ? $row_array['cols'] : 1;
|
4532 |
+
if ( is_numeric( $cols ) ) {
|
4533 |
+
$cols_num = (int) $cols;
|
4534 |
+
} else {
|
4535 |
+
if ( strstr( $cols, ':' ) ) {
|
4536 |
+
$col_split = explode( ':', $cols );
|
4537 |
+
} else {
|
4538 |
+
$col_split = array( $cols );
|
4539 |
+
}
|
4540 |
+
$cols_num = $col_split[ $c ];
|
4541 |
+
}
|
4542 |
+
|
4543 |
+
// sub row fields
|
4544 |
+
$subrow_fields = null;
|
4545 |
+
$subrow_fields = $this->get_fields_in_subrow( $row_fields, $c );
|
4546 |
+
|
4547 |
+
if ( is_array( $subrow_fields ) ) {
|
4548 |
+
|
4549 |
+
$subrow_fields = $this->array_sort_by_column( $subrow_fields, 'position' );
|
4550 |
+
|
4551 |
+
if ( $cols_num == 1 ) {
|
4552 |
+
|
4553 |
+
$output .= '<div class="um-col-1">';
|
4554 |
+
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4555 |
+
if ( $col1_fields ) {
|
4556 |
+
foreach ( $col1_fields as $key => $data ) {
|
4557 |
+
|
4558 |
+
$data = $this->view_field_output( $data );
|
4559 |
+
$output .= $this->view_field( $key, $data );
|
4560 |
+
|
4561 |
+
}
|
4562 |
+
}
|
4563 |
+
$output .= '</div>';
|
4564 |
+
|
4565 |
+
} elseif ( $cols_num == 2 ) {
|
4566 |
+
|
4567 |
+
$output .= '<div class="um-col-121">';
|
4568 |
+
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4569 |
+
if ( $col1_fields ) {
|
4570 |
+
foreach ( $col1_fields as $key => $data ) {
|
4571 |
+
|
4572 |
+
$data = $this->view_field_output( $data );
|
4573 |
+
$output .= $this->view_field( $key, $data );
|
4574 |
+
|
4575 |
+
}
|
4576 |
+
}
|
4577 |
+
$output .= '</div>';
|
4578 |
+
|
4579 |
+
$output .= '<div class="um-col-122">';
|
4580 |
+
$col2_fields = $this->get_fields_in_column( $subrow_fields, 2 );
|
4581 |
+
if ( $col2_fields ) {
|
4582 |
+
foreach ( $col2_fields as $key => $data ) {
|
4583 |
+
|
4584 |
+
$data = $this->view_field_output( $data );
|
4585 |
+
$output .= $this->view_field( $key, $data );
|
4586 |
+
|
4587 |
+
}
|
4588 |
+
}
|
4589 |
+
$output .= '</div><div class="um-clear"></div>';
|
4590 |
+
|
4591 |
+
} else {
|
4592 |
+
|
4593 |
+
$output .= '<div class="um-col-131">';
|
4594 |
+
$col1_fields = $this->get_fields_in_column( $subrow_fields, 1 );
|
4595 |
+
if ( $col1_fields ) {
|
4596 |
+
foreach ( $col1_fields as $key => $data ) {
|
4597 |
+
|
4598 |
+
$data = $this->view_field_output( $data );
|
4599 |
+
$output .= $this->view_field( $key, $data );
|
4600 |
+
|
4601 |
+
}
|
4602 |
+
}
|
4603 |
+
$output .= '</div>';
|
4604 |
+
|
4605 |
+
$output .= '<div class="um-col-132">';
|
4606 |
+
$col2_fields = $this->get_fields_in_column( $subrow_fields, 2 );
|
4607 |
+
if ( $col2_fields ) {
|
4608 |
+
foreach ( $col2_fields as $key => $data ) {
|
4609 |
+
|
4610 |
+
$data = $this->view_field_output( $data );
|
4611 |
+
$output .= $this->view_field( $key, $data );
|
4612 |
+
|
4613 |
+
}
|
4614 |
+
}
|
4615 |
+
$output .= '</div>';
|
4616 |
+
|
4617 |
+
$output .= '<div class="um-col-133">';
|
4618 |
+
$col3_fields = $this->get_fields_in_column( $subrow_fields, 3 );
|
4619 |
+
if ( $col3_fields ) {
|
4620 |
+
foreach ( $col3_fields as $key => $data ) {
|
4621 |
+
|
4622 |
+
$data = $this->view_field_output( $data );
|
4623 |
+
$output .= $this->view_field( $key, $data );
|
4624 |
+
|
4625 |
+
}
|
4626 |
+
}
|
4627 |
+
$output .= '</div><div class="um-clear"></div>';
|
4628 |
+
|
4629 |
+
}
|
4630 |
+
|
4631 |
+
}
|
4632 |
+
|
4633 |
+
}
|
4634 |
+
|
4635 |
+
$output .= '</div>';
|
4636 |
+
|
4637 |
+
}
|
4638 |
+
|
4639 |
+
}
|
4640 |
+
|
4641 |
+
}
|
4642 |
+
|
4643 |
+
return $output;
|
4644 |
+
}
|
4645 |
+
|
4646 |
+
|
4647 |
+
/**
|
4648 |
+
* Get new row in form
|
4649 |
+
*
|
4650 |
+
* @param string $row_id
|
4651 |
+
* @param array $row_array
|
4652 |
+
*
|
4653 |
+
* @return string
|
4654 |
+
*/
|
4655 |
+
function new_row_output( $row_id, $row_array ) {
|
4656 |
+
$output = null;
|
4657 |
+
extract( $row_array );
|
4658 |
+
|
4659 |
+
$padding = ( isset( $padding ) ) ? $padding : '';
|
4660 |
+
$margin = ( isset( $margin ) ) ? $margin : '';
|
4661 |
+
$background = ( isset( $background ) ) ? $background : '';
|
4662 |
+
$text_color = ( isset( $text_color ) ) ? $text_color : '';
|
4663 |
+
$borderradius = ( isset( $borderradius ) ) ? $borderradius : '';
|
4664 |
+
$border = ( isset( $border ) ) ? $border : '';
|
4665 |
+
$bordercolor = ( isset( $bordercolor ) ) ? $bordercolor : '';
|
4666 |
+
$borderstyle = ( isset( $borderstyle ) ) ? $borderstyle : '';
|
4667 |
+
$heading = ( isset( $heading ) ) ? $heading : '';
|
4668 |
+
$css_class = ( isset( $css_class ) ) ? $css_class : '';
|
4669 |
+
|
4670 |
+
$css_padding = '';
|
4671 |
+
$css_margin = '';
|
4672 |
+
$css_background = '';
|
4673 |
+
$css_borderradius = '';
|
4674 |
+
$css_border = '';
|
4675 |
+
$css_bordercolor = '';
|
4676 |
+
$css_borderstyle = '';
|
4677 |
+
$css_heading_background_color = '';
|
4678 |
+
$css_heading_padding = '';
|
4679 |
+
$css_heading_text_color = '';
|
4680 |
+
$css_heading_borderradius = '';
|
4681 |
+
$css_text_color = '';
|
4682 |
+
|
4683 |
+
// row css rules
|
4684 |
+
if ( $padding ) {
|
4685 |
+
$css_padding = 'padding: ' . $padding . ';';
|
4686 |
+
}
|
4687 |
+
if ( $margin ) {
|
4688 |
+
$css_margin = 'margin: ' . $margin . ';';
|
4689 |
+
} else {
|
4690 |
+
$css_margin = 'margin: 0 0 30px 0;';
|
4691 |
+
}
|
4692 |
+
|
4693 |
+
if ( $background ) {
|
4694 |
+
$css_background = 'background-color: ' . $background . ';';
|
4695 |
+
}
|
4696 |
+
if ( $borderradius ) {
|
4697 |
+
$css_borderradius = 'border-radius: 0px 0px ' . $borderradius . ' ' . $borderradius . ';';
|
4698 |
+
}
|
4699 |
+
if ( $border ) {
|
4700 |
+
$css_border = 'border-width: ' . $border . ';';
|
4701 |
+
}
|
4702 |
+
if ( $bordercolor ) {
|
4703 |
+
$css_bordercolor = 'border-color: ' . $bordercolor . ';';
|
4704 |
+
}
|
4705 |
+
if ( $borderstyle ) {
|
4706 |
+
$css_borderstyle = 'border-style: ' . $borderstyle . ';';
|
4707 |
+
}
|
4708 |
+
if ( $text_color ) {
|
4709 |
+
$css_text_color = 'color: ' . $text_color . ' !important;';
|
4710 |
+
$css_class .= ' um-customized-row';
|
4711 |
+
}
|
4712 |
+
|
4713 |
+
// show the heading
|
4714 |
+
if ( $heading ) {
|
4715 |
+
|
4716 |
+
if ( ! empty( $heading_background_color ) ) {
|
4717 |
+
$css_heading_background_color = "background-color: $heading_background_color;";
|
4718 |
+
$css_heading_padding = 'padding: 10px 15px;';
|
4719 |
+
}
|
4720 |
+
|
4721 |
+
$css_heading_borderradius = empty( $borderradius ) ? '' : "border-radius: $borderradius $borderradius 0px 0px;";
|
4722 |
+
$css_heading_border = $css_border . $css_borderstyle . $css_bordercolor . $css_heading_borderradius . 'border-bottom-width: 0px;';
|
4723 |
+
$css_heading_margin = $css_margin . 'margin-bottom: 0px;';
|
4724 |
+
$css_heading_text_color = empty( $heading_text_color ) ? '' : "color: $heading_text_color;";
|
4725 |
+
$css_icon_color = empty( $icon_color ) ? '' : "color: $icon_color;";
|
4726 |
+
|
4727 |
+
$output .= '<div class="um-row-heading" style="' . $css_heading_margin . $css_heading_padding . $css_heading_border . $css_heading_background_color . $css_heading_text_color . '">';
|
4728 |
+
|
4729 |
+
if ( ! empty( $icon ) ) {
|
4730 |
+
$output .= '<span class="um-row-heading-icon" style="' . $css_icon_color . '"><i class="' . $icon . '"></i></span>';
|
4731 |
+
}
|
4732 |
+
if ( ! empty( $heading_text ) ) {
|
4733 |
+
$output .= htmlspecialchars( $heading_text );
|
4734 |
+
}
|
4735 |
+
|
4736 |
+
$output .= '</div>';
|
4737 |
+
|
4738 |
+
$css_border .= 'border-top-width: 0px;';
|
4739 |
+
$css_margin .= 'margin-top: 0px;';
|
4740 |
+
|
4741 |
+
} else {
|
4742 |
+
|
4743 |
+
// no heading
|
4744 |
+
$css_borderradius = empty( $borderradius ) ? '' : "border-radius: $borderradius;";
|
4745 |
+
|
4746 |
+
}
|
4747 |
+
|
4748 |
+
$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 . '">';
|
4749 |
+
|
4750 |
+
return $output;
|
4751 |
+
}
|
4752 |
+
|
4753 |
+
|
4754 |
+
/**
|
4755 |
+
*
|
4756 |
+
*/
|
4757 |
+
function do_ajax_action() {
|
4758 |
+
UM()->admin()->check_ajax_nonce();
|
4759 |
+
|
4760 |
+
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
|
4761 |
+
wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
|
4762 |
+
}
|
4763 |
+
|
4764 |
+
/**
|
4765 |
+
* @var $in_row
|
4766 |
+
* @var $in_sub_row
|
4767 |
+
* @var $in_column
|
4768 |
+
* @var $in_group
|
4769 |
+
* @var $act_id
|
4770 |
+
* @var $arg1
|
4771 |
+
* @var $arg2
|
4772 |
+
*/
|
4773 |
+
extract( $_POST );
|
4774 |
+
|
4775 |
+
$output = null;
|
4776 |
+
|
4777 |
+
$position = array();
|
4778 |
+
if ( ! empty( $in_column ) ) {
|
4779 |
+
$position['in_row'] = '_um_row_' . ( (int) $in_row + 1 );
|
4780 |
+
$position['in_sub_row'] = $in_sub_row;
|
4781 |
+
$position['in_column'] = $in_column;
|
4782 |
+
$position['in_group'] = $in_group;
|
4783 |
+
}
|
4784 |
+
|
4785 |
+
switch ( $act_id ) {
|
4786 |
+
|
4787 |
+
case 'um_admin_duplicate_field':
|
4788 |
+
$this->duplicate_field( $arg1, $arg2 );
|
4789 |
+
break;
|
4790 |
+
|
4791 |
+
case 'um_admin_remove_field_global':
|
4792 |
+
$this->delete_field_from_db( $arg1 );
|
4793 |
+
break;
|
4794 |
+
|
4795 |
+
case 'um_admin_remove_field':
|
4796 |
+
$this->delete_field_from_form( $arg1, $arg2 );
|
4797 |
+
break;
|
4798 |
+
|
4799 |
+
case 'um_admin_add_field_from_predefined':
|
4800 |
+
$this->add_field_from_predefined( $arg1, $arg2, $position );
|
4801 |
+
break;
|
4802 |
+
|
4803 |
+
case 'um_admin_add_field_from_list':
|
4804 |
+
$this->add_field_from_list( $arg1, $arg2, $position );
|
4805 |
+
break;
|
4806 |
+
|
4807 |
+
}
|
4808 |
+
|
4809 |
+
if ( is_array( $output ) ) {
|
4810 |
+
print_r( $output );
|
4811 |
+
} else {
|
4812 |
+
echo $output;
|
4813 |
+
}
|
4814 |
+
die;
|
4815 |
+
|
4816 |
+
}
|
4817 |
+
|
4818 |
+
|
4819 |
+
|
4820 |
+
/**
|
4821 |
+
* Get rendered field attributes
|
4822 |
+
*
|
4823 |
+
* @since 2.1.2
|
4824 |
+
*
|
4825 |
+
* @param string $key
|
4826 |
+
* @param array $classes
|
4827 |
+
* @param string $conditional
|
4828 |
+
* @param array $data
|
4829 |
+
* @param array $field_style
|
4830 |
+
*
|
4831 |
+
* @return string/html
|
4832 |
+
*/
|
4833 |
+
function get_atts( $key, $classes, $conditional, $data, $field_style = array() ) {
|
4834 |
+
|
4835 |
+
array_unshift( $classes, 'um-field-' . $data['type'] );
|
4836 |
+
array_unshift( $classes, 'um-field' );
|
4837 |
+
|
4838 |
+
$field_atts = array(
|
4839 |
+
'id' => array(
|
4840 |
+
"um_field_{$this->set_id}_{$key}",
|
4841 |
+
),
|
4842 |
+
'class' => $classes,
|
4843 |
+
'data-key' => array(
|
4844 |
+
esc_attr( $key )
|
4845 |
+
)
|
4846 |
+
);
|
4847 |
+
|
4848 |
+
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
4849 |
+
|
4850 |
+
if ( in_array( $data['type'], $fields_without_metakey ) ) {
|
4851 |
+
unset( $field_atts['id'] );
|
4852 |
+
|
4853 |
+
if ( empty( $field_atts['data-key'] ) ) {
|
4854 |
+
unset( $field_atts['data-key'] );
|
4855 |
+
}
|
4856 |
+
}
|
4857 |
+
|
4858 |
+
if ( ! empty( $field_style ) && is_array( $field_style ) ) {
|
4859 |
+
|
4860 |
+
$arr_inline_style = '';
|
4861 |
+
foreach ( $field_style as $style_attr => $style_value ) {
|
4862 |
+
$arr_inline_style .= esc_attr( $style_attr ) . ':' . esc_attr( $style_value ) . ';';
|
4863 |
+
}
|
4864 |
+
$field_atts['style'] = array( $arr_inline_style );
|
4865 |
+
}
|
4866 |
+
|
4867 |
+
/**
|
4868 |
+
* UM hook
|
4869 |
+
*
|
4870 |
+
* @type filter
|
4871 |
+
* @title um_field_extra_atts
|
4872 |
+
* @description user for adding extra field attributes
|
4873 |
+
* @input_vars
|
4874 |
+
* [{"var":"$field_atts","type":"array","desc":"Field attributes"},
|
4875 |
+
* [{"var":"$key","type":"string","desc":"Field id"},
|
4876 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
4877 |
+
* @change_log
|
4878 |
+
* ["Since: 2.0.57"]
|
4879 |
+
* @usage add_filter( 'um_field_extra_atts', 'function_name', 10, 3 );
|
4880 |
+
* @example
|
4881 |
+
* <?php
|
4882 |
+
* add_filter( 'um_field_extra_atts', 'function_name', 10, 3 );
|
4883 |
+
* function function_name( $field_atts, $key, $data ) {
|
4884 |
+
* // your code here
|
4885 |
+
* return $array_extra_atts;
|
4886 |
+
* }
|
4887 |
+
* ?>
|
4888 |
+
*/
|
4889 |
+
$field_atts = apply_filters( 'um_field_extra_atts', $field_atts, $key, $data );
|
4890 |
+
|
4891 |
+
$html_atts = '';
|
4892 |
+
foreach ( $field_atts as $att_name => $att_values ) {
|
4893 |
+
$att_values = implode( " ", $att_values );
|
4894 |
+
$html_atts .= " {$att_name}=\"" . esc_attr( $att_values ) . "\"";
|
4895 |
+
}
|
4896 |
+
|
4897 |
+
$html_atts .= $conditional;
|
4898 |
+
|
4899 |
+
return $html_atts;
|
4900 |
+
}
|
4901 |
+
}
|
4902 |
+
}
|
includes/core/class-form.php
CHANGED
@@ -1,831 +1,837 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\core;
|
3 |
-
|
4 |
-
// Exit if accessed directly
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
if ( ! class_exists( 'um\core\Form' ) ) {
|
8 |
-
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class Form
|
12 |
-
* @package um\core
|
13 |
-
*/
|
14 |
-
class Form {
|
15 |
-
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @var null
|
19 |
-
*/
|
20 |
-
public $form_suffix;
|
21 |
-
|
22 |
-
|
23 |
-
/**
|
24 |
-
* @var
|
25 |
-
*/
|
26 |
-
var $form_id;
|
27 |
-
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @var null
|
31 |
-
*/
|
32 |
-
var $post_form = null;
|
33 |
-
|
34 |
-
|
35 |
-
var $nonce = null;
|
36 |
-
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Form constructor.
|
40 |
-
*/
|
41 |
-
function __construct() {
|
42 |
-
|
43 |
-
$this->form_suffix = null;
|
44 |
-
|
45 |
-
$this->errors = null;
|
46 |
-
|
47 |
-
$this->processing = null;
|
48 |
-
|
49 |
-
add_action( 'template_redirect', array( &$this, 'form_init' ), 2 );
|
50 |
-
|
51 |
-
add_action( 'init', array( &$this, 'field_declare' ), 10 );
|
52 |
-
|
53 |
-
}
|
54 |
-
|
55 |
-
|
56 |
-
/**
|
57 |
-
*
|
58 |
-
*/
|
59 |
-
public function ajax_muted_action() {
|
60 |
-
UM()->check_ajax_nonce();
|
61 |
-
|
62 |
-
/**
|
63 |
-
* @var $user_id
|
64 |
-
* @var $hook
|
65 |
-
*/
|
66 |
-
extract( $_REQUEST );
|
67 |
-
|
68 |
-
if ( isset( $user_id ) ) {
|
69 |
-
$user_id = absint( $user_id );
|
70 |
-
}
|
71 |
-
|
72 |
-
if ( isset( $hook ) ) {
|
73 |
-
$hook = sanitize_key( $hook );
|
74 |
-
}
|
75 |
-
|
76 |
-
if ( ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
|
77 |
-
die( esc_html__( 'You can not edit this user', 'ultimate-member' ) );
|
78 |
-
}
|
79 |
-
|
80 |
-
switch ( $hook ) {
|
81 |
-
default:
|
82 |
-
/**
|
83 |
-
* UM hook
|
84 |
-
*
|
85 |
-
* @type action
|
86 |
-
* @title um_run_ajax_function__{$hook}
|
87 |
-
* @description Action on AJAX muted action
|
88 |
-
* @input_vars
|
89 |
-
* [{"var":"$request","type":"int","desc":"Request"}]
|
90 |
-
* @change_log
|
91 |
-
* ["Since: 2.0"]
|
92 |
-
* @usage add_action( 'um_run_ajax_function__{$hook}', 'function_name', 10, 1 );
|
93 |
-
* @example
|
94 |
-
* <?php
|
95 |
-
* add_action( 'um_run_ajax_function__{$hook}', 'my_run_ajax_function', 10, 1 );
|
96 |
-
* function my_run_ajax_function( $request ) {
|
97 |
-
* // your code here
|
98 |
-
* }
|
99 |
-
* ?>
|
100 |
-
*/
|
101 |
-
do_action( "um_run_ajax_function__{$hook}", $_REQUEST );
|
102 |
-
break;
|
103 |
-
}
|
104 |
-
}
|
105 |
-
|
106 |
-
|
107 |
-
/**
|
108 |
-
*
|
109 |
-
*/
|
110 |
-
public function ajax_select_options() {
|
111 |
-
UM()->check_ajax_nonce();
|
112 |
-
|
113 |
-
$arr_options = array();
|
114 |
-
$arr_options['status'] = 'success';
|
115 |
-
$arr_options['post'] = $_POST;
|
116 |
-
|
117 |
-
// Callback validation
|
118 |
-
if ( empty( $_POST['child_callback'] ) ) {
|
119 |
-
$arr_options['status'] = 'error';
|
120 |
-
$arr_options['message'] = __( 'Wrong callback.', 'ultimate-member' );
|
121 |
-
|
122 |
-
wp_send_json( $arr_options );
|
123 |
-
}
|
124 |
-
|
125 |
-
$ajax_source_func = sanitize_text_field( $_POST['child_callback'] );
|
126 |
-
|
127 |
-
if ( ! function_exists( $ajax_source_func ) ) {
|
128 |
-
$arr_options['status'] = 'error';
|
129 |
-
$arr_options['message'] = __( 'Wrong callback.', 'ultimate-member' );
|
130 |
-
|
131 |
-
wp_send_json( $arr_options );
|
132 |
-
}
|
133 |
-
|
134 |
-
$allowed_callbacks = UM()->options()->get( 'allowed_choice_callbacks' );
|
135 |
-
|
136 |
-
|
137 |
-
$arr_options['
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
$arr_options['
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
$
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
$arr_options['
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
*
|
190 |
-
*
|
191 |
-
* @
|
192 |
-
* @
|
193 |
-
* @
|
194 |
-
*
|
195 |
-
*
|
196 |
-
*
|
197 |
-
*
|
198 |
-
*
|
199 |
-
*
|
200 |
-
*
|
201 |
-
*
|
202 |
-
*
|
203 |
-
*
|
204 |
-
*
|
205 |
-
*
|
206 |
-
*
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
$
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
$form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source']
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
$arr_options['
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
*
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
*
|
254 |
-
*
|
255 |
-
* @param string $
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
*
|
262 |
-
*
|
263 |
-
* @
|
264 |
-
* @
|
265 |
-
* @
|
266 |
-
*
|
267 |
-
* {"var":"$
|
268 |
-
*
|
269 |
-
*
|
270 |
-
*
|
271 |
-
*
|
272 |
-
*
|
273 |
-
*
|
274 |
-
*
|
275 |
-
*
|
276 |
-
*
|
277 |
-
*
|
278 |
-
*
|
279 |
-
*
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
*
|
288 |
-
* @param string $
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
*
|
295 |
-
*
|
296 |
-
* @
|
297 |
-
* @
|
298 |
-
* @
|
299 |
-
*
|
300 |
-
* {"var":"$
|
301 |
-
*
|
302 |
-
*
|
303 |
-
*
|
304 |
-
*
|
305 |
-
*
|
306 |
-
*
|
307 |
-
*
|
308 |
-
*
|
309 |
-
*
|
310 |
-
*
|
311 |
-
*
|
312 |
-
*
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
*
|
322 |
-
*
|
323 |
-
* @
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
*
|
336 |
-
*
|
337 |
-
* @
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
*
|
350 |
-
*
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
*
|
402 |
-
*
|
403 |
-
* @
|
404 |
-
* @
|
405 |
-
* @
|
406 |
-
*
|
407 |
-
*
|
408 |
-
* @
|
409 |
-
*
|
410 |
-
*
|
411 |
-
*
|
412 |
-
*
|
413 |
-
*
|
414 |
-
*
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
*
|
422 |
-
*
|
423 |
-
* @
|
424 |
-
* @
|
425 |
-
* @
|
426 |
-
*
|
427 |
-
*
|
428 |
-
*
|
429 |
-
*
|
430 |
-
*
|
431 |
-
*
|
432 |
-
*
|
433 |
-
*
|
434 |
-
*
|
435 |
-
*
|
436 |
-
*
|
437 |
-
*
|
438 |
-
*
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
$this->post_form = $this->
|
448 |
-
$this->post_form
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
if
|
454 |
-
|
455 |
-
|
456 |
-
unset( $this->post_form['
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
$this->
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
$role =
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
$
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
$this->post_form['
|
503 |
-
|
504 |
-
|
505 |
-
unset( $this->post_form['
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
$this->
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
*
|
519 |
-
*
|
520 |
-
* @
|
521 |
-
* @
|
522 |
-
* @
|
523 |
-
*
|
524 |
-
* {"var":"$
|
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 |
-
$this->
|
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 |
-
case '
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
case '
|
681 |
-
case '
|
682 |
-
case '
|
683 |
-
case '
|
684 |
-
case '
|
685 |
-
|
686 |
-
|
687 |
-
case '
|
688 |
-
case '
|
689 |
-
case '
|
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 |
-
case '
|
720 |
-
$output = __( '
|
721 |
-
break;
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
$
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
$
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
);
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace um\core;
|
3 |
+
|
4 |
+
// Exit if accessed directly
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
if ( ! class_exists( 'um\core\Form' ) ) {
|
8 |
+
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Form
|
12 |
+
* @package um\core
|
13 |
+
*/
|
14 |
+
class Form {
|
15 |
+
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var null
|
19 |
+
*/
|
20 |
+
public $form_suffix;
|
21 |
+
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var
|
25 |
+
*/
|
26 |
+
var $form_id;
|
27 |
+
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @var null
|
31 |
+
*/
|
32 |
+
var $post_form = null;
|
33 |
+
|
34 |
+
|
35 |
+
var $nonce = null;
|
36 |
+
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Form constructor.
|
40 |
+
*/
|
41 |
+
function __construct() {
|
42 |
+
|
43 |
+
$this->form_suffix = null;
|
44 |
+
|
45 |
+
$this->errors = null;
|
46 |
+
|
47 |
+
$this->processing = null;
|
48 |
+
|
49 |
+
add_action( 'template_redirect', array( &$this, 'form_init' ), 2 );
|
50 |
+
|
51 |
+
add_action( 'init', array( &$this, 'field_declare' ), 10 );
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
/**
|
57 |
+
*
|
58 |
+
*/
|
59 |
+
public function ajax_muted_action() {
|
60 |
+
UM()->check_ajax_nonce();
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @var $user_id
|
64 |
+
* @var $hook
|
65 |
+
*/
|
66 |
+
extract( $_REQUEST );
|
67 |
+
|
68 |
+
if ( isset( $user_id ) ) {
|
69 |
+
$user_id = absint( $user_id );
|
70 |
+
}
|
71 |
+
|
72 |
+
if ( isset( $hook ) ) {
|
73 |
+
$hook = sanitize_key( $hook );
|
74 |
+
}
|
75 |
+
|
76 |
+
if ( ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
|
77 |
+
die( esc_html__( 'You can not edit this user', 'ultimate-member' ) );
|
78 |
+
}
|
79 |
+
|
80 |
+
switch ( $hook ) {
|
81 |
+
default:
|
82 |
+
/**
|
83 |
+
* UM hook
|
84 |
+
*
|
85 |
+
* @type action
|
86 |
+
* @title um_run_ajax_function__{$hook}
|
87 |
+
* @description Action on AJAX muted action
|
88 |
+
* @input_vars
|
89 |
+
* [{"var":"$request","type":"int","desc":"Request"}]
|
90 |
+
* @change_log
|
91 |
+
* ["Since: 2.0"]
|
92 |
+
* @usage add_action( 'um_run_ajax_function__{$hook}', 'function_name', 10, 1 );
|
93 |
+
* @example
|
94 |
+
* <?php
|
95 |
+
* add_action( 'um_run_ajax_function__{$hook}', 'my_run_ajax_function', 10, 1 );
|
96 |
+
* function my_run_ajax_function( $request ) {
|
97 |
+
* // your code here
|
98 |
+
* }
|
99 |
+
* ?>
|
100 |
+
*/
|
101 |
+
do_action( "um_run_ajax_function__{$hook}", $_REQUEST );
|
102 |
+
break;
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
/**
|
108 |
+
*
|
109 |
+
*/
|
110 |
+
public function ajax_select_options() {
|
111 |
+
UM()->check_ajax_nonce();
|
112 |
+
|
113 |
+
$arr_options = array();
|
114 |
+
$arr_options['status'] = 'success';
|
115 |
+
$arr_options['post'] = $_POST;
|
116 |
+
|
117 |
+
// Callback validation
|
118 |
+
if ( empty( $_POST['child_callback'] ) ) {
|
119 |
+
$arr_options['status'] = 'error';
|
120 |
+
$arr_options['message'] = __( 'Wrong callback.', 'ultimate-member' );
|
121 |
+
|
122 |
+
wp_send_json( $arr_options );
|
123 |
+
}
|
124 |
+
|
125 |
+
$ajax_source_func = sanitize_text_field( $_POST['child_callback'] );
|
126 |
+
|
127 |
+
if ( ! function_exists( $ajax_source_func ) ) {
|
128 |
+
$arr_options['status'] = 'error';
|
129 |
+
$arr_options['message'] = __( 'Wrong callback.', 'ultimate-member' );
|
130 |
+
|
131 |
+
wp_send_json( $arr_options );
|
132 |
+
}
|
133 |
+
|
134 |
+
$allowed_callbacks = UM()->options()->get( 'allowed_choice_callbacks' );
|
135 |
+
|
136 |
+
if ( empty( $allowed_callbacks ) ) {
|
137 |
+
$arr_options['status'] = 'error';
|
138 |
+
$arr_options['message'] = __( 'This is not possible for security reasons.', 'ultimate-member' );
|
139 |
+
wp_send_json( $arr_options );
|
140 |
+
}
|
141 |
+
|
142 |
+
$allowed_callbacks = array_map( 'rtrim', explode( "\n", wp_unslash( $allowed_callbacks ) ) );
|
143 |
+
|
144 |
+
if ( ! in_array( $ajax_source_func, $allowed_callbacks, true ) ) {
|
145 |
+
$arr_options['status'] = 'error';
|
146 |
+
$arr_options['message'] = __( 'This is not possible for security reasons.', 'ultimate-member' );
|
147 |
+
|
148 |
+
wp_send_json( $arr_options );
|
149 |
+
}
|
150 |
+
|
151 |
+
if ( isset( $_POST['form_id'] ) ) {
|
152 |
+
UM()->fields()->set_id = absint( $_POST['form_id'] );
|
153 |
+
}
|
154 |
+
UM()->fields()->set_mode = 'profile';
|
155 |
+
$form_fields = UM()->fields()->get_fields();
|
156 |
+
$arr_options['fields'] = $form_fields;
|
157 |
+
|
158 |
+
if ( isset( $arr_options['post']['members_directory'] ) && 'yes' === $arr_options['post']['members_directory'] ) {
|
159 |
+
global $wpdb;
|
160 |
+
|
161 |
+
$values_array = $wpdb->get_col(
|
162 |
+
$wpdb->prepare(
|
163 |
+
"SELECT DISTINCT meta_value
|
164 |
+
FROM $wpdb->usermeta
|
165 |
+
WHERE meta_key = %s AND
|
166 |
+
meta_value != ''",
|
167 |
+
$arr_options['post']['child_name']
|
168 |
+
)
|
169 |
+
);
|
170 |
+
|
171 |
+
if ( ! empty( $values_array ) ) {
|
172 |
+
$parent_dropdown = isset( $arr_options['field']['parent_dropdown_relationship'] ) ? $arr_options['field']['parent_dropdown_relationship'] : '';
|
173 |
+
$arr_options['items'] = call_user_func( $ajax_source_func, $parent_dropdown );
|
174 |
+
|
175 |
+
if ( array_keys( $arr_options['items'] ) !== range( 0, count( $arr_options['items'] ) - 1 ) ) {
|
176 |
+
// array with dropdown items is associative
|
177 |
+
$arr_options['items'] = array_intersect_key( array_map( 'trim', $arr_options['items'] ), array_flip( $values_array ) );
|
178 |
+
} else {
|
179 |
+
// array with dropdown items has sequential numeric keys, starting from 0 and there are intersected values with $values_array
|
180 |
+
$arr_options['items'] = array_intersect( $arr_options['items'], $values_array );
|
181 |
+
}
|
182 |
+
} else {
|
183 |
+
$arr_options['items'] = array();
|
184 |
+
}
|
185 |
+
|
186 |
+
wp_send_json( $arr_options );
|
187 |
+
} else {
|
188 |
+
/**
|
189 |
+
* UM hook
|
190 |
+
*
|
191 |
+
* @type filter
|
192 |
+
* @title um_ajax_select_options__debug_mode
|
193 |
+
* @description Activate debug mode for AJAX select options
|
194 |
+
* @input_vars
|
195 |
+
* [{"var":"$debug_mode","type":"bool","desc":"Enable Debug mode"}]
|
196 |
+
* @change_log
|
197 |
+
* ["Since: 2.0"]
|
198 |
+
* @usage
|
199 |
+
* <?php add_filter( 'um_ajax_select_options__debug_mode', 'function_name', 10, 1 ); ?>
|
200 |
+
* @example
|
201 |
+
* <?php
|
202 |
+
* add_filter( 'um_ajax_select_options__debug_mode', 'my_ajax_select_options__debug_mode', 10, 1 );
|
203 |
+
* function my_ajax_select_options__debug_mode( $debug_mode ) {
|
204 |
+
* // your code here
|
205 |
+
* return $debug_mode;
|
206 |
+
* }
|
207 |
+
* ?>
|
208 |
+
*/
|
209 |
+
$debug = apply_filters( 'um_ajax_select_options__debug_mode', false );
|
210 |
+
if ( $debug ) {
|
211 |
+
$arr_options['debug'] = array(
|
212 |
+
$_POST,
|
213 |
+
$form_fields,
|
214 |
+
);
|
215 |
+
}
|
216 |
+
|
217 |
+
if ( ! empty( $_POST['child_callback'] ) && isset( $form_fields[ $_POST['child_name'] ] ) ) {
|
218 |
+
// If the requested callback function is added in the form or added in the field option, execute it with call_user_func.
|
219 |
+
if ( isset( $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] ) &&
|
220 |
+
! empty( $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] ) &&
|
221 |
+
$form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] === $ajax_source_func ) {
|
222 |
+
|
223 |
+
$arr_options['field'] = $form_fields[ $_POST['child_name'] ];
|
224 |
+
|
225 |
+
$arr_options['items'] = call_user_func( $ajax_source_func, $arr_options['field']['parent_dropdown_relationship'] );
|
226 |
+
} else {
|
227 |
+
$arr_options['status'] = 'error';
|
228 |
+
$arr_options['message'] = __( 'This is not possible for security reasons.', 'ultimate-member' );
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
wp_send_json( $arr_options );
|
233 |
+
}
|
234 |
+
}
|
235 |
+
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Count the form errors.
|
239 |
+
* @return integer
|
240 |
+
*/
|
241 |
+
public function count_errors() {
|
242 |
+
$errors = $this->errors;
|
243 |
+
|
244 |
+
if ( $errors && is_array( $errors ) ) {
|
245 |
+
return count( $errors );
|
246 |
+
}
|
247 |
+
|
248 |
+
return 0;
|
249 |
+
}
|
250 |
+
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Appends field errors
|
254 |
+
*
|
255 |
+
* @param string $key
|
256 |
+
* @param string $error
|
257 |
+
*/
|
258 |
+
public function add_error( $key, $error ) {
|
259 |
+
if ( ! isset( $this->errors[ $key ] ) ) {
|
260 |
+
/**
|
261 |
+
* UM hook
|
262 |
+
*
|
263 |
+
* @type filter
|
264 |
+
* @title um_submit_form_error
|
265 |
+
* @description Change error text on submit form
|
266 |
+
* @input_vars
|
267 |
+
* [{"var":"$error","type":"string","desc":"Error String"},
|
268 |
+
* {"var":"$key","type":"string","desc":"Error Key"}]
|
269 |
+
* @change_log
|
270 |
+
* ["Since: 2.0"]
|
271 |
+
* @usage
|
272 |
+
* <?php add_filter( 'um_submit_form_error', 'function_name', 10, 2 ); ?>
|
273 |
+
* @example
|
274 |
+
* <?php
|
275 |
+
* add_filter( 'um_submit_form_error', 'my_submit_form_error', 10, 2 );
|
276 |
+
* function my_submit_form_error( $error, $key ) {
|
277 |
+
* // your code here
|
278 |
+
* return $error;
|
279 |
+
* }
|
280 |
+
* ?>
|
281 |
+
*/
|
282 |
+
$this->errors[ $key ] = apply_filters( 'um_submit_form_error', $error, $key );
|
283 |
+
}
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Appends field notices
|
288 |
+
* @param string $key
|
289 |
+
* @param string $notice
|
290 |
+
*/
|
291 |
+
public function add_notice( $key, $notice ) {
|
292 |
+
if ( ! isset( $this->notices[ $key ] ) ) {
|
293 |
+
/**
|
294 |
+
* UM hook
|
295 |
+
*
|
296 |
+
* @type filter
|
297 |
+
* @title um_submit_form_notice
|
298 |
+
* @description Change notice text on submit form
|
299 |
+
* @input_vars
|
300 |
+
* [{"var":"$notice","type":"string","desc":"notice String"},
|
301 |
+
* {"var":"$key","type":"string","desc":"notice Key"}]
|
302 |
+
* @change_log
|
303 |
+
* ["Since: 2.0"]
|
304 |
+
* @usage
|
305 |
+
* <?php add_filter( 'um_submit_form_notice', 'function_name', 10, 2 ); ?>
|
306 |
+
* @example
|
307 |
+
* <?php
|
308 |
+
* add_filter( 'um_submit_form_notice', 'my_submit_form_notice', 10, 2 );
|
309 |
+
* function my_submit_form_notice( $notice, $key ) {
|
310 |
+
* // your code here
|
311 |
+
* return $notice;
|
312 |
+
* }
|
313 |
+
* ?>
|
314 |
+
*/
|
315 |
+
$this->notices[ $key ] = apply_filters( 'um_submit_form_notice', $notice, $key );
|
316 |
+
}
|
317 |
+
}
|
318 |
+
|
319 |
+
|
320 |
+
/**
|
321 |
+
* If a form has errors
|
322 |
+
*
|
323 |
+
* @param string $key
|
324 |
+
* @return boolean
|
325 |
+
*/
|
326 |
+
public function has_error( $key ) {
|
327 |
+
if ( isset( $this->errors[ $key ] ) ) {
|
328 |
+
return true;
|
329 |
+
}
|
330 |
+
return false;
|
331 |
+
}
|
332 |
+
|
333 |
+
|
334 |
+
/**
|
335 |
+
* If a form has notices/info
|
336 |
+
*
|
337 |
+
* @param string $key
|
338 |
+
* @return boolean
|
339 |
+
*/
|
340 |
+
public function has_notice( $key ) {
|
341 |
+
if ( isset( $this->notices[ $key ] ) ) {
|
342 |
+
return true;
|
343 |
+
}
|
344 |
+
return false;
|
345 |
+
}
|
346 |
+
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Return the errors as a WordPress Error object
|
350 |
+
*
|
351 |
+
* @return \WP_Error
|
352 |
+
*/
|
353 |
+
function get_wp_error() {
|
354 |
+
$wp_error = new \WP_Error();
|
355 |
+
if ( $this->count_errors() > 0 ) {
|
356 |
+
foreach ( $this->errors as $key => $value ) {
|
357 |
+
$wp_error->add( $key, $value );
|
358 |
+
}
|
359 |
+
}
|
360 |
+
return $wp_error;
|
361 |
+
}
|
362 |
+
|
363 |
+
|
364 |
+
/**
|
365 |
+
* Declare all fields
|
366 |
+
*/
|
367 |
+
public function field_declare() {
|
368 |
+
if ( isset( UM()->builtin()->custom_fields ) ) {
|
369 |
+
$this->all_fields = UM()->builtin()->custom_fields;
|
370 |
+
} else {
|
371 |
+
$this->all_fields = null;
|
372 |
+
}
|
373 |
+
}
|
374 |
+
|
375 |
+
|
376 |
+
/**
|
377 |
+
* Validate form on submit
|
378 |
+
*/
|
379 |
+
public function form_init() {
|
380 |
+
if ( isset( $_SERVER['REQUEST_METHOD'] ) ) {
|
381 |
+
$http_post = ( 'POST' === $_SERVER['REQUEST_METHOD'] );
|
382 |
+
} else {
|
383 |
+
$http_post = 'POST';
|
384 |
+
}
|
385 |
+
|
386 |
+
if ( $http_post && ! is_admin() && isset( $_POST['form_id'] ) && is_numeric( $_POST['form_id'] ) ) {
|
387 |
+
|
388 |
+
$this->form_id = absint( $_POST['form_id'] );
|
389 |
+
if ( 'um_form' !== get_post_type( $this->form_id ) ) {
|
390 |
+
return;
|
391 |
+
}
|
392 |
+
|
393 |
+
$this->form_status = get_post_status( $this->form_id );
|
394 |
+
if ( 'publish' !== $this->form_status ) {
|
395 |
+
return;
|
396 |
+
}
|
397 |
+
|
398 |
+
$this->form_data = UM()->query()->post_data( $this->form_id );
|
399 |
+
|
400 |
+
/**
|
401 |
+
* UM hook
|
402 |
+
*
|
403 |
+
* @type action
|
404 |
+
* @title um_before_submit_form_post
|
405 |
+
* @description Before submit form
|
406 |
+
* @change_log
|
407 |
+
* ["Since: 2.0"]
|
408 |
+
* @usage add_action( 'um_before_submit_form_post', 'function_name', 10, 1 );
|
409 |
+
* @example
|
410 |
+
* <?php
|
411 |
+
* add_action( 'um_before_submit_form_post', 'my_before_submit_form_post', 10, 1 );
|
412 |
+
* function my_run_ajax_function( $post ) {
|
413 |
+
* // your code here
|
414 |
+
* }
|
415 |
+
* ?>
|
416 |
+
*/
|
417 |
+
do_action( 'um_before_submit_form_post' );
|
418 |
+
|
419 |
+
/* save entire form as global */
|
420 |
+
/**
|
421 |
+
* UM hook
|
422 |
+
*
|
423 |
+
* @type filter
|
424 |
+
* @title um_submit_post_form
|
425 |
+
* @description Change submitted data on form submit
|
426 |
+
* @input_vars
|
427 |
+
* [{"var":"$data","type":"array","desc":"Submitted data"}]
|
428 |
+
* @change_log
|
429 |
+
* ["Since: 2.0"]
|
430 |
+
* @usage
|
431 |
+
* <?php add_filter( 'um_submit_post_form', 'function_name', 10, 1 ); ?>
|
432 |
+
* @example
|
433 |
+
* <?php
|
434 |
+
* add_filter( 'um_submit_post_form', 'my_submit_post_form', 10, 1 );
|
435 |
+
* function my_submit_post_form( $data ) {
|
436 |
+
* // your code here
|
437 |
+
* return $data;
|
438 |
+
* }
|
439 |
+
* ?>
|
440 |
+
*/
|
441 |
+
$this->post_form = apply_filters( 'um_submit_post_form', $_POST );
|
442 |
+
|
443 |
+
if ( isset( $this->post_form[ UM()->honeypot ] ) && '' !== $this->post_form[ UM()->honeypot ] ) {
|
444 |
+
wp_die( esc_html__( 'Hello, spam bot!', 'ultimate-member' ) );
|
445 |
+
}
|
446 |
+
|
447 |
+
$this->post_form = $this->beautify( $this->post_form );
|
448 |
+
$this->post_form = $this->sanitize( $this->post_form );
|
449 |
+
$this->post_form['submitted'] = $this->post_form;
|
450 |
+
|
451 |
+
$this->post_form = array_merge( $this->form_data, $this->post_form );
|
452 |
+
|
453 |
+
// Remove role from post_form at first if role ! empty and there aren't custom fields with role name
|
454 |
+
if ( ! empty( $_POST['role'] ) ) {
|
455 |
+
if ( ! isset( $this->form_data['custom_fields'] ) || ! strstr( $this->form_data['custom_fields'], 'role_' ) ) {
|
456 |
+
unset( $this->post_form['role'] );
|
457 |
+
unset( $this->post_form['submitted']['role'] );
|
458 |
+
}
|
459 |
+
}
|
460 |
+
|
461 |
+
// Secure sanitize of the submitted data
|
462 |
+
if ( ! empty( $this->post_form ) ) {
|
463 |
+
$this->post_form = array_diff_key( $this->post_form, array_flip( UM()->user()->banned_keys ) );
|
464 |
+
}
|
465 |
+
if ( ! empty( $this->post_form['submitted'] ) ) {
|
466 |
+
$this->post_form['submitted'] = array_diff_key( $this->post_form['submitted'], array_flip( UM()->user()->banned_keys ) );
|
467 |
+
}
|
468 |
+
|
469 |
+
// set default role from settings on registration form
|
470 |
+
if ( isset( $this->post_form['mode'] ) && 'register' === $this->post_form['mode'] ) {
|
471 |
+
$role = $this->assigned_role( $this->form_id );
|
472 |
+
$this->post_form['role'] = $role;
|
473 |
+
}
|
474 |
+
|
475 |
+
if ( isset( $this->form_data['custom_fields'] ) && strstr( $this->form_data['custom_fields'], 'role_' ) ) { // Secure selected role
|
476 |
+
|
477 |
+
if ( ! empty( $_POST['role'] ) ) {
|
478 |
+
$custom_field_roles = $this->custom_field_roles( $this->form_data['custom_fields'] );
|
479 |
+
|
480 |
+
if ( ! empty( $custom_field_roles ) ) {
|
481 |
+
if ( is_array( $_POST['role'] ) ) {
|
482 |
+
$role = current( $_POST['role'] );
|
483 |
+
$role = sanitize_key( $role );
|
484 |
+
} else {
|
485 |
+
$role = sanitize_key( $_POST['role'] );
|
486 |
+
}
|
487 |
+
|
488 |
+
global $wp_roles;
|
489 |
+
$role_keys = array_map(
|
490 |
+
function( $item ) {
|
491 |
+
return 'um_' . $item;
|
492 |
+
},
|
493 |
+
get_option( 'um_roles', array() )
|
494 |
+
);
|
495 |
+
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
496 |
+
|
497 |
+
if ( ! empty( $role ) &&
|
498 |
+
( ! in_array( $role, $custom_field_roles, true ) || in_array( $role, $exclude_roles, true ) ) ) {
|
499 |
+
wp_die( esc_html__( 'This is not possible for security reasons.', 'ultimate-member' ) );
|
500 |
+
}
|
501 |
+
|
502 |
+
$this->post_form['role'] = $role;
|
503 |
+
$this->post_form['submitted']['role'] = $role;
|
504 |
+
} else {
|
505 |
+
unset( $this->post_form['role'] );
|
506 |
+
unset( $this->post_form['submitted']['role'] );
|
507 |
+
|
508 |
+
// set default role for registration form if custom field hasn't proper value
|
509 |
+
if ( isset( $this->post_form['mode'] ) && 'register' === $this->post_form['mode'] ) {
|
510 |
+
$role = $this->assigned_role( $this->form_id );
|
511 |
+
$this->post_form['role'] = $role;
|
512 |
+
}
|
513 |
+
}
|
514 |
+
}
|
515 |
+
}
|
516 |
+
|
517 |
+
/**
|
518 |
+
* UM hook
|
519 |
+
*
|
520 |
+
* @type filter
|
521 |
+
* @title um_submit_form_data
|
522 |
+
* @description Change submitted data on form submit
|
523 |
+
* @input_vars
|
524 |
+
* [{"var":"$data","type":"array","desc":"Submitted data"},
|
525 |
+
* {"var":"$mode","type":"string","desc":"Form mode"}]
|
526 |
+
* @change_log
|
527 |
+
* ["Since: 2.0"]
|
528 |
+
* @usage
|
529 |
+
* <?php add_filter( 'um_submit_form_data', 'function_name', 10, 2 ); ?>
|
530 |
+
* @example
|
531 |
+
* <?php
|
532 |
+
* add_filter( 'um_submit_form_data', 'my_submit_form_data', 10, 2 );
|
533 |
+
* function my_submit_form_data( $data ) {
|
534 |
+
* // your code here
|
535 |
+
* return $data;
|
536 |
+
* }
|
537 |
+
* ?>
|
538 |
+
*/
|
539 |
+
$this->post_form = apply_filters( 'um_submit_form_data', $this->post_form, $this->post_form['mode'] );
|
540 |
+
|
541 |
+
/* Continue based on form mode - pre-validation */
|
542 |
+
|
543 |
+
/**
|
544 |
+
* UM hook
|
545 |
+
*
|
546 |
+
* @type action
|
547 |
+
* @title um_submit_form_errors_hook
|
548 |
+
* @description Action on submit form
|
549 |
+
* @input_vars
|
550 |
+
* [{"var":"$post","type":"int","desc":"Post data"}]
|
551 |
+
* @change_log
|
552 |
+
* ["Since: 2.0"]
|
553 |
+
* @usage add_action( 'um_submit_form_errors_hook', 'function_name', 10, 1 );
|
554 |
+
* @example
|
555 |
+
* <?php
|
556 |
+
* add_action( 'um_submit_form_errors_hook', 'my_submit_form_errors', 10, 1 );
|
557 |
+
* function my_submit_form_errors( $post ) {
|
558 |
+
* // your code here
|
559 |
+
* }
|
560 |
+
* ?>
|
561 |
+
*/
|
562 |
+
do_action( 'um_submit_form_errors_hook', $this->post_form );
|
563 |
+
/**
|
564 |
+
* UM hook
|
565 |
+
*
|
566 |
+
* @type action
|
567 |
+
* @title um_submit_form_{$mode}
|
568 |
+
* @description Action on submit form
|
569 |
+
* @input_vars
|
570 |
+
* [{"var":"$post","type":"int","desc":"Post data"}]
|
571 |
+
* @change_log
|
572 |
+
* ["Since: 2.0"]
|
573 |
+
* @usage add_action( 'um_submit_form_{$mode}', 'function_name', 10, 1 );
|
574 |
+
* @example
|
575 |
+
* <?php
|
576 |
+
* add_action( 'um_submit_form_{$mode}', 'my_submit_form', 10, 1 );
|
577 |
+
* function my_submit_form( $post ) {
|
578 |
+
* // your code here
|
579 |
+
* }
|
580 |
+
* ?>
|
581 |
+
*/
|
582 |
+
do_action( "um_submit_form_{$this->post_form['mode']}", $this->post_form );
|
583 |
+
|
584 |
+
}
|
585 |
+
}
|
586 |
+
|
587 |
+
|
588 |
+
/**
|
589 |
+
* Beautify form data
|
590 |
+
*
|
591 |
+
* @param array $form
|
592 |
+
*
|
593 |
+
* @return array $form
|
594 |
+
*/
|
595 |
+
public function beautify( $form ) {
|
596 |
+
if ( isset( $form['form_id'] ) ) {
|
597 |
+
$this->form_suffix = '-' . $form['form_id'];
|
598 |
+
$this->processing = $form['form_id'];
|
599 |
+
|
600 |
+
foreach ( $form as $key => $value ) {
|
601 |
+
if ( strstr( $key, $this->form_suffix ) ) {
|
602 |
+
$a_key = str_replace( $this->form_suffix, '', $key );
|
603 |
+
$form[ $a_key ] = $value;
|
604 |
+
unset( $form[ $key ] );
|
605 |
+
}
|
606 |
+
}
|
607 |
+
}
|
608 |
+
|
609 |
+
return $form;
|
610 |
+
}
|
611 |
+
|
612 |
+
|
613 |
+
/**
|
614 |
+
* Beautify form data
|
615 |
+
*
|
616 |
+
* @param array $form
|
617 |
+
*
|
618 |
+
* @return array $form
|
619 |
+
*/
|
620 |
+
public function sanitize( $form ) {
|
621 |
+
|
622 |
+
if ( isset( $form['form_id'] ) ) {
|
623 |
+
if ( isset( $this->form_data['custom_fields'] ) ) {
|
624 |
+
$custom_fields = maybe_unserialize( $this->form_data['custom_fields'] );
|
625 |
+
|
626 |
+
if ( is_array( $custom_fields ) ) {
|
627 |
+
foreach ( $custom_fields as $k => $field ) {
|
628 |
+
|
629 |
+
if ( isset( $field['type'] ) ) {
|
630 |
+
if ( isset( $form[ $k ] ) ) {
|
631 |
+
|
632 |
+
switch ( $field['type'] ) {
|
633 |
+
default:
|
634 |
+
$form[ $k ] = apply_filters( 'um_sanitize_form_field', $form[ $k ], $field );
|
635 |
+
break;
|
636 |
+
case 'number':
|
637 |
+
$form[ $k ] = (int) $form[ $k ];
|
638 |
+
break;
|
639 |
+
case 'textarea':
|
640 |
+
if ( ! empty( $field['html'] ) || ( UM()->profile()->get_show_bio_key( $form ) === $k && UM()->options()->get( 'profile_show_html_bio' ) ) ) {
|
641 |
+
$form[ $k ] = wp_kses_post( $form[ $k ] );
|
642 |
+
} else {
|
643 |
+
$form[ $k ] = sanitize_textarea_field( $form[ $k ] );
|
644 |
+
}
|
645 |
+
break;
|
646 |
+
case 'url':
|
647 |
+
$f = UM()->builtin()->get_a_field( $k );
|
648 |
+
|
649 |
+
if ( array_key_exists( 'match', $f ) && array_key_exists( 'advanced', $f ) && 'social' === $f['advanced'] ) {
|
650 |
+
$v = sanitize_text_field( $form[ $k ] );
|
651 |
+
|
652 |
+
// Make a proper social link
|
653 |
+
if ( ! empty( $v ) && ! strstr( $v, $f['match'] ) ) {
|
654 |
+
$domain = trim( strtr( $f['match'], array(
|
655 |
+
'https://' => '',
|
656 |
+
'http://' => '',
|
657 |
+
) ), ' /' );
|
658 |
+
|
659 |
+
if ( ! strstr( $v, $domain ) ) {
|
660 |
+
$v = $f['match'] . $v;
|
661 |
+
} else {
|
662 |
+
$v = 'https://' . trim( strtr( $v, array(
|
663 |
+
'https://' => '',
|
664 |
+
'http://' => '',
|
665 |
+
) ), ' /' );
|
666 |
+
}
|
667 |
+
}
|
668 |
+
|
669 |
+
$form[ $k ] = $v;
|
670 |
+
} else {
|
671 |
+
$form[ $k ] = esc_url_raw( $form[ $k ] );
|
672 |
+
}
|
673 |
+
break;
|
674 |
+
case 'password':
|
675 |
+
$form[ $k ] = trim( $form[ $k ] );
|
676 |
+
if ( array_key_exists( 'confirm_' . $k, $form ) ) {
|
677 |
+
$form[ 'confirm_' . $k ] = trim( $form[ 'confirm_' . $k ] );
|
678 |
+
}
|
679 |
+
break;
|
680 |
+
case 'text':
|
681 |
+
case 'select':
|
682 |
+
case 'image':
|
683 |
+
case 'file':
|
684 |
+
case 'date':
|
685 |
+
case 'time':
|
686 |
+
case 'rating':
|
687 |
+
case 'googlemap':
|
688 |
+
case 'youtube_video':
|
689 |
+
case 'vimeo_video':
|
690 |
+
case 'soundcloud_track':
|
691 |
+
$form[ $k ] = sanitize_text_field( $form[ $k ] );
|
692 |
+
break;
|
693 |
+
case 'multiselect':
|
694 |
+
case 'radio':
|
695 |
+
case 'checkbox':
|
696 |
+
$form[ $k ] = is_array( $form[ $k ] ) ? array_map( 'sanitize_text_field', $form[ $k ] ) : sanitize_text_field( $form[ $k ] );
|
697 |
+
break;
|
698 |
+
}
|
699 |
+
}
|
700 |
+
}
|
701 |
+
}
|
702 |
+
}
|
703 |
+
}
|
704 |
+
}
|
705 |
+
|
706 |
+
return $form;
|
707 |
+
}
|
708 |
+
|
709 |
+
|
710 |
+
/**
|
711 |
+
* Display form type as Title
|
712 |
+
* @param string $mode
|
713 |
+
* @param integer $post_id
|
714 |
+
* @return string $output
|
715 |
+
*/
|
716 |
+
public function display_form_type( $mode, $post_id ) {
|
717 |
+
$output = null;
|
718 |
+
switch ( $mode ) {
|
719 |
+
case 'login':
|
720 |
+
$output = __( 'Login', 'ultimate-member' );
|
721 |
+
break;
|
722 |
+
case 'profile':
|
723 |
+
$output = __( 'Profile', 'ultimate-member' );
|
724 |
+
break;
|
725 |
+
case 'register':
|
726 |
+
$output = __( 'Register', 'ultimate-member' );
|
727 |
+
break;
|
728 |
+
}
|
729 |
+
return $output;
|
730 |
+
}
|
731 |
+
|
732 |
+
|
733 |
+
/**
|
734 |
+
* Assigned roles to a form
|
735 |
+
* @param integer $post_id
|
736 |
+
* @return string $role
|
737 |
+
*/
|
738 |
+
public function assigned_role( $post_id ) {
|
739 |
+
|
740 |
+
$global_role = get_option( 'default_role' ); // WP Global settings
|
741 |
+
|
742 |
+
$um_global_role = UM()->options()->get( 'register_role' ); // UM Settings Global settings
|
743 |
+
if ( ! empty( $um_global_role ) ) {
|
744 |
+
$global_role = $um_global_role; // Form Global settings
|
745 |
+
}
|
746 |
+
|
747 |
+
$mode = $this->form_type( $post_id );
|
748 |
+
|
749 |
+
/**
|
750 |
+
* @todo WPML integration to get role from original if it's empty
|
751 |
+
*/
|
752 |
+
$use_custom = get_post_meta( $post_id, "_um_{$mode}_use_custom_settings", true );
|
753 |
+
if ( $use_custom ) { // Custom Form settings
|
754 |
+
$role = get_post_meta( $post_id, "_um_{$mode}_role", true );
|
755 |
+
}
|
756 |
+
|
757 |
+
if ( empty( $role ) ) { // custom role is default, return default role's slug
|
758 |
+
$role = $global_role;
|
759 |
+
}
|
760 |
+
|
761 |
+
return $role;
|
762 |
+
}
|
763 |
+
|
764 |
+
|
765 |
+
/**
|
766 |
+
* Get form type
|
767 |
+
* @param integer $post_id
|
768 |
+
* @return string
|
769 |
+
*/
|
770 |
+
public function form_type( $post_id ) {
|
771 |
+
$mode = get_post_meta( $post_id, '_um_mode', true );
|
772 |
+
return $mode;
|
773 |
+
}
|
774 |
+
|
775 |
+
|
776 |
+
/**
|
777 |
+
* Get custom field roles
|
778 |
+
*
|
779 |
+
* @param string $custom_fields serialized
|
780 |
+
* @return bool|array roles
|
781 |
+
*/
|
782 |
+
public function custom_field_roles( $custom_fields ) {
|
783 |
+
|
784 |
+
$fields = maybe_unserialize( $custom_fields );
|
785 |
+
if ( ! is_array( $fields ) ) {
|
786 |
+
return false;
|
787 |
+
}
|
788 |
+
|
789 |
+
// role field
|
790 |
+
global $wp_roles;
|
791 |
+
$role_keys = array_map(
|
792 |
+
function( $item ) {
|
793 |
+
return 'um_' . $item;
|
794 |
+
},
|
795 |
+
get_option( 'um_roles', array() )
|
796 |
+
);
|
797 |
+
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
798 |
+
|
799 |
+
$roles = UM()->roles()->get_roles( false, $exclude_roles );
|
800 |
+
$roles = array_map(
|
801 |
+
function( $item ) {
|
802 |
+
return html_entity_decode( $item, ENT_QUOTES );
|
803 |
+
},
|
804 |
+
$roles
|
805 |
+
);
|
806 |
+
|
807 |
+
foreach ( $fields as $field_key => $field_settings ) {
|
808 |
+
|
809 |
+
if ( strstr( $field_key, 'role_' ) && is_array( $field_settings['options'] ) ) {
|
810 |
+
|
811 |
+
if ( isset( $this->post_form['mode'] ) && 'profile' === $this->post_form['mode'] &&
|
812 |
+
isset( $field_settings['editable'] ) && $field_settings['editable'] == 0 ) {
|
813 |
+
continue;
|
814 |
+
}
|
815 |
+
|
816 |
+
if ( ! um_can_view_field( $field_settings ) ) {
|
817 |
+
continue;
|
818 |
+
}
|
819 |
+
|
820 |
+
$intersected_options = array();
|
821 |
+
foreach ( $field_settings['options'] as $key => $title ) {
|
822 |
+
if ( false !== $search_key = array_search( $title, $roles ) ) {
|
823 |
+
$intersected_options[ $search_key ] = $title;
|
824 |
+
} elseif ( isset( $roles[ $key ] ) ) {
|
825 |
+
$intersected_options[ $key ] = $title;
|
826 |
+
}
|
827 |
+
}
|
828 |
+
|
829 |
+
// getting roles only from the first role fields
|
830 |
+
return array_keys( $intersected_options );
|
831 |
+
}
|
832 |
+
}
|
833 |
+
|
834 |
+
return false;
|
835 |
+
}
|
836 |
+
}
|
837 |
+
}
|
includes/core/class-member-directory-meta.php
CHANGED
@@ -1,864 +1,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 |
-
$directory_id = $this->get_directory_by_hash( $_POST['directory_id'] );
|
450 |
-
$directory_data = UM()->query()->post_data( $directory_id );
|
451 |
-
|
452 |
-
//predefined result for user without capabilities to see other members
|
453 |
-
$this->predefined_no_caps( $directory_data );
|
454 |
-
|
455 |
-
do_action( 'um_member_directory_before_query' );
|
456 |
-
|
457 |
-
// Prepare for BIG SELECT query
|
458 |
-
$wpdb->query( 'SET SQL_BIG_SELECTS=1' );
|
459 |
-
|
460 |
-
|
461 |
-
if ( ! empty( $directory_data['show_these_users'] ) ) {
|
462 |
-
$show_these_users = maybe_unserialize( $directory_data['show_these_users'] );
|
463 |
-
|
464 |
-
if ( is_array( $show_these_users ) && ! empty( $show_these_users ) ) {
|
465 |
-
$users_array = array();
|
466 |
-
foreach ( $show_these_users as $username ) {
|
467 |
-
if ( false !== ( $exists_id = username_exists( $username ) ) ) {
|
468 |
-
$users_array[] = $exists_id;
|
469 |
-
}
|
470 |
-
}
|
471 |
-
|
472 |
-
if ( ! empty( $users_array ) ) {
|
473 |
-
$this->where_clauses[] = "u.ID IN ( '" . implode( "','", $users_array ) . "' )";
|
474 |
-
}
|
475 |
-
}
|
476 |
-
}
|
477 |
-
|
478 |
-
if ( ! empty( $directory_data['exclude_these_users'] ) ) {
|
479 |
-
$exclude_these_users = maybe_unserialize( $directory_data['exclude_these_users'] );
|
480 |
-
|
481 |
-
if ( is_array( $exclude_these_users ) && ! empty( $exclude_these_users ) ) {
|
482 |
-
$users_array = array();
|
483 |
-
foreach ( $exclude_these_users as $username ) {
|
484 |
-
if ( false !== ( $exists_id = username_exists( $username ) ) ) {
|
485 |
-
$users_array[] = $exists_id;
|
486 |
-
}
|
487 |
-
}
|
488 |
-
|
489 |
-
if ( ! empty( $users_array ) ) {
|
490 |
-
$this->where_clauses[] = "u.ID NOT IN ( '" . implode( "','", $users_array ) . "' )";
|
491 |
-
}
|
492 |
-
}
|
493 |
-
}
|
494 |
-
|
495 |
-
|
496 |
-
$profile_photo_where = '';
|
497 |
-
if ( $directory_data['has_profile_photo'] == 1 ) {
|
498 |
-
$profile_photo_where = " AND umm_general.um_value LIKE '%s:13:\"profile_photo\";b:1;%'";
|
499 |
-
}
|
500 |
-
|
501 |
-
$cover_photo_where = '';
|
502 |
-
if ( $directory_data['has_cover_photo'] == 1 ) {
|
503 |
-
$cover_photo_where = " AND umm_general.um_value LIKE '%s:11:\"cover_photo\";b:1;%'";
|
504 |
-
}
|
505 |
-
|
506 |
-
if ( ! UM()->roles()->um_user_can( 'can_edit_everyone' ) ) {
|
507 |
-
if ( ! $this->general_meta_joined ) {
|
508 |
-
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_general ON umm_general.user_id = u.ID";
|
509 |
-
$this->general_meta_joined = true;
|
510 |
-
}
|
511 |
-
$this->where_clauses[] = "( umm_general.um_key = 'um_member_directory_data' AND
|
512 |
-
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} )";
|
513 |
-
} else {
|
514 |
-
if ( ! empty( $cover_photo_where ) || ! empty( $profile_photo_where ) ) {
|
515 |
-
if ( ! $this->general_meta_joined ) {
|
516 |
-
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_general ON umm_general.user_id = u.ID";
|
517 |
-
$this->general_meta_joined = true;
|
518 |
-
}
|
519 |
-
$this->where_clauses[] = "( umm_general.um_key = 'um_member_directory_data'{$profile_photo_where}{$cover_photo_where} )";
|
520 |
-
}
|
521 |
-
}
|
522 |
-
|
523 |
-
//$this->roles = array();
|
524 |
-
if ( UM()->roles()->um_user_can( 'can_view_all' ) ) {
|
525 |
-
$view_roles = um_user( 'can_view_roles' );
|
526 |
-
|
527 |
-
if ( ! $view_roles ) {
|
528 |
-
$view_roles = array();
|
529 |
-
} else {
|
530 |
-
$this->roles_in_query = true;
|
531 |
-
}
|
532 |
-
|
533 |
-
$this->roles = array_merge( $this->roles, maybe_unserialize( $view_roles ) );
|
534 |
-
}
|
535 |
-
|
536 |
-
if ( ! empty( $directory_data['roles'] ) ) {
|
537 |
-
if ( ! empty( $this->roles ) ) {
|
538 |
-
$this->roles = array_intersect( $this->roles, maybe_unserialize( $directory_data['roles'] ) );
|
539 |
-
} else {
|
540 |
-
$this->roles = array_merge( $this->roles, maybe_unserialize( $directory_data['roles'] ) );
|
541 |
-
}
|
542 |
-
|
543 |
-
$this->roles_in_query = true;
|
544 |
-
}
|
545 |
-
|
546 |
-
if ( ! empty( $this->roles ) ) {
|
547 |
-
$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' )";
|
548 |
-
|
549 |
-
$roles_clauses = array();
|
550 |
-
foreach ( $this->roles as $role ) {
|
551 |
-
$roles_clauses[] = $wpdb->prepare( 'umm_roles.um_value LIKE %s', '%"' . $role . '"%' );
|
552 |
-
}
|
553 |
-
|
554 |
-
$this->where_clauses[] = '( ' . implode( ' OR ', $roles_clauses ) . ' )';
|
555 |
-
} else {
|
556 |
-
|
557 |
-
if ( ! $this->roles_in_query && is_multisite() ) {
|
558 |
-
// select users who have capabilities for current blog
|
559 |
-
$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' )";
|
560 |
-
$this->where_clauses[] = "umm_roles.um_value IS NOT NULL";
|
561 |
-
} elseif ( $this->roles_in_query ) {
|
562 |
-
$member_directory_response = apply_filters( 'um_ajax_get_members_response', array(
|
563 |
-
'pagination' => $this->calculate_pagination( $directory_data, 0 ),
|
564 |
-
'users' => array(),
|
565 |
-
'is_search' => $this->is_search,
|
566 |
-
), $directory_data );
|
567 |
-
|
568 |
-
wp_send_json_success( $member_directory_response );
|
569 |
-
}
|
570 |
-
}
|
571 |
-
|
572 |
-
|
573 |
-
if ( ! empty( $_POST['search'] ) ) {
|
574 |
-
$search_line = trim( stripslashes( sanitize_text_field( $_POST['search'] ) ) );
|
575 |
-
|
576 |
-
$searches = array();
|
577 |
-
foreach ( $this->core_search_fields as $field ) {
|
578 |
-
$searches[] = $wpdb->prepare( "u.{$field} LIKE %s", '%' . $search_line . '%' );
|
579 |
-
}
|
580 |
-
|
581 |
-
$core_search = implode( ' OR ', $searches );
|
582 |
-
|
583 |
-
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_search ON umm_search.user_id = u.ID";
|
584 |
-
|
585 |
-
$additional_search = apply_filters( 'um_member_directory_meta_general_search_meta_query', '', stripslashes( sanitize_text_field( $_POST['search'] ) ) );
|
586 |
-
|
587 |
-
$search_like_string = apply_filters( 'um_member_directory_meta_search_like_type', '%' . $search_line . '%', $search_line );
|
588 |
-
|
589 |
-
$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 ) . '%' );
|
590 |
-
|
591 |
-
$this->is_search = true;
|
592 |
-
}
|
593 |
-
|
594 |
-
|
595 |
-
//filters
|
596 |
-
$filter_query = array();
|
597 |
-
if ( ! empty( $directory_data['search_fields'] ) ) {
|
598 |
-
$search_filters = maybe_unserialize( $directory_data['search_fields'] );
|
599 |
-
if ( ! empty( $search_filters ) && is_array( $search_filters ) ) {
|
600 |
-
$filter_query = array_intersect_key( $_POST, array_flip( $search_filters ) );
|
601 |
-
}
|
602 |
-
}
|
603 |
-
|
604 |
-
// added for user tags extension integration on individual tag page
|
605 |
-
$ignore_empty_filters = apply_filters( 'um_member_directory_ignore_empty_filters', false );
|
606 |
-
|
607 |
-
if ( ! empty( $filter_query ) || $ignore_empty_filters ) {
|
608 |
-
$this->is_search = true;
|
609 |
-
|
610 |
-
$i = 1;
|
611 |
-
foreach ( $filter_query as $field => $value ) {
|
612 |
-
|
613 |
-
$field = sanitize_text_field( $field );
|
614 |
-
if ( is_array( $value ) ) {
|
615 |
-
$value = array_map( 'sanitize_text_field', $value );
|
616 |
-
} else {
|
617 |
-
$value = sanitize_text_field( $value );
|
618 |
-
}
|
619 |
-
|
620 |
-
$attrs = UM()->fields()->get_field( $field );
|
621 |
-
// skip private invisible fields
|
622 |
-
if ( ! um_can_view_field( $attrs ) ) {
|
623 |
-
continue;
|
624 |
-
}
|
625 |
-
|
626 |
-
$this->handle_filter_query( $directory_data, $field, $value, $i );
|
627 |
-
|
628 |
-
$i++;
|
629 |
-
}
|
630 |
-
}
|
631 |
-
|
632 |
-
|
633 |
-
//unable default filter in case if we select other filters in frontend filters
|
634 |
-
//if ( empty( $this->custom_filters_in_query ) ) {
|
635 |
-
$default_filters = array();
|
636 |
-
if ( ! empty( $directory_data['search_filters'] ) ) {
|
637 |
-
$default_filters = maybe_unserialize( $directory_data['search_filters'] );
|
638 |
-
}
|
639 |
-
|
640 |
-
if ( ! empty( $default_filters ) ) {
|
641 |
-
$i = 1;
|
642 |
-
foreach ( $default_filters as $field => $value ) {
|
643 |
-
|
644 |
-
$this->handle_filter_query( $directory_data, $field, $value, $i, true );
|
645 |
-
|
646 |
-
$i++;
|
647 |
-
}
|
648 |
-
}
|
649 |
-
//}
|
650 |
-
|
651 |
-
$order = 'ASC';
|
652 |
-
$sortby = ! empty( $_POST['sorting'] ) ? sanitize_text_field( $_POST['sorting'] ) : $directory_data['sortby'];
|
653 |
-
$sortby = ( $sortby == 'other' ) ? $directory_data['sortby_custom'] : $sortby;
|
654 |
-
|
655 |
-
$custom_sort = array();
|
656 |
-
if ( ! empty( $directory_data['sorting_fields'] ) ) {
|
657 |
-
$sorting_fields = maybe_unserialize( $directory_data['sorting_fields'] );
|
658 |
-
foreach ( $sorting_fields as $field ) {
|
659 |
-
if ( is_array( $field ) ) {
|
660 |
-
$field_keys = array_keys( $field );
|
661 |
-
$custom_sort[] = $field_keys[0];
|
662 |
-
}
|
663 |
-
}
|
664 |
-
}
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
if (
|
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 |
-
} elseif (
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
$this->sql_order = " ORDER BY
|
713 |
-
|
714 |
-
} elseif (
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
$this->
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
}
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
}
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
$user_ids = $wpdb->get_col(
|
796 |
-
"SELECT SQL_CALC_FOUND_ROWS DISTINCT u.ID
|
797 |
-
{$this->select}
|
798 |
-
FROM {$wpdb->users} AS u
|
799 |
-
{$sql_join}
|
800 |
-
WHERE 1=1 {$sql_where}
|
801 |
-
{$this->having}
|
802 |
-
{$this->sql_order}
|
803 |
-
{$this->sql_limit}"
|
804 |
-
);
|
805 |
-
|
806 |
-
$query = array(
|
807 |
-
'select' => $this->select,
|
808 |
-
'sql_where' => $sql_where,
|
809 |
-
'having' => $this->having,
|
810 |
-
'sql_limit' => $this->sql_limit,
|
811 |
-
);
|
812 |
-
|
813 |
-
$total_users = (int) $wpdb->get_var( 'SELECT FOUND_ROWS()' );
|
814 |
-
|
815 |
-
/**
|
816 |
-
* UM hook
|
817 |
-
*
|
818 |
-
* @type filter
|
819 |
-
* @title um_prepare_user_results_array_meta
|
820 |
-
* @description Extend member directory query result
|
821 |
-
* @input_vars
|
822 |
-
* [{"var":"$result","type":"array","desc":"Members Query Result"}]
|
823 |
-
* @change_log
|
824 |
-
* ["Since: 2.0"]
|
825 |
-
* @usage
|
826 |
-
* <?php add_filter( 'um_prepare_user_results_array', 'function_name', 10, 2 ); ?>
|
827 |
-
* @example
|
828 |
-
* <?php
|
829 |
-
* add_filter( 'um_prepare_user_results_array', 'my_prepare_user_results', 10, 2 );
|
830 |
-
* function my_prepare_user_results( $user_ids, $query ) {
|
831 |
-
* // your code here
|
832 |
-
* return $user_ids;
|
833 |
-
* }
|
834 |
-
* ?>
|
835 |
-
*/
|
836 |
-
$user_ids = apply_filters( 'um_prepare_user_results_array_meta', $user_ids, $query );
|
837 |
-
|
838 |
-
$pagination_data = $this->calculate_pagination( $directory_data, $total_users );
|
839 |
-
|
840 |
-
$sizes = UM()->options()->get( 'cover_thumb_sizes' );
|
841 |
-
|
842 |
-
$this->cover_size = UM()->mobile()->isTablet() ? $sizes[1] : end( $sizes );
|
843 |
-
|
844 |
-
$avatar_size = UM()->options()->get( 'profile_photosize' );
|
845 |
-
$this->avatar_size = str_replace( 'px', '', $avatar_size );
|
846 |
-
|
847 |
-
$users = array();
|
848 |
-
foreach ( $user_ids as $user_id ) {
|
849 |
-
$users[] = $this->build_user_card_data( $user_id, $directory_data );
|
850 |
-
}
|
851 |
-
|
852 |
-
um_reset_user();
|
853 |
-
// end of user card
|
854 |
-
|
855 |
-
$member_directory_response = apply_filters( 'um_ajax_get_members_response', array(
|
856 |
-
'pagination' => $pagination_data,
|
857 |
-
'users' => $users,
|
858 |
-
'is_search' => $this->is_search,
|
859 |
-
), $directory_data );
|
860 |
-
|
861 |
-
wp_send_json_success( $member_directory_response );
|
862 |
-
}
|
863 |
-
}
|
864 |
-
}
|
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 |
+
$directory_id = $this->get_directory_by_hash( $_POST['directory_id'] );
|
450 |
+
$directory_data = UM()->query()->post_data( $directory_id );
|
451 |
+
|
452 |
+
//predefined result for user without capabilities to see other members
|
453 |
+
$this->predefined_no_caps( $directory_data );
|
454 |
+
|
455 |
+
do_action( 'um_member_directory_before_query' );
|
456 |
+
|
457 |
+
// Prepare for BIG SELECT query
|
458 |
+
$wpdb->query( 'SET SQL_BIG_SELECTS=1' );
|
459 |
+
|
460 |
+
|
461 |
+
if ( ! empty( $directory_data['show_these_users'] ) ) {
|
462 |
+
$show_these_users = maybe_unserialize( $directory_data['show_these_users'] );
|
463 |
+
|
464 |
+
if ( is_array( $show_these_users ) && ! empty( $show_these_users ) ) {
|
465 |
+
$users_array = array();
|
466 |
+
foreach ( $show_these_users as $username ) {
|
467 |
+
if ( false !== ( $exists_id = username_exists( $username ) ) ) {
|
468 |
+
$users_array[] = $exists_id;
|
469 |
+
}
|
470 |
+
}
|
471 |
+
|
472 |
+
if ( ! empty( $users_array ) ) {
|
473 |
+
$this->where_clauses[] = "u.ID IN ( '" . implode( "','", $users_array ) . "' )";
|
474 |
+
}
|
475 |
+
}
|
476 |
+
}
|
477 |
+
|
478 |
+
if ( ! empty( $directory_data['exclude_these_users'] ) ) {
|
479 |
+
$exclude_these_users = maybe_unserialize( $directory_data['exclude_these_users'] );
|
480 |
+
|
481 |
+
if ( is_array( $exclude_these_users ) && ! empty( $exclude_these_users ) ) {
|
482 |
+
$users_array = array();
|
483 |
+
foreach ( $exclude_these_users as $username ) {
|
484 |
+
if ( false !== ( $exists_id = username_exists( $username ) ) ) {
|
485 |
+
$users_array[] = $exists_id;
|
486 |
+
}
|
487 |
+
}
|
488 |
+
|
489 |
+
if ( ! empty( $users_array ) ) {
|
490 |
+
$this->where_clauses[] = "u.ID NOT IN ( '" . implode( "','", $users_array ) . "' )";
|
491 |
+
}
|
492 |
+
}
|
493 |
+
}
|
494 |
+
|
495 |
+
|
496 |
+
$profile_photo_where = '';
|
497 |
+
if ( $directory_data['has_profile_photo'] == 1 ) {
|
498 |
+
$profile_photo_where = " AND umm_general.um_value LIKE '%s:13:\"profile_photo\";b:1;%'";
|
499 |
+
}
|
500 |
+
|
501 |
+
$cover_photo_where = '';
|
502 |
+
if ( $directory_data['has_cover_photo'] == 1 ) {
|
503 |
+
$cover_photo_where = " AND umm_general.um_value LIKE '%s:11:\"cover_photo\";b:1;%'";
|
504 |
+
}
|
505 |
+
|
506 |
+
if ( ! UM()->roles()->um_user_can( 'can_edit_everyone' ) ) {
|
507 |
+
if ( ! $this->general_meta_joined ) {
|
508 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_general ON umm_general.user_id = u.ID";
|
509 |
+
$this->general_meta_joined = true;
|
510 |
+
}
|
511 |
+
$this->where_clauses[] = "( umm_general.um_key = 'um_member_directory_data' AND
|
512 |
+
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} )";
|
513 |
+
} else {
|
514 |
+
if ( ! empty( $cover_photo_where ) || ! empty( $profile_photo_where ) ) {
|
515 |
+
if ( ! $this->general_meta_joined ) {
|
516 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_general ON umm_general.user_id = u.ID";
|
517 |
+
$this->general_meta_joined = true;
|
518 |
+
}
|
519 |
+
$this->where_clauses[] = "( umm_general.um_key = 'um_member_directory_data'{$profile_photo_where}{$cover_photo_where} )";
|
520 |
+
}
|
521 |
+
}
|
522 |
+
|
523 |
+
//$this->roles = array();
|
524 |
+
if ( UM()->roles()->um_user_can( 'can_view_all' ) ) {
|
525 |
+
$view_roles = um_user( 'can_view_roles' );
|
526 |
+
|
527 |
+
if ( ! $view_roles ) {
|
528 |
+
$view_roles = array();
|
529 |
+
} else {
|
530 |
+
$this->roles_in_query = true;
|
531 |
+
}
|
532 |
+
|
533 |
+
$this->roles = array_merge( $this->roles, maybe_unserialize( $view_roles ) );
|
534 |
+
}
|
535 |
+
|
536 |
+
if ( ! empty( $directory_data['roles'] ) ) {
|
537 |
+
if ( ! empty( $this->roles ) ) {
|
538 |
+
$this->roles = array_intersect( $this->roles, maybe_unserialize( $directory_data['roles'] ) );
|
539 |
+
} else {
|
540 |
+
$this->roles = array_merge( $this->roles, maybe_unserialize( $directory_data['roles'] ) );
|
541 |
+
}
|
542 |
+
|
543 |
+
$this->roles_in_query = true;
|
544 |
+
}
|
545 |
+
|
546 |
+
if ( ! empty( $this->roles ) ) {
|
547 |
+
$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' )";
|
548 |
+
|
549 |
+
$roles_clauses = array();
|
550 |
+
foreach ( $this->roles as $role ) {
|
551 |
+
$roles_clauses[] = $wpdb->prepare( 'umm_roles.um_value LIKE %s', '%"' . $role . '"%' );
|
552 |
+
}
|
553 |
+
|
554 |
+
$this->where_clauses[] = '( ' . implode( ' OR ', $roles_clauses ) . ' )';
|
555 |
+
} else {
|
556 |
+
|
557 |
+
if ( ! $this->roles_in_query && is_multisite() ) {
|
558 |
+
// select users who have capabilities for current blog
|
559 |
+
$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' )";
|
560 |
+
$this->where_clauses[] = "umm_roles.um_value IS NOT NULL";
|
561 |
+
} elseif ( $this->roles_in_query ) {
|
562 |
+
$member_directory_response = apply_filters( 'um_ajax_get_members_response', array(
|
563 |
+
'pagination' => $this->calculate_pagination( $directory_data, 0 ),
|
564 |
+
'users' => array(),
|
565 |
+
'is_search' => $this->is_search,
|
566 |
+
), $directory_data );
|
567 |
+
|
568 |
+
wp_send_json_success( $member_directory_response );
|
569 |
+
}
|
570 |
+
}
|
571 |
+
|
572 |
+
|
573 |
+
if ( ! empty( $_POST['search'] ) ) {
|
574 |
+
$search_line = trim( stripslashes( sanitize_text_field( $_POST['search'] ) ) );
|
575 |
+
|
576 |
+
$searches = array();
|
577 |
+
foreach ( $this->core_search_fields as $field ) {
|
578 |
+
$searches[] = $wpdb->prepare( "u.{$field} LIKE %s", '%' . $search_line . '%' );
|
579 |
+
}
|
580 |
+
|
581 |
+
$core_search = implode( ' OR ', $searches );
|
582 |
+
|
583 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_search ON umm_search.user_id = u.ID";
|
584 |
+
|
585 |
+
$additional_search = apply_filters( 'um_member_directory_meta_general_search_meta_query', '', stripslashes( sanitize_text_field( $_POST['search'] ) ) );
|
586 |
+
|
587 |
+
$search_like_string = apply_filters( 'um_member_directory_meta_search_like_type', '%' . $search_line . '%', $search_line );
|
588 |
+
|
589 |
+
$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 ) . '%' );
|
590 |
+
|
591 |
+
$this->is_search = true;
|
592 |
+
}
|
593 |
+
|
594 |
+
|
595 |
+
//filters
|
596 |
+
$filter_query = array();
|
597 |
+
if ( ! empty( $directory_data['search_fields'] ) ) {
|
598 |
+
$search_filters = maybe_unserialize( $directory_data['search_fields'] );
|
599 |
+
if ( ! empty( $search_filters ) && is_array( $search_filters ) ) {
|
600 |
+
$filter_query = array_intersect_key( $_POST, array_flip( $search_filters ) );
|
601 |
+
}
|
602 |
+
}
|
603 |
+
|
604 |
+
// added for user tags extension integration on individual tag page
|
605 |
+
$ignore_empty_filters = apply_filters( 'um_member_directory_ignore_empty_filters', false );
|
606 |
+
|
607 |
+
if ( ! empty( $filter_query ) || $ignore_empty_filters ) {
|
608 |
+
$this->is_search = true;
|
609 |
+
|
610 |
+
$i = 1;
|
611 |
+
foreach ( $filter_query as $field => $value ) {
|
612 |
+
|
613 |
+
$field = sanitize_text_field( $field );
|
614 |
+
if ( is_array( $value ) ) {
|
615 |
+
$value = array_map( 'sanitize_text_field', $value );
|
616 |
+
} else {
|
617 |
+
$value = sanitize_text_field( $value );
|
618 |
+
}
|
619 |
+
|
620 |
+
$attrs = UM()->fields()->get_field( $field );
|
621 |
+
// skip private invisible fields
|
622 |
+
if ( ! um_can_view_field( $attrs ) ) {
|
623 |
+
continue;
|
624 |
+
}
|
625 |
+
|
626 |
+
$this->handle_filter_query( $directory_data, $field, $value, $i );
|
627 |
+
|
628 |
+
$i++;
|
629 |
+
}
|
630 |
+
}
|
631 |
+
|
632 |
+
|
633 |
+
//unable default filter in case if we select other filters in frontend filters
|
634 |
+
//if ( empty( $this->custom_filters_in_query ) ) {
|
635 |
+
$default_filters = array();
|
636 |
+
if ( ! empty( $directory_data['search_filters'] ) ) {
|
637 |
+
$default_filters = maybe_unserialize( $directory_data['search_filters'] );
|
638 |
+
}
|
639 |
+
|
640 |
+
if ( ! empty( $default_filters ) ) {
|
641 |
+
$i = 1;
|
642 |
+
foreach ( $default_filters as $field => $value ) {
|
643 |
+
|
644 |
+
$this->handle_filter_query( $directory_data, $field, $value, $i, true );
|
645 |
+
|
646 |
+
$i++;
|
647 |
+
}
|
648 |
+
}
|
649 |
+
//}
|
650 |
+
|
651 |
+
$order = 'ASC';
|
652 |
+
$sortby = ! empty( $_POST['sorting'] ) ? sanitize_text_field( $_POST['sorting'] ) : $directory_data['sortby'];
|
653 |
+
$sortby = ( $sortby == 'other' ) ? $directory_data['sortby_custom'] : $sortby;
|
654 |
+
|
655 |
+
$custom_sort = array();
|
656 |
+
if ( ! empty( $directory_data['sorting_fields'] ) ) {
|
657 |
+
$sorting_fields = maybe_unserialize( $directory_data['sorting_fields'] );
|
658 |
+
foreach ( $sorting_fields as $field ) {
|
659 |
+
if ( is_array( $field ) ) {
|
660 |
+
$field_keys = array_keys( $field );
|
661 |
+
$custom_sort[] = $field_keys[0];
|
662 |
+
}
|
663 |
+
}
|
664 |
+
}
|
665 |
+
|
666 |
+
$numeric_sorting_keys = array();
|
667 |
+
|
668 |
+
if ( ! empty( UM()->builtin()->saved_fields ) ) {
|
669 |
+
foreach ( UM()->builtin()->saved_fields as $key => $data ) {
|
670 |
+
if ( $key == '_um_last_login' ) {
|
671 |
+
continue;
|
672 |
+
}
|
673 |
+
|
674 |
+
if ( isset( $data['type'] ) && 'number' === $data['type'] ) {
|
675 |
+
if ( array_key_exists( $key . '_desc', $this->sort_fields ) ) {
|
676 |
+
$numeric_sorting_keys[] = $key . '_desc';
|
677 |
+
}
|
678 |
+
if ( array_key_exists( $key . '_asc', $this->sort_fields ) ) {
|
679 |
+
$numeric_sorting_keys[] = $key . '_asc';
|
680 |
+
}
|
681 |
+
}
|
682 |
+
}
|
683 |
+
}
|
684 |
+
|
685 |
+
// handle sorting options
|
686 |
+
// sort members by
|
687 |
+
if ( $sortby == $directory_data['sortby_custom'] || in_array( $sortby, $custom_sort ) ) {
|
688 |
+
|
689 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = '{$sortby}' )";
|
690 |
+
|
691 |
+
$custom_sort_type = apply_filters( 'um_member_directory_custom_sorting_type', 'CHAR', $sortby, $directory_data );
|
692 |
+
|
693 |
+
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS {$custom_sort_type} ) {$order} ";
|
694 |
+
|
695 |
+
} elseif ( count( $numeric_sorting_keys ) && in_array( $sortby, $numeric_sorting_keys ) ) {
|
696 |
+
|
697 |
+
if ( strstr( $sortby, '_desc' ) ) {
|
698 |
+
$sortby = str_replace( '_desc', '', $sortby );
|
699 |
+
$order = 'DESC';
|
700 |
+
}
|
701 |
+
|
702 |
+
if ( strstr( $sortby, '_asc' ) ) {
|
703 |
+
$sortby = str_replace( '_asc', '', $sortby );
|
704 |
+
$order = 'ASC';
|
705 |
+
}
|
706 |
+
|
707 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = '{$sortby}' )";
|
708 |
+
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS SIGNED ) {$order}, u.user_registered DESC ";
|
709 |
+
|
710 |
+
} elseif ( 'username' == $sortby ) {
|
711 |
+
|
712 |
+
$this->sql_order = " ORDER BY u.user_login {$order} ";
|
713 |
+
|
714 |
+
} elseif ( 'display_name' == $sortby ) {
|
715 |
+
|
716 |
+
$display_name = UM()->options()->get( 'display_name' );
|
717 |
+
if ( $display_name == 'username' ) {
|
718 |
+
|
719 |
+
$this->sql_order = " ORDER BY u.user_login {$order} ";
|
720 |
+
|
721 |
+
} else {
|
722 |
+
|
723 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = 'full_name' )";
|
724 |
+
|
725 |
+
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS CHAR ) {$order}, u.display_name {$order} ";
|
726 |
+
|
727 |
+
}
|
728 |
+
|
729 |
+
} elseif ( in_array( $sortby, array( 'last_name', 'first_name', 'nickname' ) ) ) {
|
730 |
+
|
731 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = '{$sortby}' )";
|
732 |
+
|
733 |
+
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS CHAR ) {$order} ";
|
734 |
+
|
735 |
+
} elseif ( $sortby == 'last_login' ) {
|
736 |
+
|
737 |
+
$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' )";
|
738 |
+
|
739 |
+
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS SIGNED ) DESC ";
|
740 |
+
|
741 |
+
} elseif ( $sortby == 'last_first_name' ) {
|
742 |
+
|
743 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = 'last_name' )";
|
744 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort2 ON ( umm_sort2.user_id = u.ID AND umm_sort2.um_key = 'first_name' )";
|
745 |
+
|
746 |
+
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS CHAR ) ASC, CAST( umm_sort2.um_value AS CHAR ) ASC ";
|
747 |
+
|
748 |
+
} elseif ( $sortby == 'random' ) {
|
749 |
+
|
750 |
+
if ( um_is_session_started() === false ) {
|
751 |
+
@session_start();
|
752 |
+
}
|
753 |
+
|
754 |
+
// Reset seed on load of initial
|
755 |
+
if ( empty( $_REQUEST['directory_id'] ) && isset( $_SESSION['um_member_directory_seed'] ) ) {
|
756 |
+
unset( $_SESSION['um_member_directory_seed'] );
|
757 |
+
}
|
758 |
+
|
759 |
+
// Get seed from session variable if it exists
|
760 |
+
$seed = false;
|
761 |
+
if ( isset( $_SESSION['um_member_directory_seed'] ) ) {
|
762 |
+
$seed = $_SESSION['um_member_directory_seed'];
|
763 |
+
}
|
764 |
+
|
765 |
+
// Set new seed if none exists
|
766 |
+
if ( ! $seed ) {
|
767 |
+
$seed = rand();
|
768 |
+
$_SESSION['um_member_directory_seed'] = $seed;
|
769 |
+
}
|
770 |
+
|
771 |
+
$this->sql_order = 'ORDER BY RAND(' . $seed . ')';
|
772 |
+
|
773 |
+
} else {
|
774 |
+
|
775 |
+
if ( strstr( $sortby, '_desc' ) ) {
|
776 |
+
$sortby = str_replace( '_desc', '', $sortby );
|
777 |
+
$order = 'DESC';
|
778 |
+
}
|
779 |
+
|
780 |
+
if ( strstr( $sortby, '_asc' ) ) {
|
781 |
+
$sortby = str_replace( '_asc', '', $sortby );
|
782 |
+
$order = 'ASC';
|
783 |
+
}
|
784 |
+
|
785 |
+
$metakeys = get_option( 'um_usermeta_fields', array() );
|
786 |
+
if ( false !== array_search( $sortby, $metakeys ) ) {
|
787 |
+
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = '{$sortby}' )";
|
788 |
+
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS CHAR ) {$order} ";
|
789 |
+
} else {
|
790 |
+
$this->sql_order = " ORDER BY u.{$sortby} {$order} ";
|
791 |
+
}
|
792 |
+
}
|
793 |
+
|
794 |
+
$this->sq
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|