Version Description
Download this release
Release Info
Developer | nsinelnikov |
Plugin | Ultimate Member – User Profile & Membership Plugin |
Version | 2.5.1 |
Comparing to | |
See all releases |
Code changes from version 2.5.0 to 2.5.1
- includes/admin/core/class-admin-builder.php +1236 -1232
- includes/admin/core/class-admin-settings.php +3477 -3478
- includes/admin/core/class-admin-upgrade.php +15 -5
- includes/core/class-access.php +2141 -2136
- includes/core/class-builtin.php +17 -14
- includes/core/class-fields.php +56 -28
- includes/core/class-form.php +872 -837
- includes/core/class-shortcodes.php +6 -1
- includes/core/class-uploader.php +6 -6
- includes/core/class-user.php +21 -1
- includes/core/class-validation.php +422 -420
- includes/core/um-actions-form.php +934 -934
- includes/core/um-actions-login.php +481 -481
- includes/core/um-actions-profile.php +6 -4
- includes/core/um-actions-register.php +5 -2
- includes/core/um-filters-fields.php +3 -0
- includes/core/um-filters-navmenu.php +19 -16
- includes/um-short-functions.php +2793 -2808
- languages/ultimate-member.pot +575 -566
- readme.txt +26 -1
- ultimate-member.php +1 -1
includes/admin/core/class-admin-builder.php
CHANGED
@@ -1,1232 +1,1236 @@
|
|
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 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
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, $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 |
+
if ( in_array( $um_callback_func, UM()->fields()->dropdown_options_source_blacklist(), true ) ) {
|
1224 |
+
wp_send_json_error( __( 'This is not possible for security reasons. Don\'t use internal PHP functions.', 'ultimate-member' ) );
|
1225 |
+
}
|
1226 |
+
|
1227 |
+
$arr_options['data'] = array();
|
1228 |
+
if ( function_exists( $um_callback_func ) ) {
|
1229 |
+
$arr_options['data'] = call_user_func( $um_callback_func );
|
1230 |
+
}
|
1231 |
+
|
1232 |
+
wp_send_json( $arr_options );
|
1233 |
+
}
|
1234 |
+
|
1235 |
+
}
|
1236 |
+
}
|
includes/admin/core/class-admin-settings.php
CHANGED
@@ -1,3478 +1,3477 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\admin\core;
|
3 |
-
|
4 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
-
exit;
|
6 |
-
}
|
7 |
-
|
8 |
-
if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Admin_Settings
|
13 |
-
* @package um\admin\core
|
14 |
-
*/
|
15 |
-
class Admin_Settings {
|
16 |
-
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @var array
|
20 |
-
*/
|
21 |
-
public $settings_map;
|
22 |
-
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @var array
|
26 |
-
*/
|
27 |
-
public $settings_structure;
|
28 |
-
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @var
|
32 |
-
*/
|
33 |
-
private $previous_licenses;
|
34 |
-
|
35 |
-
|
36 |
-
/**
|
37 |
-
* @var
|
38 |
-
*/
|
39 |
-
private $need_change_permalinks;
|
40 |
-
|
41 |
-
|
42 |
-
private $gravatar_changed = false;
|
43 |
-
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Admin_Settings constructor.
|
47 |
-
*/
|
48 |
-
public function __construct() {
|
49 |
-
//init settings structure
|
50 |
-
add_action( 'admin_init', array( &$this, 'init_variables' ), 9 );
|
51 |
-
|
52 |
-
//admin menu
|
53 |
-
add_action( 'admin_menu', array( &$this, 'primary_admin_menu' ), 0 );
|
54 |
-
|
55 |
-
//settings structure handlers
|
56 |
-
add_action( 'um_settings_page_before_email__content', array( $this, 'settings_before_email_tab' ) );
|
57 |
-
add_filter( 'um_settings_section_email__content', array( $this, 'settings_email_tab' ), 10, 1 );
|
58 |
-
|
59 |
-
//enqueue wp_media for profiles tab
|
60 |
-
add_action( 'um_settings_page_appearance__before_section', array( $this, 'settings_appearance_profile_tab' ) );
|
61 |
-
|
62 |
-
//custom content for licenses tab
|
63 |
-
add_filter( 'um_settings_section_licenses__content', array( $this, 'settings_licenses_tab' ), 10, 2 );
|
64 |
-
|
65 |
-
add_filter( 'um_settings_section_install_info__content', array( $this, 'settings_install_info_tab' ), 10, 2 );
|
66 |
-
|
67 |
-
|
68 |
-
add_filter( 'um_settings_structure', array( $this, 'sorting_licenses_options' ), 9999, 1 );
|
69 |
-
|
70 |
-
|
71 |
-
//save handlers
|
72 |
-
add_action( 'admin_init', array( $this, 'save_settings_handler' ), 10 );
|
73 |
-
|
74 |
-
//save pages options
|
75 |
-
add_action( 'um_settings_before_save', array( $this, 'check_permalinks_changes' ) );
|
76 |
-
add_action( 'um_settings_save', array( $this, 'on_settings_save' ) );
|
77 |
-
|
78 |
-
|
79 |
-
add_filter( 'um_change_settings_before_save', array( $this, 'save_email_templates' ) );
|
80 |
-
|
81 |
-
|
82 |
-
//save licenses options
|
83 |
-
add_action( 'um_settings_before_save', array( $this, 'before_licenses_save' ) );
|
84 |
-
add_action( 'um_settings_save', array( $this, 'licenses_save' ) );
|
85 |
-
|
86 |
-
add_filter( 'um_change_settings_before_save', array( $this, 'set_default_if_empty' ), 9, 1 );
|
87 |
-
add_filter( 'um_change_settings_before_save', array( $this, 'remove_empty_values' ), 10, 1 );
|
88 |
-
|
89 |
-
add_action( 'admin_init', array( &$this, 'um_download_install_info' ) );
|
90 |
-
}
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
public function same_page_update_ajax() {
|
95 |
-
UM()->admin()->check_ajax_nonce();
|
96 |
-
|
97 |
-
if ( empty( $_POST['cb_func'] ) ) {
|
98 |
-
wp_send_json_error( __( 'Wrong callback', 'ultimate-member' ) );
|
99 |
-
}
|
100 |
-
|
101 |
-
$cb_func = sanitize_key( $_POST['cb_func'] );
|
102 |
-
|
103 |
-
if ( 'um_usermeta_fields' === $cb_func ) {
|
104 |
-
//first install metatable
|
105 |
-
global $wpdb;
|
106 |
-
|
107 |
-
$metakeys = array();
|
108 |
-
foreach ( UM()->builtin()->all_user_fields as $all_user_field ) {
|
109 |
-
$metakeys[] = $all_user_field['metakey'];
|
110 |
-
}
|
111 |
-
|
112 |
-
$metakeys = apply_filters( 'um_metadata_same_page_update_ajax', $metakeys, UM()->builtin()->all_user_fields );
|
113 |
-
|
114 |
-
if ( is_multisite() ) {
|
115 |
-
|
116 |
-
$sites = get_sites( array( 'fields' => 'ids' ) );
|
117 |
-
foreach ( $sites as $blog_id ) {
|
118 |
-
$metakeys[] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
|
119 |
-
}
|
120 |
-
} else {
|
121 |
-
$blog_id = get_current_blog_id();
|
122 |
-
$metakeys[] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
|
123 |
-
}
|
124 |
-
|
125 |
-
//member directory data
|
126 |
-
$metakeys[] = 'um_member_directory_data';
|
127 |
-
$metakeys[] = '_um_verified';
|
128 |
-
$metakeys[] = '_money_spent';
|
129 |
-
$metakeys[] = '_completed';
|
130 |
-
$metakeys[] = '_reviews_avg';
|
131 |
-
|
132 |
-
//myCred meta
|
133 |
-
if ( function_exists( 'mycred_get_types' ) ) {
|
134 |
-
$mycred_types = mycred_get_types();
|
135 |
-
if ( ! empty( $mycred_types ) ) {
|
136 |
-
foreach ( array_keys( $mycred_types ) as $point_type ) {
|
137 |
-
$metakeys[] = $point_type;
|
138 |
-
}
|
139 |
-
}
|
140 |
-
}
|
141 |
-
|
142 |
-
$sortby_custom_keys = $wpdb->get_col( "SELECT DISTINCT meta_value FROM {$wpdb->postmeta} WHERE meta_key='_um_sortby_custom'" );
|
143 |
-
if ( empty( $sortby_custom_keys ) ) {
|
144 |
-
$sortby_custom_keys = array();
|
145 |
-
}
|
146 |
-
|
147 |
-
$sortby_custom_keys2 = $wpdb->get_col( "SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key='_um_sorting_fields'" );
|
148 |
-
if ( ! empty( $sortby_custom_keys2 ) ) {
|
149 |
-
foreach ( $sortby_custom_keys2 as $custom_val ) {
|
150 |
-
$custom_val = maybe_unserialize( $custom_val );
|
151 |
-
|
152 |
-
foreach ( $custom_val as $sort_value ) {
|
153 |
-
if ( is_array( $sort_value ) ) {
|
154 |
-
$field_keys = array_keys( $sort_value );
|
155 |
-
$sortby_custom_keys[] = $field_keys[0];
|
156 |
-
}
|
157 |
-
}
|
158 |
-
}
|
159 |
-
}
|
160 |
-
|
161 |
-
if ( ! empty( $sortby_custom_keys ) ) {
|
162 |
-
$sortby_custom_keys = array_unique( $sortby_custom_keys );
|
163 |
-
$metakeys = array_merge( $metakeys, $sortby_custom_keys );
|
164 |
-
}
|
165 |
-
|
166 |
-
$skip_fields = UM()->builtin()->get_fields_without_metakey();
|
167 |
-
$skip_fields = array_merge( $skip_fields, UM()->member_directory()->core_search_fields );
|
168 |
-
|
169 |
-
$real_usermeta = $wpdb->get_col( "SELECT DISTINCT meta_key FROM {$wpdb->usermeta}" );
|
170 |
-
$real_usermeta = ! empty( $real_usermeta ) ? $real_usermeta : array();
|
171 |
-
$real_usermeta = array_merge( $real_usermeta, array( 'um_member_directory_data' ) );
|
172 |
-
|
173 |
-
if ( ! empty( $sortby_custom_keys ) ) {
|
174 |
-
$real_usermeta = array_merge( $real_usermeta, $sortby_custom_keys );
|
175 |
-
}
|
176 |
-
|
177 |
-
$wp_usermeta_option = array_intersect( array_diff( $metakeys, $skip_fields ), $real_usermeta );
|
178 |
-
|
179 |
-
update_option( 'um_usermeta_fields', array_values( $wp_usermeta_option ) );
|
180 |
-
|
181 |
-
update_option( 'um_member_directory_update_meta', time() );
|
182 |
-
|
183 |
-
UM()->options()->update( 'member_directory_own_table', true );
|
184 |
-
|
185 |
-
wp_send_json_success();
|
186 |
-
} elseif ( 'um_get_metadata' === $cb_func ) {
|
187 |
-
global $wpdb;
|
188 |
-
|
189 |
-
$wp_usermeta_option = get_option( 'um_usermeta_fields', array() );
|
190 |
-
|
191 |
-
$count = $wpdb->get_var(
|
192 |
-
"SELECT COUNT(*)
|
193 |
-
FROM {$wpdb->usermeta}
|
194 |
-
WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "')"
|
195 |
-
);
|
196 |
-
|
197 |
-
wp_send_json_success( array( 'count' => $count ) );
|
198 |
-
} elseif ( 'um_update_metadata_per_page' === $cb_func ) {
|
199 |
-
|
200 |
-
if ( empty( $_POST['page'] ) ) {
|
201 |
-
wp_send_json_error( __( 'Wrong data', 'ultimate-member' ) );
|
202 |
-
}
|
203 |
-
|
204 |
-
$per_page = 500;
|
205 |
-
$wp_usermeta_option = get_option( 'um_usermeta_fields', array() );
|
206 |
-
|
207 |
-
global $wpdb;
|
208 |
-
$metadata = $wpdb->get_results(
|
209 |
-
$wpdb->prepare(
|
210 |
-
"SELECT *
|
211 |
-
FROM {$wpdb->usermeta}
|
212 |
-
WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "')
|
213 |
-
LIMIT %d, %d",
|
214 |
-
( absint( $_POST['page'] ) - 1 ) * $per_page,
|
215 |
-
$per_page
|
216 |
-
),
|
217 |
-
ARRAY_A
|
218 |
-
);
|
219 |
-
|
220 |
-
$values = array();
|
221 |
-
foreach ( $metadata as $metarow ) {
|
222 |
-
$values[] = $wpdb->prepare( '(%d, %s, %s)', $metarow['user_id'], $metarow['meta_key'], $metarow['meta_value'] );
|
223 |
-
}
|
224 |
-
|
225 |
-
if ( ! empty( $values ) ) {
|
226 |
-
$wpdb->query(
|
227 |
-
"INSERT INTO
|
228 |
-
{$wpdb->prefix}um_metadata(user_id, um_key, um_value)
|
229 |
-
VALUES " . implode( ',', $values )
|
230 |
-
);
|
231 |
-
}
|
232 |
-
|
233 |
-
$from = ( absint( $_POST['page'] ) * $per_page ) - $per_page + 1;
|
234 |
-
$to = absint( $_POST['page'] ) * $per_page;
|
235 |
-
|
236 |
-
wp_send_json_success( array( 'message' => sprintf( __( 'Metadata from %1$s to %2$s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
|
237 |
-
} else {
|
238 |
-
do_action( 'um_same_page_update_ajax_action', $cb_func );
|
239 |
-
}
|
240 |
-
}
|
241 |
-
|
242 |
-
|
243 |
-
/**
|
244 |
-
*
|
245 |
-
*/
|
246 |
-
public function init_variables() {
|
247 |
-
|
248 |
-
$settings_map = array();
|
249 |
-
|
250 |
-
$general_pages_fields = array(
|
251 |
-
array(
|
252 |
-
'id' => 'pages_settings',
|
253 |
-
'type' => 'hidden',
|
254 |
-
'value' => true,
|
255 |
-
'is_option' => false,
|
256 |
-
),
|
257 |
-
);
|
258 |
-
|
259 |
-
$core_pages = UM()->config()->core_pages;
|
260 |
-
|
261 |
-
foreach ( $core_pages as $page_s => $page ) {
|
262 |
-
$have_pages = UM()->query()->wp_pages();
|
263 |
-
$page_id = UM()->options()->get_core_page_id( $page_s );
|
264 |
-
|
265 |
-
$page_title = ! empty( $page['title'] ) ? $page['title'] : '';
|
266 |
-
|
267 |
-
if ( 'reached_maximum_limit' === $have_pages ) {
|
268 |
-
$general_pages_fields[] = array(
|
269 |
-
'id' => $page_id,
|
270 |
-
'type' => 'text',
|
271 |
-
// translators: %s: Page title
|
272 |
-
'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ),
|
273 |
-
'placeholder' => __( 'Add page ID', 'ultimate-member' ),
|
274 |
-
'compiler' => true,
|
275 |
-
'size' => 'small',
|
276 |
-
);
|
277 |
-
} else {
|
278 |
-
$general_pages_fields[] = array(
|
279 |
-
'id' => $page_id,
|
280 |
-
'type' => 'select',
|
281 |
-
// translators: %s: Page title
|
282 |
-
'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ),
|
283 |
-
'options' => UM()->query()->wp_pages(),
|
284 |
-
'placeholder' => __( 'Choose a page...', 'ultimate-member' ),
|
285 |
-
'compiler' => true,
|
286 |
-
'size' => 'small',
|
287 |
-
);
|
288 |
-
}
|
289 |
-
|
290 |
-
|
291 |
-
$settings_map[ $page_id ] = array(
|
292 |
-
'sanitize' => 'absint',
|
293 |
-
);
|
294 |
-
}
|
295 |
-
|
296 |
-
$appearances_profile_menu_fields = array(
|
297 |
-
array(
|
298 |
-
'id' => 'profile_menu',
|
299 |
-
'type' => 'checkbox',
|
300 |
-
'label' => __( 'Enable profile menu', 'ultimate-member' ),
|
301 |
-
),
|
302 |
-
);
|
303 |
-
|
304 |
-
$settings_map['profile_menu'] = array(
|
305 |
-
'sanitize' => 'bool',
|
306 |
-
);
|
307 |
-
|
308 |
-
$tabs = UM()->profile()->tabs();
|
309 |
-
|
310 |
-
$tabs_options = array();
|
311 |
-
$tabs_condition = array();
|
312 |
-
foreach ( $tabs as $id => $tab ) {
|
313 |
-
|
314 |
-
if ( ! empty( $tab['hidden'] ) ) {
|
315 |
-
continue;
|
316 |
-
}
|
317 |
-
|
318 |
-
if ( isset( $tab['name'] ) ) {
|
319 |
-
$tabs_options[ $id ] = $tab['name'];
|
320 |
-
$tabs_condition[] = 'profile_tab_' . $id;
|
321 |
-
}
|
322 |
-
|
323 |
-
if ( isset( $tab['default_privacy'] ) ) {
|
324 |
-
$fields = array(
|
325 |
-
array(
|
326 |
-
'id' => 'profile_tab_' . $id,
|
327 |
-
'type' => 'checkbox',
|
328 |
-
// translators: %s: Tab title
|
329 |
-
'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ),
|
330 |
-
'conditional' => array( 'profile_menu', '=', 1 ),
|
331 |
-
'data' => array( 'fill_profile_menu_default_tab' => $id ),
|
332 |
-
),
|
333 |
-
);
|
334 |
-
|
335 |
-
$settings_map[ 'profile_tab_' . $id ] = array(
|
336 |
-
'sanitize' => 'bool',
|
337 |
-
);
|
338 |
-
} else {
|
339 |
-
|
340 |
-
$fields = array(
|
341 |
-
array(
|
342 |
-
'id' => 'profile_tab_' . $id,
|
343 |
-
'type' => 'checkbox',
|
344 |
-
// translators: %s: Tab title
|
345 |
-
'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ),
|
346 |
-
'conditional' => array( 'profile_menu', '=', 1 ),
|
347 |
-
'data' => array( 'fill_profile_menu_default_tab' => $id ),
|
348 |
-
),
|
349 |
-
array(
|
350 |
-
'id' => 'profile_tab_' . $id . '_privacy',
|
351 |
-
'type' => 'select',
|
352 |
-
// translators: %s: Tab title
|
353 |
-
'label' => sprintf( __( 'Who can see %s Tab?', 'ultimate-member' ), $tab['name'] ),
|
354 |
-
'tooltip' => __( 'Select which users can view this tab.', 'ultimate-member' ),
|
355 |
-
'options' => UM()->profile()->tabs_privacy(),
|
356 |
-
'conditional' => array( 'profile_tab_' . $id, '=', 1 ),
|
357 |
-
'size' => 'small',
|
358 |
-
),
|
359 |
-
array(
|
360 |
-
'id' => 'profile_tab_' . $id . '_roles',
|
361 |
-
'type' => 'select',
|
362 |
-
'multi' => true,
|
363 |
-
'label' => __( 'Allowed roles', 'ultimate-member' ),
|
364 |
-
'tooltip' => __( 'Select the the user roles allowed to view this tab.', 'ultimate-member' ),
|
365 |
-
'options' => UM()->roles()->get_roles(),
|
366 |
-
'placeholder' => __( 'Choose user roles...', 'ultimate-member' ),
|
367 |
-
'conditional' => array( 'profile_tab_' . $id . '_privacy', '=', array( '4', '5' ) ),
|
368 |
-
'size' => 'small',
|
369 |
-
),
|
370 |
-
);
|
371 |
-
|
372 |
-
$settings_map = array_merge(
|
373 |
-
$settings_map,
|
374 |
-
array(
|
375 |
-
"profile_tab_{$id}" => array(
|
376 |
-
'sanitize' => 'bool',
|
377 |
-
),
|
378 |
-
"profile_tab_{$id}_privacy" => array(
|
379 |
-
'sanitize' => array( UM()->admin(), 'sanitize_tabs_privacy' ),
|
380 |
-
),
|
381 |
-
"profile_tab_{$id}_roles" => array(
|
382 |
-
'sanitize' => array( UM()->admin(), 'sanitize_existed_role' ),
|
383 |
-
),
|
384 |
-
)
|
385 |
-
);
|
386 |
-
}
|
387 |
-
|
388 |
-
$appearances_profile_menu_fields = array_merge( $appearances_profile_menu_fields, $fields );
|
389 |
-
}
|
390 |
-
|
391 |
-
$appearances_profile_menu_fields[] = array(
|
392 |
-
'id' => 'profile_menu_default_tab',
|
393 |
-
'type' => 'select',
|
394 |
-
'label' => __( 'Profile menu default tab', 'ultimate-member' ),
|
395 |
-
'tooltip' => __( 'This will be the default tab on user profile page', 'ultimate-member' ),
|
396 |
-
'options' => $tabs_options,
|
397 |
-
'conditional' => array( implode( '|', $tabs_condition ), '~', 1 ),
|
398 |
-
'size' => 'small',
|
399 |
-
);
|
400 |
-
|
401 |
-
$settings_map['profile_menu_default_tab'] = array(
|
402 |
-
'sanitize' => 'key',
|
403 |
-
);
|
404 |
-
|
405 |
-
$appearances_profile_menu_fields = array_merge(
|
406 |
-
$appearances_profile_menu_fields,
|
407 |
-
array(
|
408 |
-
array(
|
409 |
-
'id' => 'profile_menu_icons',
|
410 |
-
'type' => 'checkbox',
|
411 |
-
'label' => __( 'Enable menu icons in desktop view', 'ultimate-member' ),
|
412 |
-
'conditional' => array( 'profile_menu', '=', 1 ),
|
413 |
-
),
|
414 |
-
)
|
415 |
-
);
|
416 |
-
|
417 |
-
$settings_map['profile_menu_icons'] = array(
|
418 |
-
'sanitize' => 'bool',
|
419 |
-
);
|
420 |
-
|
421 |
-
$post_types_options = array();
|
422 |
-
$all_post_types = get_post_types( array( 'public' => true ), 'objects' );
|
423 |
-
foreach ( $all_post_types as $key => $post_type_data ) {
|
424 |
-
$post_types_options[ $key ] = $post_type_data->labels->singular_name;
|
425 |
-
}
|
426 |
-
|
427 |
-
$duplicates = array();
|
428 |
-
$taxonomies_options = array();
|
429 |
-
$exclude_taxonomies = UM()->excluded_taxonomies();
|
430 |
-
$all_taxonomies = get_taxonomies( array( 'public' => true ), 'objects' );
|
431 |
-
foreach ( $all_taxonomies as $key => $taxonomy ) {
|
432 |
-
if ( in_array( $key, $exclude_taxonomies, true ) ) {
|
433 |
-
continue;
|
434 |
-
}
|
435 |
-
|
436 |
-
if ( ! in_array( $taxonomy->labels->singular_name, $duplicates, true ) ) {
|
437 |
-
$duplicates[] = $taxonomy->labels->singular_name;
|
438 |
-
$label = $taxonomy->labels->singular_name;
|
439 |
-
} else {
|
440 |
-
$label = $taxonomy->labels->singular_name . ' (' . $key . ')';
|
441 |
-
}
|
442 |
-
|
443 |
-
$taxonomies_options[ $key ] = $label;
|
444 |
-
}
|
445 |
-
|
446 |
-
$restricted_access_post_metabox_value = array();
|
447 |
-
$restricted_access_post_metabox = UM()->options()->get( 'restricted_access_post_metabox' );
|
448 |
-
if ( ! empty( $restricted_access_post_metabox ) && is_array( $restricted_access_post_metabox ) ) {
|
449 |
-
foreach ( $restricted_access_post_metabox as $key => $value ) {
|
450 |
-
if ( $value ) {
|
451 |
-
$restricted_access_post_metabox_value[] = $key;
|
452 |
-
}
|
453 |
-
}
|
454 |
-
}
|
455 |
-
|
456 |
-
|
457 |
-
$restricted_access_taxonomy_metabox_value = array();
|
458 |
-
$restricted_access_taxonomy_metabox = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
459 |
-
if ( ! empty( $restricted_access_taxonomy_metabox ) && is_array( $restricted_access_taxonomy_metabox ) ) {
|
460 |
-
foreach ( $restricted_access_taxonomy_metabox as $key => $value ) {
|
461 |
-
if ( $value ) {
|
462 |
-
$restricted_access_taxonomy_metabox_value[] = $key;
|
463 |
-
}
|
464 |
-
}
|
465 |
-
}
|
466 |
-
|
467 |
-
$access_fields = array(
|
468 |
-
array(
|
469 |
-
'id' => 'accessible',
|
470 |
-
'type' => 'select',
|
471 |
-
'label' => __( 'Global Site Access', 'ultimate-member' ),
|
472 |
-
'tooltip' => __( 'Globally control the access of your site, you can have separate restrict options per post/page by editing the desired item.', 'ultimate-member' ),
|
473 |
-
'options' => array(
|
474 |
-
0 => __( 'Site accessible to Everyone', 'ultimate-member' ),
|
475 |
-
2 => __( 'Site accessible to Logged In Users', 'ultimate-member' ),
|
476 |
-
),
|
477 |
-
'size' => 'medium',
|
478 |
-
),
|
479 |
-
array(
|
480 |
-
'id' => 'access_redirect',
|
481 |
-
'type' => 'text',
|
482 |
-
'label' => __( 'Custom Redirect URL', 'ultimate-member' ),
|
483 |
-
'tooltip' => __( 'A logged out user will be redirected to this url If he is not permitted to access the site', 'ultimate-member' ),
|
484 |
-
'conditional' => array( 'accessible', '=', 2 ),
|
485 |
-
),
|
486 |
-
array(
|
487 |
-
'id' => 'access_exclude_uris',
|
488 |
-
'type' => 'multi_text',
|
489 |
-
'label' => __( 'Exclude the following URLs', 'ultimate-member' ),
|
490 |
-
'tooltip' => __( 'Here you can exclude URLs beside the redirect URI to be accessible to everyone', 'ultimate-member' ),
|
491 |
-
'add_text' => __( 'Add New URL', 'ultimate-member' ),
|
492 |
-
'conditional' => array( 'accessible', '=', 2 ),
|
493 |
-
'show_default_number' => 0,
|
494 |
-
),
|
495 |
-
array(
|
496 |
-
'id' => 'home_page_accessible',
|
497 |
-
'type' => 'checkbox',
|
498 |
-
'label' => __( 'Allow Homepage to be accessible', 'ultimate-member' ),
|
499 |
-
'conditional' => array( 'accessible', '=', 2 ),
|
500 |
-
),
|
501 |
-
array(
|
502 |
-
'id' => 'category_page_accessible',
|
503 |
-
'type' => 'checkbox',
|
504 |
-
'label' => __( 'Allow Category pages to be accessible', 'ultimate-member' ),
|
505 |
-
'conditional' => array( 'accessible', '=', 2 ),
|
506 |
-
),
|
507 |
-
array(
|
508 |
-
'id' => 'restricted_post_title_replace',
|
509 |
-
'type' => 'checkbox',
|
510 |
-
'label' => __( 'Replace the restricted Post Title', 'ultimate-member' ),
|
511 |
-
'tooltip' => __( 'Allow to replace the restricted post title to users that do not have permission to view the content', 'ultimate-member' ),
|
512 |
-
),
|
513 |
-
array(
|
514 |
-
'id' => 'restricted_access_post_title',
|
515 |
-
'type' => 'text',
|
516 |
-
'label' => __( 'Restricted Access Post Title', 'ultimate-member' ),
|
517 |
-
'tooltip' => __( 'This is the post title shown to users that do not have permission to view the content', 'ultimate-member' ),
|
518 |
-
'conditional' => array( 'restricted_post_title_replace', '=', 1 ),
|
519 |
-
),
|
520 |
-
array(
|
521 |
-
'id' => 'restricted_access_message',
|
522 |
-
'type' => 'wp_editor',
|
523 |
-
'label' => __( 'Restricted Access Message', 'ultimate-member' ),
|
524 |
-
'tooltip' => __( 'This is the message shown to users that do not have permission to view the content', 'ultimate-member' ),
|
525 |
-
),
|
526 |
-
);
|
527 |
-
|
528 |
-
$settings_map = array_merge(
|
529 |
-
$settings_map,
|
530 |
-
array(
|
531 |
-
'accessible' => array(
|
532 |
-
'sanitize' => 'int',
|
533 |
-
),
|
534 |
-
'access_redirect' => array(
|
535 |
-
'sanitize' => 'url',
|
536 |
-
),
|
537 |
-
'access_exclude_uris' => array(
|
538 |
-
'sanitize' => 'url',
|
539 |
-
),
|
540 |
-
'home_page_accessible' => array(
|
541 |
-
'sanitize' => 'bool',
|
542 |
-
),
|
543 |
-
'category_page_accessible' => array(
|
544 |
-
'sanitize' => 'bool',
|
545 |
-
),
|
546 |
-
'restricted_post_title_replace' => array(
|
547 |
-
'sanitize' => 'bool',
|
548 |
-
),
|
549 |
-
'restricted_access_post_title' => array(
|
550 |
-
'sanitize' => 'text',
|
551 |
-
),
|
552 |
-
'restricted_access_message' => array(
|
553 |
-
'sanitize' => 'wp_kses',
|
554 |
-
),
|
555 |
-
)
|
556 |
-
);
|
557 |
-
|
558 |
-
global $wp_version;
|
559 |
-
if ( version_compare( $wp_version, '5.0', '>=' ) ) {
|
560 |
-
$access_fields = array_merge(
|
561 |
-
$access_fields,
|
562 |
-
array(
|
563 |
-
array(
|
564 |
-
'id' => 'restricted_blocks',
|
565 |
-
'type' => 'checkbox',
|
566 |
-
'label' => __( 'Enable the "Content Restriction" settings for the Gutenberg Blocks', 'ultimate-member' ),
|
567 |
-
),
|
568 |
-
array(
|
569 |
-
'id' => 'restricted_block_message',
|
570 |
-
'type' => 'textarea',
|
571 |
-
'label' => __( 'Restricted Access Block Message', 'ultimate-member' ),
|
572 |
-
'tooltip' => __( 'This is the message shown to users that do not have permission to view the block\'s content', 'ultimate-member' ),
|
573 |
-
'conditional' => array( 'restricted_blocks', '=', 1 ),
|
574 |
-
),
|
575 |
-
)
|
576 |
-
);
|
577 |
-
|
578 |
-
$settings_map['restricted_blocks'] = array(
|
579 |
-
'sanitize' => 'bool',
|
580 |
-
);
|
581 |
-
$settings_map['restricted_block_message'] = array(
|
582 |
-
'sanitize' => 'textarea',
|
583 |
-
);
|
584 |
-
}
|
585 |
-
|
586 |
-
$access_fields = array_merge(
|
587 |
-
$access_fields,
|
588 |
-
array(
|
589 |
-
array(
|
590 |
-
'id' => 'restricted_access_post_metabox',
|
591 |
-
'type' => 'hidden',
|
592 |
-
'value' => '',
|
593 |
-
),
|
594 |
-
array(
|
595 |
-
'id' => 'restricted_access_taxonomy_metabox',
|
596 |
-
'type' => 'hidden',
|
597 |
-
'value' => '',
|
598 |
-
),
|
599 |
-
array(
|
600 |
-
'id' => 'restricted_access_post_metabox',
|
601 |
-
'type' => 'multi_checkbox',
|
602 |
-
'label' => __( 'Enable the "Content Restriction" settings for post types', 'ultimate-member' ),
|
603 |
-
'tooltip' => __( 'Check post types for which you plan to use the "Content Restriction" settings', 'ultimate-member' ),
|
604 |
-
'options' => $post_types_options,
|
605 |
-
'columns' => 3,
|
606 |
-
'value' => $restricted_access_post_metabox_value,
|
607 |
-
'default' => UM()->options()->get_default( 'restricted_access_post_metabox' ),
|
608 |
-
),
|
609 |
-
array(
|
610 |
-
'id' => 'restricted_access_taxonomy_metabox',
|
611 |
-
'type' => 'multi_checkbox',
|
612 |
-
'label' => __( 'Enable the "Content Restriction" settings for taxonomies', 'ultimate-member' ),
|
613 |
-
'tooltip' => __( 'Check taxonomies for which you plan to use the "Content Restriction" settings', 'ultimate-member' ),
|
614 |
-
'options' => $taxonomies_options,
|
615 |
-
'columns' => 3,
|
616 |
-
'value' => $restricted_access_taxonomy_metabox_value,
|
617 |
-
'default' => UM()->options()->get_default( 'restricted_access_taxonomy_metabox' ),
|
618 |
-
),
|
619 |
-
)
|
620 |
-
);
|
621 |
-
|
622 |
-
$settings_map = array_merge(
|
623 |
-
$settings_map,
|
624 |
-
array(
|
625 |
-
'restricted_access_post_metabox' => array(
|
626 |
-
'sanitize' => 'key',
|
627 |
-
),
|
628 |
-
'restricted_access_taxonomy_metabox' => array(
|
629 |
-
'sanitize' => 'key',
|
630 |
-
),
|
631 |
-
)
|
632 |
-
);
|
633 |
-
|
634 |
-
$latest_update = get_option( 'um_member_directory_update_meta', false );
|
635 |
-
$latest_truncate = get_option( 'um_member_directory_truncated', false );
|
636 |
-
|
637 |
-
$same_page_update = array(
|
638 |
-
'id' => 'member_directory_own_table',
|
639 |
-
'type' => 'same_page_update',
|
640 |
-
'label' => __( 'Enable custom table for usermeta', 'ultimate-member' ),
|
641 |
-
'tooltip' => __( 'Check this box if you would like to enable the use of a custom table for user metadata. Improved performance for member directory searches.', 'ultimate-member' ),
|
642 |
-
);
|
643 |
-
|
644 |
-
if ( empty( $latest_update ) || ( ! empty( $latest_truncate ) && $latest_truncate > $latest_update ) ) {
|
645 |
-
$same_page_update['upgrade_cb'] = 'sync_metatable';
|
646 |
-
$same_page_update['upgrade_description'] = '<p>' . __( 'We recommend creating a backup of your site before running the update process. Do not exit the page before the update process has complete.', 'ultimate-member' ) . '</p>
|
647 |
-
<p>' . __( 'After clicking the <strong>"Run"</strong> button, the update process will start. All information will be displayed in the field below.', 'ultimate-member' ) . '</p>
|
648 |
-
<p>' . __( 'If the update was successful, you will see a corresponding message. Otherwise, contact technical support if the update failed.', 'ultimate-member' ) . '</p>';
|
649 |
-
}
|
650 |
-
|
651 |
-
$settings_map = array_merge(
|
652 |
-
$settings_map,
|
653 |
-
array(
|
654 |
-
'permalink_base' => array(
|
655 |
-
'sanitize' => 'key',
|
656 |
-
),
|
657 |
-
'display_name' => array(
|
658 |
-
'sanitize' => 'key',
|
659 |
-
),
|
660 |
-
'display_name_field' => array(
|
661 |
-
'sanitize' => 'text',
|
662 |
-
),
|
663 |
-
'author_redirect' => array(
|
664 |
-
'sanitize' => 'bool',
|
665 |
-
),
|
666 |
-
'members_page' => array(
|
667 |
-
'sanitize' => 'bool',
|
668 |
-
),
|
669 |
-
'use_gravatars' => array(
|
670 |
-
'sanitize' => 'bool',
|
671 |
-
),
|
672 |
-
'use_um_gravatar_default_builtin_image' => array(
|
673 |
-
'sanitize' => 'key',
|
674 |
-
),
|
675 |
-
'use_um_gravatar_default_image' => array(
|
676 |
-
'sanitize' => 'bool',
|
677 |
-
),
|
678 |
-
'require_strongpass' => array(
|
679 |
-
'sanitize' => 'bool',
|
680 |
-
),
|
681 |
-
'password_min_chars' => array(
|
682 |
-
'sanitize' => 'absint',
|
683 |
-
),
|
684 |
-
'password_max_chars' => array(
|
685 |
-
'sanitize' => 'absint',
|
686 |
-
),
|
687 |
-
'profile_noindex' => array(
|
688 |
-
'sanitize' => 'bool',
|
689 |
-
),
|
690 |
-
'activation_link_expiry_time' => array(
|
691 |
-
'sanitize' => 'absint',
|
692 |
-
),
|
693 |
-
'account_tab_password' => array(
|
694 |
-
'sanitize' => 'bool',
|
695 |
-
),
|
696 |
-
'account_tab_privacy' => array(
|
697 |
-
'sanitize' => 'bool',
|
698 |
-
),
|
699 |
-
'account_tab_notifications' => array(
|
700 |
-
'sanitize' => 'bool',
|
701 |
-
),
|
702 |
-
'account_tab_delete' => array(
|
703 |
-
'sanitize' => 'bool',
|
704 |
-
),
|
705 |
-
'delete_account_text' => array(
|
706 |
-
'sanitize' => 'textarea',
|
707 |
-
),
|
708 |
-
'delete_account_no_pass_required_text' => array(
|
709 |
-
'sanitize' => 'textarea',
|
710 |
-
),
|
711 |
-
'account_name' => array(
|
712 |
-
'sanitize' => 'bool',
|
713 |
-
),
|
714 |
-
'account_name_disable' => array(
|
715 |
-
'sanitize' => 'bool',
|
716 |
-
),
|
717 |
-
'account_name_require' => array(
|
718 |
-
'sanitize' => 'bool',
|
719 |
-
),
|
720 |
-
'account_email' => array(
|
721 |
-
'sanitize' => 'bool',
|
722 |
-
),
|
723 |
-
'account_general_password' => array(
|
724 |
-
'sanitize' => 'bool',
|
725 |
-
),
|
726 |
-
'account_hide_in_directory' => array(
|
727 |
-
'sanitize' => 'bool',
|
728 |
-
),
|
729 |
-
'account_hide_in_directory_default' => array(
|
730 |
-
'sanitize' => 'text',
|
731 |
-
),
|
732 |
-
'profile_photo_max_size' => array(
|
733 |
-
'sanitize' => 'absint',
|
734 |
-
),
|
735 |
-
'cover_photo_max_size' => array(
|
736 |
-
'sanitize' => 'absint',
|
737 |
-
),
|
738 |
-
'photo_thumb_sizes' => array(
|
739 |
-
'sanitize' => 'absint',
|
740 |
-
),
|
741 |
-
'cover_thumb_sizes' => array(
|
742 |
-
'sanitize' => 'absint',
|
743 |
-
),
|
744 |
-
'image_orientation_by_exif' => array(
|
745 |
-
'sanitize' => 'bool',
|
746 |
-
),
|
747 |
-
'image_compression' => array(
|
748 |
-
'sanitize' => 'absint',
|
749 |
-
),
|
750 |
-
'image_max_width' => array(
|
751 |
-
'sanitize' => 'absint',
|
752 |
-
),
|
753 |
-
'cover_min_width' => array(
|
754 |
-
'sanitize' => 'absint',
|
755 |
-
),
|
756 |
-
'enable_reset_password_limit' => array(
|
757 |
-
'sanitize' => 'bool',
|
758 |
-
),
|
759 |
-
'reset_password_limit_number' => array(
|
760 |
-
'sanitize' => 'absint',
|
761 |
-
),
|
762 |
-
'blocked_emails' => array(
|
763 |
-
'sanitize' => 'textarea',
|
764 |
-
),
|
765 |
-
'blocked_words' => array(
|
766 |
-
'sanitize' => 'textarea',
|
767 |
-
),
|
768 |
-
'allowed_choice_callbacks' => array(
|
769 |
-
'sanitize' => 'textarea',
|
770 |
-
),
|
771 |
-
'allow_url_redirect_confirm' => array(
|
772 |
-
'sanitize' => 'bool',
|
773 |
-
),
|
774 |
-
'admin_email' => array(
|
775 |
-
'sanitize' => 'text',
|
776 |
-
),
|
777 |
-
'mail_from' => array(
|
778 |
-
'sanitize' => 'text',
|
779 |
-
),
|
780 |
-
'mail_from_addr' => array(
|
781 |
-
'sanitize' => 'text',
|
782 |
-
),
|
783 |
-
'email_html' => array(
|
784 |
-
'sanitize' => 'bool',
|
785 |
-
),
|
786 |
-
'profile_template' => array(
|
787 |
-
'sanitize' => 'text',
|
788 |
-
),
|
789 |
-
'profile_max_width' => array(
|
790 |
-
'sanitize' => 'text',
|
791 |
-
),
|
792 |
-
'profile_area_max_width' => array(
|
793 |
-
'sanitize' => 'text',
|
794 |
-
),
|
795 |
-
'profile_icons' => array(
|
796 |
-
'sanitize' => 'key',
|
797 |
-
),
|
798 |
-
'profile_primary_btn_word' => array(
|
799 |
-
'sanitize' => 'text',
|
800 |
-
),
|
801 |
-
'profile_secondary_btn' => array(
|
802 |
-
'sanitize' => 'bool',
|
803 |
-
),
|
804 |
-
'profile_secondary_btn_word' => array(
|
805 |
-
'sanitize' => 'text',
|
806 |
-
),
|
807 |
-
'default_avatar' => array(
|
808 |
-
'sanitize' => 'url',
|
809 |
-
),
|
810 |
-
'default_cover' => array(
|
811 |
-
'sanitize' => 'url',
|
812 |
-
),
|
813 |
-
'disable_profile_photo_upload' => array(
|
814 |
-
'sanitize' => 'bool',
|
815 |
-
),
|
816 |
-
'profile_photosize' => array(
|
817 |
-
'sanitize' => array( UM()->admin(), 'sanitize_photosize' ),
|
818 |
-
),
|
819 |
-
'profile_cover_enabled' => array(
|
820 |
-
'sanitize' => 'bool',
|
821 |
-
),
|
822 |
-
'profile_coversize' => array(
|
823 |
-
'sanitize' => array( UM()->admin(), 'sanitize_cover_photosize' ),
|
824 |
-
),
|
825 |
-
'profile_cover_ratio' => array(
|
826 |
-
'sanitize' => 'text',
|
827 |
-
),
|
828 |
-
'profile_show_metaicon' => array(
|
829 |
-
'sanitize' => 'bool',
|
830 |
-
),
|
831 |
-
'profile_show_name' => array(
|
832 |
-
'sanitize' => 'bool',
|
833 |
-
),
|
834 |
-
'profile_show_social_links' => array(
|
835 |
-
'sanitize' => 'bool',
|
836 |
-
),
|
837 |
-
'profile_show_bio' => array(
|
838 |
-
'sanitize' => 'bool',
|
839 |
-
),
|
840 |
-
'profile_show_html_bio' => array(
|
841 |
-
'sanitize' => 'bool',
|
842 |
-
),
|
843 |
-
'profile_bio_maxchars' => array(
|
844 |
-
'sanitize' => 'absint',
|
845 |
-
),
|
846 |
-
'profile_header_menu' => array(
|
847 |
-
'sanitize' => 'key',
|
848 |
-
),
|
849 |
-
'profile_empty_text' => array(
|
850 |
-
'sanitize' => 'bool',
|
851 |
-
),
|
852 |
-
'profile_empty_text_emo' => array(
|
853 |
-
'sanitize' => 'bool',
|
854 |
-
),
|
855 |
-
'register_template' => array(
|
856 |
-
'sanitize' => 'text',
|
857 |
-
),
|
858 |
-
'register_max_width' => array(
|
859 |
-
'sanitize' => 'text',
|
860 |
-
),
|
861 |
-
'register_align' => array(
|
862 |
-
'sanitize' => 'key',
|
863 |
-
),
|
864 |
-
'register_icons' => array(
|
865 |
-
'sanitize' => 'key',
|
866 |
-
),
|
867 |
-
'register_primary_btn_word' => array(
|
868 |
-
'sanitize' => 'text',
|
869 |
-
),
|
870 |
-
'register_secondary_btn' => array(
|
871 |
-
'sanitize' => 'bool',
|
872 |
-
),
|
873 |
-
'register_secondary_btn_word' => array(
|
874 |
-
'sanitize' => 'text',
|
875 |
-
),
|
876 |
-
'register_secondary_btn_url' => array(
|
877 |
-
'sanitize' => 'url',
|
878 |
-
),
|
879 |
-
'register_role' => array(
|
880 |
-
'sanitize' => 'key',
|
881 |
-
),
|
882 |
-
'login_template' => array(
|
883 |
-
'sanitize' => 'text',
|
884 |
-
),
|
885 |
-
'login_max_width' => array(
|
886 |
-
'sanitize' => 'text',
|
887 |
-
),
|
888 |
-
'login_align' => array(
|
889 |
-
'sanitize' => 'key',
|
890 |
-
),
|
891 |
-
'login_icons' => array(
|
892 |
-
'sanitize' => 'key',
|
893 |
-
),
|
894 |
-
'login_primary_btn_word' => array(
|
895 |
-
'sanitize' => 'text',
|
896 |
-
),
|
897 |
-
'login_secondary_btn' => array(
|
898 |
-
'sanitize' => 'bool',
|
899 |
-
),
|
900 |
-
'login_secondary_btn_word' => array(
|
901 |
-
'sanitize' => 'text',
|
902 |
-
),
|
903 |
-
'login_secondary_btn_url' => array(
|
904 |
-
'sanitize' => 'url',
|
905 |
-
),
|
906 |
-
'login_forgot_pass_link' => array(
|
907 |
-
'sanitize' => 'bool',
|
908 |
-
),
|
909 |
-
'login_show_rememberme' => array(
|
910 |
-
'sanitize' => 'bool',
|
911 |
-
),
|
912 |
-
'form_asterisk' => array(
|
913 |
-
'sanitize' => 'bool',
|
914 |
-
),
|
915 |
-
'profile_title' => array(
|
916 |
-
'sanitize' => 'text',
|
917 |
-
),
|
918 |
-
'profile_desc' => array(
|
919 |
-
'sanitize' => 'textarea',
|
920 |
-
),
|
921 |
-
'um_profile_object_cache_stop' => array(
|
922 |
-
'sanitize' => 'bool',
|
923 |
-
),
|
924 |
-
'enable_blocks' => array(
|
925 |
-
'sanitize' => 'bool',
|
926 |
-
),
|
927 |
-
'rest_api_version' => array(
|
928 |
-
'sanitize' => 'text',
|
929 |
-
),
|
930 |
-
'uninstall_on_delete' => array(
|
931 |
-
'sanitize' => 'bool',
|
932 |
-
),
|
933 |
-
)
|
934 |
-
);
|
935 |
-
|
936 |
-
$this->settings_map = apply_filters( 'um_settings_map', $settings_map );
|
937 |
-
|
938 |
-
/**
|
939 |
-
* UM hook
|
940 |
-
*
|
941 |
-
* @type filter
|
942 |
-
* @title um_settings_structure
|
943 |
-
* @description Extend UM Settings
|
944 |
-
* @input_vars
|
945 |
-
* [{"var":"$settings","type":"array","desc":"UM Settings"}]
|
946 |
-
* @change_log
|
947 |
-
* ["Since: 2.0"]
|
948 |
-
* @usage add_filter( 'um_settings_structure', 'function_name', 10, 1 );
|
949 |
-
* @example
|
950 |
-
* <?php
|
951 |
-
* add_filter( 'um_settings_structure', 'my_settings_structure', 10, 1 );
|
952 |
-
* function my_settings_structure( $settings ) {
|
953 |
-
* // your code here
|
954 |
-
* return $settings;
|
955 |
-
* }
|
956 |
-
* ?>
|
957 |
-
*/
|
958 |
-
$this->settings_structure = apply_filters(
|
959 |
-
'um_settings_structure',
|
960 |
-
array(
|
961 |
-
'' => array(
|
962 |
-
'title' => __( 'General', 'ultimate-member' ),
|
963 |
-
'sections' => array(
|
964 |
-
'' => array(
|
965 |
-
'title' => __( 'Pages', 'ultimate-member' ),
|
966 |
-
'fields' => $general_pages_fields,
|
967 |
-
),
|
968 |
-
'users' => array(
|
969 |
-
'title' => __( 'Users', 'ultimate-member' ),
|
970 |
-
'fields' => array(
|
971 |
-
array(
|
972 |
-
'id' => 'permalink_base',
|
973 |
-
'type' => 'select',
|
974 |
-
'size' => 'small',
|
975 |
-
'label' => __( 'Profile Permalink Base', 'ultimate-member' ),
|
976 |
-
// translators: %s: Profile page URL
|
977 |
-
'tooltip' => sprintf( __( 'Here you can control the permalink structure of the user profile URL globally e.g. %s<strong>username</strong>/', 'ultimate-member' ), trailingslashit( um_get_core_page( 'user' ) ) ),
|
978 |
-
'options' => array(
|
979 |
-
'user_login' => __( 'Username', 'ultimate-member' ),
|
980 |
-
'name' => __( 'First and Last Name with \'.\'', 'ultimate-member' ),
|
981 |
-
'name_dash' => __( 'First and Last Name with \'-\'', 'ultimate-member' ),
|
982 |
-
'name_plus' => __( 'First and Last Name with \'+\'', 'ultimate-member' ),
|
983 |
-
'user_id' => __( 'User ID', 'ultimate-member' ),
|
984 |
-
),
|
985 |
-
'placeholder' => __( 'Select...', 'ultimate-member' ),
|
986 |
-
),
|
987 |
-
array(
|
988 |
-
'id' => 'display_name',
|
989 |
-
'type' => 'select',
|
990 |
-
'size' => 'medium',
|
991 |
-
'label' => __( 'User Display Name', 'ultimate-member' ),
|
992 |
-
'tooltip' => __( 'This is the name that will be displayed for users on the front end of your site. Default setting uses first/last name as display name if it exists', 'ultimate-member' ),
|
993 |
-
'options' => array(
|
994 |
-
'default' => __( 'Default WP Display Name', 'ultimate-member' ),
|
995 |
-
'nickname' => __( 'Nickname', 'ultimate-member' ),
|
996 |
-
'username' => __( 'Username', 'ultimate-member' ),
|
997 |
-
'full_name' => __( 'First name & last name', 'ultimate-member' ),
|
998 |
-
'sur_name' => __( 'Last name & first name', 'ultimate-member' ),
|
999 |
-
'initial_name' => __( 'First name & first initial of last name', 'ultimate-member' ),
|
1000 |
-
'initial_name_f' => __( 'First initial of first name & last name', 'ultimate-member' ),
|
1001 |
-
'first_name' => __( 'First name only', 'ultimate-member' ),
|
1002 |
-
'field' => __( 'Custom field(s)', 'ultimate-member' ),
|
1003 |
-
),
|
1004 |
-
'placeholder' => __( 'Select...', 'ultimate-member' ),
|
1005 |
-
),
|
1006 |
-
array(
|
1007 |
-
'id' => 'display_name_field',
|
1008 |
-
'type' => 'text',
|
1009 |
-
'label' => __( 'Display Name Custom Field(s)', 'ultimate-member' ),
|
1010 |
-
'tooltip' => __( 'Specify the custom field meta key or custom fields seperated by comma that you want to use to display users name on the frontend of your site', 'ultimate-member' ),
|
1011 |
-
'conditional' => array( 'display_name', '=', 'field' ),
|
1012 |
-
),
|
1013 |
-
array(
|
1014 |
-
'id' => 'author_redirect',
|
1015 |
-
'type' => 'checkbox',
|
1016 |
-
'label' => __( 'Automatically redirect author page to their profile?', 'ultimate-member' ),
|
1017 |
-
'tooltip' => __( 'If enabled, author pages will automatically redirect to the user\'s profile page', 'ultimate-member' ),
|
1018 |
-
),
|
1019 |
-
array(
|
1020 |
-
'id' => 'members_page',
|
1021 |
-
'type' => 'checkbox',
|
1022 |
-
'label' => __( 'Enable Members Directory', 'ultimate-member' ),
|
1023 |
-
'tooltip' => __( 'Control whether to enable or disable member directories on this site', 'ultimate-member' ),
|
1024 |
-
),
|
1025 |
-
array(
|
1026 |
-
'id' => 'use_gravatars',
|
1027 |
-
'type' => 'checkbox',
|
1028 |
-
'label' => __( 'Use Gravatars?', 'ultimate-member' ),
|
1029 |
-
'tooltip' => __( 'Do you want to use gravatars instead of the default plugin profile photo (If the user did not upload a custom profile photo / avatar)', 'ultimate-member' ),
|
1030 |
-
),
|
1031 |
-
array(
|
1032 |
-
'id' => 'use_um_gravatar_default_builtin_image',
|
1033 |
-
'type' => 'select',
|
1034 |
-
'label' => __( 'Use Gravatar builtin image', 'ultimate-member' ),
|
1035 |
-
'tooltip' => __( 'Gravatar has a number of built in options which you can also use as defaults', 'ultimate-member' ),
|
1036 |
-
'options' => array(
|
1037 |
-
'default' => __( 'Default', 'ultimate-member' ),
|
1038 |
-
'404' => __( '404 ( File Not Found response )', 'ultimate-member' ),
|
1039 |
-
'mm' => __( 'Mystery Man', 'ultimate-member' ),
|
1040 |
-
'identicon' => __( 'Identicon', 'ultimate-member' ),
|
1041 |
-
'monsterid' => __( 'Monsterid', 'ultimate-member' ),
|
1042 |
-
'wavatar' => __( 'Wavatar', 'ultimate-member' ),
|
1043 |
-
'retro' => __( 'Retro', 'ultimate-member' ),
|
1044 |
-
'blank' => __( 'Blank ( a transparent PNG image )', 'ultimate-member' ),
|
1045 |
-
),
|
1046 |
-
'conditional' => array( 'use_gravatars', '=', 1 ),
|
1047 |
-
'size' => 'medium',
|
1048 |
-
),
|
1049 |
-
array(
|
1050 |
-
'id' => 'use_um_gravatar_default_image',
|
1051 |
-
'type' => 'checkbox',
|
1052 |
-
'label' => __( 'Use Default plugin avatar as Gravatar\'s Default avatar', 'ultimate-member' ),
|
1053 |
-
'tooltip' => __( 'Do you want to use the plugin default avatar instead of the gravatar default photo (If the user did not upload a custom profile photo / avatar)', 'ultimate-member' ),
|
1054 |
-
'conditional' => array( 'use_um_gravatar_default_builtin_image', '=', 'default' ),
|
1055 |
-
),
|
1056 |
-
array(
|
1057 |
-
'id' => 'require_strongpass',
|
1058 |
-
'type' => 'checkbox',
|
1059 |
-
'label' => __( 'Require a strong password?', 'ultimate-member' ),
|
1060 |
-
'tooltip' => __( 'Enable or disable a strong password rules common for all Ultimate Member forms.', 'ultimate-member' ),
|
1061 |
-
),
|
1062 |
-
array(
|
1063 |
-
'id' => 'password_min_chars',
|
1064 |
-
'type' => 'number',
|
1065 |
-
'label' => __( 'Password minimum length', 'ultimate-member' ),
|
1066 |
-
'tooltip' => __( 'If you want to enable a minimum number of characters to be in password. User password field in the UM forms has own settings for that. Leave empty to use default value 8', 'ultimate-member' ),
|
1067 |
-
'size' => 'small',
|
1068 |
-
),
|
1069 |
-
array(
|
1070 |
-
'id' => 'password_max_chars',
|
1071 |
-
'type' => 'number',
|
1072 |
-
'label' => __( 'Password maximum length', 'ultimate-member' ),
|
1073 |
-
'tooltip' => __( 'If you want to enable a maximum number of characters to be in password. User password field in the UM forms has own settings for that. Leave empty to use default value 30', 'ultimate-member' ),
|
1074 |
-
'size' => 'small',
|
1075 |
-
),
|
1076 |
-
array(
|
1077 |
-
'id' => 'profile_noindex',
|
1078 |
-
'type' => 'select',
|
1079 |
-
'size' => 'small',
|
1080 |
-
'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ),
|
1081 |
-
'tooltip' => __( 'Hides the profile page for robots. This setting can be overridden by individual role settings.', 'ultimate-member' ),
|
1082 |
-
'options' => array(
|
1083 |
-
'0' => __( 'No', 'ultimate-member' ),
|
1084 |
-
'1' => __( 'Yes', 'ultimate-member' ),
|
1085 |
-
),
|
1086 |
-
),
|
1087 |
-
array(
|
1088 |
-
'id' => 'activation_link_expiry_time',
|
1089 |
-
'type' => 'number',
|
1090 |
-
'label' => __( 'Activation link lifetime', 'ultimate-member' ),
|
1091 |
-
'tooltip' => __( 'How long does an activation link live in seconds? Leave empty for endless links.', 'ultimate-member' ),
|
1092 |
-
'size' => 'small',
|
1093 |
-
),
|
1094 |
-
),
|
1095 |
-
),
|
1096 |
-
'account' => array(
|
1097 |
-
'title' => __( 'Account', 'ultimate-member' ),
|
1098 |
-
'fields' => array(
|
1099 |
-
array(
|
1100 |
-
'id' => 'account_tab_password',
|
1101 |
-
'type' => 'checkbox',
|
1102 |
-
'label' => __( 'Password Account Tab', 'ultimate-member' ),
|
1103 |
-
'tooltip' => __( 'Enable/disable the Password account tab in account page', 'ultimate-member' ),
|
1104 |
-
),
|
1105 |
-
array(
|
1106 |
-
'id' => 'account_tab_privacy',
|
1107 |
-
'type' => 'checkbox',
|
1108 |
-
'label' => __( 'Privacy Account Tab', 'ultimate-member' ),
|
1109 |
-
'tooltip' => __( 'Enable/disable the Privacy account tab in account page', 'ultimate-member' ),
|
1110 |
-
),
|
1111 |
-
array(
|
1112 |
-
'id' => 'account_tab_notifications',
|
1113 |
-
'type' => 'checkbox',
|
1114 |
-
'label' => __( 'Notifications Account Tab', 'ultimate-member' ),
|
1115 |
-
'tooltip' => __( 'Enable/disable the Notifications account tab in account page', 'ultimate-member' ),
|
1116 |
-
),
|
1117 |
-
array(
|
1118 |
-
'id' => 'account_tab_delete',
|
1119 |
-
'type' => 'checkbox',
|
1120 |
-
'label' => __( 'Delete Account Tab', 'ultimate-member' ),
|
1121 |
-
'tooltip' => __( 'Enable/disable the Delete account tab in account page', 'ultimate-member' ),
|
1122 |
-
),
|
1123 |
-
array(
|
1124 |
-
'id' => 'delete_account_text',
|
1125 |
-
'type' => 'textarea', // bug with wp 4.4? should be editor
|
1126 |
-
'label' => __( 'Account Deletion Custom Text', 'ultimate-member' ),
|
1127 |
-
'tooltip' => __( 'This is custom text that will be displayed to users before they delete their accounts from your site when password is required.', 'ultimate-member' ),
|
1128 |
-
'args' => array(
|
1129 |
-
'textarea_rows' => 6,
|
1130 |
-
),
|
1131 |
-
),
|
1132 |
-
array(
|
1133 |
-
'id' => 'delete_account_no_pass_required_text',
|
1134 |
-
'type' => 'textarea',
|
1135 |
-
'label' => __( 'Account Deletion without password Custom Text', 'ultimate-member' ),
|
1136 |
-
'tooltip' => __( 'This is custom text that will be displayed to users before they delete their accounts from your site when password isn\'t required.', 'ultimate-member' ),
|
1137 |
-
'args' => array(
|
1138 |
-
'textarea_rows' => 6,
|
1139 |
-
),
|
1140 |
-
),
|
1141 |
-
array(
|
1142 |
-
'id' => 'account_name',
|
1143 |
-
'type' => 'checkbox',
|
1144 |
-
'label' => __( 'Add a First & Last Name fields', 'ultimate-member' ),
|
1145 |
-
'tooltip' => __( 'Whether to enable these fields on the user account page by default or hide them.', 'ultimate-member' ),
|
1146 |
-
),
|
1147 |
-
array(
|
1148 |
-
'id' => 'account_name_disable',
|
1149 |
-
'type' => 'checkbox',
|
1150 |
-
'label' => __( 'Disable First & Last Name fields', 'ultimate-member' ),
|
1151 |
-
'tooltip' => __( 'Whether to allow users changing their first and last name in account page.', 'ultimate-member' ),
|
1152 |
-
'conditional' => array( 'account_name', '=', '1' ),
|
1153 |
-
),
|
1154 |
-
array(
|
1155 |
-
'id' => 'account_name_require',
|
1156 |
-
'type' => 'checkbox',
|
1157 |
-
'label' => __( 'Require First & Last Name', 'ultimate-member' ),
|
1158 |
-
'tooltip' => __( 'Require first and last name?', 'ultimate-member' ),
|
1159 |
-
'conditional' => array( 'account_name', '=', '1' ),
|
1160 |
-
),
|
1161 |
-
array(
|
1162 |
-
'id' => 'account_email',
|
1163 |
-
'type' => 'checkbox',
|
1164 |
-
'label' => __( 'Allow users to change e-mail', 'ultimate-member' ),
|
1165 |
-
'tooltip' => __( 'Whether to allow users changing their email in account page.', 'ultimate-member' ),
|
1166 |
-
),
|
1167 |
-
array(
|
1168 |
-
'id' => 'account_general_password',
|
1169 |
-
'type' => 'checkbox',
|
1170 |
-
'label' => __( 'Password is required?', 'ultimate-member' ),
|
1171 |
-
'tooltip' => __( 'Password is required to save account data.', 'ultimate-member' ),
|
1172 |
-
),
|
1173 |
-
array(
|
1174 |
-
'id' => 'account_hide_in_directory',
|
1175 |
-
'type' => 'checkbox',
|
1176 |
-
'label' => __( 'Allow users to hide their profiles from directory', 'ultimate-member' ),
|
1177 |
-
'tooltip' => __( 'Whether to allow users changing their profile visibility from member directory in account page.', 'ultimate-member' ),
|
1178 |
-
'conditional' => array( 'account_tab_privacy', '=', '1' ),
|
1179 |
-
),
|
1180 |
-
array(
|
1181 |
-
'id' => 'account_hide_in_directory_default',
|
1182 |
-
'type' => 'select',
|
1183 |
-
'label' => __( 'Hide profiles from directory by default', 'ultimate-member' ),
|
1184 |
-
'tooltip' => __( 'Set default value for the "Hide my profile from directory" option', 'ultimate-member' ),
|
1185 |
-
'options' => array(
|
1186 |
-
'No' => __( 'No', 'ultimate-member' ),
|
1187 |
-
'Yes' => __( 'Yes', 'ultimate-member' ),
|
1188 |
-
),
|
1189 |
-
'size' => 'small',
|
1190 |
-
'conditional' => array( 'account_hide_in_directory', '=', '1' ),
|
1191 |
-
),
|
1192 |
-
),
|
1193 |
-
),
|
1194 |
-
'uploads' => array(
|
1195 |
-
'title' => __( 'Uploads', 'ultimate-member' ),
|
1196 |
-
'fields' => array(
|
1197 |
-
array(
|
1198 |
-
'id' => 'profile_photo_max_size',
|
1199 |
-
'type' => 'text',
|
1200 |
-
'size' => 'small',
|
1201 |
-
'label' => __( 'Profile Photo Maximum File Size (bytes)', 'ultimate-member' ),
|
1202 |
-
'tooltip' => __( 'Sets a maximum size for the uploaded photo', 'ultimate-member' ),
|
1203 |
-
),
|
1204 |
-
array(
|
1205 |
-
'id' => 'cover_photo_max_size',
|
1206 |
-
'type' => 'text',
|
1207 |
-
'size' => 'small',
|
1208 |
-
'label' => __( 'Cover Photo Maximum File Size (bytes)', 'ultimate-member' ),
|
1209 |
-
'tooltip' => __( 'Sets a maximum size for the uploaded cover', 'ultimate-member' ),
|
1210 |
-
),
|
1211 |
-
array(
|
1212 |
-
'id' => 'photo_thumb_sizes',
|
1213 |
-
'type' => 'multi_text',
|
1214 |
-
'size' => 'small',
|
1215 |
-
'label' => __( 'Profile Photo Thumbnail Sizes (px)', 'ultimate-member' ),
|
1216 |
-
'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each profile photo upload.', 'ultimate-member' ),
|
1217 |
-
'validate' => 'numeric',
|
1218 |
-
'add_text' => __( 'Add New Size', 'ultimate-member' ),
|
1219 |
-
'show_default_number' => 1,
|
1220 |
-
),
|
1221 |
-
array(
|
1222 |
-
'id' => 'cover_thumb_sizes',
|
1223 |
-
'type' => 'multi_text',
|
1224 |
-
'size' => 'small',
|
1225 |
-
'label' => __( 'Cover Photo Thumbnail Sizes (px)', 'ultimate-member' ),
|
1226 |
-
'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each cover photo upload.', 'ultimate-member' ),
|
1227 |
-
'validate' => 'numeric',
|
1228 |
-
'add_text' => __( 'Add New Size', 'ultimate-member' ),
|
1229 |
-
'show_default_number' => 1,
|
1230 |
-
),
|
1231 |
-
array(
|
1232 |
-
'id' => 'image_orientation_by_exif',
|
1233 |
-
'type' => 'checkbox',
|
1234 |
-
'label' => __( 'Change image orientation', 'ultimate-member' ),
|
1235 |
-
'tooltip' => __( 'Rotate image to and use orientation by the camera EXIF data.', 'ultimate-member' ),
|
1236 |
-
),
|
1237 |
-
array(
|
1238 |
-
'id' => 'image_compression',
|
1239 |
-
'type' => 'text',
|
1240 |
-
'size' => 'small',
|
1241 |
-
'label' => __( 'Image Quality', 'ultimate-member' ),
|
1242 |
-
'tooltip' => __( 'Quality is used to determine quality of image uploads, and ranges from 0 (worst quality, smaller file) to 100 (best quality, biggest file). The default range is 60.', 'ultimate-member' ),
|
1243 |
-
),
|
1244 |
-
|
1245 |
-
array(
|
1246 |
-
'id' => 'image_max_width',
|
1247 |
-
'type' => 'text',
|
1248 |
-
'size' => 'small',
|
1249 |
-
'label' => __( 'Image Upload Maximum Width (px)', 'ultimate-member' ),
|
1250 |
-
'tooltip' => __( 'Any image upload above this width will be resized to this limit automatically.', 'ultimate-member' ),
|
1251 |
-
),
|
1252 |
-
|
1253 |
-
array(
|
1254 |
-
'id' => 'cover_min_width',
|
1255 |
-
'type' => 'text',
|
1256 |
-
'size' => 'small',
|
1257 |
-
'label' => __( 'Cover Photo Minimum Width (px)', 'ultimate-member' ),
|
1258 |
-
'tooltip' => __( 'This will be the minimum width for cover photo uploads', 'ultimate-member' ),
|
1259 |
-
),
|
1260 |
-
),
|
1261 |
-
),
|
1262 |
-
),
|
1263 |
-
),
|
1264 |
-
'access' => array(
|
1265 |
-
'title' => __( 'Access', 'ultimate-member' ),
|
1266 |
-
'sections' => array(
|
1267 |
-
'' => array(
|
1268 |
-
'title' => __( 'Restriction Content', 'ultimate-member' ),
|
1269 |
-
'fields' => $access_fields,
|
1270 |
-
),
|
1271 |
-
'other' => array(
|
1272 |
-
'title' => __( 'Other', 'ultimate-member' ),
|
1273 |
-
'fields' => array(
|
1274 |
-
array(
|
1275 |
-
'id' => 'enable_reset_password_limit',
|
1276 |
-
'type' => 'checkbox',
|
1277 |
-
'label' => __( 'Enable the Reset Password Limit?', 'ultimate-member' ),
|
1278 |
-
),
|
1279 |
-
array(
|
1280 |
-
'id' => 'reset_password_limit_number',
|
1281 |
-
'type' => 'text',
|
1282 |
-
'label' => __( 'Reset Password Limit', 'ultimate-member' ),
|
1283 |
-
'tooltip' => __( 'Set the maximum reset password limit. If reached the maximum limit, user will be locked from using this.', 'ultimate-member' ),
|
1284 |
-
'validate' => 'numeric',
|
1285 |
-
'conditional' => array( 'enable_reset_password_limit', '=', 1 ),
|
1286 |
-
'size' => 'small',
|
1287 |
-
),
|
1288 |
-
array(
|
1289 |
-
'id' => 'blocked_emails',
|
1290 |
-
'type' => 'textarea',
|
1291 |
-
'label' => __( 'Blocked Email Addresses (Enter one email per line)', 'ultimate-member' ),
|
1292 |
-
'tooltip' => __( 'This will block the specified e-mail addresses from being able to sign up or sign in to your site. To block an entire domain, use something like *@domain.com', 'ultimate-member' ),
|
1293 |
-
),
|
1294 |
-
array(
|
1295 |
-
'id' => 'blocked_words',
|
1296 |
-
'type' => 'textarea',
|
1297 |
-
'label' => __( 'Blacklist Words (Enter one word per line)', 'ultimate-member' ),
|
1298 |
-
'tooltip' => __( 'This option lets you specify blacklist of words to prevent anyone from signing up with such a word as their username', 'ultimate-member' ),
|
1299 |
-
),
|
1300 |
-
array(
|
1301 |
-
'id' => 'allowed_choice_callbacks',
|
1302 |
-
'type' => 'textarea',
|
1303 |
-
'label' => __( 'Allowed Choice Callbacks (Enter one PHP function per line)', 'ultimate-member' ),
|
1304 |
-
'tooltip' => __( 'This option lets you specify the choice callback functions to prevent anyone from using 3rd-party functions that may put your site at risk.', 'ultimate-member' ),
|
1305 |
-
),
|
1306 |
-
array(
|
1307 |
-
'id' => 'allow_url_redirect_confirm',
|
1308 |
-
'type' => 'checkbox',
|
1309 |
-
'label' => __( 'Allow external link redirect confirm', 'ultimate-member' ),
|
1310 |
-
'tooltip' => __( 'Using JS.confirm alert when you go to an external link.', 'ultimate-member' ),
|
1311 |
-
),
|
1312 |
-
),
|
1313 |
-
),
|
1314 |
-
),
|
1315 |
-
),
|
1316 |
-
'email' => array(
|
1317 |
-
'title' => __( 'Email', 'ultimate-member' ),
|
1318 |
-
'fields' => array(
|
1319 |
-
array(
|
1320 |
-
'id' => 'admin_email',
|
1321 |
-
'type' => 'text',
|
1322 |
-
'label' => __( 'Admin E-mail Address', 'ultimate-member' ),
|
1323 |
-
'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
|
1324 |
-
),
|
1325 |
-
array(
|
1326 |
-
'id' => 'mail_from',
|
1327 |
-
'type' => 'text',
|
1328 |
-
'label' => __( 'Mail appears from', 'ultimate-member' ),
|
1329 |
-
'tooltip' => __( 'e.g. Site Name', 'ultimate-member' ),
|
1330 |
-
),
|
1331 |
-
array(
|
1332 |
-
'id' => 'mail_from_addr',
|
1333 |
-
'type' => 'text',
|
1334 |
-
'label' => __( 'Mail appears from address', 'ultimate-member' ),
|
1335 |
-
'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
|
1336 |
-
),
|
1337 |
-
array(
|
1338 |
-
'id' => 'email_html',
|
1339 |
-
'type' => 'checkbox',
|
1340 |
-
'label' => __( 'Use HTML for E-mails?', 'ultimate-member' ),
|
1341 |
-
'tooltip' => __( 'If you plan use e-mails with HTML, please make sure that this option is enabled. Otherwise, HTML will be displayed as plain text.', 'ultimate-member' ),
|
1342 |
-
),
|
1343 |
-
),
|
1344 |
-
),
|
1345 |
-
'appearance' => array(
|
1346 |
-
'title' => __( 'Appearance', 'ultimate-member' ),
|
1347 |
-
'sections' => array(
|
1348 |
-
'' => array(
|
1349 |
-
'title' => __( 'Profile', 'ultimate-member' ),
|
1350 |
-
'fields' => array(
|
1351 |
-
array(
|
1352 |
-
'id' => 'profile_template',
|
1353 |
-
'type' => 'select',
|
1354 |
-
'label' => __( 'Profile Default Template', 'ultimate-member' ),
|
1355 |
-
'tooltip' => __( 'This will be the default template to output profile', 'ultimate-member' ),
|
1356 |
-
'default' => um_get_metadefault( 'profile_template' ),
|
1357 |
-
'options' => UM()->shortcodes()->get_templates( 'profile' ),
|
1358 |
-
'size' => 'small',
|
1359 |
-
),
|
1360 |
-
array(
|
1361 |
-
'id' => 'profile_max_width',
|
1362 |
-
'type' => 'text',
|
1363 |
-
'label' => __( 'Profile Maximum Width', 'ultimate-member' ),
|
1364 |
-
'default' => um_get_metadefault( 'profile_max_width' ),
|
1365 |
-
'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
|
1366 |
-
'size' => 'small',
|
1367 |
-
),
|
1368 |
-
array(
|
1369 |
-
'id' => 'profile_area_max_width',
|
1370 |
-
'type' => 'text',
|
1371 |
-
'label' => __( 'Profile Area Maximum Width', 'ultimate-member' ),
|
1372 |
-
'default' => um_get_metadefault( 'profile_area_max_width' ),
|
1373 |
-
'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ),
|
1374 |
-
'size' => 'small',
|
1375 |
-
),
|
1376 |
-
array(
|
1377 |
-
'id' => 'profile_icons',
|
1378 |
-
'type' => 'select',
|
1379 |
-
'label' => __( 'Profile Field Icons', 'ultimate-member' ),
|
1380 |
-
'tooltip' => __( 'This is applicable for edit mode only', 'ultimate-member' ),
|
1381 |
-
'default' => um_get_metadefault( 'profile_icons' ),
|
1382 |
-
'options' => array(
|
1383 |
-
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
1384 |
-
'label' => __( 'Show with label', 'ultimate-member' ),
|
1385 |
-
'off' => __( 'Turn off', 'ultimate-member' ),
|
1386 |
-
),
|
1387 |
-
'size' => 'small',
|
1388 |
-
),
|
1389 |
-
array(
|
1390 |
-
'id' => 'profile_primary_btn_word',
|
1391 |
-
'type' => 'text',
|
1392 |
-
'label' => __( 'Profile Primary Button Text', 'ultimate-member' ),
|
1393 |
-
'default' => um_get_metadefault( 'profile_primary_btn_word' ),
|
1394 |
-
'tooltip' => __( 'The text that is used for updating profile button', 'ultimate-member' ),
|
1395 |
-
'size' => 'medium',
|
1396 |
-
),
|
1397 |
-
array(
|
1398 |
-
'id' => 'profile_secondary_btn',
|
1399 |
-
'type' => 'checkbox',
|
1400 |
-
'label' => __( 'Profile Secondary Button', 'ultimate-member' ),
|
1401 |
-
'default' => um_get_metadefault( 'profile_secondary_btn' ),
|
1402 |
-
'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
|
1403 |
-
),
|
1404 |
-
array(
|
1405 |
-
'id' => 'profile_secondary_btn_word',
|
1406 |
-
'type' => 'text',
|
1407 |
-
'label' => __( 'Profile Secondary Button Text', 'ultimate-member' ),
|
1408 |
-
'default' => um_get_metadefault( 'profile_secondary_btn_word' ),
|
1409 |
-
'tooltip' => __( 'The text that is used for cancelling update profile button', 'ultimate-member' ),
|
1410 |
-
'conditional' => array( 'profile_secondary_btn', '=', 1 ),
|
1411 |
-
'size' => 'medium',
|
1412 |
-
),
|
1413 |
-
array(
|
1414 |
-
'id' => 'default_avatar',
|
1415 |
-
'type' => 'media',
|
1416 |
-
'label' => __( 'Default Profile Photo', 'ultimate-member' ),
|
1417 |
-
'tooltip' => __( 'You can change the default profile picture globally here. Please make sure that the photo is 300x300px.', 'ultimate-member' ),
|
1418 |
-
'upload_frame_title' => __( 'Select Default Profile Photo', 'ultimate-member' ),
|
1419 |
-
'default' => array(
|
1420 |
-
'url' => um_url . 'assets/img/default_avatar.jpg',
|
1421 |
-
),
|
1422 |
-
),
|
1423 |
-
array(
|
1424 |
-
'id' => 'default_cover',
|
1425 |
-
'type' => 'media',
|
1426 |
-
'url' => true,
|
1427 |
-
'preview' => false,
|
1428 |
-
'label' => __( 'Default Cover Photo', 'ultimate-member' ),
|
1429 |
-
'tooltip' => __( 'You can change the default cover photo globally here. Please make sure that the default cover is large enough and respects the ratio you are using for cover photos.', 'ultimate-member' ),
|
1430 |
-
'upload_frame_title' => __( 'Select Default Cover Photo', 'ultimate-member' ),
|
1431 |
-
),
|
1432 |
-
array(
|
1433 |
-
'id' => 'disable_profile_photo_upload',
|
1434 |
-
'type' => 'checkbox',
|
1435 |
-
'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ),
|
1436 |
-
'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ),
|
1437 |
-
'default' => um_get_metadefault( 'disable_profile_photo_upload' ),
|
1438 |
-
),
|
1439 |
-
array(
|
1440 |
-
'id' => 'profile_photosize',
|
1441 |
-
'type' => 'select',
|
1442 |
-
'label' => __( 'Profile Photo Size', 'ultimate-member' ),
|
1443 |
-
'default' => um_get_metadefault( 'profile_photosize' ),
|
1444 |
-
'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ),
|
1445 |
-
'tooltip' => __( 'The global default of profile photo size. This can be overridden by individual form settings', 'ultimate-member' ),
|
1446 |
-
'size' => 'small',
|
1447 |
-
),
|
1448 |
-
array(
|
1449 |
-
'id' => 'profile_cover_enabled',
|
1450 |
-
'type' => 'checkbox',
|
1451 |
-
'label' => __( 'Profile Cover Photos', 'ultimate-member' ),
|
1452 |
-
'default' => um_get_metadefault( 'profile_cover_enabled' ),
|
1453 |
-
'tooltip' => __( 'Switch on/off the profile cover photos', 'ultimate-member' ),
|
1454 |
-
),
|
1455 |
-
array(
|
1456 |
-
'id' => 'profile_coversize',
|
1457 |
-
'type' => 'select',
|
1458 |
-
'label' => __( 'Profile Cover Size', 'ultimate-member' ),
|
1459 |
-
'default' => um_get_metadefault( 'profile_coversize' ),
|
1460 |
-
'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ),
|
1461 |
-
'tooltip' => __( 'The global default width of cover photo size. This can be overridden by individual form settings', 'ultimate-member' ),
|
1462 |
-
'conditional' => array( 'profile_cover_enabled', '=', 1 ),
|
1463 |
-
'size' => 'small',
|
1464 |
-
),
|
1465 |
-
array(
|
1466 |
-
'id' => 'profile_cover_ratio',
|
1467 |
-
'type' => 'select',
|
1468 |
-
'label' => __( 'Profile Cover Ratio', 'ultimate-member' ),
|
1469 |
-
'tooltip' => __( 'Choose global ratio for cover photos of profiles', 'ultimate-member' ),
|
1470 |
-
'default' => um_get_metadefault( 'profile_cover_ratio' ),
|
1471 |
-
'options' => array(
|
1472 |
-
'1.6:1' => '1.6:1',
|
1473 |
-
'2.7:1' => '2.7:1',
|
1474 |
-
'2.2:1' => '2.2:1',
|
1475 |
-
'3.2:1' => '3.2:1',
|
1476 |
-
),
|
1477 |
-
'conditional' => array( 'profile_cover_enabled', '=', 1 ),
|
1478 |
-
'size' => 'small',
|
1479 |
-
),
|
1480 |
-
array(
|
1481 |
-
'id' => 'profile_show_metaicon',
|
1482 |
-
'type' => 'checkbox',
|
1483 |
-
'label' => __( 'Profile Header Meta Text Icon', 'ultimate-member' ),
|
1484 |
-
'default' => 0,
|
1485 |
-
'tooltip' => __( 'Display field icons for related user meta fields in header or not', 'ultimate-member' ),
|
1486 |
-
),
|
1487 |
-
array(
|
1488 |
-
'id' => 'profile_show_name',
|
1489 |
-
'type' => 'checkbox',
|
1490 |
-
'label' => __( 'Show display name in profile header', 'ultimate-member' ),
|
1491 |
-
'default' => um_get_metadefault( 'profile_show_name' ),
|
1492 |
-
'tooltip' => __( 'Switch on/off the user name on profile header', 'ultimate-member' ),
|
1493 |
-
),
|
1494 |
-
array(
|
1495 |
-
'id' => 'profile_show_social_links',
|
1496 |
-
'type' => 'checkbox',
|
1497 |
-
'label' => __( 'Show social links in profile header', 'ultimate-member' ),
|
1498 |
-
'default' => um_get_metadefault( 'profile_show_social_links' ),
|
1499 |
-
'tooltip' => __( 'Switch on/off the social links on profile header', 'ultimate-member' ),
|
1500 |
-
),
|
1501 |
-
array(
|
1502 |
-
'id' => 'profile_show_bio',
|
1503 |
-
'type' => 'checkbox',
|
1504 |
-
'label' => __( 'Show user description in header', 'ultimate-member' ),
|
1505 |
-
'default' => um_get_metadefault( 'profile_show_bio' ),
|
1506 |
-
'tooltip' => __( 'Switch on/off the user description on profile header', 'ultimate-member' ),
|
1507 |
-
),
|
1508 |
-
array(
|
1509 |
-
'id' => 'profile_show_html_bio',
|
1510 |
-
'type' => 'checkbox',
|
1511 |
-
'label' => __( 'Enable HTML support for user description', 'ultimate-member' ),
|
1512 |
-
'tooltip' => __( 'Switch on/off to enable/disable support for html tags on user description.', 'ultimate-member' ),
|
1513 |
-
),
|
1514 |
-
array(
|
1515 |
-
'id' => 'profile_bio_maxchars',
|
1516 |
-
'type' => 'text',
|
1517 |
-
'label' => __( 'User description maximum chars', 'ultimate-member' ),
|
1518 |
-
'default' => um_get_metadefault( 'profile_bio_maxchars' ),
|
1519 |
-
'tooltip' => __( 'Maximum number of characters to allow in user description field in header.', 'ultimate-member' ),
|
1520 |
-
'conditional' => array( 'profile_show_bio', '=', 1 ),
|
1521 |
-
'size' => 'small',
|
1522 |
-
),
|
1523 |
-
array(
|
1524 |
-
'id' => 'profile_header_menu',
|
1525 |
-
'type' => 'select',
|
1526 |
-
'label' => __( 'Profile Header Menu Position', 'ultimate-member' ),
|
1527 |
-
'default' => um_get_metadefault( 'profile_header_menu' ),
|
1528 |
-
'tooltip' => __( 'For incompatible themes, please make the menu open from left instead of bottom by default.', 'ultimate-member' ),
|
1529 |
-
'options' => array(
|
1530 |
-
'bc' => __( 'Bottom of Icon', 'ultimate-member' ),
|
1531 |
-
'lc' => __( 'Left of Icon (right for RTL)', 'ultimate-member' ),
|
1532 |
-
),
|
1533 |
-
'size' => 'small',
|
1534 |
-
),
|
1535 |
-
array(
|
1536 |
-
'id' => 'profile_empty_text',
|
1537 |
-
'type' => 'checkbox',
|
1538 |
-
'label' => __( 'Show a custom message if profile is empty', 'ultimate-member' ),
|
1539 |
-
'default' => um_get_metadefault( 'profile_empty_text' ),
|
1540 |
-
'tooltip' => __( 'Switch on/off the custom message that appears when the profile is empty', 'ultimate-member' ),
|
1541 |
-
),
|
1542 |
-
array(
|
1543 |
-
'id' => 'profile_empty_text_emo',
|
1544 |
-
'type' => 'checkbox',
|
1545 |
-
'label' => __( 'Show the emoticon', 'ultimate-member' ),
|
1546 |
-
'default' => um_get_metadefault( 'profile_empty_text_emo' ),
|
1547 |
-
'tooltip' => __( 'Switch on/off the emoticon (sad face) that appears above the message', 'ultimate-member' ),
|
1548 |
-
'conditional' => array( 'profile_empty_text', '=', 1 ),
|
1549 |
-
),
|
1550 |
-
),
|
1551 |
-
),
|
1552 |
-
'profile_menu' => array(
|
1553 |
-
'title' => __( 'Profile Menu', 'ultimate-member' ),
|
1554 |
-
'fields' => $appearances_profile_menu_fields,
|
1555 |
-
),
|
1556 |
-
'registration_form' => array(
|
1557 |
-
'title' => __( 'Registration Form', 'ultimate-member' ),
|
1558 |
-
'fields' => array(
|
1559 |
-
array(
|
1560 |
-
'id' => 'register_template',
|
1561 |
-
'type' => 'select',
|
1562 |
-
'label' => __( 'Registration Default Template', 'ultimate-member' ),
|
1563 |
-
'tooltip' => __( 'This will be the default template to output registration', 'ultimate-member' ),
|
1564 |
-
'default' => um_get_metadefault( 'register_template' ),
|
1565 |
-
'options' => UM()->shortcodes()->get_templates( 'register' ),
|
1566 |
-
'size' => 'small',
|
1567 |
-
),
|
1568 |
-
array(
|
1569 |
-
'id' => 'register_max_width',
|
1570 |
-
'type' => 'text',
|
1571 |
-
'label' => __( 'Registration Maximum Width', 'ultimate-member' ),
|
1572 |
-
'default' => um_get_metadefault( 'register_max_width' ),
|
1573 |
-
'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
|
1574 |
-
'size' => 'small',
|
1575 |
-
),
|
1576 |
-
array(
|
1577 |
-
'id' => 'register_align',
|
1578 |
-
'type' => 'select',
|
1579 |
-
'label' => __( 'Registration Shortcode Alignment', 'ultimate-member' ),
|
1580 |
-
'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
|
1581 |
-
'default' => um_get_metadefault( 'register_align' ),
|
1582 |
-
'options' => array(
|
1583 |
-
'center' => __( 'Centered', 'ultimate-member' ),
|
1584 |
-
'left' => __( 'Left aligned', 'ultimate-member' ),
|
1585 |
-
'right' => __( 'Right aligned', 'ultimate-member' ),
|
1586 |
-
),
|
1587 |
-
'size' => 'small',
|
1588 |
-
),
|
1589 |
-
array(
|
1590 |
-
'id' => 'register_icons',
|
1591 |
-
'type' => 'select',
|
1592 |
-
'label' => __( 'Registration Field Icons', 'ultimate-member' ),
|
1593 |
-
'tooltip' => __( 'This controls the display of field icons in the registration form', 'ultimate-member' ),
|
1594 |
-
'default' => um_get_metadefault( 'register_icons' ),
|
1595 |
-
'options' => array(
|
1596 |
-
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
1597 |
-
'label' => __( 'Show with label', 'ultimate-member' ),
|
1598 |
-
'off' => __( 'Turn off', 'ultimate-member' ),
|
1599 |
-
),
|
1600 |
-
'size' => 'small',
|
1601 |
-
),
|
1602 |
-
array(
|
1603 |
-
'id' => 'register_primary_btn_word',
|
1604 |
-
'type' => 'text',
|
1605 |
-
'label' => __( 'Registration Primary Button Text', 'ultimate-member' ),
|
1606 |
-
'default' => um_get_metadefault( 'register_primary_btn_word' ),
|
1607 |
-
'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
|
1608 |
-
'size' => 'medium',
|
1609 |
-
),
|
1610 |
-
array(
|
1611 |
-
'id' => 'register_secondary_btn',
|
1612 |
-
'type' => 'checkbox',
|
1613 |
-
'label' => __( 'Registration Secondary Button', 'ultimate-member' ),
|
1614 |
-
'default' => 1,
|
1615 |
-
'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
|
1616 |
-
),
|
1617 |
-
array(
|
1618 |
-
'id' => 'register_secondary_btn_word',
|
1619 |
-
'type' => 'text',
|
1620 |
-
'label' => __( 'Registration Secondary Button Text', 'ultimate-member' ),
|
1621 |
-
'default' => um_get_metadefault( 'register_secondary_btn_word' ),
|
1622 |
-
'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
|
1623 |
-
'conditional' => array( 'register_secondary_btn', '=', 1 ),
|
1624 |
-
'size' => 'medium',
|
1625 |
-
),
|
1626 |
-
array(
|
1627 |
-
'id' => 'register_secondary_btn_url',
|
1628 |
-
'type' => 'text',
|
1629 |
-
'label' => __( 'Registration Secondary Button URL', 'ultimate-member' ),
|
1630 |
-
'default' => um_get_metadefault( 'register_secondary_btn_url' ),
|
1631 |
-
'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
|
1632 |
-
'conditional' => array( 'register_secondary_btn', '=', 1 ),
|
1633 |
-
'size' => 'medium',
|
1634 |
-
),
|
1635 |
-
array(
|
1636 |
-
'id' => 'register_role',
|
1637 |
-
'type' => 'select',
|
1638 |
-
'label' => __( 'Registration Default Role', 'ultimate-member' ),
|
1639 |
-
'tooltip' => __( 'This will be the default role assigned to users registering thru registration form', 'ultimate-member' ),
|
1640 |
-
'default' => um_get_metadefault( 'register_role' ),
|
1641 |
-
'options' => UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ),
|
1642 |
-
'size' => 'small',
|
1643 |
-
),
|
1644 |
-
),
|
1645 |
-
),
|
1646 |
-
'login_form' => array(
|
1647 |
-
'title' => __( 'Login Form', 'ultimate-member' ),
|
1648 |
-
'fields' => array(
|
1649 |
-
array(
|
1650 |
-
'id' => 'login_template',
|
1651 |
-
'type' => 'select',
|
1652 |
-
'label' => __( 'Login Default Template', 'ultimate-member' ),
|
1653 |
-
'tooltip' => __( 'This will be the default template to output login', 'ultimate-member' ),
|
1654 |
-
'default' => um_get_metadefault( 'login_template' ),
|
1655 |
-
'options' => UM()->shortcodes()->get_templates( 'login' ),
|
1656 |
-
'size' => 'small',
|
1657 |
-
),
|
1658 |
-
array(
|
1659 |
-
'id' => 'login_max_width',
|
1660 |
-
'type' => 'text',
|
1661 |
-
'label' => __( 'Login Maximum Width', 'ultimate-member' ),
|
1662 |
-
'default' => um_get_metadefault( 'login_max_width' ),
|
1663 |
-
'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
|
1664 |
-
'size' => 'small',
|
1665 |
-
),
|
1666 |
-
array(
|
1667 |
-
'id' => 'login_align',
|
1668 |
-
'type' => 'select',
|
1669 |
-
'label' => __( 'Login Shortcode Alignment', 'ultimate-member' ),
|
1670 |
-
'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
|
1671 |
-
'default' => um_get_metadefault( 'login_align' ),
|
1672 |
-
'options' => array(
|
1673 |
-
'center' => __( 'Centered', 'ultimate-member' ),
|
1674 |
-
'left' => __( 'Left aligned', 'ultimate-member' ),
|
1675 |
-
'right' => __( 'Right aligned', 'ultimate-member' ),
|
1676 |
-
),
|
1677 |
-
'size' => 'small',
|
1678 |
-
),
|
1679 |
-
array(
|
1680 |
-
'id' => 'login_icons',
|
1681 |
-
'type' => 'select',
|
1682 |
-
'label' => __( 'Login Field Icons', 'ultimate-member' ),
|
1683 |
-
'tooltip' => __( 'This controls the display of field icons in the login form', 'ultimate-member' ),
|
1684 |
-
'default' => um_get_metadefault( 'login_icons' ),
|
1685 |
-
'options' => array(
|
1686 |
-
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
1687 |
-
'label' => __( 'Show with label', 'ultimate-member' ),
|
1688 |
-
'off' => __( 'Turn off', 'ultimate-member' ),
|
1689 |
-
),
|
1690 |
-
'size' => 'small',
|
1691 |
-
),
|
1692 |
-
array(
|
1693 |
-
'id' => 'login_primary_btn_word',
|
1694 |
-
'type' => 'text',
|
1695 |
-
'label' => __( 'Login Primary Button Text', 'ultimate-member' ),
|
1696 |
-
'default' => um_get_metadefault( 'login_primary_btn_word' ),
|
1697 |
-
'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
|
1698 |
-
'size' => 'medium',
|
1699 |
-
),
|
1700 |
-
array(
|
1701 |
-
'id' => 'login_secondary_btn',
|
1702 |
-
'type' => 'checkbox',
|
1703 |
-
'label' => __( 'Login Secondary Button', 'ultimate-member' ),
|
1704 |
-
'default' => 1,
|
1705 |
-
'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
|
1706 |
-
),
|
1707 |
-
array(
|
1708 |
-
'id' => 'login_secondary_btn_word',
|
1709 |
-
'type' => 'text',
|
1710 |
-
'label' => __( 'Login Secondary Button Text', 'ultimate-member' ),
|
1711 |
-
'default' => um_get_metadefault( 'login_secondary_btn_word' ),
|
1712 |
-
'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
|
1713 |
-
'conditional' => array( 'login_secondary_btn', '=', 1 ),
|
1714 |
-
'size' => 'medium',
|
1715 |
-
),
|
1716 |
-
array(
|
1717 |
-
'id' => 'login_secondary_btn_url',
|
1718 |
-
'type' => 'text',
|
1719 |
-
'label' => __( 'Login Secondary Button URL', 'ultimate-member' ),
|
1720 |
-
'default' => um_get_metadefault( 'login_secondary_btn_url' ),
|
1721 |
-
'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
|
1722 |
-
'conditional' => array( 'login_secondary_btn', '=', 1 ),
|
1723 |
-
'size' => 'medium',
|
1724 |
-
),
|
1725 |
-
array(
|
1726 |
-
'id' => 'login_forgot_pass_link',
|
1727 |
-
'type' => 'checkbox',
|
1728 |
-
'label' => __( 'Login Forgot Password Link', 'ultimate-member' ),
|
1729 |
-
'default' => 1,
|
1730 |
-
'tooltip' => __( 'Switch on/off the forgot password link in login form', 'ultimate-member' ),
|
1731 |
-
),
|
1732 |
-
array(
|
1733 |
-
'id' => 'login_show_rememberme',
|
1734 |
-
'type' => 'checkbox',
|
1735 |
-
'label' => __( 'Show "Remember Me"', 'ultimate-member' ),
|
1736 |
-
'default' => 1,
|
1737 |
-
'tooltip' => __( 'Allow users to choose If they want to stay signed in even after closing the browser. If you do not show this option, the default will be to not remember login session.', 'ultimate-member' ),
|
1738 |
-
),
|
1739 |
-
),
|
1740 |
-
),
|
1741 |
-
),
|
1742 |
-
),
|
1743 |
-
'extensions' => array(
|
1744 |
-
'title' => __( 'Extensions', 'ultimate-member' ),
|
1745 |
-
),
|
1746 |
-
'licenses' => array(
|
1747 |
-
'title' => __( 'Licenses', 'ultimate-member' ),
|
1748 |
-
),
|
1749 |
-
'misc' => array(
|
1750 |
-
'title' => __( 'Misc', 'ultimate-member' ),
|
1751 |
-
'fields' => array(
|
1752 |
-
array(
|
1753 |
-
'id' => 'form_asterisk',
|
1754 |
-
'type' => 'checkbox',
|
1755 |
-
'label' => __( 'Show an asterisk for required fields', 'ultimate-member' ),
|
1756 |
-
),
|
1757 |
-
array(
|
1758 |
-
'id' => 'profile_title',
|
1759 |
-
'type' => 'text',
|
1760 |
-
'label' => __( 'User Profile Title', 'ultimate-member' ),
|
1761 |
-
'tooltip' => __( 'This is the title that is displayed on a specific user profile', 'ultimate-member' ),
|
1762 |
-
'size' => 'medium',
|
1763 |
-
),
|
1764 |
-
array(
|
1765 |
-
'id' => 'profile_desc',
|
1766 |
-
'type' => 'textarea',
|
1767 |
-
'label' => __( 'User Profile Dynamic Meta Description', 'ultimate-member' ),
|
1768 |
-
'tooltip' => __( 'This will be used in the meta description that is available for search-engines.', 'ultimate-member' ),
|
1769 |
-
'args' => array(
|
1770 |
-
'textarea_rows' => 6,
|
1771 |
-
),
|
1772 |
-
),
|
1773 |
-
array(
|
1774 |
-
'id' => 'um_profile_object_cache_stop',
|
1775 |
-
'type' => 'checkbox',
|
1776 |
-
'label' => __( 'Disable Cache User Profile', 'ultimate-member' ),
|
1777 |
-
'tooltip' => __( 'Check this box if you would like to disable Ultimate Member user\'s cache.', 'ultimate-member' ),
|
1778 |
-
),
|
1779 |
-
array(
|
1780 |
-
'id' => 'enable_blocks',
|
1781 |
-
'type' => 'checkbox',
|
1782 |
-
'label' => __( 'Enable Gutenberg Blocks', 'ultimate-member' ),
|
1783 |
-
'tooltip' => __( 'Check this box if you would like to use Ultimate Member blocks in Gutenberg editor. Important some themes have the conflicts with Gutenberg editor.', 'ultimate-member' ),
|
1784 |
-
),
|
1785 |
-
array(
|
1786 |
-
'id' => 'rest_api_version',
|
1787 |
-
'type' => 'select',
|
1788 |
-
'label' => __( 'REST API version', 'ultimate-member' ),
|
1789 |
-
'tooltip' => __( 'This controls the REST API version, we recommend to use the last version', 'ultimate-member' ),
|
1790 |
-
'options' => array(
|
1791 |
-
'1.0' => __( '1.0 version', 'ultimate-member' ),
|
1792 |
-
'2.0' => __( '2.0 version', 'ultimate-member' ),
|
1793 |
-
),
|
1794 |
-
),
|
1795 |
-
// backward compatibility option leave it disabled for better security and ability to exclude posts/terms pre-query
|
1796 |
-
// otherwise we filtering only results and restricted posts/terms can be visible
|
1797 |
-
array(
|
1798 |
-
'id' => 'disable_restriction_pre_queries',
|
1799 |
-
'type' => 'checkbox',
|
1800 |
-
'label' => __( 'Disable pre-queries for restriction content logic (advanced)', 'ultimate-member' ),
|
1801 |
-
'tooltip' => __( 'Please enable this option only in the cases when you have big or unnecessary queries on your site with active restriction logic. If you want to exclude posts only from the results queries instead of pre_get_posts and fully-hidden post logic also please enable this option. It activates the restriction content logic until 2.2.x version without latest security enhancements', 'ultimate-member' ),
|
1802 |
-
),
|
1803 |
-
$same_page_update,
|
1804 |
-
array(
|
1805 |
-
'id' => 'uninstall_on_delete',
|
1806 |
-
'type' => 'checkbox',
|
1807 |
-
'label' => __( 'Remove Data on Uninstall?', 'ultimate-member' ),
|
1808 |
-
'tooltip' => __( 'Check this box if you would like Ultimate Member to completely remove all of its data when the plugin/extensions are deleted.', 'ultimate-member' ),
|
1809 |
-
),
|
1810 |
-
),
|
1811 |
-
),
|
1812 |
-
'install_info' => array(
|
1813 |
-
'title' => __( 'Install Info', 'ultimate-member' ),
|
1814 |
-
'fields' => array(
|
1815 |
-
array(
|
1816 |
-
'type' => 'install_info',
|
1817 |
-
),
|
1818 |
-
),
|
1819 |
-
),
|
1820 |
-
)
|
1821 |
-
);
|
1822 |
-
|
1823 |
-
}
|
1824 |
-
|
1825 |
-
|
1826 |
-
/**
|
1827 |
-
* @param array $settings
|
1828 |
-
*
|
1829 |
-
* @return array
|
1830 |
-
*/
|
1831 |
-
public function sorting_licenses_options( $settings ) {
|
1832 |
-
//sorting licenses
|
1833 |
-
if ( ! empty( $settings['licenses']['fields'] ) ) {
|
1834 |
-
$licenses = $settings['licenses']['fields'];
|
1835 |
-
@uasort( $licenses, function( $a, $b ) {
|
1836 |
-
return strnatcasecmp( $a['label'], $b['label'] );
|
1837 |
-
} );
|
1838 |
-
$settings['licenses']['fields'] = $licenses;
|
1839 |
-
}
|
1840 |
-
|
1841 |
-
//sorting extensions by the title
|
1842 |
-
if ( ! empty( $settings['extensions']['sections'] ) ) {
|
1843 |
-
$extensions = $settings['extensions']['sections'];
|
1844 |
-
|
1845 |
-
@uasort( $extensions, function( $a, $b ) {
|
1846 |
-
return strnatcasecmp( $a['title'], $b['title'] );
|
1847 |
-
} );
|
1848 |
-
|
1849 |
-
$keys = array_keys( $extensions );
|
1850 |
-
$temp = array(
|
1851 |
-
'' => $extensions[ $keys[0] ],
|
1852 |
-
);
|
1853 |
-
|
1854 |
-
unset( $extensions[ $keys[0] ] );
|
1855 |
-
$extensions = $temp + $extensions;
|
1856 |
-
|
1857 |
-
$settings['extensions']['sections'] = $extensions;
|
1858 |
-
}
|
1859 |
-
|
1860 |
-
return $settings;
|
1861 |
-
}
|
1862 |
-
|
1863 |
-
|
1864 |
-
/**
|
1865 |
-
* @param $tab
|
1866 |
-
* @param $section
|
1867 |
-
*
|
1868 |
-
* @return array
|
1869 |
-
*/
|
1870 |
-
function get_section_fields( $tab, $section ) {
|
1871 |
-
|
1872 |
-
if ( empty( $this->settings_structure[ $tab ] ) ) {
|
1873 |
-
return array();
|
1874 |
-
}
|
1875 |
-
|
1876 |
-
if ( ! empty( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) {
|
1877 |
-
return $this->settings_structure[ $tab ]['sections'][ $section ]['fields'];
|
1878 |
-
} elseif ( ! empty( $this->settings_structure[ $tab ]['fields'] ) ) {
|
1879 |
-
return $this->settings_structure[ $tab ]['fields'];
|
1880 |
-
}
|
1881 |
-
|
1882 |
-
return array();
|
1883 |
-
}
|
1884 |
-
|
1885 |
-
|
1886 |
-
/**
|
1887 |
-
* Setup admin menu
|
1888 |
-
*/
|
1889 |
-
function primary_admin_menu() {
|
1890 |
-
add_submenu_page( 'ultimatemember', __( 'Settings', 'ultimate-member' ), __( 'Settings', 'ultimate-member' ), 'manage_options', 'um_options', array( &$this, 'settings_page' ) );
|
1891 |
-
}
|
1892 |
-
|
1893 |
-
|
1894 |
-
/**
|
1895 |
-
* Settings page callback
|
1896 |
-
*/
|
1897 |
-
function settings_page() {
|
1898 |
-
$current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
|
1899 |
-
$current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
|
1900 |
-
|
1901 |
-
$settings_struct = $this->settings_structure[ $current_tab ];
|
1902 |
-
|
1903 |
-
//remove not option hidden fields
|
1904 |
-
if ( ! empty( $settings_struct['fields'] ) ) {
|
1905 |
-
foreach ( $settings_struct['fields'] as $field_key => $field_options ) {
|
1906 |
-
|
1907 |
-
if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) {
|
1908 |
-
unset( $settings_struct['fields'][ $field_key ] );
|
1909 |
-
}
|
1910 |
-
|
1911 |
-
}
|
1912 |
-
}
|
1913 |
-
|
1914 |
-
if ( empty( $settings_struct['fields'] ) && empty( $settings_struct['sections'] ) ) {
|
1915 |
-
um_js_redirect( add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) ) );
|
1916 |
-
}
|
1917 |
-
|
1918 |
-
if ( ! empty( $settings_struct['sections'] ) ) {
|
1919 |
-
if ( empty( $settings_struct['sections'][ $current_subtab ] ) ) {
|
1920 |
-
um_js_redirect( add_query_arg( array( 'page' => 'um_options', 'tab' => $current_tab ), admin_url( 'admin.php' ) ) );
|
1921 |
-
}
|
1922 |
-
}
|
1923 |
-
|
1924 |
-
echo '<div id="um-settings-wrap" class="wrap"><h2>' . __( 'Ultimate Member - Settings', 'ultimate-member' ) . '</h2>';
|
1925 |
-
|
1926 |
-
echo $this->generate_tabs_menu() . $this->generate_subtabs_menu( $current_tab );
|
1927 |
-
|
1928 |
-
/**
|
1929 |
-
* UM hook
|
1930 |
-
*
|
1931 |
-
* @type action
|
1932 |
-
* @title um_settings_page_before_{$current_tab}_{$current_subtab}_content
|
1933 |
-
* @description Show some content before settings page content
|
1934 |
-
* @change_log
|
1935 |
-
* ["Since: 2.0"]
|
1936 |
-
* @usage add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'function_name', 10 );
|
1937 |
-
* @example
|
1938 |
-
* <?php
|
1939 |
-
* add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'my_settings_page_before', 10 );
|
1940 |
-
* function my_settings_page_before() {
|
1941 |
-
* // your code here
|
1942 |
-
* }
|
1943 |
-
* ?>
|
1944 |
-
*/
|
1945 |
-
do_action( "um_settings_page_before_" . $current_tab . "_" . $current_subtab . "_content" );
|
1946 |
-
|
1947 |
-
if ( in_array( $current_tab, apply_filters('um_settings_custom_tabs', array( 'licenses', 'install_info' ) ) ) || in_array( $current_subtab, apply_filters( 'um_settings_custom_subtabs', array(), $current_tab ) ) ) {
|
1948 |
-
|
1949 |
-
/**
|
1950 |
-
* UM hook
|
1951 |
-
*
|
1952 |
-
* @type action
|
1953 |
-
* @title um_settings_page_{$current_tab}_{$current_subtab}_before_section
|
1954 |
-
* @description Show some content before section content at settings page
|
1955 |
-
* @change_log
|
1956 |
-
* ["Since: 2.0"]
|
1957 |
-
* @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 );
|
1958 |
-
* @example
|
1959 |
-
* <?php
|
1960 |
-
* add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'my_settings_page_before_section', 10 );
|
1961 |
-
* function my_settings_page_before_section() {
|
1962 |
-
* // your code here
|
1963 |
-
* }
|
1964 |
-
* ?>
|
1965 |
-
*/
|
1966 |
-
do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" );
|
1967 |
-
|
1968 |
-
$section_fields = $this->get_section_fields( $current_tab, $current_subtab );
|
1969 |
-
$settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab );
|
1970 |
-
|
1971 |
-
/**
|
1972 |
-
* UM hook
|
1973 |
-
*
|
1974 |
-
* @type filter
|
1975 |
-
* @title um_settings_section_{$current_tab}_{$current_subtab}_content
|
1976 |
-
*
|
1977 |
-
* @description Render settings section
|
1978 |
-
* @input_vars
|
1979 |
-
* [{"var":"$content","type":"string","desc":"Section content"},
|
1980 |
-
* {"var":"$section_fields","type":"array","desc":"Section Fields"}]
|
1981 |
-
* @change_log
|
1982 |
-
* ["Since: 2.0"]
|
1983 |
-
* @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 );
|
1984 |
-
* @example
|
1985 |
-
* <?php
|
1986 |
-
* add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'my_settings_section', 10, 2 );
|
1987 |
-
* function my_settings_section( $content ) {
|
1988 |
-
* // your code here
|
1989 |
-
* return $content;
|
1990 |
-
* }
|
1991 |
-
* ?>
|
1992 |
-
*/
|
1993 |
-
echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content',
|
1994 |
-
$settings_section,
|
1995 |
-
$section_fields
|
1996 |
-
);
|
1997 |
-
|
1998 |
-
} else { ?>
|
1999 |
-
|
2000 |
-
<form method="post" action="" name="um-settings-form" id="um-settings-form">
|
2001 |
-
<input type="hidden" value="save" name="um-settings-action" />
|
2002 |
-
|
2003 |
-
<?php
|
2004 |
-
/**
|
2005 |
-
* UM hook
|
2006 |
-
*
|
2007 |
-
* @type action
|
2008 |
-
* @title um_settings_page_{$current_tab}_{$current_subtab}_before_section
|
2009 |
-
* @description Show some content before section content at settings page
|
2010 |
-
* @change_log
|
2011 |
-
* ["Since: 2.0"]
|
2012 |
-
* @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 );
|
2013 |
-
* @example
|
2014 |
-
* <?php
|
2015 |
-
* add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'my_settings_page_before_section', 10 );
|
2016 |
-
* function my_settings_page_before_section() {
|
2017 |
-
* // your code here
|
2018 |
-
* }
|
2019 |
-
* ?>
|
2020 |
-
*/
|
2021 |
-
do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" );
|
2022 |
-
|
2023 |
-
$section_fields = $this->get_section_fields( $current_tab, $current_subtab );
|
2024 |
-
$settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab );
|
2025 |
-
|
2026 |
-
/**
|
2027 |
-
* UM hook
|
2028 |
-
*
|
2029 |
-
* @type filter
|
2030 |
-
* @title um_settings_section_{$current_tab}_{$current_subtab}_content
|
2031 |
-
* @description Render settings section
|
2032 |
-
* @input_vars
|
2033 |
-
* [{"var":"$content","type":"string","desc":"Section content"},
|
2034 |
-
* {"var":"$section_fields","type":"array","desc":"Section Fields"}]
|
2035 |
-
* @change_log
|
2036 |
-
* ["Since: 2.0"]
|
2037 |
-
* @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 );
|
2038 |
-
* @example
|
2039 |
-
* <?php
|
2040 |
-
* add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'my_settings_section', 10, 2 );
|
2041 |
-
* function my_settings_section( $content ) {
|
2042 |
-
* // your code here
|
2043 |
-
* return $content;
|
2044 |
-
* }
|
2045 |
-
* ?>
|
2046 |
-
*/
|
2047 |
-
echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content',
|
2048 |
-
$settings_section,
|
2049 |
-
$section_fields
|
2050 |
-
); ?>
|
2051 |
-
|
2052 |
-
|
2053 |
-
<p class="submit">
|
2054 |
-
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Save Changes', 'ultimate-member' ) ?>" />
|
2055 |
-
<?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
|
2056 |
-
<input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
|
2057 |
-
</p>
|
2058 |
-
</form>
|
2059 |
-
|
2060 |
-
<?php }
|
2061 |
-
}
|
2062 |
-
|
2063 |
-
|
2064 |
-
/**
|
2065 |
-
* Generate pages tabs
|
2066 |
-
*
|
2067 |
-
* @param string $page
|
2068 |
-
* @return string
|
2069 |
-
*/
|
2070 |
-
function generate_tabs_menu( $page = 'settings' ) {
|
2071 |
-
|
2072 |
-
$tabs = '<h2 class="nav-tab-wrapper um-nav-tab-wrapper">';
|
2073 |
-
|
2074 |
-
switch( $page ) {
|
2075 |
-
case 'settings':
|
2076 |
-
$menu_tabs = array();
|
2077 |
-
foreach ( $this->settings_structure as $slug => $tab ) {
|
2078 |
-
if ( ! empty( $tab['fields'] ) ) {
|
2079 |
-
foreach ( $tab['fields'] as $field_key => $field_options ) {
|
2080 |
-
if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) {
|
2081 |
-
unset( $tab['fields'][ $field_key ] );
|
2082 |
-
}
|
2083 |
-
}
|
2084 |
-
}
|
2085 |
-
|
2086 |
-
if ( ! empty( $tab['fields'] ) || ! empty( $tab['sections'] ) ) {
|
2087 |
-
$menu_tabs[ $slug ] = $tab['title'];
|
2088 |
-
}
|
2089 |
-
}
|
2090 |
-
|
2091 |
-
$current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
|
2092 |
-
foreach ( $menu_tabs as $name => $label ) {
|
2093 |
-
$active = ( $current_tab == $name ) ? 'nav-tab-active' : '';
|
2094 |
-
$tabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $name ) ? '' : '&tab=' . $name ) ) ) . '" class="nav-tab ' . esc_attr( $active ) . '">' .
|
2095 |
-
$label .
|
2096 |
-
'</a>';
|
2097 |
-
}
|
2098 |
-
|
2099 |
-
break;
|
2100 |
-
default:
|
2101 |
-
/**
|
2102 |
-
* UM hook
|
2103 |
-
*
|
2104 |
-
* @type filter
|
2105 |
-
* @title um_generate_tabs_menu_{$page}
|
2106 |
-
* @description Generate tabs menu
|
2107 |
-
* @input_vars
|
2108 |
-
* [{"var":"$tabs","type":"array","desc":"UM menu tabs"}]
|
2109 |
-
* @change_log
|
2110 |
-
* ["Since: 2.0"]
|
2111 |
-
* @usage add_filter( 'um_generate_tabs_menu_{$page}', 'function_name', 10, 1 );
|
2112 |
-
* @example
|
2113 |
-
* <?php
|
2114 |
-
* add_filter( 'um_generate_tabs_menu_{$page}', 'my_tabs_menu', 10, 1 );
|
2115 |
-
* function my_tabs_menu( $tabs ) {
|
2116 |
-
* // your code here
|
2117 |
-
* return $tabs;
|
2118 |
-
* }
|
2119 |
-
* ?>
|
2120 |
-
*/
|
2121 |
-
$tabs = apply_filters( 'um_generate_tabs_menu_' . $page, $tabs );
|
2122 |
-
break;
|
2123 |
-
}
|
2124 |
-
|
2125 |
-
return $tabs . '</h2>';
|
2126 |
-
}
|
2127 |
-
|
2128 |
-
|
2129 |
-
/**
|
2130 |
-
* @param string $tab
|
2131 |
-
*
|
2132 |
-
* @return string
|
2133 |
-
*/
|
2134 |
-
function generate_subtabs_menu( $tab = '' ) {
|
2135 |
-
if ( empty( $this->settings_structure[ $tab ]['sections'] ) ) {
|
2136 |
-
return '';
|
2137 |
-
}
|
2138 |
-
|
2139 |
-
$menu_subtabs = array();
|
2140 |
-
foreach ( $this->settings_structure[ $tab ]['sections'] as $slug => $subtab ) {
|
2141 |
-
$menu_subtabs[ $slug ] = $subtab['title'];
|
2142 |
-
}
|
2143 |
-
|
2144 |
-
$subtabs = '<div><ul class="subsubsub">';
|
2145 |
-
|
2146 |
-
$current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
|
2147 |
-
$current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
|
2148 |
-
foreach ( $menu_subtabs as $name => $label ) {
|
2149 |
-
$active = ( $current_subtab == $name ) ? 'current' : '';
|
2150 |
-
$subtabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $current_tab ) ? '' : '&tab=' . $current_tab ) . ( empty( $name ) ? '' : '§ion=' . $name ) ) ) . '" class="' . $active . '">'
|
2151 |
-
. $label .
|
2152 |
-
'</a> | ';
|
2153 |
-
}
|
2154 |
-
|
2155 |
-
return substr( $subtabs, 0, -3 ) . '</ul></div>';
|
2156 |
-
}
|
2157 |
-
|
2158 |
-
|
2159 |
-
/**
|
2160 |
-
* Handler for settings forms
|
2161 |
-
* when "Save Settings" button click
|
2162 |
-
*
|
2163 |
-
*/
|
2164 |
-
function save_settings_handler() {
|
2165 |
-
|
2166 |
-
if ( isset( $_POST['um-settings-action'] ) && 'save' === sanitize_key( $_POST['um-settings-action'] ) && ! empty( $_POST['um_options'] ) ) {
|
2167 |
-
|
2168 |
-
$nonce = ! empty( $_POST['__umnonce'] ) ? $_POST['__umnonce'] : '';
|
2169 |
-
|
2170 |
-
if ( ( ! wp_verify_nonce( $nonce, 'um-settings-nonce' ) || empty( $nonce ) ) || ! current_user_can( 'manage_options' ) ) {
|
2171 |
-
// This nonce is not valid.
|
2172 |
-
wp_die( __( 'Security Check', 'ultimate-member' ) );
|
2173 |
-
}
|
2174 |
-
|
2175 |
-
/**
|
2176 |
-
* UM hook
|
2177 |
-
*
|
2178 |
-
* @type action
|
2179 |
-
* @title um_settings_before_save
|
2180 |
-
* @description Before settings save action
|
2181 |
-
* @change_log
|
2182 |
-
* ["Since: 2.0"]
|
2183 |
-
* @usage add_action( 'um_settings_before_save', 'function_name', 10 );
|
2184 |
-
* @example
|
2185 |
-
* <?php
|
2186 |
-
* add_action( 'um_settings_before_save', 'my_settings_before_save', 10 );
|
2187 |
-
* function my_settings_before_save() {
|
2188 |
-
* // your code here
|
2189 |
-
* }
|
2190 |
-
* ?>
|
2191 |
-
*/
|
2192 |
-
do_action( "um_settings_before_save" );
|
2193 |
-
|
2194 |
-
/**
|
2195 |
-
* UM hook
|
2196 |
-
*
|
2197 |
-
* @type filter
|
2198 |
-
* @title um_change_settings_before_save
|
2199 |
-
* @description Change settings before save
|
2200 |
-
* @input_vars
|
2201 |
-
* [{"var":"$settings","type":"array","desc":"UM Settings on save"}]
|
2202 |
-
* @change_log
|
2203 |
-
* ["Since: 2.0"]
|
2204 |
-
* @usage add_filter( 'um_change_settings_before_save', 'function_name', 10, 1 );
|
2205 |
-
* @example
|
2206 |
-
* <?php
|
2207 |
-
* add_filter( 'um_change_settings_before_save', 'my_change_settings_before_save', 10, 1 );
|
2208 |
-
* function my_change_settings_before_save( $settings ) {
|
2209 |
-
* // your code here
|
2210 |
-
* return $settings;
|
2211 |
-
* }
|
2212 |
-
* ?>
|
2213 |
-
*/
|
2214 |
-
$settings = apply_filters( 'um_change_settings_before_save', $_POST['um_options'] );
|
2215 |
-
|
2216 |
-
$settings = UM()->admin()->sanitize_options( $settings );
|
2217 |
-
|
2218 |
-
foreach ( $settings as $key => $value ) {
|
2219 |
-
UM()->options()->update( $key, $value );
|
2220 |
-
}
|
2221 |
-
|
2222 |
-
/**
|
2223 |
-
* UM hook
|
2224 |
-
*
|
2225 |
-
* @type action
|
2226 |
-
* @title um_settings_save
|
2227 |
-
* @description After settings save action
|
2228 |
-
* @change_log
|
2229 |
-
* ["Since: 2.0"]
|
2230 |
-
* @usage add_action( 'um_settings_save', 'function_name', 10 );
|
2231 |
-
* @example
|
2232 |
-
* <?php
|
2233 |
-
* add_action( 'um_settings_save', 'my_settings_save', 10 );
|
2234 |
-
* function my_settings_save() {
|
2235 |
-
* // your code here
|
2236 |
-
* }
|
2237 |
-
* ?>
|
2238 |
-
*/
|
2239 |
-
do_action( 'um_settings_save' );
|
2240 |
-
|
2241 |
-
//redirect after save settings
|
2242 |
-
$arg = array(
|
2243 |
-
'page' => 'um_options',
|
2244 |
-
'update' => 'settings_updated',
|
2245 |
-
);
|
2246 |
-
|
2247 |
-
if ( ! empty( $_GET['tab'] ) ) {
|
2248 |
-
$arg['tab'] = sanitize_key( $_GET['tab'] );
|
2249 |
-
}
|
2250 |
-
|
2251 |
-
if ( ! empty( $_GET['section'] ) ) {
|
2252 |
-
$arg['section'] = sanitize_key( $_GET['section'] );
|
2253 |
-
}
|
2254 |
-
|
2255 |
-
um_js_redirect( add_query_arg( $arg, admin_url( 'admin.php' ) ) );
|
2256 |
-
}
|
2257 |
-
}
|
2258 |
-
|
2259 |
-
|
2260 |
-
function set_default_if_empty( $settings ) {
|
2261 |
-
$tab = '';
|
2262 |
-
if ( ! empty( $_GET['tab'] ) ) {
|
2263 |
-
$tab = sanitize_key( $_GET['tab'] );
|
2264 |
-
}
|
2265 |
-
|
2266 |
-
$section = '';
|
2267 |
-
if ( ! empty( $_GET['section'] ) ) {
|
2268 |
-
$section = sanitize_key( $_GET['section'] );
|
2269 |
-
}
|
2270 |
-
|
2271 |
-
|
2272 |
-
if ( 'access' === $tab && empty( $section ) ) {
|
2273 |
-
if ( ! array_key_exists( 'access_exclude_uris', $settings ) ) {
|
2274 |
-
$settings['access_exclude_uris'] = array();
|
2275 |
-
}
|
2276 |
-
}
|
2277 |
-
|
2278 |
-
return $settings;
|
2279 |
-
}
|
2280 |
-
|
2281 |
-
|
2282 |
-
/**
|
2283 |
-
* Remove empty values from multi text fields
|
2284 |
-
*
|
2285 |
-
* @param $settings
|
2286 |
-
* @return array
|
2287 |
-
*/
|
2288 |
-
function remove_empty_values( $settings ) {
|
2289 |
-
$tab = '';
|
2290 |
-
if ( ! empty( $_GET['tab'] ) ) {
|
2291 |
-
$tab = sanitize_key( $_GET['tab'] );
|
2292 |
-
}
|
2293 |
-
|
2294 |
-
$section = '';
|
2295 |
-
if ( ! empty( $_GET['section'] ) ) {
|
2296 |
-
$section = sanitize_key( $_GET['section'] );
|
2297 |
-
}
|
2298 |
-
|
2299 |
-
if ( isset( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) {
|
2300 |
-
$fields = $this->settings_structure[ $tab ]['sections'][ $section ]['fields'];
|
2301 |
-
} else {
|
2302 |
-
$fields = $this->settings_structure[ $tab ]['fields'];
|
2303 |
-
}
|
2304 |
-
|
2305 |
-
if ( empty( $fields ) ) {
|
2306 |
-
return $settings;
|
2307 |
-
}
|
2308 |
-
|
2309 |
-
|
2310 |
-
$filtered_settings = array();
|
2311 |
-
foreach ( $settings as $key => $value ) {
|
2312 |
-
|
2313 |
-
$filtered_settings[ $key ] = $value;
|
2314 |
-
|
2315 |
-
foreach ( $fields as $field ) {
|
2316 |
-
if ( $field['id'] == $key && isset( $field['type'] ) && $field['type'] == 'multi_text' ) {
|
2317 |
-
$filtered_settings[ $key ] = array_filter( $settings[ $key ] );
|
2318 |
-
}
|
2319 |
-
}
|
2320 |
-
}
|
2321 |
-
|
2322 |
-
return $filtered_settings;
|
2323 |
-
}
|
2324 |
-
|
2325 |
-
|
2326 |
-
/**
|
2327 |
-
*
|
2328 |
-
*/
|
2329 |
-
function check_permalinks_changes() {
|
2330 |
-
if ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
|
2331 |
-
if ( UM()->options()->get( 'permalink_base' ) !== $_POST['um_options']['permalink_base'] ) {
|
2332 |
-
$this->need_change_permalinks = true;
|
2333 |
-
}
|
2334 |
-
}
|
2335 |
-
|
2336 |
-
// set variable if gravatar settings were changed
|
2337 |
-
// update for um_member_directory_data metakey
|
2338 |
-
if ( isset( $_POST['um_options']['use_gravatars'] ) ) {
|
2339 |
-
$use_gravatar = UM()->options()->get( 'use_gravatars' );
|
2340 |
-
if ( ( empty( $use_gravatar ) && ! empty( $_POST['um_options']['use_gravatars'] ) ) || ( ! empty( $use_gravatar ) && empty( $_POST['um_options']['use_gravatars'] ) ) ) {
|
2341 |
-
$this->gravatar_changed = true;
|
2342 |
-
}
|
2343 |
-
}
|
2344 |
-
}
|
2345 |
-
|
2346 |
-
|
2347 |
-
/**
|
2348 |
-
*
|
2349 |
-
*/
|
2350 |
-
function on_settings_save() {
|
2351 |
-
if ( ! empty( $_POST['um_options'] ) ) {
|
2352 |
-
|
2353 |
-
if ( ! empty( $_POST['um_options']['pages_settings'] ) ) {
|
2354 |
-
$post_ids = new \WP_Query( array(
|
2355 |
-
'post_type' => 'page',
|
2356 |
-
'meta_query' => array(
|
2357 |
-
array(
|
2358 |
-
'key' => '_um_core',
|
2359 |
-
'compare' => 'EXISTS'
|
2360 |
-
)
|
2361 |
-
),
|
2362 |
-
'posts_per_page' => -1,
|
2363 |
-
'fields' => 'ids'
|
2364 |
-
) );
|
2365 |
-
|
2366 |
-
$post_ids = $post_ids->get_posts();
|
2367 |
-
|
2368 |
-
if ( ! empty( $post_ids ) ) {
|
2369 |
-
foreach ( $post_ids as $post_id ) {
|
2370 |
-
delete_post_meta( $post_id, '_um_core' );
|
2371 |
-
}
|
2372 |
-
}
|
2373 |
-
|
2374 |
-
foreach ( $_POST['um_options'] as $option_slug => $post_id ) {
|
2375 |
-
$slug = str_replace( 'core_', '', $option_slug );
|
2376 |
-
update_post_meta( $post_id, '_um_core', $slug );
|
2377 |
-
}
|
2378 |
-
|
2379 |
-
// reset rewrite rules after re-save pages
|
2380 |
-
UM()->rewrite()->reset_rules();
|
2381 |
-
|
2382 |
-
} elseif ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
|
2383 |
-
if ( ! empty( $this->need_change_permalinks ) ) {
|
2384 |
-
$users = get_users( array(
|
2385 |
-
'fields' => 'ids',
|
2386 |
-
) );
|
2387 |
-
if ( ! empty( $users ) ) {
|
2388 |
-
foreach ( $users as $user_id ) {
|
2389 |
-
UM()->user()->generate_profile_slug( $user_id );
|
2390 |
-
}
|
2391 |
-
}
|
2392 |
-
}
|
2393 |
-
|
2394 |
-
|
2395 |
-
// update for um_member_directory_data metakey
|
2396 |
-
if ( isset( $_POST['um_options']['use_gravatars'] ) ) {
|
2397 |
-
if ( $this->gravatar_changed ) {
|
2398 |
-
global $wpdb;
|
2399 |
-
|
2400 |
-
if ( ! empty( $_POST['um_options']['use_gravatars'] ) ) {
|
2401 |
-
|
2402 |
-
$results = $wpdb->get_col(
|
2403 |
-
"SELECT u.ID FROM {$wpdb->users} AS u
|
2404 |
-
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'synced_gravatar_hashed_id' )
|
2405 |
-
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2406 |
-
WHERE um.meta_value != '' AND um.meta_value IS NOT NULL AND
|
2407 |
-
um2.meta_value LIKE '%s:13:\"profile_photo\";b:0;%'"
|
2408 |
-
);
|
2409 |
-
|
2410 |
-
} else {
|
2411 |
-
|
2412 |
-
$results = $wpdb->get_col(
|
2413 |
-
"SELECT u.ID FROM {$wpdb->users} AS u
|
2414 |
-
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND ( um.meta_key = 'synced_profile_photo' || um.meta_key = 'profile_photo' ) )
|
2415 |
-
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2416 |
-
WHERE ( um.meta_value IS NULL OR um.meta_value = '' ) AND
|
2417 |
-
um2.meta_value LIKE '%s:13:\"profile_photo\";b:1;%'"
|
2418 |
-
);
|
2419 |
-
|
2420 |
-
}
|
2421 |
-
|
2422 |
-
if ( ! empty( $results ) ) {
|
2423 |
-
foreach ( $results as $user_id ) {
|
2424 |
-
$md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
|
2425 |
-
if ( ! empty( $md_data ) ) {
|
2426 |
-
$md_data['profile_photo'] = ! empty( $_POST['um_options']['use_gravatars'] );
|
2427 |
-
update_user_meta( $user_id, 'um_member_directory_data', $md_data );
|
2428 |
-
}
|
2429 |
-
}
|
2430 |
-
}
|
2431 |
-
}
|
2432 |
-
}
|
2433 |
-
|
2434 |
-
} elseif ( isset( $_POST['um_options']['member_directory_own_table'] ) ) {
|
2435 |
-
if ( empty( $_POST['um_options']['member_directory_own_table'] ) ) {
|
2436 |
-
global $wpdb;
|
2437 |
-
|
2438 |
-
$results = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}um_metadata LIMIT 1", ARRAY_A );
|
2439 |
-
|
2440 |
-
if ( ! empty( $results ) ) {
|
2441 |
-
$wpdb->query("TRUNCATE TABLE {$wpdb->prefix}um_metadata" );
|
2442 |
-
}
|
2443 |
-
|
2444 |
-
update_option( 'um_member_directory_truncated', time() );
|
2445 |
-
}
|
2446 |
-
} elseif ( isset( $_POST['um_options']['account_hide_in_directory_default'] ) ) {
|
2447 |
-
|
2448 |
-
global $wpdb;
|
2449 |
-
|
2450 |
-
if ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) {
|
2451 |
-
|
2452 |
-
$results = $wpdb->get_col(
|
2453 |
-
"SELECT u.ID FROM {$wpdb->users} AS u
|
2454 |
-
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'hide_in_members' )
|
2455 |
-
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2456 |
-
WHERE um.meta_value IS NULL AND
|
2457 |
-
um2.meta_value LIKE '%s:15:\"hide_in_members\";b:1;%'"
|
2458 |
-
);
|
2459 |
-
|
2460 |
-
} else {
|
2461 |
-
|
2462 |
-
$results = $wpdb->get_col(
|
2463 |
-
"SELECT u.ID FROM {$wpdb->users} AS u
|
2464 |
-
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'hide_in_members' )
|
2465 |
-
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2466 |
-
WHERE um.meta_value IS NULL AND
|
2467 |
-
um2.meta_value LIKE '%s:15:\"hide_in_members\";b:0;%'"
|
2468 |
-
);
|
2469 |
-
|
2470 |
-
}
|
2471 |
-
|
2472 |
-
if ( ! empty( $results ) ) {
|
2473 |
-
foreach ( $results as $user_id ) {
|
2474 |
-
$md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
|
2475 |
-
if ( ! empty( $md_data ) ) {
|
2476 |
-
$md_data['hide_in_members'] = ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) ? false : true;
|
2477 |
-
update_user_meta( $user_id, 'um_member_directory_data', $md_data );
|
2478 |
-
}
|
2479 |
-
}
|
2480 |
-
}
|
2481 |
-
|
2482 |
-
}
|
2483 |
-
}
|
2484 |
-
}
|
2485 |
-
|
2486 |
-
|
2487 |
-
/**
|
2488 |
-
*
|
2489 |
-
*/
|
2490 |
-
function before_licenses_save() {
|
2491 |
-
if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) {
|
2492 |
-
return;
|
2493 |
-
}
|
2494 |
-
|
2495 |
-
foreach ( $_POST['um_options'] as $key => $value ) {
|
2496 |
-
$this->previous_licenses[ sanitize_key( $key ) ] = UM()->options()->get( $key );
|
2497 |
-
}
|
2498 |
-
}
|
2499 |
-
|
2500 |
-
|
2501 |
-
/**
|
2502 |
-
*
|
2503 |
-
*/
|
2504 |
-
function licenses_save() {
|
2505 |
-
if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) {
|
2506 |
-
return;
|
2507 |
-
}
|
2508 |
-
|
2509 |
-
foreach ( $_POST['um_options'] as $key => $value ) {
|
2510 |
-
$key = sanitize_key( $key );
|
2511 |
-
$value = sanitize_text_field( $value );
|
2512 |
-
|
2513 |
-
$edd_action = '';
|
2514 |
-
$license_key = '';
|
2515 |
-
if ( empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) || ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) && $this->previous_licenses[ $key ] != $value ) ) {
|
2516 |
-
$edd_action = 'activate_license';
|
2517 |
-
$license_key = $value;
|
2518 |
-
} elseif ( ! empty( $this->previous_licenses[ $key ] ) && empty( $value ) ) {
|
2519 |
-
$edd_action = 'deactivate_license';
|
2520 |
-
$license_key = $this->previous_licenses[ $key ];
|
2521 |
-
} elseif ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) ) {
|
2522 |
-
$edd_action = 'check_license';
|
2523 |
-
$license_key = $value;
|
2524 |
-
}
|
2525 |
-
|
2526 |
-
if ( empty( $edd_action ) ) {
|
2527 |
-
continue;
|
2528 |
-
}
|
2529 |
-
|
2530 |
-
$item_name = false;
|
2531 |
-
$version = false;
|
2532 |
-
$author = false;
|
2533 |
-
foreach ( $this->settings_structure['licenses']['fields'] as $field_data ) {
|
2534 |
-
if ( $field_data['id'] == $key ) {
|
2535 |
-
$item_name = ! empty( $field_data['item_name'] ) ? $field_data['item_name'] : false;
|
2536 |
-
$version = ! empty( $field_data['version'] ) ? $field_data['version'] : false;
|
2537 |
-
$author = ! empty( $field_data['author'] ) ? $field_data['author'] : false;
|
2538 |
-
}
|
2539 |
-
}
|
2540 |
-
|
2541 |
-
$api_params = array(
|
2542 |
-
'edd_action' => $edd_action,
|
2543 |
-
'license' => $license_key,
|
2544 |
-
'item_name' => $item_name,
|
2545 |
-
'version' => $version,
|
2546 |
-
'author' => $author,
|
2547 |
-
'url' => home_url(),
|
2548 |
-
);
|
2549 |
-
|
2550 |
-
$request = wp_remote_post(
|
2551 |
-
UM()->store_url,
|
2552 |
-
array(
|
2553 |
-
'timeout' => UM()->request_timeout,
|
2554 |
-
'sslverify' => false,
|
2555 |
-
'body' => $api_params
|
2556 |
-
)
|
2557 |
-
);
|
2558 |
-
|
2559 |
-
if ( ! is_wp_error( $request ) ) {
|
2560 |
-
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
2561 |
-
} else {
|
2562 |
-
$request = wp_remote_post(
|
2563 |
-
UM()->store_url,
|
2564 |
-
array(
|
2565 |
-
'timeout' => UM()->request_timeout,
|
2566 |
-
'sslverify' => true,
|
2567 |
-
'body' => $api_params
|
2568 |
-
)
|
2569 |
-
);
|
2570 |
-
|
2571 |
-
if ( ! is_wp_error( $request ) ) {
|
2572 |
-
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
2573 |
-
}
|
2574 |
-
}
|
2575 |
-
|
2576 |
-
$request = ( $request ) ? maybe_unserialize( $request ) : false;
|
2577 |
-
|
2578 |
-
if ( $edd_action == 'activate_license' || $edd_action == 'check_license' ) {
|
2579 |
-
update_option( "{$key}_edd_answer", $request );
|
2580 |
-
} else {
|
2581 |
-
delete_option( "{$key}_edd_answer" );
|
2582 |
-
}
|
2583 |
-
|
2584 |
-
}
|
2585 |
-
}
|
2586 |
-
|
2587 |
-
|
2588 |
-
/**
|
2589 |
-
*
|
2590 |
-
*/
|
2591 |
-
function settings_before_email_tab() {
|
2592 |
-
$email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] );
|
2593 |
-
$emails = UM()->config()->email_notifications;
|
2594 |
-
|
2595 |
-
if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) {
|
2596 |
-
include_once um_path . 'includes/admin/core/list-tables/emails-list-table.php';
|
2597 |
-
}
|
2598 |
-
}
|
2599 |
-
|
2600 |
-
|
2601 |
-
/**
|
2602 |
-
* @param $section
|
2603 |
-
*
|
2604 |
-
* @return string
|
2605 |
-
*/
|
2606 |
-
function settings_email_tab( $section ) {
|
2607 |
-
$email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] );
|
2608 |
-
$emails = UM()->config()->email_notifications;
|
2609 |
-
|
2610 |
-
if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) {
|
2611 |
-
return $section;
|
2612 |
-
}
|
2613 |
-
|
2614 |
-
$in_theme = UM()->mail()->template_in_theme( $email_key );
|
2615 |
-
|
2616 |
-
/**
|
2617 |
-
* UM hook
|
2618 |
-
*
|
2619 |
-
* @type filter
|
2620 |
-
* @title um_admin_settings_email_section_fields
|
2621 |
-
* @description Extend UM Email Settings
|
2622 |
-
* @input_vars
|
2623 |
-
* [{"var":"$settings","type":"array","desc":"UM Email Settings"},
|
2624 |
-
* {"var":"$email_key","type":"string","desc":"Email Key"}]
|
2625 |
-
* @change_log
|
2626 |
-
* ["Since: 2.0"]
|
2627 |
-
* @usage add_filter( 'um_admin_settings_email_section_fields', 'function_name', 10, 2 );
|
2628 |
-
* @example
|
2629 |
-
* <?php
|
2630 |
-
* add_filter( 'um_admin_settings_email_section_fields', 'my_admin_settings_email_section', 10, 2 );
|
2631 |
-
* function my_admin_settings_email_section( $settings, $email_key ) {
|
2632 |
-
* // your code here
|
2633 |
-
* return $settings;
|
2634 |
-
* }
|
2635 |
-
* ?>
|
2636 |
-
*/
|
2637 |
-
$section_fields = apply_filters( 'um_admin_settings_email_section_fields', array(
|
2638 |
-
array(
|
2639 |
-
'id' => 'um_email_template',
|
2640 |
-
'type' => 'hidden',
|
2641 |
-
'value' => $email_key,
|
2642 |
-
),
|
2643 |
-
array(
|
2644 |
-
'id' => $email_key . '_on',
|
2645 |
-
'type' => 'checkbox',
|
2646 |
-
'label' => $emails[ $email_key ]['title'],
|
2647 |
-
'tooltip' => $emails[ $email_key ]['description'],
|
2648 |
-
),
|
2649 |
-
array(
|
2650 |
-
'id' => $email_key . '_sub',
|
2651 |
-
'type' => 'text',
|
2652 |
-
'label' => __( 'Subject Line', 'ultimate-member' ),
|
2653 |
-
'conditional' => array( $email_key . '_on', '=', 1 ),
|
2654 |
-
'tooltip' => __( 'This is the subject line of the e-mail', 'ultimate-member' ),
|
2655 |
-
),
|
2656 |
-
array(
|
2657 |
-
'id' => $email_key,
|
2658 |
-
'type' => 'email_template',
|
2659 |
-
'label' => __( 'Message Body', 'ultimate-member' ),
|
2660 |
-
'conditional' => array( $email_key . '_on', '=', 1 ),
|
2661 |
-
'tooltip' => __( 'This is the content of the e-mail', 'ultimate-member' ),
|
2662 |
-
'value' => UM()->mail()->get_email_template( $email_key ),
|
2663 |
-
'in_theme' => $in_theme
|
2664 |
-
),
|
2665 |
-
), $email_key );
|
2666 |
-
|
2667 |
-
return $this->render_settings_section( $section_fields, 'email', $email_key );
|
2668 |
-
}
|
2669 |
-
|
2670 |
-
|
2671 |
-
/**
|
2672 |
-
*
|
2673 |
-
*/
|
2674 |
-
function settings_appearance_profile_tab() {
|
2675 |
-
wp_enqueue_media();
|
2676 |
-
}
|
2677 |
-
|
2678 |
-
|
2679 |
-
/**
|
2680 |
-
* @param $html
|
2681 |
-
* @param $section_fields
|
2682 |
-
*
|
2683 |
-
* @return string
|
2684 |
-
*/
|
2685 |
-
function settings_licenses_tab( $html, $section_fields ) {
|
2686 |
-
ob_start(); ?>
|
2687 |
-
|
2688 |
-
<div class="wrap-licenses">
|
2689 |
-
<input type="hidden" id="licenses_settings" name="licenses_settings" value="1">
|
2690 |
-
<?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
|
2691 |
-
<input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
|
2692 |
-
<table class="form-table um-settings-section">
|
2693 |
-
<tbody>
|
2694 |
-
<?php foreach ( $section_fields as $field_data ) {
|
2695 |
-
$option_value = UM()->options()->get( $field_data['id'] );
|
2696 |
-
$value = isset( $option_value ) && ! empty( $option_value ) ? $option_value : ( isset( $field_data['default'] ) ? $field_data['default'] : '' );
|
2697 |
-
|
2698 |
-
$license = get_option( "{$field_data['id']}_edd_answer" );
|
2699 |
-
|
2700 |
-
if ( is_object( $license ) && ! empty( $value ) ) {
|
2701 |
-
// activate_license 'invalid' on anything other than valid, so if there was an error capture it
|
2702 |
-
if ( empty( $license->success ) ) {
|
2703 |
-
|
2704 |
-
if ( ! empty( $license->error ) ) {
|
2705 |
-
switch ( $license->error ) {
|
2706 |
-
|
2707 |
-
case 'expired' :
|
2708 |
-
|
2709 |
-
$class = 'expired';
|
2710 |
-
$messages[] = sprintf(
|
2711 |
-
__( 'Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'ultimate-member' ),
|
2712 |
-
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
|
2713 |
-
'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
|
2714 |
-
);
|
2715 |
-
|
2716 |
-
$license_status = 'license-' . $class . '-notice';
|
2717 |
-
|
2718 |
-
break;
|
2719 |
-
|
2720 |
-
case 'revoked' :
|
2721 |
-
|
2722 |
-
$class = 'error';
|
2723 |
-
$messages[] = sprintf(
|
2724 |
-
__( 'Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'ultimate-member' ),
|
2725 |
-
'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked'
|
2726 |
-
);
|
2727 |
-
|
2728 |
-
$license_status = 'license-' . $class . '-notice';
|
2729 |
-
|
2730 |
-
break;
|
2731 |
-
|
2732 |
-
case 'missing' :
|
2733 |
-
|
2734 |
-
$class = 'error';
|
2735 |
-
$messages[] = sprintf(
|
2736 |
-
__( 'Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'ultimate-member' ),
|
2737 |
-
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
|
2738 |
-
);
|
2739 |
-
|
2740 |
-
$license_status = 'license-' . $class . '-notice';
|
2741 |
-
|
2742 |
-
break;
|
2743 |
-
|
2744 |
-
case 'invalid' :
|
2745 |
-
case 'site_inactive' :
|
2746 |
-
|
2747 |
-
$class = 'error';
|
2748 |
-
$messages[] = sprintf(
|
2749 |
-
__( 'Your %s is not active for this URL. Please <a href="%s" target="_blank">visit your account page</a> to manage your license key URLs.', 'ultimate-member' ),
|
2750 |
-
$field_data['item_name'],
|
2751 |
-
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
|
2752 |
-
);
|
2753 |
-
|
2754 |
-
$license_status = 'license-' . $class . '-notice';
|
2755 |
-
|
2756 |
-
break;
|
2757 |
-
|
2758 |
-
case 'item_name_mismatch' :
|
2759 |
-
|
2760 |
-
$class = 'error';
|
2761 |
-
$messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] );
|
2762 |
-
|
2763 |
-
$license_status = 'license-' . $class . '-notice';
|
2764 |
-
|
2765 |
-
break;
|
2766 |
-
|
2767 |
-
case 'no_activations_left':
|
2768 |
-
|
2769 |
-
$class = 'error';
|
2770 |
-
$messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'ultimate-member' ), 'https://ultimatemember.com/account' );
|
2771 |
-
|
2772 |
-
$license_status = 'license-' . $class . '-notice';
|
2773 |
-
|
2774 |
-
break;
|
2775 |
-
|
2776 |
-
case 'license_not_activable':
|
2777 |
-
|
2778 |
-
$class = 'error';
|
2779 |
-
$messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' );
|
2780 |
-
|
2781 |
-
$license_status = 'license-' . $class . '-notice';
|
2782 |
-
break;
|
2783 |
-
|
2784 |
-
default :
|
2785 |
-
|
2786 |
-
$class = 'error';
|
2787 |
-
$error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' );
|
2788 |
-
$messages[] = sprintf( __( 'There was an error with this license key: %s. Please <a href="%s">contact our support team</a>.', 'ultimate-member' ), $error, 'https://ultimatemember.com/support' );
|
2789 |
-
|
2790 |
-
$license_status = 'license-' . $class . '-notice';
|
2791 |
-
break;
|
2792 |
-
}
|
2793 |
-
} else {
|
2794 |
-
$class = 'error';
|
2795 |
-
$error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' );
|
2796 |
-
$messages[] = sprintf( __( 'There was an error with this license key: %s. Please <a href="%s">contact our support team</a>.', 'ultimate-member' ), $error, 'https://ultimatemember.com/support' );
|
2797 |
-
|
2798 |
-
$license_status = 'license-' . $class . '-notice';
|
2799 |
-
}
|
2800 |
-
|
2801 |
-
} elseif ( ! empty( $license->errors ) ) {
|
2802 |
-
|
2803 |
-
$errors = array_keys( $license->errors );
|
2804 |
-
$errors_data = array_values( $license->errors );
|
2805 |
-
|
2806 |
-
$class = 'error';
|
2807 |
-
$error = ! empty( $errors[0] ) ? $errors[0] : __( 'unknown_error', 'ultimate-member' );
|
2808 |
-
$errors_data = ! empty( $errors_data[0][0] ) ? ', ' . $errors_data[0][0] : '';
|
2809 |
-
$messages[] = sprintf( __( 'There was an error with this license key: %s%s. Please <a href="%s">contact our support team</a>.', 'ultimate-member' ), $error, $errors_data, 'https://ultimatemember.com/support' );
|
2810 |
-
|
2811 |
-
$license_status = 'license-' . $class . '-notice';
|
2812 |
-
|
2813 |
-
} else {
|
2814 |
-
|
2815 |
-
switch( $license->license ) {
|
2816 |
-
|
2817 |
-
case 'expired' :
|
2818 |
-
|
2819 |
-
$class = 'expired';
|
2820 |
-
$messages[] = sprintf(
|
2821 |
-
__( 'Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'ultimate-member' ),
|
2822 |
-
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
|
2823 |
-
'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
|
2824 |
-
);
|
2825 |
-
|
2826 |
-
$license_status = 'license-' . $class . '-notice';
|
2827 |
-
|
2828 |
-
break;
|
2829 |
-
|
2830 |
-
case 'revoked' :
|
2831 |
-
|
2832 |
-
$class = 'error';
|
2833 |
-
$messages[] = sprintf(
|
2834 |
-
__( 'Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'ultimate-member' ),
|
2835 |
-
'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked'
|
2836 |
-
);
|
2837 |
-
|
2838 |
-
$license_status = 'license-' . $class . '-notice';
|
2839 |
-
|
2840 |
-
break;
|
2841 |
-
|
2842 |
-
case 'missing' :
|
2843 |
-
|
2844 |
-
$class = 'error';
|
2845 |
-
$messages[] = sprintf(
|
2846 |
-
__( 'Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'ultimate-member' ),
|
2847 |
-
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
|
2848 |
-
);
|
2849 |
-
|
2850 |
-
$license_status = 'license-' . $class . '-notice';
|
2851 |
-
|
2852 |
-
break;
|
2853 |
-
|
2854 |
-
case 'invalid' :
|
2855 |
-
case 'site_inactive' :
|
2856 |
-
|
2857 |
-
$class = 'error';
|
2858 |
-
$messages[] = sprintf(
|
2859 |
-
__( 'Your %s is not active for this URL. Please <a href="%s" target="_blank">visit your account page</a> to manage your license key URLs.', 'ultimate-member' ),
|
2860 |
-
$field_data['item_name'],
|
2861 |
-
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
|
2862 |
-
);
|
2863 |
-
|
2864 |
-
$license_status = 'license-' . $class . '-notice';
|
2865 |
-
|
2866 |
-
break;
|
2867 |
-
|
2868 |
-
case 'item_name_mismatch' :
|
2869 |
-
|
2870 |
-
$class = 'error';
|
2871 |
-
$messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] );
|
2872 |
-
|
2873 |
-
$license_status = 'license-' . $class . '-notice';
|
2874 |
-
|
2875 |
-
break;
|
2876 |
-
|
2877 |
-
case 'no_activations_left':
|
2878 |
-
|
2879 |
-
$class = 'error';
|
2880 |
-
$messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'ultimate-member' ), 'https://ultimatemember.com/account' );
|
2881 |
-
|
2882 |
-
$license_status = 'license-' . $class . '-notice';
|
2883 |
-
|
2884 |
-
break;
|
2885 |
-
|
2886 |
-
case 'license_not_activable':
|
2887 |
-
|
2888 |
-
$class = 'error';
|
2889 |
-
$messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' );
|
2890 |
-
|
2891 |
-
$license_status = 'license-' . $class . '-notice';
|
2892 |
-
break;
|
2893 |
-
|
2894 |
-
case 'valid' :
|
2895 |
-
default:
|
2896 |
-
|
2897 |
-
$class = 'valid';
|
2898 |
-
|
2899 |
-
$now = current_time( 'timestamp' );
|
2900 |
-
$expiration = strtotime( $license->expires, $now );
|
2901 |
-
|
2902 |
-
if( 'lifetime' === $license->expires ) {
|
2903 |
-
|
2904 |
-
$messages[] = __( 'License key never expires.', 'ultimate-member' );
|
2905 |
-
|
2906 |
-
$license_status = 'license-lifetime-notice';
|
2907 |
-
|
2908 |
-
} elseif( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) {
|
2909 |
-
|
2910 |
-
$messages[] = sprintf(
|
2911 |
-
__( 'Your license key expires soon! It expires on %s. <a href="%s" target="_blank">Renew your license key</a>.', 'ultimate-member' ),
|
2912 |
-
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
|
2913 |
-
'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=renew'
|
2914 |
-
);
|
2915 |
-
|
2916 |
-
$license_status = 'license-expires-soon-notice';
|
2917 |
-
|
2918 |
-
} else {
|
2919 |
-
|
2920 |
-
$messages[] = sprintf(
|
2921 |
-
__( 'Your license key expires on %s.', 'ultimate-member' ),
|
2922 |
-
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) )
|
2923 |
-
);
|
2924 |
-
|
2925 |
-
$license_status = 'license-expiration-date-notice';
|
2926 |
-
|
2927 |
-
}
|
2928 |
-
|
2929 |
-
break;
|
2930 |
-
|
2931 |
-
}
|
2932 |
-
|
2933 |
-
}
|
2934 |
-
|
2935 |
-
} else {
|
2936 |
-
$class = 'empty';
|
2937 |
-
|
2938 |
-
$messages[] = sprintf(
|
2939 |
-
__( 'To receive updates, please enter your valid %s license key.', 'ultimate-member' ),
|
2940 |
-
$field_data['item_name']
|
2941 |
-
);
|
2942 |
-
|
2943 |
-
$license_status = null;
|
2944 |
-
|
2945 |
-
} ?>
|
2946 |
-
|
2947 |
-
<tr class="um-settings-line">
|
2948 |
-
<th><label for="um_options_<?php echo esc_attr( $field_data['id'] ) ?>"><?php echo esc_html( $field_data['label'] ) ?></label></th>
|
2949 |
-
<td>
|
2950 |
-
<form method="post" action="" name="um-settings-form" class="um-settings-form">
|
2951 |
-
<input type="hidden" value="save" name="um-settings-action" />
|
2952 |
-
<input type="hidden" name="licenses_settings" value="1" />
|
2953 |
-
<?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
|
2954 |
-
<input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
|
2955 |
-
<input type="text" id="um_options_<?php echo esc_attr( $field_data['id'] ) ?>" name="um_options[<?php echo esc_attr( $field_data['id'] ) ?>]" value="<?php echo $value ?>" class="um-option-field um-long-field" data-field_id="<?php echo esc_attr( $field_data['id'] ) ?>" />
|
2956 |
-
<?php if ( ! empty( $field_data['description'] ) ) { ?>
|
2957 |
-
<div class="description"><?php echo $field_data['description'] ?></div>
|
2958 |
-
<?php } ?>
|
2959 |
-
|
2960 |
-
<?php if ( ! empty( $value ) && ( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license ) ) { ?>
|
2961 |
-
<input type="button" class="button um_license_deactivate" id="<?php echo esc_attr( $field_data['id'] ) ?>_deactivate" value="<?php esc_attr_e( 'Clear License', 'ultimate-member' ) ?>"/>
|
2962 |
-
<?php } elseif ( empty( $value ) ) { ?>
|
2963 |
-
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Activate', 'ultimate-member' ) ?>" />
|
2964 |
-
<?php } else { ?>
|
2965 |
-
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Re-Activate', 'ultimate-member' ) ?>" />
|
2966 |
-
<input type="button" class="button um_license_deactivate" id="<?php echo esc_attr( $field_data['id'] ) ?>_deactivate" value="<?php esc_attr_e( 'Clear License', 'ultimate-member' ) ?>"/>
|
2967 |
-
<?php }
|
2968 |
-
|
2969 |
-
if ( ! empty( $messages ) ) {
|
2970 |
-
foreach ( $messages as $message ) { ?>
|
2971 |
-
<div class="edd-license-data edd-license-<?php echo esc_attr( $class . ' ' . $license_status ) ?>">
|
2972 |
-
<p><?php echo $message ?></p>
|
2973 |
-
</div>
|
2974 |
-
<?php }
|
2975 |
-
} ?>
|
2976 |
-
</form>
|
2977 |
-
</td>
|
2978 |
-
</tr>
|
2979 |
-
<?php } ?>
|
2980 |
-
</tbody>
|
2981 |
-
</table>
|
2982 |
-
</div>
|
2983 |
-
<?php $section = ob_get_clean();
|
2984 |
-
|
2985 |
-
return $section;
|
2986 |
-
}
|
2987 |
-
|
2988 |
-
|
2989 |
-
/**
|
2990 |
-
* @param $html
|
2991 |
-
* @param $section_fields
|
2992 |
-
*/
|
2993 |
-
function settings_install_info_tab( $html, $section_fields ) {
|
2994 |
-
global $wpdb;
|
2995 |
-
|
2996 |
-
if ( ! class_exists( '\Browser' ) )
|
2997 |
-
require_once um_path . 'includes/lib/browser.php';
|
2998 |
-
|
2999 |
-
// Detect browser
|
3000 |
-
$browser = new \Browser();
|
3001 |
-
|
3002 |
-
// Get theme info
|
3003 |
-
$theme_data = wp_get_theme();
|
3004 |
-
$theme = $theme_data->Name . ' ' . $theme_data->Version;
|
3005 |
-
|
3006 |
-
// Identify Hosting Provider
|
3007 |
-
$host = um_get_host();
|
3008 |
-
|
3009 |
-
um_fetch_user( get_current_user_id() );
|
3010 |
-
|
3011 |
-
if ( isset( $this->content ) ) {
|
3012 |
-
echo $this->content;
|
3013 |
-
} else { ?>
|
3014 |
-
|
3015 |
-
<h3>Install Info</h3>
|
3016 |
-
|
3017 |
-
<form action="" method="post" dir="ltr">
|
3018 |
-
<textarea style="width:70%; height:400px;" readonly="readonly" onclick="this.focus();this.select()" id="install-info-textarea" name="um-install-info" title="<?php _e( 'To copy the Install info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'ultimate-member' ); ?>">
|
3019 |
-
### Begin Install Info ###
|
3020 |
-
|
3021 |
-
## Please include this information when posting support requests ##
|
3022 |
-
|
3023 |
-
<?php
|
3024 |
-
/**
|
3025 |
-
* UM hook
|
3026 |
-
*
|
3027 |
-
* @type action
|
3028 |
-
* @title um_install_info_before
|
3029 |
-
* @description Before install info settings
|
3030 |
-
* @change_log
|
3031 |
-
* ["Since: 2.0"]
|
3032 |
-
* @usage add_action( 'um_install_info_before', 'function_name', 10 );
|
3033 |
-
* @example
|
3034 |
-
* <?php
|
3035 |
-
* add_action( 'um_install_info_before', 'my_install_info_before', 10 );
|
3036 |
-
* function my_install_info_before() {
|
3037 |
-
* // your code here
|
3038 |
-
* }
|
3039 |
-
* ?>
|
3040 |
-
*/
|
3041 |
-
do_action( 'um_install_info_before' ); ?>
|
3042 |
-
|
3043 |
-
--- Site Info ---
|
3044 |
-
|
3045 |
-
Site URL: <?php echo site_url() . "\n"; ?>
|
3046 |
-
Home URL: <?php echo home_url() . "\n"; ?>
|
3047 |
-
Multisite: <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n" ?>
|
3048 |
-
|
3049 |
-
--- Hosting Provider ---
|
3050 |
-
|
3051 |
-
<?php if( $host ) : ?>
|
3052 |
-
Host: <?php echo $host . "\n"; ?>
|
3053 |
-
<?php endif; ?>
|
3054 |
-
|
3055 |
-
--- User Browser ---
|
3056 |
-
|
3057 |
-
<?php echo $browser ; ?>
|
3058 |
-
|
3059 |
-
---- Current User Details --
|
3060 |
-
|
3061 |
-
<?php $user = wp_get_current_user(); ?>
|
3062 |
-
Role: <?php echo implode( ', ', um_user( 'roles' ) ). "\n"; ?>
|
3063 |
-
|
3064 |
-
|
3065 |
-
--- WordPress Configurations ---
|
3066 |
-
|
3067 |
-
Version: <?php echo get_bloginfo( 'version' ) . "\n"; ?>
|
3068 |
-
Language: <?php echo get_locale()."\n"; ?>
|
3069 |
-
Permalink Structure: <?php echo get_option( 'permalink_structure' ) . "\n"; ?>
|
3070 |
-
Active Theme: <?php echo $theme . "\n"; ?>
|
3071 |
-
<?php $show_on_front = get_option( 'show_on_front' ); ?>
|
3072 |
-
<?php if( $show_on_front == "posts" ): ?>
|
3073 |
-
Show On Front: <?php echo get_option( 'show_on_front' ) . "/static\n" ?>
|
3074 |
-
<?php elseif( $show_on_front == "page" ): ?>
|
3075 |
-
Page On Front: <?php $id = get_option( 'page_on_front' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
|
3076 |
-
Page For Posts: <?php $id = get_option( 'page_for_posts' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
|
3077 |
-
<?php endif; ?>
|
3078 |
-
ABSPATH: <?php echo ABSPATH."\n"; ?>
|
3079 |
-
<?php $wp_count_posts = wp_count_posts(); ?>
|
3080 |
-
All Posts/Pages: <?php echo array_sum((array)$wp_count_posts)."\n";?>
|
3081 |
-
<?php
|
3082 |
-
$request['cmd'] = '_notify-validate';
|
3083 |
-
|
3084 |
-
$params = array(
|
3085 |
-
'sslverify' => false,
|
3086 |
-
'timeout' => 60,
|
3087 |
-
'user-agent' => 'UltimateMember/' . ultimatemember_version,
|
3088 |
-
'body' => $request
|
3089 |
-
);
|
3090 |
-
|
3091 |
-
$response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
|
3092 |
-
|
3093 |
-
if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
|
3094 |
-
$WP_REMOTE_POST = 'wp_remote_post() works' . "\n";
|
3095 |
-
} else {
|
3096 |
-
$WP_REMOTE_POST = 'wp_remote_post() does not work' . "\n";
|
3097 |
-
}
|
3098 |
-
?>
|
3099 |
-
WP Remote Post: <?php echo $WP_REMOTE_POST; ?>
|
3100 |
-
WP_DEBUG: <?php echo defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n" ?>
|
3101 |
-
WP Table Prefix: <?php echo "Length: ". strlen( $wpdb->prefix ); echo ", Status:"; if ( strlen( $wpdb->prefix )>16 ) {echo " ERROR: Too Long";} else {echo " Acceptable";} echo "\n"; ?>
|
3102 |
-
Memory Limit: <?php echo ( um_let_to_num( WP_MEMORY_LIMIT )/( 1024 ) )."MB"; ?><?php echo "\n"; ?>
|
3103 |
-
|
3104 |
-
|
3105 |
-
--- UM Configurations ---
|
3106 |
-
|
3107 |
-
Version: <?php echo ultimatemember_version . "\n"; ?>
|
3108 |
-
Upgraded From: <?php echo get_option( 'um_last_version_upgrade', 'None' ) . "\n"; ?>
|
3109 |
-
Current URL Method: <?php echo UM()->options()->get( 'current_url_method' ). "\n"; ?>
|
3110 |
-
Cache User Profile: <?php if( UM()->options()->get( 'um_profile_object_cache_stop' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
|
3111 |
-
Generate Slugs on Directories: <?php if( UM()->options()->get( 'um_generate_slug_in_directory' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
|
3112 |
-
Force UTF-8 Encoding: <?php if( UM()->options()->get( 'um_force_utf8_strings' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3113 |
-
JS/CSS Compression: <?php if ( defined('SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3114 |
-
<?php if( is_multisite() ): ?>
|
3115 |
-
Network Structure: <?php echo UM()->options()->get( 'network_permalink_structure' ). "\n"; ?>
|
3116 |
-
<?php endif; ?>
|
3117 |
-
Port Forwarding in URL: <?php if( UM()->options()->get( 'um_port_forwarding_url' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3118 |
-
Exclude CSS/JS on Home: <?php if( UM()->options()->get( 'js_css_exlcude_home' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3119 |
-
|
3120 |
-
|
3121 |
-
--- UM Pages Configuration ---
|
3122 |
-
|
3123 |
-
<?php
|
3124 |
-
/**
|
3125 |
-
* UM hook
|
3126 |
-
*
|
3127 |
-
* @type action
|
3128 |
-
* @title um_install_info_before_page_config
|
3129 |
-
* @description Before page config install info
|
3130 |
-
* @change_log
|
3131 |
-
* ["Since: 2.0"]
|
3132 |
-
* @usage add_action( 'um_install_info_before_page_config', 'function_name', 10 );
|
3133 |
-
* @example
|
3134 |
-
* <?php
|
3135 |
-
* add_action( 'um_install_info_before_page_config', 'my_install_info_before_page_config', 10 );
|
3136 |
-
* function my_install_info_before_page_config() {
|
3137 |
-
* // your code here
|
3138 |
-
* }
|
3139 |
-
* ?>
|
3140 |
-
*/
|
3141 |
-
do_action( "um_install_info_before_page_config" ); ?>
|
3142 |
-
User: <?php echo get_permalink( UM()->options()->get('core_user') ) . "\n"; ?>
|
3143 |
-
Account: <?php echo get_permalink( UM()->options()->get('core_account') ) . "\n"; ?>
|
3144 |
-
Members: <?php echo get_permalink( UM()->options()->get('core_members') ) . "\n"; ?>
|
3145 |
-
Register: <?php echo get_permalink( UM()->options()->get('core_register') ) . "\n"; ?>
|
3146 |
-
Login: <?php echo get_permalink( UM()->options()->get('core_login') ) . "\n"; ?>
|
3147 |
-
Logout: <?php echo get_permalink( UM()->options()->get('core_logout') ) . "\n"; ?>
|
3148 |
-
Password Reset: <?php echo get_permalink( UM()->options()->get('core_password-reset') ) . "\n"; ?>
|
3149 |
-
<?php
|
3150 |
-
/**
|
3151 |
-
* UM hook
|
3152 |
-
*
|
3153 |
-
* @type action
|
3154 |
-
* @title um_install_info_after_page_config
|
3155 |
-
* @description After page config install info
|
3156 |
-
* @change_log
|
3157 |
-
* ["Since: 2.0"]
|
3158 |
-
* @usage add_action( 'um_install_info_after_page_config', 'function_name', 10 );
|
3159 |
-
* @example
|
3160 |
-
* <?php
|
3161 |
-
* add_action( 'um_install_info_after_page_config', 'my_install_info_after_page_config', 10 );
|
3162 |
-
* function my_install_info_after_page_config() {
|
3163 |
-
* // your code here
|
3164 |
-
* }
|
3165 |
-
* ?>
|
3166 |
-
*/
|
3167 |
-
do_action( "um_install_info_after_page_config" ); ?>
|
3168 |
-
|
3169 |
-
|
3170 |
-
--- UM Users Configuration ---
|
3171 |
-
|
3172 |
-
Default New User Role: <?php echo UM()->options()->get('register_role') . "\n"; ?>
|
3173 |
-
Profile Permalink Base: <?php echo UM()->options()->get('permalink_base') . "\n"; ?>
|
3174 |
-
User Display Name: <?php echo UM()->options()->get('display_name') . "\n"; ?>
|
3175 |
-
|
3176 |
-
|
3177 |
-
|
3178 |
-
|
3179 |
-
|
3180 |
-
|
3181 |
-
|
3182 |
-
|
3183 |
-
|
3184 |
-
|
3185 |
-
|
3186 |
-
|
3187 |
-
|
3188 |
-
<?php
|
3189 |
-
|
3190 |
-
|
3191 |
-
<?php
|
3192 |
-
|
3193 |
-
<?php if(
|
3194 |
-
|
3195 |
-
<?php
|
3196 |
-
|
3197 |
-
<?php if(
|
3198 |
-
|
3199 |
-
<?php
|
3200 |
-
|
3201 |
-
|
3202 |
-
<?php
|
3203 |
-
Reset Password Limit: <?php echo UM()->options()->get('
|
3204 |
-
|
3205 |
-
<?php
|
3206 |
-
<?php
|
3207 |
-
|
3208 |
-
<?php
|
3209 |
-
<?php
|
3210 |
-
|
3211 |
-
<?php
|
3212 |
-
<?php
|
3213 |
-
|
3214 |
-
|
3215 |
-
|
3216 |
-
|
3217 |
-
|
3218 |
-
|
3219 |
-
Mail appears from:
|
3220 |
-
|
3221 |
-
|
3222 |
-
Account
|
3223 |
-
|
3224 |
-
|
3225 |
-
Account
|
3226 |
-
Account
|
3227 |
-
Account
|
3228 |
-
|
3229 |
-
Password
|
3230 |
-
|
3231 |
-
|
3232 |
-
|
3233 |
-
|
3234 |
-
|
3235 |
-
|
3236 |
-
|
3237 |
-
|
3238 |
-
|
3239 |
-
|
3240 |
-
|
3241 |
-
|
3242 |
-
|
3243 |
-
|
3244 |
-
|
3245 |
-
|
3246 |
-
|
3247 |
-
|
3248 |
-
|
3249 |
-
|
3250 |
-
|
3251 |
-
|
3252 |
-
$dir
|
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 |
-
PHP
|
3291 |
-
PHP
|
3292 |
-
PHP
|
3293 |
-
PHP
|
3294 |
-
PHP
|
3295 |
-
PHP
|
3296 |
-
PHP
|
3297 |
-
|
3298 |
-
|
3299 |
-
|
3300 |
-
|
3301 |
-
|
3302 |
-
|
3303 |
-
|
3304 |
-
|
3305 |
-
|
3306 |
-
|
3307 |
-
|
3308 |
-
|
3309 |
-
|
3310 |
-
|
3311 |
-
|
3312 |
-
|
3313 |
-
|
3314 |
-
Session:
|
3315 |
-
|
3316 |
-
|
3317 |
-
|
3318 |
-
Use Cookies:
|
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 |
-
header(
|
3395 |
-
|
3396 |
-
|
3397 |
-
|
3398 |
-
|
3399 |
-
|
3400 |
-
|
3401 |
-
|
3402 |
-
|
3403 |
-
|
3404 |
-
* @param string $
|
3405 |
-
* @param string $
|
3406 |
-
*
|
3407 |
-
*
|
3408 |
-
|
3409 |
-
|
3410 |
-
|
3411 |
-
|
3412 |
-
|
3413 |
-
|
3414 |
-
|
3415 |
-
|
3416 |
-
|
3417 |
-
|
3418 |
-
|
3419 |
-
|
3420 |
-
|
3421 |
-
|
3422 |
-
|
3423 |
-
*
|
3424 |
-
*
|
3425 |
-
* @param
|
3426 |
-
* @param string $
|
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 |
-
unset( $settings[
|
3472 |
-
|
3473 |
-
|
3474 |
-
|
3475 |
-
|
3476 |
-
|
3477 |
-
|
3478 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace um\admin\core;
|
3 |
+
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
+
exit;
|
6 |
+
}
|
7 |
+
|
8 |
+
if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Admin_Settings
|
13 |
+
* @package um\admin\core
|
14 |
+
*/
|
15 |
+
class Admin_Settings {
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var array
|
20 |
+
*/
|
21 |
+
public $settings_map;
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var array
|
26 |
+
*/
|
27 |
+
public $settings_structure;
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @var
|
32 |
+
*/
|
33 |
+
private $previous_licenses;
|
34 |
+
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @var
|
38 |
+
*/
|
39 |
+
private $need_change_permalinks;
|
40 |
+
|
41 |
+
|
42 |
+
private $gravatar_changed = false;
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Admin_Settings constructor.
|
47 |
+
*/
|
48 |
+
public function __construct() {
|
49 |
+
//init settings structure
|
50 |
+
add_action( 'admin_init', array( &$this, 'init_variables' ), 9 );
|
51 |
+
|
52 |
+
//admin menu
|
53 |
+
add_action( 'admin_menu', array( &$this, 'primary_admin_menu' ), 0 );
|
54 |
+
|
55 |
+
//settings structure handlers
|
56 |
+
add_action( 'um_settings_page_before_email__content', array( $this, 'settings_before_email_tab' ) );
|
57 |
+
add_filter( 'um_settings_section_email__content', array( $this, 'settings_email_tab' ), 10, 1 );
|
58 |
+
|
59 |
+
//enqueue wp_media for profiles tab
|
60 |
+
add_action( 'um_settings_page_appearance__before_section', array( $this, 'settings_appearance_profile_tab' ) );
|
61 |
+
|
62 |
+
//custom content for licenses tab
|
63 |
+
add_filter( 'um_settings_section_licenses__content', array( $this, 'settings_licenses_tab' ), 10, 2 );
|
64 |
+
|
65 |
+
add_filter( 'um_settings_section_install_info__content', array( $this, 'settings_install_info_tab' ), 10, 2 );
|
66 |
+
|
67 |
+
|
68 |
+
add_filter( 'um_settings_structure', array( $this, 'sorting_licenses_options' ), 9999, 1 );
|
69 |
+
|
70 |
+
|
71 |
+
//save handlers
|
72 |
+
add_action( 'admin_init', array( $this, 'save_settings_handler' ), 10 );
|
73 |
+
|
74 |
+
//save pages options
|
75 |
+
add_action( 'um_settings_before_save', array( $this, 'check_permalinks_changes' ) );
|
76 |
+
add_action( 'um_settings_save', array( $this, 'on_settings_save' ) );
|
77 |
+
|
78 |
+
|
79 |
+
add_filter( 'um_change_settings_before_save', array( $this, 'save_email_templates' ) );
|
80 |
+
|
81 |
+
|
82 |
+
//save licenses options
|
83 |
+
add_action( 'um_settings_before_save', array( $this, 'before_licenses_save' ) );
|
84 |
+
add_action( 'um_settings_save', array( $this, 'licenses_save' ) );
|
85 |
+
|
86 |
+
add_filter( 'um_change_settings_before_save', array( $this, 'set_default_if_empty' ), 9, 1 );
|
87 |
+
add_filter( 'um_change_settings_before_save', array( $this, 'remove_empty_values' ), 10, 1 );
|
88 |
+
|
89 |
+
add_action( 'admin_init', array( &$this, 'um_download_install_info' ) );
|
90 |
+
}
|
91 |
+
|
92 |
+
|
93 |
+
|
94 |
+
public function same_page_update_ajax() {
|
95 |
+
UM()->admin()->check_ajax_nonce();
|
96 |
+
|
97 |
+
if ( empty( $_POST['cb_func'] ) ) {
|
98 |
+
wp_send_json_error( __( 'Wrong callback', 'ultimate-member' ) );
|
99 |
+
}
|
100 |
+
|
101 |
+
$cb_func = sanitize_key( $_POST['cb_func'] );
|
102 |
+
|
103 |
+
if ( 'um_usermeta_fields' === $cb_func ) {
|
104 |
+
//first install metatable
|
105 |
+
global $wpdb;
|
106 |
+
|
107 |
+
$metakeys = array();
|
108 |
+
foreach ( UM()->builtin()->all_user_fields as $all_user_field ) {
|
109 |
+
$metakeys[] = $all_user_field['metakey'];
|
110 |
+
}
|
111 |
+
|
112 |
+
$metakeys = apply_filters( 'um_metadata_same_page_update_ajax', $metakeys, UM()->builtin()->all_user_fields );
|
113 |
+
|
114 |
+
if ( is_multisite() ) {
|
115 |
+
|
116 |
+
$sites = get_sites( array( 'fields' => 'ids' ) );
|
117 |
+
foreach ( $sites as $blog_id ) {
|
118 |
+
$metakeys[] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
|
119 |
+
}
|
120 |
+
} else {
|
121 |
+
$blog_id = get_current_blog_id();
|
122 |
+
$metakeys[] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
|
123 |
+
}
|
124 |
+
|
125 |
+
//member directory data
|
126 |
+
$metakeys[] = 'um_member_directory_data';
|
127 |
+
$metakeys[] = '_um_verified';
|
128 |
+
$metakeys[] = '_money_spent';
|
129 |
+
$metakeys[] = '_completed';
|
130 |
+
$metakeys[] = '_reviews_avg';
|
131 |
+
|
132 |
+
//myCred meta
|
133 |
+
if ( function_exists( 'mycred_get_types' ) ) {
|
134 |
+
$mycred_types = mycred_get_types();
|
135 |
+
if ( ! empty( $mycred_types ) ) {
|
136 |
+
foreach ( array_keys( $mycred_types ) as $point_type ) {
|
137 |
+
$metakeys[] = $point_type;
|
138 |
+
}
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
$sortby_custom_keys = $wpdb->get_col( "SELECT DISTINCT meta_value FROM {$wpdb->postmeta} WHERE meta_key='_um_sortby_custom'" );
|
143 |
+
if ( empty( $sortby_custom_keys ) ) {
|
144 |
+
$sortby_custom_keys = array();
|
145 |
+
}
|
146 |
+
|
147 |
+
$sortby_custom_keys2 = $wpdb->get_col( "SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key='_um_sorting_fields'" );
|
148 |
+
if ( ! empty( $sortby_custom_keys2 ) ) {
|
149 |
+
foreach ( $sortby_custom_keys2 as $custom_val ) {
|
150 |
+
$custom_val = maybe_unserialize( $custom_val );
|
151 |
+
|
152 |
+
foreach ( $custom_val as $sort_value ) {
|
153 |
+
if ( is_array( $sort_value ) ) {
|
154 |
+
$field_keys = array_keys( $sort_value );
|
155 |
+
$sortby_custom_keys[] = $field_keys[0];
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
if ( ! empty( $sortby_custom_keys ) ) {
|
162 |
+
$sortby_custom_keys = array_unique( $sortby_custom_keys );
|
163 |
+
$metakeys = array_merge( $metakeys, $sortby_custom_keys );
|
164 |
+
}
|
165 |
+
|
166 |
+
$skip_fields = UM()->builtin()->get_fields_without_metakey();
|
167 |
+
$skip_fields = array_merge( $skip_fields, UM()->member_directory()->core_search_fields );
|
168 |
+
|
169 |
+
$real_usermeta = $wpdb->get_col( "SELECT DISTINCT meta_key FROM {$wpdb->usermeta}" );
|
170 |
+
$real_usermeta = ! empty( $real_usermeta ) ? $real_usermeta : array();
|
171 |
+
$real_usermeta = array_merge( $real_usermeta, array( 'um_member_directory_data' ) );
|
172 |
+
|
173 |
+
if ( ! empty( $sortby_custom_keys ) ) {
|
174 |
+
$real_usermeta = array_merge( $real_usermeta, $sortby_custom_keys );
|
175 |
+
}
|
176 |
+
|
177 |
+
$wp_usermeta_option = array_intersect( array_diff( $metakeys, $skip_fields ), $real_usermeta );
|
178 |
+
|
179 |
+
update_option( 'um_usermeta_fields', array_values( $wp_usermeta_option ) );
|
180 |
+
|
181 |
+
update_option( 'um_member_directory_update_meta', time() );
|
182 |
+
|
183 |
+
UM()->options()->update( 'member_directory_own_table', true );
|
184 |
+
|
185 |
+
wp_send_json_success();
|
186 |
+
} elseif ( 'um_get_metadata' === $cb_func ) {
|
187 |
+
global $wpdb;
|
188 |
+
|
189 |
+
$wp_usermeta_option = get_option( 'um_usermeta_fields', array() );
|
190 |
+
|
191 |
+
$count = $wpdb->get_var(
|
192 |
+
"SELECT COUNT(*)
|
193 |
+
FROM {$wpdb->usermeta}
|
194 |
+
WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "')"
|
195 |
+
);
|
196 |
+
|
197 |
+
wp_send_json_success( array( 'count' => $count ) );
|
198 |
+
} elseif ( 'um_update_metadata_per_page' === $cb_func ) {
|
199 |
+
|
200 |
+
if ( empty( $_POST['page'] ) ) {
|
201 |
+
wp_send_json_error( __( 'Wrong data', 'ultimate-member' ) );
|
202 |
+
}
|
203 |
+
|
204 |
+
$per_page = 500;
|
205 |
+
$wp_usermeta_option = get_option( 'um_usermeta_fields', array() );
|
206 |
+
|
207 |
+
global $wpdb;
|
208 |
+
$metadata = $wpdb->get_results(
|
209 |
+
$wpdb->prepare(
|
210 |
+
"SELECT *
|
211 |
+
FROM {$wpdb->usermeta}
|
212 |
+
WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "')
|
213 |
+
LIMIT %d, %d",
|
214 |
+
( absint( $_POST['page'] ) - 1 ) * $per_page,
|
215 |
+
$per_page
|
216 |
+
),
|
217 |
+
ARRAY_A
|
218 |
+
);
|
219 |
+
|
220 |
+
$values = array();
|
221 |
+
foreach ( $metadata as $metarow ) {
|
222 |
+
$values[] = $wpdb->prepare( '(%d, %s, %s)', $metarow['user_id'], $metarow['meta_key'], $metarow['meta_value'] );
|
223 |
+
}
|
224 |
+
|
225 |
+
if ( ! empty( $values ) ) {
|
226 |
+
$wpdb->query(
|
227 |
+
"INSERT INTO
|
228 |
+
{$wpdb->prefix}um_metadata(user_id, um_key, um_value)
|
229 |
+
VALUES " . implode( ',', $values )
|
230 |
+
);
|
231 |
+
}
|
232 |
+
|
233 |
+
$from = ( absint( $_POST['page'] ) * $per_page ) - $per_page + 1;
|
234 |
+
$to = absint( $_POST['page'] ) * $per_page;
|
235 |
+
|
236 |
+
wp_send_json_success( array( 'message' => sprintf( __( 'Metadata from %1$s to %2$s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
|
237 |
+
} else {
|
238 |
+
do_action( 'um_same_page_update_ajax_action', $cb_func );
|
239 |
+
}
|
240 |
+
}
|
241 |
+
|
242 |
+
|
243 |
+
/**
|
244 |
+
*
|
245 |
+
*/
|
246 |
+
public function init_variables() {
|
247 |
+
|
248 |
+
$settings_map = array();
|
249 |
+
|
250 |
+
$general_pages_fields = array(
|
251 |
+
array(
|
252 |
+
'id' => 'pages_settings',
|
253 |
+
'type' => 'hidden',
|
254 |
+
'value' => true,
|
255 |
+
'is_option' => false,
|
256 |
+
),
|
257 |
+
);
|
258 |
+
|
259 |
+
$core_pages = UM()->config()->core_pages;
|
260 |
+
|
261 |
+
foreach ( $core_pages as $page_s => $page ) {
|
262 |
+
$have_pages = UM()->query()->wp_pages();
|
263 |
+
$page_id = UM()->options()->get_core_page_id( $page_s );
|
264 |
+
|
265 |
+
$page_title = ! empty( $page['title'] ) ? $page['title'] : '';
|
266 |
+
|
267 |
+
if ( 'reached_maximum_limit' === $have_pages ) {
|
268 |
+
$general_pages_fields[] = array(
|
269 |
+
'id' => $page_id,
|
270 |
+
'type' => 'text',
|
271 |
+
// translators: %s: Page title
|
272 |
+
'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ),
|
273 |
+
'placeholder' => __( 'Add page ID', 'ultimate-member' ),
|
274 |
+
'compiler' => true,
|
275 |
+
'size' => 'small',
|
276 |
+
);
|
277 |
+
} else {
|
278 |
+
$general_pages_fields[] = array(
|
279 |
+
'id' => $page_id,
|
280 |
+
'type' => 'select',
|
281 |
+
// translators: %s: Page title
|
282 |
+
'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ),
|
283 |
+
'options' => UM()->query()->wp_pages(),
|
284 |
+
'placeholder' => __( 'Choose a page...', 'ultimate-member' ),
|
285 |
+
'compiler' => true,
|
286 |
+
'size' => 'small',
|
287 |
+
);
|
288 |
+
}
|
289 |
+
|
290 |
+
|
291 |
+
$settings_map[ $page_id ] = array(
|
292 |
+
'sanitize' => 'absint',
|
293 |
+
);
|
294 |
+
}
|
295 |
+
|
296 |
+
$appearances_profile_menu_fields = array(
|
297 |
+
array(
|
298 |
+
'id' => 'profile_menu',
|
299 |
+
'type' => 'checkbox',
|
300 |
+
'label' => __( 'Enable profile menu', 'ultimate-member' ),
|
301 |
+
),
|
302 |
+
);
|
303 |
+
|
304 |
+
$settings_map['profile_menu'] = array(
|
305 |
+
'sanitize' => 'bool',
|
306 |
+
);
|
307 |
+
|
308 |
+
$tabs = UM()->profile()->tabs();
|
309 |
+
|
310 |
+
$tabs_options = array();
|
311 |
+
$tabs_condition = array();
|
312 |
+
foreach ( $tabs as $id => $tab ) {
|
313 |
+
|
314 |
+
if ( ! empty( $tab['hidden'] ) ) {
|
315 |
+
continue;
|
316 |
+
}
|
317 |
+
|
318 |
+
if ( isset( $tab['name'] ) ) {
|
319 |
+
$tabs_options[ $id ] = $tab['name'];
|
320 |
+
$tabs_condition[] = 'profile_tab_' . $id;
|
321 |
+
}
|
322 |
+
|
323 |
+
if ( isset( $tab['default_privacy'] ) ) {
|
324 |
+
$fields = array(
|
325 |
+
array(
|
326 |
+
'id' => 'profile_tab_' . $id,
|
327 |
+
'type' => 'checkbox',
|
328 |
+
// translators: %s: Tab title
|
329 |
+
'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ),
|
330 |
+
'conditional' => array( 'profile_menu', '=', 1 ),
|
331 |
+
'data' => array( 'fill_profile_menu_default_tab' => $id ),
|
332 |
+
),
|
333 |
+
);
|
334 |
+
|
335 |
+
$settings_map[ 'profile_tab_' . $id ] = array(
|
336 |
+
'sanitize' => 'bool',
|
337 |
+
);
|
338 |
+
} else {
|
339 |
+
|
340 |
+
$fields = array(
|
341 |
+
array(
|
342 |
+
'id' => 'profile_tab_' . $id,
|
343 |
+
'type' => 'checkbox',
|
344 |
+
// translators: %s: Tab title
|
345 |
+
'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ),
|
346 |
+
'conditional' => array( 'profile_menu', '=', 1 ),
|
347 |
+
'data' => array( 'fill_profile_menu_default_tab' => $id ),
|
348 |
+
),
|
349 |
+
array(
|
350 |
+
'id' => 'profile_tab_' . $id . '_privacy',
|
351 |
+
'type' => 'select',
|
352 |
+
// translators: %s: Tab title
|
353 |
+
'label' => sprintf( __( 'Who can see %s Tab?', 'ultimate-member' ), $tab['name'] ),
|
354 |
+
'tooltip' => __( 'Select which users can view this tab.', 'ultimate-member' ),
|
355 |
+
'options' => UM()->profile()->tabs_privacy(),
|
356 |
+
'conditional' => array( 'profile_tab_' . $id, '=', 1 ),
|
357 |
+
'size' => 'small',
|
358 |
+
),
|
359 |
+
array(
|
360 |
+
'id' => 'profile_tab_' . $id . '_roles',
|
361 |
+
'type' => 'select',
|
362 |
+
'multi' => true,
|
363 |
+
'label' => __( 'Allowed roles', 'ultimate-member' ),
|
364 |
+
'tooltip' => __( 'Select the the user roles allowed to view this tab.', 'ultimate-member' ),
|
365 |
+
'options' => UM()->roles()->get_roles(),
|
366 |
+
'placeholder' => __( 'Choose user roles...', 'ultimate-member' ),
|
367 |
+
'conditional' => array( 'profile_tab_' . $id . '_privacy', '=', array( '4', '5' ) ),
|
368 |
+
'size' => 'small',
|
369 |
+
),
|
370 |
+
);
|
371 |
+
|
372 |
+
$settings_map = array_merge(
|
373 |
+
$settings_map,
|
374 |
+
array(
|
375 |
+
"profile_tab_{$id}" => array(
|
376 |
+
'sanitize' => 'bool',
|
377 |
+
),
|
378 |
+
"profile_tab_{$id}_privacy" => array(
|
379 |
+
'sanitize' => array( UM()->admin(), 'sanitize_tabs_privacy' ),
|
380 |
+
),
|
381 |
+
"profile_tab_{$id}_roles" => array(
|
382 |
+
'sanitize' => array( UM()->admin(), 'sanitize_existed_role' ),
|
383 |
+
),
|
384 |
+
)
|
385 |
+
);
|
386 |
+
}
|
387 |
+
|
388 |
+
$appearances_profile_menu_fields = array_merge( $appearances_profile_menu_fields, $fields );
|
389 |
+
}
|
390 |
+
|
391 |
+
$appearances_profile_menu_fields[] = array(
|
392 |
+
'id' => 'profile_menu_default_tab',
|
393 |
+
'type' => 'select',
|
394 |
+
'label' => __( 'Profile menu default tab', 'ultimate-member' ),
|
395 |
+
'tooltip' => __( 'This will be the default tab on user profile page', 'ultimate-member' ),
|
396 |
+
'options' => $tabs_options,
|
397 |
+
'conditional' => array( implode( '|', $tabs_condition ), '~', 1 ),
|
398 |
+
'size' => 'small',
|
399 |
+
);
|
400 |
+
|
401 |
+
$settings_map['profile_menu_default_tab'] = array(
|
402 |
+
'sanitize' => 'key',
|
403 |
+
);
|
404 |
+
|
405 |
+
$appearances_profile_menu_fields = array_merge(
|
406 |
+
$appearances_profile_menu_fields,
|
407 |
+
array(
|
408 |
+
array(
|
409 |
+
'id' => 'profile_menu_icons',
|
410 |
+
'type' => 'checkbox',
|
411 |
+
'label' => __( 'Enable menu icons in desktop view', 'ultimate-member' ),
|
412 |
+
'conditional' => array( 'profile_menu', '=', 1 ),
|
413 |
+
),
|
414 |
+
)
|
415 |
+
);
|
416 |
+
|
417 |
+
$settings_map['profile_menu_icons'] = array(
|
418 |
+
'sanitize' => 'bool',
|
419 |
+
);
|
420 |
+
|
421 |
+
$post_types_options = array();
|
422 |
+
$all_post_types = get_post_types( array( 'public' => true ), 'objects' );
|
423 |
+
foreach ( $all_post_types as $key => $post_type_data ) {
|
424 |
+
$post_types_options[ $key ] = $post_type_data->labels->singular_name;
|
425 |
+
}
|
426 |
+
|
427 |
+
$duplicates = array();
|
428 |
+
$taxonomies_options = array();
|
429 |
+
$exclude_taxonomies = UM()->excluded_taxonomies();
|
430 |
+
$all_taxonomies = get_taxonomies( array( 'public' => true ), 'objects' );
|
431 |
+
foreach ( $all_taxonomies as $key => $taxonomy ) {
|
432 |
+
if ( in_array( $key, $exclude_taxonomies, true ) ) {
|
433 |
+
continue;
|
434 |
+
}
|
435 |
+
|
436 |
+
if ( ! in_array( $taxonomy->labels->singular_name, $duplicates, true ) ) {
|
437 |
+
$duplicates[] = $taxonomy->labels->singular_name;
|
438 |
+
$label = $taxonomy->labels->singular_name;
|
439 |
+
} else {
|
440 |
+
$label = $taxonomy->labels->singular_name . ' (' . $key . ')';
|
441 |
+
}
|
442 |
+
|
443 |
+
$taxonomies_options[ $key ] = $label;
|
444 |
+
}
|
445 |
+
|
446 |
+
$restricted_access_post_metabox_value = array();
|
447 |
+
$restricted_access_post_metabox = UM()->options()->get( 'restricted_access_post_metabox' );
|
448 |
+
if ( ! empty( $restricted_access_post_metabox ) && is_array( $restricted_access_post_metabox ) ) {
|
449 |
+
foreach ( $restricted_access_post_metabox as $key => $value ) {
|
450 |
+
if ( $value ) {
|
451 |
+
$restricted_access_post_metabox_value[] = $key;
|
452 |
+
}
|
453 |
+
}
|
454 |
+
}
|
455 |
+
|
456 |
+
|
457 |
+
$restricted_access_taxonomy_metabox_value = array();
|
458 |
+
$restricted_access_taxonomy_metabox = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
459 |
+
if ( ! empty( $restricted_access_taxonomy_metabox ) && is_array( $restricted_access_taxonomy_metabox ) ) {
|
460 |
+
foreach ( $restricted_access_taxonomy_metabox as $key => $value ) {
|
461 |
+
if ( $value ) {
|
462 |
+
$restricted_access_taxonomy_metabox_value[] = $key;
|
463 |
+
}
|
464 |
+
}
|
465 |
+
}
|
466 |
+
|
467 |
+
$access_fields = array(
|
468 |
+
array(
|
469 |
+
'id' => 'accessible',
|
470 |
+
'type' => 'select',
|
471 |
+
'label' => __( 'Global Site Access', 'ultimate-member' ),
|
472 |
+
'tooltip' => __( 'Globally control the access of your site, you can have separate restrict options per post/page by editing the desired item.', 'ultimate-member' ),
|
473 |
+
'options' => array(
|
474 |
+
0 => __( 'Site accessible to Everyone', 'ultimate-member' ),
|
475 |
+
2 => __( 'Site accessible to Logged In Users', 'ultimate-member' ),
|
476 |
+
),
|
477 |
+
'size' => 'medium',
|
478 |
+
),
|
479 |
+
array(
|
480 |
+
'id' => 'access_redirect',
|
481 |
+
'type' => 'text',
|
482 |
+
'label' => __( 'Custom Redirect URL', 'ultimate-member' ),
|
483 |
+
'tooltip' => __( 'A logged out user will be redirected to this url If he is not permitted to access the site', 'ultimate-member' ),
|
484 |
+
'conditional' => array( 'accessible', '=', 2 ),
|
485 |
+
),
|
486 |
+
array(
|
487 |
+
'id' => 'access_exclude_uris',
|
488 |
+
'type' => 'multi_text',
|
489 |
+
'label' => __( 'Exclude the following URLs', 'ultimate-member' ),
|
490 |
+
'tooltip' => __( 'Here you can exclude URLs beside the redirect URI to be accessible to everyone', 'ultimate-member' ),
|
491 |
+
'add_text' => __( 'Add New URL', 'ultimate-member' ),
|
492 |
+
'conditional' => array( 'accessible', '=', 2 ),
|
493 |
+
'show_default_number' => 0,
|
494 |
+
),
|
495 |
+
array(
|
496 |
+
'id' => 'home_page_accessible',
|
497 |
+
'type' => 'checkbox',
|
498 |
+
'label' => __( 'Allow Homepage to be accessible', 'ultimate-member' ),
|
499 |
+
'conditional' => array( 'accessible', '=', 2 ),
|
500 |
+
),
|
501 |
+
array(
|
502 |
+
'id' => 'category_page_accessible',
|
503 |
+
'type' => 'checkbox',
|
504 |
+
'label' => __( 'Allow Category pages to be accessible', 'ultimate-member' ),
|
505 |
+
'conditional' => array( 'accessible', '=', 2 ),
|
506 |
+
),
|
507 |
+
array(
|
508 |
+
'id' => 'restricted_post_title_replace',
|
509 |
+
'type' => 'checkbox',
|
510 |
+
'label' => __( 'Replace the restricted Post Title', 'ultimate-member' ),
|
511 |
+
'tooltip' => __( 'Allow to replace the restricted post title to users that do not have permission to view the content', 'ultimate-member' ),
|
512 |
+
),
|
513 |
+
array(
|
514 |
+
'id' => 'restricted_access_post_title',
|
515 |
+
'type' => 'text',
|
516 |
+
'label' => __( 'Restricted Access Post Title', 'ultimate-member' ),
|
517 |
+
'tooltip' => __( 'This is the post title shown to users that do not have permission to view the content', 'ultimate-member' ),
|
518 |
+
'conditional' => array( 'restricted_post_title_replace', '=', 1 ),
|
519 |
+
),
|
520 |
+
array(
|
521 |
+
'id' => 'restricted_access_message',
|
522 |
+
'type' => 'wp_editor',
|
523 |
+
'label' => __( 'Restricted Access Message', 'ultimate-member' ),
|
524 |
+
'tooltip' => __( 'This is the message shown to users that do not have permission to view the content', 'ultimate-member' ),
|
525 |
+
),
|
526 |
+
);
|
527 |
+
|
528 |
+
$settings_map = array_merge(
|
529 |
+
$settings_map,
|
530 |
+
array(
|
531 |
+
'accessible' => array(
|
532 |
+
'sanitize' => 'int',
|
533 |
+
),
|
534 |
+
'access_redirect' => array(
|
535 |
+
'sanitize' => 'url',
|
536 |
+
),
|
537 |
+
'access_exclude_uris' => array(
|
538 |
+
'sanitize' => 'url',
|
539 |
+
),
|
540 |
+
'home_page_accessible' => array(
|
541 |
+
'sanitize' => 'bool',
|
542 |
+
),
|
543 |
+
'category_page_accessible' => array(
|
544 |
+
'sanitize' => 'bool',
|
545 |
+
),
|
546 |
+
'restricted_post_title_replace' => array(
|
547 |
+
'sanitize' => 'bool',
|
548 |
+
),
|
549 |
+
'restricted_access_post_title' => array(
|
550 |
+
'sanitize' => 'text',
|
551 |
+
),
|
552 |
+
'restricted_access_message' => array(
|
553 |
+
'sanitize' => 'wp_kses',
|
554 |
+
),
|
555 |
+
)
|
556 |
+
);
|
557 |
+
|
558 |
+
global $wp_version;
|
559 |
+
if ( version_compare( $wp_version, '5.0', '>=' ) ) {
|
560 |
+
$access_fields = array_merge(
|
561 |
+
$access_fields,
|
562 |
+
array(
|
563 |
+
array(
|
564 |
+
'id' => 'restricted_blocks',
|
565 |
+
'type' => 'checkbox',
|
566 |
+
'label' => __( 'Enable the "Content Restriction" settings for the Gutenberg Blocks', 'ultimate-member' ),
|
567 |
+
),
|
568 |
+
array(
|
569 |
+
'id' => 'restricted_block_message',
|
570 |
+
'type' => 'textarea',
|
571 |
+
'label' => __( 'Restricted Access Block Message', 'ultimate-member' ),
|
572 |
+
'tooltip' => __( 'This is the message shown to users that do not have permission to view the block\'s content', 'ultimate-member' ),
|
573 |
+
'conditional' => array( 'restricted_blocks', '=', 1 ),
|
574 |
+
),
|
575 |
+
)
|
576 |
+
);
|
577 |
+
|
578 |
+
$settings_map['restricted_blocks'] = array(
|
579 |
+
'sanitize' => 'bool',
|
580 |
+
);
|
581 |
+
$settings_map['restricted_block_message'] = array(
|
582 |
+
'sanitize' => 'textarea',
|
583 |
+
);
|
584 |
+
}
|
585 |
+
|
586 |
+
$access_fields = array_merge(
|
587 |
+
$access_fields,
|
588 |
+
array(
|
589 |
+
array(
|
590 |
+
'id' => 'restricted_access_post_metabox',
|
591 |
+
'type' => 'hidden',
|
592 |
+
'value' => '',
|
593 |
+
),
|
594 |
+
array(
|
595 |
+
'id' => 'restricted_access_taxonomy_metabox',
|
596 |
+
'type' => 'hidden',
|
597 |
+
'value' => '',
|
598 |
+
),
|
599 |
+
array(
|
600 |
+
'id' => 'restricted_access_post_metabox',
|
601 |
+
'type' => 'multi_checkbox',
|
602 |
+
'label' => __( 'Enable the "Content Restriction" settings for post types', 'ultimate-member' ),
|
603 |
+
'tooltip' => __( 'Check post types for which you plan to use the "Content Restriction" settings', 'ultimate-member' ),
|
604 |
+
'options' => $post_types_options,
|
605 |
+
'columns' => 3,
|
606 |
+
'value' => $restricted_access_post_metabox_value,
|
607 |
+
'default' => UM()->options()->get_default( 'restricted_access_post_metabox' ),
|
608 |
+
),
|
609 |
+
array(
|
610 |
+
'id' => 'restricted_access_taxonomy_metabox',
|
611 |
+
'type' => 'multi_checkbox',
|
612 |
+
'label' => __( 'Enable the "Content Restriction" settings for taxonomies', 'ultimate-member' ),
|
613 |
+
'tooltip' => __( 'Check taxonomies for which you plan to use the "Content Restriction" settings', 'ultimate-member' ),
|
614 |
+
'options' => $taxonomies_options,
|
615 |
+
'columns' => 3,
|
616 |
+
'value' => $restricted_access_taxonomy_metabox_value,
|
617 |
+
'default' => UM()->options()->get_default( 'restricted_access_taxonomy_metabox' ),
|
618 |
+
),
|
619 |
+
)
|
620 |
+
);
|
621 |
+
|
622 |
+
$settings_map = array_merge(
|
623 |
+
$settings_map,
|
624 |
+
array(
|
625 |
+
'restricted_access_post_metabox' => array(
|
626 |
+
'sanitize' => 'key',
|
627 |
+
),
|
628 |
+
'restricted_access_taxonomy_metabox' => array(
|
629 |
+
'sanitize' => 'key',
|
630 |
+
),
|
631 |
+
)
|
632 |
+
);
|
633 |
+
|
634 |
+
$latest_update = get_option( 'um_member_directory_update_meta', false );
|
635 |
+
$latest_truncate = get_option( 'um_member_directory_truncated', false );
|
636 |
+
|
637 |
+
$same_page_update = array(
|
638 |
+
'id' => 'member_directory_own_table',
|
639 |
+
'type' => 'same_page_update',
|
640 |
+
'label' => __( 'Enable custom table for usermeta', 'ultimate-member' ),
|
641 |
+
'tooltip' => __( 'Check this box if you would like to enable the use of a custom table for user metadata. Improved performance for member directory searches.', 'ultimate-member' ),
|
642 |
+
);
|
643 |
+
|
644 |
+
if ( empty( $latest_update ) || ( ! empty( $latest_truncate ) && $latest_truncate > $latest_update ) ) {
|
645 |
+
$same_page_update['upgrade_cb'] = 'sync_metatable';
|
646 |
+
$same_page_update['upgrade_description'] = '<p>' . __( 'We recommend creating a backup of your site before running the update process. Do not exit the page before the update process has complete.', 'ultimate-member' ) . '</p>
|
647 |
+
<p>' . __( 'After clicking the <strong>"Run"</strong> button, the update process will start. All information will be displayed in the field below.', 'ultimate-member' ) . '</p>
|
648 |
+
<p>' . __( 'If the update was successful, you will see a corresponding message. Otherwise, contact technical support if the update failed.', 'ultimate-member' ) . '</p>';
|
649 |
+
}
|
650 |
+
|
651 |
+
$settings_map = array_merge(
|
652 |
+
$settings_map,
|
653 |
+
array(
|
654 |
+
'permalink_base' => array(
|
655 |
+
'sanitize' => 'key',
|
656 |
+
),
|
657 |
+
'display_name' => array(
|
658 |
+
'sanitize' => 'key',
|
659 |
+
),
|
660 |
+
'display_name_field' => array(
|
661 |
+
'sanitize' => 'text',
|
662 |
+
),
|
663 |
+
'author_redirect' => array(
|
664 |
+
'sanitize' => 'bool',
|
665 |
+
),
|
666 |
+
'members_page' => array(
|
667 |
+
'sanitize' => 'bool',
|
668 |
+
),
|
669 |
+
'use_gravatars' => array(
|
670 |
+
'sanitize' => 'bool',
|
671 |
+
),
|
672 |
+
'use_um_gravatar_default_builtin_image' => array(
|
673 |
+
'sanitize' => 'key',
|
674 |
+
),
|
675 |
+
'use_um_gravatar_default_image' => array(
|
676 |
+
'sanitize' => 'bool',
|
677 |
+
),
|
678 |
+
'require_strongpass' => array(
|
679 |
+
'sanitize' => 'bool',
|
680 |
+
),
|
681 |
+
'password_min_chars' => array(
|
682 |
+
'sanitize' => 'absint',
|
683 |
+
),
|
684 |
+
'password_max_chars' => array(
|
685 |
+
'sanitize' => 'absint',
|
686 |
+
),
|
687 |
+
'profile_noindex' => array(
|
688 |
+
'sanitize' => 'bool',
|
689 |
+
),
|
690 |
+
'activation_link_expiry_time' => array(
|
691 |
+
'sanitize' => 'absint',
|
692 |
+
),
|
693 |
+
'account_tab_password' => array(
|
694 |
+
'sanitize' => 'bool',
|
695 |
+
),
|
696 |
+
'account_tab_privacy' => array(
|
697 |
+
'sanitize' => 'bool',
|
698 |
+
),
|
699 |
+
'account_tab_notifications' => array(
|
700 |
+
'sanitize' => 'bool',
|
701 |
+
),
|
702 |
+
'account_tab_delete' => array(
|
703 |
+
'sanitize' => 'bool',
|
704 |
+
),
|
705 |
+
'delete_account_text' => array(
|
706 |
+
'sanitize' => 'textarea',
|
707 |
+
),
|
708 |
+
'delete_account_no_pass_required_text' => array(
|
709 |
+
'sanitize' => 'textarea',
|
710 |
+
),
|
711 |
+
'account_name' => array(
|
712 |
+
'sanitize' => 'bool',
|
713 |
+
),
|
714 |
+
'account_name_disable' => array(
|
715 |
+
'sanitize' => 'bool',
|
716 |
+
),
|
717 |
+
'account_name_require' => array(
|
718 |
+
'sanitize' => 'bool',
|
719 |
+
),
|
720 |
+
'account_email' => array(
|
721 |
+
'sanitize' => 'bool',
|
722 |
+
),
|
723 |
+
'account_general_password' => array(
|
724 |
+
'sanitize' => 'bool',
|
725 |
+
),
|
726 |
+
'account_hide_in_directory' => array(
|
727 |
+
'sanitize' => 'bool',
|
728 |
+
),
|
729 |
+
'account_hide_in_directory_default' => array(
|
730 |
+
'sanitize' => 'text',
|
731 |
+
),
|
732 |
+
'profile_photo_max_size' => array(
|
733 |
+
'sanitize' => 'absint',
|
734 |
+
),
|
735 |
+
'cover_photo_max_size' => array(
|
736 |
+
'sanitize' => 'absint',
|
737 |
+
),
|
738 |
+
'photo_thumb_sizes' => array(
|
739 |
+
'sanitize' => 'absint',
|
740 |
+
),
|
741 |
+
'cover_thumb_sizes' => array(
|
742 |
+
'sanitize' => 'absint',
|
743 |
+
),
|
744 |
+
'image_orientation_by_exif' => array(
|
745 |
+
'sanitize' => 'bool',
|
746 |
+
),
|
747 |
+
'image_compression' => array(
|
748 |
+
'sanitize' => 'absint',
|
749 |
+
),
|
750 |
+
'image_max_width' => array(
|
751 |
+
'sanitize' => 'absint',
|
752 |
+
),
|
753 |
+
'cover_min_width' => array(
|
754 |
+
'sanitize' => 'absint',
|
755 |
+
),
|
756 |
+
'enable_reset_password_limit' => array(
|
757 |
+
'sanitize' => 'bool',
|
758 |
+
),
|
759 |
+
'reset_password_limit_number' => array(
|
760 |
+
'sanitize' => 'absint',
|
761 |
+
),
|
762 |
+
'blocked_emails' => array(
|
763 |
+
'sanitize' => 'textarea',
|
764 |
+
),
|
765 |
+
'blocked_words' => array(
|
766 |
+
'sanitize' => 'textarea',
|
767 |
+
),
|
768 |
+
'allowed_choice_callbacks' => array(
|
769 |
+
'sanitize' => 'textarea',
|
770 |
+
),
|
771 |
+
'allow_url_redirect_confirm' => array(
|
772 |
+
'sanitize' => 'bool',
|
773 |
+
),
|
774 |
+
'admin_email' => array(
|
775 |
+
'sanitize' => 'text',
|
776 |
+
),
|
777 |
+
'mail_from' => array(
|
778 |
+
'sanitize' => 'text',
|
779 |
+
),
|
780 |
+
'mail_from_addr' => array(
|
781 |
+
'sanitize' => 'text',
|
782 |
+
),
|
783 |
+
'email_html' => array(
|
784 |
+
'sanitize' => 'bool',
|
785 |
+
),
|
786 |
+
'profile_template' => array(
|
787 |
+
'sanitize' => 'text',
|
788 |
+
),
|
789 |
+
'profile_max_width' => array(
|
790 |
+
'sanitize' => 'text',
|
791 |
+
),
|
792 |
+
'profile_area_max_width' => array(
|
793 |
+
'sanitize' => 'text',
|
794 |
+
),
|
795 |
+
'profile_icons' => array(
|
796 |
+
'sanitize' => 'key',
|
797 |
+
),
|
798 |
+
'profile_primary_btn_word' => array(
|
799 |
+
'sanitize' => 'text',
|
800 |
+
),
|
801 |
+
'profile_secondary_btn' => array(
|
802 |
+
'sanitize' => 'bool',
|
803 |
+
),
|
804 |
+
'profile_secondary_btn_word' => array(
|
805 |
+
'sanitize' => 'text',
|
806 |
+
),
|
807 |
+
'default_avatar' => array(
|
808 |
+
'sanitize' => 'url',
|
809 |
+
),
|
810 |
+
'default_cover' => array(
|
811 |
+
'sanitize' => 'url',
|
812 |
+
),
|
813 |
+
'disable_profile_photo_upload' => array(
|
814 |
+
'sanitize' => 'bool',
|
815 |
+
),
|
816 |
+
'profile_photosize' => array(
|
817 |
+
'sanitize' => array( UM()->admin(), 'sanitize_photosize' ),
|
818 |
+
),
|
819 |
+
'profile_cover_enabled' => array(
|
820 |
+
'sanitize' => 'bool',
|
821 |
+
),
|
822 |
+
'profile_coversize' => array(
|
823 |
+
'sanitize' => array( UM()->admin(), 'sanitize_cover_photosize' ),
|
824 |
+
),
|
825 |
+
'profile_cover_ratio' => array(
|
826 |
+
'sanitize' => 'text',
|
827 |
+
),
|
828 |
+
'profile_show_metaicon' => array(
|
829 |
+
'sanitize' => 'bool',
|
830 |
+
),
|
831 |
+
'profile_show_name' => array(
|
832 |
+
'sanitize' => 'bool',
|
833 |
+
),
|
834 |
+
'profile_show_social_links' => array(
|
835 |
+
'sanitize' => 'bool',
|
836 |
+
),
|
837 |
+
'profile_show_bio' => array(
|
838 |
+
'sanitize' => 'bool',
|
839 |
+
),
|
840 |
+
'profile_show_html_bio' => array(
|
841 |
+
'sanitize' => 'bool',
|
842 |
+
),
|
843 |
+
'profile_bio_maxchars' => array(
|
844 |
+
'sanitize' => 'absint',
|
845 |
+
),
|
846 |
+
'profile_header_menu' => array(
|
847 |
+
'sanitize' => 'key',
|
848 |
+
),
|
849 |
+
'profile_empty_text' => array(
|
850 |
+
'sanitize' => 'bool',
|
851 |
+
),
|
852 |
+
'profile_empty_text_emo' => array(
|
853 |
+
'sanitize' => 'bool',
|
854 |
+
),
|
855 |
+
'register_template' => array(
|
856 |
+
'sanitize' => 'text',
|
857 |
+
),
|
858 |
+
'register_max_width' => array(
|
859 |
+
'sanitize' => 'text',
|
860 |
+
),
|
861 |
+
'register_align' => array(
|
862 |
+
'sanitize' => 'key',
|
863 |
+
),
|
864 |
+
'register_icons' => array(
|
865 |
+
'sanitize' => 'key',
|
866 |
+
),
|
867 |
+
'register_primary_btn_word' => array(
|
868 |
+
'sanitize' => 'text',
|
869 |
+
),
|
870 |
+
'register_secondary_btn' => array(
|
871 |
+
'sanitize' => 'bool',
|
872 |
+
),
|
873 |
+
'register_secondary_btn_word' => array(
|
874 |
+
'sanitize' => 'text',
|
875 |
+
),
|
876 |
+
'register_secondary_btn_url' => array(
|
877 |
+
'sanitize' => 'url',
|
878 |
+
),
|
879 |
+
'register_role' => array(
|
880 |
+
'sanitize' => 'key',
|
881 |
+
),
|
882 |
+
'login_template' => array(
|
883 |
+
'sanitize' => 'text',
|
884 |
+
),
|
885 |
+
'login_max_width' => array(
|
886 |
+
'sanitize' => 'text',
|
887 |
+
),
|
888 |
+
'login_align' => array(
|
889 |
+
'sanitize' => 'key',
|
890 |
+
),
|
891 |
+
'login_icons' => array(
|
892 |
+
'sanitize' => 'key',
|
893 |
+
),
|
894 |
+
'login_primary_btn_word' => array(
|
895 |
+
'sanitize' => 'text',
|
896 |
+
),
|
897 |
+
'login_secondary_btn' => array(
|
898 |
+
'sanitize' => 'bool',
|
899 |
+
),
|
900 |
+
'login_secondary_btn_word' => array(
|
901 |
+
'sanitize' => 'text',
|
902 |
+
),
|
903 |
+
'login_secondary_btn_url' => array(
|
904 |
+
'sanitize' => 'url',
|
905 |
+
),
|
906 |
+
'login_forgot_pass_link' => array(
|
907 |
+
'sanitize' => 'bool',
|
908 |
+
),
|
909 |
+
'login_show_rememberme' => array(
|
910 |
+
'sanitize' => 'bool',
|
911 |
+
),
|
912 |
+
'form_asterisk' => array(
|
913 |
+
'sanitize' => 'bool',
|
914 |
+
),
|
915 |
+
'profile_title' => array(
|
916 |
+
'sanitize' => 'text',
|
917 |
+
),
|
918 |
+
'profile_desc' => array(
|
919 |
+
'sanitize' => 'textarea',
|
920 |
+
),
|
921 |
+
'um_profile_object_cache_stop' => array(
|
922 |
+
'sanitize' => 'bool',
|
923 |
+
),
|
924 |
+
'enable_blocks' => array(
|
925 |
+
'sanitize' => 'bool',
|
926 |
+
),
|
927 |
+
'rest_api_version' => array(
|
928 |
+
'sanitize' => 'text',
|
929 |
+
),
|
930 |
+
'uninstall_on_delete' => array(
|
931 |
+
'sanitize' => 'bool',
|
932 |
+
),
|
933 |
+
)
|
934 |
+
);
|
935 |
+
|
936 |
+
$this->settings_map = apply_filters( 'um_settings_map', $settings_map );
|
937 |
+
|
938 |
+
/**
|
939 |
+
* UM hook
|
940 |
+
*
|
941 |
+
* @type filter
|
942 |
+
* @title um_settings_structure
|
943 |
+
* @description Extend UM Settings
|
944 |
+
* @input_vars
|
945 |
+
* [{"var":"$settings","type":"array","desc":"UM Settings"}]
|
946 |
+
* @change_log
|
947 |
+
* ["Since: 2.0"]
|
948 |
+
* @usage add_filter( 'um_settings_structure', 'function_name', 10, 1 );
|
949 |
+
* @example
|
950 |
+
* <?php
|
951 |
+
* add_filter( 'um_settings_structure', 'my_settings_structure', 10, 1 );
|
952 |
+
* function my_settings_structure( $settings ) {
|
953 |
+
* // your code here
|
954 |
+
* return $settings;
|
955 |
+
* }
|
956 |
+
* ?>
|
957 |
+
*/
|
958 |
+
$this->settings_structure = apply_filters(
|
959 |
+
'um_settings_structure',
|
960 |
+
array(
|
961 |
+
'' => array(
|
962 |
+
'title' => __( 'General', 'ultimate-member' ),
|
963 |
+
'sections' => array(
|
964 |
+
'' => array(
|
965 |
+
'title' => __( 'Pages', 'ultimate-member' ),
|
966 |
+
'fields' => $general_pages_fields,
|
967 |
+
),
|
968 |
+
'users' => array(
|
969 |
+
'title' => __( 'Users', 'ultimate-member' ),
|
970 |
+
'fields' => array(
|
971 |
+
array(
|
972 |
+
'id' => 'permalink_base',
|
973 |
+
'type' => 'select',
|
974 |
+
'size' => 'small',
|
975 |
+
'label' => __( 'Profile Permalink Base', 'ultimate-member' ),
|
976 |
+
// translators: %s: Profile page URL
|
977 |
+
'tooltip' => sprintf( __( 'Here you can control the permalink structure of the user profile URL globally e.g. %s<strong>username</strong>/', 'ultimate-member' ), trailingslashit( um_get_core_page( 'user' ) ) ),
|
978 |
+
'options' => array(
|
979 |
+
'user_login' => __( 'Username', 'ultimate-member' ),
|
980 |
+
'name' => __( 'First and Last Name with \'.\'', 'ultimate-member' ),
|
981 |
+
'name_dash' => __( 'First and Last Name with \'-\'', 'ultimate-member' ),
|
982 |
+
'name_plus' => __( 'First and Last Name with \'+\'', 'ultimate-member' ),
|
983 |
+
'user_id' => __( 'User ID', 'ultimate-member' ),
|
984 |
+
),
|
985 |
+
'placeholder' => __( 'Select...', 'ultimate-member' ),
|
986 |
+
),
|
987 |
+
array(
|
988 |
+
'id' => 'display_name',
|
989 |
+
'type' => 'select',
|
990 |
+
'size' => 'medium',
|
991 |
+
'label' => __( 'User Display Name', 'ultimate-member' ),
|
992 |
+
'tooltip' => __( 'This is the name that will be displayed for users on the front end of your site. Default setting uses first/last name as display name if it exists', 'ultimate-member' ),
|
993 |
+
'options' => array(
|
994 |
+
'default' => __( 'Default WP Display Name', 'ultimate-member' ),
|
995 |
+
'nickname' => __( 'Nickname', 'ultimate-member' ),
|
996 |
+
'username' => __( 'Username', 'ultimate-member' ),
|
997 |
+
'full_name' => __( 'First name & last name', 'ultimate-member' ),
|
998 |
+
'sur_name' => __( 'Last name & first name', 'ultimate-member' ),
|
999 |
+
'initial_name' => __( 'First name & first initial of last name', 'ultimate-member' ),
|
1000 |
+
'initial_name_f' => __( 'First initial of first name & last name', 'ultimate-member' ),
|
1001 |
+
'first_name' => __( 'First name only', 'ultimate-member' ),
|
1002 |
+
'field' => __( 'Custom field(s)', 'ultimate-member' ),
|
1003 |
+
),
|
1004 |
+
'placeholder' => __( 'Select...', 'ultimate-member' ),
|
1005 |
+
),
|
1006 |
+
array(
|
1007 |
+
'id' => 'display_name_field',
|
1008 |
+
'type' => 'text',
|
1009 |
+
'label' => __( 'Display Name Custom Field(s)', 'ultimate-member' ),
|
1010 |
+
'tooltip' => __( 'Specify the custom field meta key or custom fields seperated by comma that you want to use to display users name on the frontend of your site', 'ultimate-member' ),
|
1011 |
+
'conditional' => array( 'display_name', '=', 'field' ),
|
1012 |
+
),
|
1013 |
+
array(
|
1014 |
+
'id' => 'author_redirect',
|
1015 |
+
'type' => 'checkbox',
|
1016 |
+
'label' => __( 'Automatically redirect author page to their profile?', 'ultimate-member' ),
|
1017 |
+
'tooltip' => __( 'If enabled, author pages will automatically redirect to the user\'s profile page', 'ultimate-member' ),
|
1018 |
+
),
|
1019 |
+
array(
|
1020 |
+
'id' => 'members_page',
|
1021 |
+
'type' => 'checkbox',
|
1022 |
+
'label' => __( 'Enable Members Directory', 'ultimate-member' ),
|
1023 |
+
'tooltip' => __( 'Control whether to enable or disable member directories on this site', 'ultimate-member' ),
|
1024 |
+
),
|
1025 |
+
array(
|
1026 |
+
'id' => 'use_gravatars',
|
1027 |
+
'type' => 'checkbox',
|
1028 |
+
'label' => __( 'Use Gravatars?', 'ultimate-member' ),
|
1029 |
+
'tooltip' => __( 'Do you want to use gravatars instead of the default plugin profile photo (If the user did not upload a custom profile photo / avatar)', 'ultimate-member' ),
|
1030 |
+
),
|
1031 |
+
array(
|
1032 |
+
'id' => 'use_um_gravatar_default_builtin_image',
|
1033 |
+
'type' => 'select',
|
1034 |
+
'label' => __( 'Use Gravatar builtin image', 'ultimate-member' ),
|
1035 |
+
'tooltip' => __( 'Gravatar has a number of built in options which you can also use as defaults', 'ultimate-member' ),
|
1036 |
+
'options' => array(
|
1037 |
+
'default' => __( 'Default', 'ultimate-member' ),
|
1038 |
+
'404' => __( '404 ( File Not Found response )', 'ultimate-member' ),
|
1039 |
+
'mm' => __( 'Mystery Man', 'ultimate-member' ),
|
1040 |
+
'identicon' => __( 'Identicon', 'ultimate-member' ),
|
1041 |
+
'monsterid' => __( 'Monsterid', 'ultimate-member' ),
|
1042 |
+
'wavatar' => __( 'Wavatar', 'ultimate-member' ),
|
1043 |
+
'retro' => __( 'Retro', 'ultimate-member' ),
|
1044 |
+
'blank' => __( 'Blank ( a transparent PNG image )', 'ultimate-member' ),
|
1045 |
+
),
|
1046 |
+
'conditional' => array( 'use_gravatars', '=', 1 ),
|
1047 |
+
'size' => 'medium',
|
1048 |
+
),
|
1049 |
+
array(
|
1050 |
+
'id' => 'use_um_gravatar_default_image',
|
1051 |
+
'type' => 'checkbox',
|
1052 |
+
'label' => __( 'Use Default plugin avatar as Gravatar\'s Default avatar', 'ultimate-member' ),
|
1053 |
+
'tooltip' => __( 'Do you want to use the plugin default avatar instead of the gravatar default photo (If the user did not upload a custom profile photo / avatar)', 'ultimate-member' ),
|
1054 |
+
'conditional' => array( 'use_um_gravatar_default_builtin_image', '=', 'default' ),
|
1055 |
+
),
|
1056 |
+
array(
|
1057 |
+
'id' => 'require_strongpass',
|
1058 |
+
'type' => 'checkbox',
|
1059 |
+
'label' => __( 'Require a strong password?', 'ultimate-member' ),
|
1060 |
+
'tooltip' => __( 'Enable or disable a strong password rules common for all Ultimate Member forms.', 'ultimate-member' ),
|
1061 |
+
),
|
1062 |
+
array(
|
1063 |
+
'id' => 'password_min_chars',
|
1064 |
+
'type' => 'number',
|
1065 |
+
'label' => __( 'Password minimum length', 'ultimate-member' ),
|
1066 |
+
'tooltip' => __( 'If you want to enable a minimum number of characters to be in password. User password field in the UM forms has own settings for that. Leave empty to use default value 8', 'ultimate-member' ),
|
1067 |
+
'size' => 'small',
|
1068 |
+
),
|
1069 |
+
array(
|
1070 |
+
'id' => 'password_max_chars',
|
1071 |
+
'type' => 'number',
|
1072 |
+
'label' => __( 'Password maximum length', 'ultimate-member' ),
|
1073 |
+
'tooltip' => __( 'If you want to enable a maximum number of characters to be in password. User password field in the UM forms has own settings for that. Leave empty to use default value 30', 'ultimate-member' ),
|
1074 |
+
'size' => 'small',
|
1075 |
+
),
|
1076 |
+
array(
|
1077 |
+
'id' => 'profile_noindex',
|
1078 |
+
'type' => 'select',
|
1079 |
+
'size' => 'small',
|
1080 |
+
'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ),
|
1081 |
+
'tooltip' => __( 'Hides the profile page for robots. This setting can be overridden by individual role settings.', 'ultimate-member' ),
|
1082 |
+
'options' => array(
|
1083 |
+
'0' => __( 'No', 'ultimate-member' ),
|
1084 |
+
'1' => __( 'Yes', 'ultimate-member' ),
|
1085 |
+
),
|
1086 |
+
),
|
1087 |
+
array(
|
1088 |
+
'id' => 'activation_link_expiry_time',
|
1089 |
+
'type' => 'number',
|
1090 |
+
'label' => __( 'Activation link lifetime', 'ultimate-member' ),
|
1091 |
+
'tooltip' => __( 'How long does an activation link live in seconds? Leave empty for endless links.', 'ultimate-member' ),
|
1092 |
+
'size' => 'small',
|
1093 |
+
),
|
1094 |
+
),
|
1095 |
+
),
|
1096 |
+
'account' => array(
|
1097 |
+
'title' => __( 'Account', 'ultimate-member' ),
|
1098 |
+
'fields' => array(
|
1099 |
+
array(
|
1100 |
+
'id' => 'account_tab_password',
|
1101 |
+
'type' => 'checkbox',
|
1102 |
+
'label' => __( 'Password Account Tab', 'ultimate-member' ),
|
1103 |
+
'tooltip' => __( 'Enable/disable the Password account tab in account page', 'ultimate-member' ),
|
1104 |
+
),
|
1105 |
+
array(
|
1106 |
+
'id' => 'account_tab_privacy',
|
1107 |
+
'type' => 'checkbox',
|
1108 |
+
'label' => __( 'Privacy Account Tab', 'ultimate-member' ),
|
1109 |
+
'tooltip' => __( 'Enable/disable the Privacy account tab in account page', 'ultimate-member' ),
|
1110 |
+
),
|
1111 |
+
array(
|
1112 |
+
'id' => 'account_tab_notifications',
|
1113 |
+
'type' => 'checkbox',
|
1114 |
+
'label' => __( 'Notifications Account Tab', 'ultimate-member' ),
|
1115 |
+
'tooltip' => __( 'Enable/disable the Notifications account tab in account page', 'ultimate-member' ),
|
1116 |
+
),
|
1117 |
+
array(
|
1118 |
+
'id' => 'account_tab_delete',
|
1119 |
+
'type' => 'checkbox',
|
1120 |
+
'label' => __( 'Delete Account Tab', 'ultimate-member' ),
|
1121 |
+
'tooltip' => __( 'Enable/disable the Delete account tab in account page', 'ultimate-member' ),
|
1122 |
+
),
|
1123 |
+
array(
|
1124 |
+
'id' => 'delete_account_text',
|
1125 |
+
'type' => 'textarea', // bug with wp 4.4? should be editor
|
1126 |
+
'label' => __( 'Account Deletion Custom Text', 'ultimate-member' ),
|
1127 |
+
'tooltip' => __( 'This is custom text that will be displayed to users before they delete their accounts from your site when password is required.', 'ultimate-member' ),
|
1128 |
+
'args' => array(
|
1129 |
+
'textarea_rows' => 6,
|
1130 |
+
),
|
1131 |
+
),
|
1132 |
+
array(
|
1133 |
+
'id' => 'delete_account_no_pass_required_text',
|
1134 |
+
'type' => 'textarea',
|
1135 |
+
'label' => __( 'Account Deletion without password Custom Text', 'ultimate-member' ),
|
1136 |
+
'tooltip' => __( 'This is custom text that will be displayed to users before they delete their accounts from your site when password isn\'t required.', 'ultimate-member' ),
|
1137 |
+
'args' => array(
|
1138 |
+
'textarea_rows' => 6,
|
1139 |
+
),
|
1140 |
+
),
|
1141 |
+
array(
|
1142 |
+
'id' => 'account_name',
|
1143 |
+
'type' => 'checkbox',
|
1144 |
+
'label' => __( 'Add a First & Last Name fields', 'ultimate-member' ),
|
1145 |
+
'tooltip' => __( 'Whether to enable these fields on the user account page by default or hide them.', 'ultimate-member' ),
|
1146 |
+
),
|
1147 |
+
array(
|
1148 |
+
'id' => 'account_name_disable',
|
1149 |
+
'type' => 'checkbox',
|
1150 |
+
'label' => __( 'Disable First & Last Name fields', 'ultimate-member' ),
|
1151 |
+
'tooltip' => __( 'Whether to allow users changing their first and last name in account page.', 'ultimate-member' ),
|
1152 |
+
'conditional' => array( 'account_name', '=', '1' ),
|
1153 |
+
),
|
1154 |
+
array(
|
1155 |
+
'id' => 'account_name_require',
|
1156 |
+
'type' => 'checkbox',
|
1157 |
+
'label' => __( 'Require First & Last Name', 'ultimate-member' ),
|
1158 |
+
'tooltip' => __( 'Require first and last name?', 'ultimate-member' ),
|
1159 |
+
'conditional' => array( 'account_name', '=', '1' ),
|
1160 |
+
),
|
1161 |
+
array(
|
1162 |
+
'id' => 'account_email',
|
1163 |
+
'type' => 'checkbox',
|
1164 |
+
'label' => __( 'Allow users to change e-mail', 'ultimate-member' ),
|
1165 |
+
'tooltip' => __( 'Whether to allow users changing their email in account page.', 'ultimate-member' ),
|
1166 |
+
),
|
1167 |
+
array(
|
1168 |
+
'id' => 'account_general_password',
|
1169 |
+
'type' => 'checkbox',
|
1170 |
+
'label' => __( 'Password is required?', 'ultimate-member' ),
|
1171 |
+
'tooltip' => __( 'Password is required to save account data.', 'ultimate-member' ),
|
1172 |
+
),
|
1173 |
+
array(
|
1174 |
+
'id' => 'account_hide_in_directory',
|
1175 |
+
'type' => 'checkbox',
|
1176 |
+
'label' => __( 'Allow users to hide their profiles from directory', 'ultimate-member' ),
|
1177 |
+
'tooltip' => __( 'Whether to allow users changing their profile visibility from member directory in account page.', 'ultimate-member' ),
|
1178 |
+
'conditional' => array( 'account_tab_privacy', '=', '1' ),
|
1179 |
+
),
|
1180 |
+
array(
|
1181 |
+
'id' => 'account_hide_in_directory_default',
|
1182 |
+
'type' => 'select',
|
1183 |
+
'label' => __( 'Hide profiles from directory by default', 'ultimate-member' ),
|
1184 |
+
'tooltip' => __( 'Set default value for the "Hide my profile from directory" option', 'ultimate-member' ),
|
1185 |
+
'options' => array(
|
1186 |
+
'No' => __( 'No', 'ultimate-member' ),
|
1187 |
+
'Yes' => __( 'Yes', 'ultimate-member' ),
|
1188 |
+
),
|
1189 |
+
'size' => 'small',
|
1190 |
+
'conditional' => array( 'account_hide_in_directory', '=', '1' ),
|
1191 |
+
),
|
1192 |
+
),
|
1193 |
+
),
|
1194 |
+
'uploads' => array(
|
1195 |
+
'title' => __( 'Uploads', 'ultimate-member' ),
|
1196 |
+
'fields' => array(
|
1197 |
+
array(
|
1198 |
+
'id' => 'profile_photo_max_size',
|
1199 |
+
'type' => 'text',
|
1200 |
+
'size' => 'small',
|
1201 |
+
'label' => __( 'Profile Photo Maximum File Size (bytes)', 'ultimate-member' ),
|
1202 |
+
'tooltip' => __( 'Sets a maximum size for the uploaded photo', 'ultimate-member' ),
|
1203 |
+
),
|
1204 |
+
array(
|
1205 |
+
'id' => 'cover_photo_max_size',
|
1206 |
+
'type' => 'text',
|
1207 |
+
'size' => 'small',
|
1208 |
+
'label' => __( 'Cover Photo Maximum File Size (bytes)', 'ultimate-member' ),
|
1209 |
+
'tooltip' => __( 'Sets a maximum size for the uploaded cover', 'ultimate-member' ),
|
1210 |
+
),
|
1211 |
+
array(
|
1212 |
+
'id' => 'photo_thumb_sizes',
|
1213 |
+
'type' => 'multi_text',
|
1214 |
+
'size' => 'small',
|
1215 |
+
'label' => __( 'Profile Photo Thumbnail Sizes (px)', 'ultimate-member' ),
|
1216 |
+
'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each profile photo upload.', 'ultimate-member' ),
|
1217 |
+
'validate' => 'numeric',
|
1218 |
+
'add_text' => __( 'Add New Size', 'ultimate-member' ),
|
1219 |
+
'show_default_number' => 1,
|
1220 |
+
),
|
1221 |
+
array(
|
1222 |
+
'id' => 'cover_thumb_sizes',
|
1223 |
+
'type' => 'multi_text',
|
1224 |
+
'size' => 'small',
|
1225 |
+
'label' => __( 'Cover Photo Thumbnail Sizes (px)', 'ultimate-member' ),
|
1226 |
+
'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each cover photo upload.', 'ultimate-member' ),
|
1227 |
+
'validate' => 'numeric',
|
1228 |
+
'add_text' => __( 'Add New Size', 'ultimate-member' ),
|
1229 |
+
'show_default_number' => 1,
|
1230 |
+
),
|
1231 |
+
array(
|
1232 |
+
'id' => 'image_orientation_by_exif',
|
1233 |
+
'type' => 'checkbox',
|
1234 |
+
'label' => __( 'Change image orientation', 'ultimate-member' ),
|
1235 |
+
'tooltip' => __( 'Rotate image to and use orientation by the camera EXIF data.', 'ultimate-member' ),
|
1236 |
+
),
|
1237 |
+
array(
|
1238 |
+
'id' => 'image_compression',
|
1239 |
+
'type' => 'text',
|
1240 |
+
'size' => 'small',
|
1241 |
+
'label' => __( 'Image Quality', 'ultimate-member' ),
|
1242 |
+
'tooltip' => __( 'Quality is used to determine quality of image uploads, and ranges from 0 (worst quality, smaller file) to 100 (best quality, biggest file). The default range is 60.', 'ultimate-member' ),
|
1243 |
+
),
|
1244 |
+
|
1245 |
+
array(
|
1246 |
+
'id' => 'image_max_width',
|
1247 |
+
'type' => 'text',
|
1248 |
+
'size' => 'small',
|
1249 |
+
'label' => __( 'Image Upload Maximum Width (px)', 'ultimate-member' ),
|
1250 |
+
'tooltip' => __( 'Any image upload above this width will be resized to this limit automatically.', 'ultimate-member' ),
|
1251 |
+
),
|
1252 |
+
|
1253 |
+
array(
|
1254 |
+
'id' => 'cover_min_width',
|
1255 |
+
'type' => 'text',
|
1256 |
+
'size' => 'small',
|
1257 |
+
'label' => __( 'Cover Photo Minimum Width (px)', 'ultimate-member' ),
|
1258 |
+
'tooltip' => __( 'This will be the minimum width for cover photo uploads', 'ultimate-member' ),
|
1259 |
+
),
|
1260 |
+
),
|
1261 |
+
),
|
1262 |
+
),
|
1263 |
+
),
|
1264 |
+
'access' => array(
|
1265 |
+
'title' => __( 'Access', 'ultimate-member' ),
|
1266 |
+
'sections' => array(
|
1267 |
+
'' => array(
|
1268 |
+
'title' => __( 'Restriction Content', 'ultimate-member' ),
|
1269 |
+
'fields' => $access_fields,
|
1270 |
+
),
|
1271 |
+
'other' => array(
|
1272 |
+
'title' => __( 'Other', 'ultimate-member' ),
|
1273 |
+
'fields' => array(
|
1274 |
+
array(
|
1275 |
+
'id' => 'enable_reset_password_limit',
|
1276 |
+
'type' => 'checkbox',
|
1277 |
+
'label' => __( 'Enable the Reset Password Limit?', 'ultimate-member' ),
|
1278 |
+
),
|
1279 |
+
array(
|
1280 |
+
'id' => 'reset_password_limit_number',
|
1281 |
+
'type' => 'text',
|
1282 |
+
'label' => __( 'Reset Password Limit', 'ultimate-member' ),
|
1283 |
+
'tooltip' => __( 'Set the maximum reset password limit. If reached the maximum limit, user will be locked from using this.', 'ultimate-member' ),
|
1284 |
+
'validate' => 'numeric',
|
1285 |
+
'conditional' => array( 'enable_reset_password_limit', '=', 1 ),
|
1286 |
+
'size' => 'small',
|
1287 |
+
),
|
1288 |
+
array(
|
1289 |
+
'id' => 'blocked_emails',
|
1290 |
+
'type' => 'textarea',
|
1291 |
+
'label' => __( 'Blocked Email Addresses (Enter one email per line)', 'ultimate-member' ),
|
1292 |
+
'tooltip' => __( 'This will block the specified e-mail addresses from being able to sign up or sign in to your site. To block an entire domain, use something like *@domain.com', 'ultimate-member' ),
|
1293 |
+
),
|
1294 |
+
array(
|
1295 |
+
'id' => 'blocked_words',
|
1296 |
+
'type' => 'textarea',
|
1297 |
+
'label' => __( 'Blacklist Words (Enter one word per line)', 'ultimate-member' ),
|
1298 |
+
'tooltip' => __( 'This option lets you specify blacklist of words to prevent anyone from signing up with such a word as their username', 'ultimate-member' ),
|
1299 |
+
),
|
1300 |
+
array(
|
1301 |
+
'id' => 'allowed_choice_callbacks',
|
1302 |
+
'type' => 'textarea',
|
1303 |
+
'label' => __( 'Allowed Choice Callbacks (Enter one PHP function per line)', 'ultimate-member' ),
|
1304 |
+
'tooltip' => __( 'This option lets you specify the choice callback functions to prevent anyone from using 3rd-party functions that may put your site at risk.', 'ultimate-member' ),
|
1305 |
+
),
|
1306 |
+
array(
|
1307 |
+
'id' => 'allow_url_redirect_confirm',
|
1308 |
+
'type' => 'checkbox',
|
1309 |
+
'label' => __( 'Allow external link redirect confirm', 'ultimate-member' ),
|
1310 |
+
'tooltip' => __( 'Using JS.confirm alert when you go to an external link.', 'ultimate-member' ),
|
1311 |
+
),
|
1312 |
+
),
|
1313 |
+
),
|
1314 |
+
),
|
1315 |
+
),
|
1316 |
+
'email' => array(
|
1317 |
+
'title' => __( 'Email', 'ultimate-member' ),
|
1318 |
+
'fields' => array(
|
1319 |
+
array(
|
1320 |
+
'id' => 'admin_email',
|
1321 |
+
'type' => 'text',
|
1322 |
+
'label' => __( 'Admin E-mail Address', 'ultimate-member' ),
|
1323 |
+
'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
|
1324 |
+
),
|
1325 |
+
array(
|
1326 |
+
'id' => 'mail_from',
|
1327 |
+
'type' => 'text',
|
1328 |
+
'label' => __( 'Mail appears from', 'ultimate-member' ),
|
1329 |
+
'tooltip' => __( 'e.g. Site Name', 'ultimate-member' ),
|
1330 |
+
),
|
1331 |
+
array(
|
1332 |
+
'id' => 'mail_from_addr',
|
1333 |
+
'type' => 'text',
|
1334 |
+
'label' => __( 'Mail appears from address', 'ultimate-member' ),
|
1335 |
+
'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
|
1336 |
+
),
|
1337 |
+
array(
|
1338 |
+
'id' => 'email_html',
|
1339 |
+
'type' => 'checkbox',
|
1340 |
+
'label' => __( 'Use HTML for E-mails?', 'ultimate-member' ),
|
1341 |
+
'tooltip' => __( 'If you plan use e-mails with HTML, please make sure that this option is enabled. Otherwise, HTML will be displayed as plain text.', 'ultimate-member' ),
|
1342 |
+
),
|
1343 |
+
),
|
1344 |
+
),
|
1345 |
+
'appearance' => array(
|
1346 |
+
'title' => __( 'Appearance', 'ultimate-member' ),
|
1347 |
+
'sections' => array(
|
1348 |
+
'' => array(
|
1349 |
+
'title' => __( 'Profile', 'ultimate-member' ),
|
1350 |
+
'fields' => array(
|
1351 |
+
array(
|
1352 |
+
'id' => 'profile_template',
|
1353 |
+
'type' => 'select',
|
1354 |
+
'label' => __( 'Profile Default Template', 'ultimate-member' ),
|
1355 |
+
'tooltip' => __( 'This will be the default template to output profile', 'ultimate-member' ),
|
1356 |
+
'default' => um_get_metadefault( 'profile_template' ),
|
1357 |
+
'options' => UM()->shortcodes()->get_templates( 'profile' ),
|
1358 |
+
'size' => 'small',
|
1359 |
+
),
|
1360 |
+
array(
|
1361 |
+
'id' => 'profile_max_width',
|
1362 |
+
'type' => 'text',
|
1363 |
+
'label' => __( 'Profile Maximum Width', 'ultimate-member' ),
|
1364 |
+
'default' => um_get_metadefault( 'profile_max_width' ),
|
1365 |
+
'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
|
1366 |
+
'size' => 'small',
|
1367 |
+
),
|
1368 |
+
array(
|
1369 |
+
'id' => 'profile_area_max_width',
|
1370 |
+
'type' => 'text',
|
1371 |
+
'label' => __( 'Profile Area Maximum Width', 'ultimate-member' ),
|
1372 |
+
'default' => um_get_metadefault( 'profile_area_max_width' ),
|
1373 |
+
'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ),
|
1374 |
+
'size' => 'small',
|
1375 |
+
),
|
1376 |
+
array(
|
1377 |
+
'id' => 'profile_icons',
|
1378 |
+
'type' => 'select',
|
1379 |
+
'label' => __( 'Profile Field Icons', 'ultimate-member' ),
|
1380 |
+
'tooltip' => __( 'This is applicable for edit mode only', 'ultimate-member' ),
|
1381 |
+
'default' => um_get_metadefault( 'profile_icons' ),
|
1382 |
+
'options' => array(
|
1383 |
+
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
1384 |
+
'label' => __( 'Show with label', 'ultimate-member' ),
|
1385 |
+
'off' => __( 'Turn off', 'ultimate-member' ),
|
1386 |
+
),
|
1387 |
+
'size' => 'small',
|
1388 |
+
),
|
1389 |
+
array(
|
1390 |
+
'id' => 'profile_primary_btn_word',
|
1391 |
+
'type' => 'text',
|
1392 |
+
'label' => __( 'Profile Primary Button Text', 'ultimate-member' ),
|
1393 |
+
'default' => um_get_metadefault( 'profile_primary_btn_word' ),
|
1394 |
+
'tooltip' => __( 'The text that is used for updating profile button', 'ultimate-member' ),
|
1395 |
+
'size' => 'medium',
|
1396 |
+
),
|
1397 |
+
array(
|
1398 |
+
'id' => 'profile_secondary_btn',
|
1399 |
+
'type' => 'checkbox',
|
1400 |
+
'label' => __( 'Profile Secondary Button', 'ultimate-member' ),
|
1401 |
+
'default' => um_get_metadefault( 'profile_secondary_btn' ),
|
1402 |
+
'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
|
1403 |
+
),
|
1404 |
+
array(
|
1405 |
+
'id' => 'profile_secondary_btn_word',
|
1406 |
+
'type' => 'text',
|
1407 |
+
'label' => __( 'Profile Secondary Button Text', 'ultimate-member' ),
|
1408 |
+
'default' => um_get_metadefault( 'profile_secondary_btn_word' ),
|
1409 |
+
'tooltip' => __( 'The text that is used for cancelling update profile button', 'ultimate-member' ),
|
1410 |
+
'conditional' => array( 'profile_secondary_btn', '=', 1 ),
|
1411 |
+
'size' => 'medium',
|
1412 |
+
),
|
1413 |
+
array(
|
1414 |
+
'id' => 'default_avatar',
|
1415 |
+
'type' => 'media',
|
1416 |
+
'label' => __( 'Default Profile Photo', 'ultimate-member' ),
|
1417 |
+
'tooltip' => __( 'You can change the default profile picture globally here. Please make sure that the photo is 300x300px.', 'ultimate-member' ),
|
1418 |
+
'upload_frame_title' => __( 'Select Default Profile Photo', 'ultimate-member' ),
|
1419 |
+
'default' => array(
|
1420 |
+
'url' => um_url . 'assets/img/default_avatar.jpg',
|
1421 |
+
),
|
1422 |
+
),
|
1423 |
+
array(
|
1424 |
+
'id' => 'default_cover',
|
1425 |
+
'type' => 'media',
|
1426 |
+
'url' => true,
|
1427 |
+
'preview' => false,
|
1428 |
+
'label' => __( 'Default Cover Photo', 'ultimate-member' ),
|
1429 |
+
'tooltip' => __( 'You can change the default cover photo globally here. Please make sure that the default cover is large enough and respects the ratio you are using for cover photos.', 'ultimate-member' ),
|
1430 |
+
'upload_frame_title' => __( 'Select Default Cover Photo', 'ultimate-member' ),
|
1431 |
+
),
|
1432 |
+
array(
|
1433 |
+
'id' => 'disable_profile_photo_upload',
|
1434 |
+
'type' => 'checkbox',
|
1435 |
+
'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ),
|
1436 |
+
'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ),
|
1437 |
+
'default' => um_get_metadefault( 'disable_profile_photo_upload' ),
|
1438 |
+
),
|
1439 |
+
array(
|
1440 |
+
'id' => 'profile_photosize',
|
1441 |
+
'type' => 'select',
|
1442 |
+
'label' => __( 'Profile Photo Size', 'ultimate-member' ),
|
1443 |
+
'default' => um_get_metadefault( 'profile_photosize' ),
|
1444 |
+
'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ),
|
1445 |
+
'tooltip' => __( 'The global default of profile photo size. This can be overridden by individual form settings', 'ultimate-member' ),
|
1446 |
+
'size' => 'small',
|
1447 |
+
),
|
1448 |
+
array(
|
1449 |
+
'id' => 'profile_cover_enabled',
|
1450 |
+
'type' => 'checkbox',
|
1451 |
+
'label' => __( 'Profile Cover Photos', 'ultimate-member' ),
|
1452 |
+
'default' => um_get_metadefault( 'profile_cover_enabled' ),
|
1453 |
+
'tooltip' => __( 'Switch on/off the profile cover photos', 'ultimate-member' ),
|
1454 |
+
),
|
1455 |
+
array(
|
1456 |
+
'id' => 'profile_coversize',
|
1457 |
+
'type' => 'select',
|
1458 |
+
'label' => __( 'Profile Cover Size', 'ultimate-member' ),
|
1459 |
+
'default' => um_get_metadefault( 'profile_coversize' ),
|
1460 |
+
'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ),
|
1461 |
+
'tooltip' => __( 'The global default width of cover photo size. This can be overridden by individual form settings', 'ultimate-member' ),
|
1462 |
+
'conditional' => array( 'profile_cover_enabled', '=', 1 ),
|
1463 |
+
'size' => 'small',
|
1464 |
+
),
|
1465 |
+
array(
|
1466 |
+
'id' => 'profile_cover_ratio',
|
1467 |
+
'type' => 'select',
|
1468 |
+
'label' => __( 'Profile Cover Ratio', 'ultimate-member' ),
|
1469 |
+
'tooltip' => __( 'Choose global ratio for cover photos of profiles', 'ultimate-member' ),
|
1470 |
+
'default' => um_get_metadefault( 'profile_cover_ratio' ),
|
1471 |
+
'options' => array(
|
1472 |
+
'1.6:1' => '1.6:1',
|
1473 |
+
'2.7:1' => '2.7:1',
|
1474 |
+
'2.2:1' => '2.2:1',
|
1475 |
+
'3.2:1' => '3.2:1',
|
1476 |
+
),
|
1477 |
+
'conditional' => array( 'profile_cover_enabled', '=', 1 ),
|
1478 |
+
'size' => 'small',
|
1479 |
+
),
|
1480 |
+
array(
|
1481 |
+
'id' => 'profile_show_metaicon',
|
1482 |
+
'type' => 'checkbox',
|
1483 |
+
'label' => __( 'Profile Header Meta Text Icon', 'ultimate-member' ),
|
1484 |
+
'default' => 0,
|
1485 |
+
'tooltip' => __( 'Display field icons for related user meta fields in header or not', 'ultimate-member' ),
|
1486 |
+
),
|
1487 |
+
array(
|
1488 |
+
'id' => 'profile_show_name',
|
1489 |
+
'type' => 'checkbox',
|
1490 |
+
'label' => __( 'Show display name in profile header', 'ultimate-member' ),
|
1491 |
+
'default' => um_get_metadefault( 'profile_show_name' ),
|
1492 |
+
'tooltip' => __( 'Switch on/off the user name on profile header', 'ultimate-member' ),
|
1493 |
+
),
|
1494 |
+
array(
|
1495 |
+
'id' => 'profile_show_social_links',
|
1496 |
+
'type' => 'checkbox',
|
1497 |
+
'label' => __( 'Show social links in profile header', 'ultimate-member' ),
|
1498 |
+
'default' => um_get_metadefault( 'profile_show_social_links' ),
|
1499 |
+
'tooltip' => __( 'Switch on/off the social links on profile header', 'ultimate-member' ),
|
1500 |
+
),
|
1501 |
+
array(
|
1502 |
+
'id' => 'profile_show_bio',
|
1503 |
+
'type' => 'checkbox',
|
1504 |
+
'label' => __( 'Show user description in header', 'ultimate-member' ),
|
1505 |
+
'default' => um_get_metadefault( 'profile_show_bio' ),
|
1506 |
+
'tooltip' => __( 'Switch on/off the user description on profile header', 'ultimate-member' ),
|
1507 |
+
),
|
1508 |
+
array(
|
1509 |
+
'id' => 'profile_show_html_bio',
|
1510 |
+
'type' => 'checkbox',
|
1511 |
+
'label' => __( 'Enable HTML support for user description', 'ultimate-member' ),
|
1512 |
+
'tooltip' => __( 'Switch on/off to enable/disable support for html tags on user description.', 'ultimate-member' ),
|
1513 |
+
),
|
1514 |
+
array(
|
1515 |
+
'id' => 'profile_bio_maxchars',
|
1516 |
+
'type' => 'text',
|
1517 |
+
'label' => __( 'User description maximum chars', 'ultimate-member' ),
|
1518 |
+
'default' => um_get_metadefault( 'profile_bio_maxchars' ),
|
1519 |
+
'tooltip' => __( 'Maximum number of characters to allow in user description field in header.', 'ultimate-member' ),
|
1520 |
+
'conditional' => array( 'profile_show_bio', '=', 1 ),
|
1521 |
+
'size' => 'small',
|
1522 |
+
),
|
1523 |
+
array(
|
1524 |
+
'id' => 'profile_header_menu',
|
1525 |
+
'type' => 'select',
|
1526 |
+
'label' => __( 'Profile Header Menu Position', 'ultimate-member' ),
|
1527 |
+
'default' => um_get_metadefault( 'profile_header_menu' ),
|
1528 |
+
'tooltip' => __( 'For incompatible themes, please make the menu open from left instead of bottom by default.', 'ultimate-member' ),
|
1529 |
+
'options' => array(
|
1530 |
+
'bc' => __( 'Bottom of Icon', 'ultimate-member' ),
|
1531 |
+
'lc' => __( 'Left of Icon (right for RTL)', 'ultimate-member' ),
|
1532 |
+
),
|
1533 |
+
'size' => 'small',
|
1534 |
+
),
|
1535 |
+
array(
|
1536 |
+
'id' => 'profile_empty_text',
|
1537 |
+
'type' => 'checkbox',
|
1538 |
+
'label' => __( 'Show a custom message if profile is empty', 'ultimate-member' ),
|
1539 |
+
'default' => um_get_metadefault( 'profile_empty_text' ),
|
1540 |
+
'tooltip' => __( 'Switch on/off the custom message that appears when the profile is empty', 'ultimate-member' ),
|
1541 |
+
),
|
1542 |
+
array(
|
1543 |
+
'id' => 'profile_empty_text_emo',
|
1544 |
+
'type' => 'checkbox',
|
1545 |
+
'label' => __( 'Show the emoticon', 'ultimate-member' ),
|
1546 |
+
'default' => um_get_metadefault( 'profile_empty_text_emo' ),
|
1547 |
+
'tooltip' => __( 'Switch on/off the emoticon (sad face) that appears above the message', 'ultimate-member' ),
|
1548 |
+
'conditional' => array( 'profile_empty_text', '=', 1 ),
|
1549 |
+
),
|
1550 |
+
),
|
1551 |
+
),
|
1552 |
+
'profile_menu' => array(
|
1553 |
+
'title' => __( 'Profile Menu', 'ultimate-member' ),
|
1554 |
+
'fields' => $appearances_profile_menu_fields,
|
1555 |
+
),
|
1556 |
+
'registration_form' => array(
|
1557 |
+
'title' => __( 'Registration Form', 'ultimate-member' ),
|
1558 |
+
'fields' => array(
|
1559 |
+
array(
|
1560 |
+
'id' => 'register_template',
|
1561 |
+
'type' => 'select',
|
1562 |
+
'label' => __( 'Registration Default Template', 'ultimate-member' ),
|
1563 |
+
'tooltip' => __( 'This will be the default template to output registration', 'ultimate-member' ),
|
1564 |
+
'default' => um_get_metadefault( 'register_template' ),
|
1565 |
+
'options' => UM()->shortcodes()->get_templates( 'register' ),
|
1566 |
+
'size' => 'small',
|
1567 |
+
),
|
1568 |
+
array(
|
1569 |
+
'id' => 'register_max_width',
|
1570 |
+
'type' => 'text',
|
1571 |
+
'label' => __( 'Registration Maximum Width', 'ultimate-member' ),
|
1572 |
+
'default' => um_get_metadefault( 'register_max_width' ),
|
1573 |
+
'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
|
1574 |
+
'size' => 'small',
|
1575 |
+
),
|
1576 |
+
array(
|
1577 |
+
'id' => 'register_align',
|
1578 |
+
'type' => 'select',
|
1579 |
+
'label' => __( 'Registration Shortcode Alignment', 'ultimate-member' ),
|
1580 |
+
'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
|
1581 |
+
'default' => um_get_metadefault( 'register_align' ),
|
1582 |
+
'options' => array(
|
1583 |
+
'center' => __( 'Centered', 'ultimate-member' ),
|
1584 |
+
'left' => __( 'Left aligned', 'ultimate-member' ),
|
1585 |
+
'right' => __( 'Right aligned', 'ultimate-member' ),
|
1586 |
+
),
|
1587 |
+
'size' => 'small',
|
1588 |
+
),
|
1589 |
+
array(
|
1590 |
+
'id' => 'register_icons',
|
1591 |
+
'type' => 'select',
|
1592 |
+
'label' => __( 'Registration Field Icons', 'ultimate-member' ),
|
1593 |
+
'tooltip' => __( 'This controls the display of field icons in the registration form', 'ultimate-member' ),
|
1594 |
+
'default' => um_get_metadefault( 'register_icons' ),
|
1595 |
+
'options' => array(
|
1596 |
+
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
1597 |
+
'label' => __( 'Show with label', 'ultimate-member' ),
|
1598 |
+
'off' => __( 'Turn off', 'ultimate-member' ),
|
1599 |
+
),
|
1600 |
+
'size' => 'small',
|
1601 |
+
),
|
1602 |
+
array(
|
1603 |
+
'id' => 'register_primary_btn_word',
|
1604 |
+
'type' => 'text',
|
1605 |
+
'label' => __( 'Registration Primary Button Text', 'ultimate-member' ),
|
1606 |
+
'default' => um_get_metadefault( 'register_primary_btn_word' ),
|
1607 |
+
'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
|
1608 |
+
'size' => 'medium',
|
1609 |
+
),
|
1610 |
+
array(
|
1611 |
+
'id' => 'register_secondary_btn',
|
1612 |
+
'type' => 'checkbox',
|
1613 |
+
'label' => __( 'Registration Secondary Button', 'ultimate-member' ),
|
1614 |
+
'default' => 1,
|
1615 |
+
'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
|
1616 |
+
),
|
1617 |
+
array(
|
1618 |
+
'id' => 'register_secondary_btn_word',
|
1619 |
+
'type' => 'text',
|
1620 |
+
'label' => __( 'Registration Secondary Button Text', 'ultimate-member' ),
|
1621 |
+
'default' => um_get_metadefault( 'register_secondary_btn_word' ),
|
1622 |
+
'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
|
1623 |
+
'conditional' => array( 'register_secondary_btn', '=', 1 ),
|
1624 |
+
'size' => 'medium',
|
1625 |
+
),
|
1626 |
+
array(
|
1627 |
+
'id' => 'register_secondary_btn_url',
|
1628 |
+
'type' => 'text',
|
1629 |
+
'label' => __( 'Registration Secondary Button URL', 'ultimate-member' ),
|
1630 |
+
'default' => um_get_metadefault( 'register_secondary_btn_url' ),
|
1631 |
+
'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
|
1632 |
+
'conditional' => array( 'register_secondary_btn', '=', 1 ),
|
1633 |
+
'size' => 'medium',
|
1634 |
+
),
|
1635 |
+
array(
|
1636 |
+
'id' => 'register_role',
|
1637 |
+
'type' => 'select',
|
1638 |
+
'label' => __( 'Registration Default Role', 'ultimate-member' ),
|
1639 |
+
'tooltip' => __( 'This will be the default role assigned to users registering thru registration form', 'ultimate-member' ),
|
1640 |
+
'default' => um_get_metadefault( 'register_role' ),
|
1641 |
+
'options' => UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ),
|
1642 |
+
'size' => 'small',
|
1643 |
+
),
|
1644 |
+
),
|
1645 |
+
),
|
1646 |
+
'login_form' => array(
|
1647 |
+
'title' => __( 'Login Form', 'ultimate-member' ),
|
1648 |
+
'fields' => array(
|
1649 |
+
array(
|
1650 |
+
'id' => 'login_template',
|
1651 |
+
'type' => 'select',
|
1652 |
+
'label' => __( 'Login Default Template', 'ultimate-member' ),
|
1653 |
+
'tooltip' => __( 'This will be the default template to output login', 'ultimate-member' ),
|
1654 |
+
'default' => um_get_metadefault( 'login_template' ),
|
1655 |
+
'options' => UM()->shortcodes()->get_templates( 'login' ),
|
1656 |
+
'size' => 'small',
|
1657 |
+
),
|
1658 |
+
array(
|
1659 |
+
'id' => 'login_max_width',
|
1660 |
+
'type' => 'text',
|
1661 |
+
'label' => __( 'Login Maximum Width', 'ultimate-member' ),
|
1662 |
+
'default' => um_get_metadefault( 'login_max_width' ),
|
1663 |
+
'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
|
1664 |
+
'size' => 'small',
|
1665 |
+
),
|
1666 |
+
array(
|
1667 |
+
'id' => 'login_align',
|
1668 |
+
'type' => 'select',
|
1669 |
+
'label' => __( 'Login Shortcode Alignment', 'ultimate-member' ),
|
1670 |
+
'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
|
1671 |
+
'default' => um_get_metadefault( 'login_align' ),
|
1672 |
+
'options' => array(
|
1673 |
+
'center' => __( 'Centered', 'ultimate-member' ),
|
1674 |
+
'left' => __( 'Left aligned', 'ultimate-member' ),
|
1675 |
+
'right' => __( 'Right aligned', 'ultimate-member' ),
|
1676 |
+
),
|
1677 |
+
'size' => 'small',
|
1678 |
+
),
|
1679 |
+
array(
|
1680 |
+
'id' => 'login_icons',
|
1681 |
+
'type' => 'select',
|
1682 |
+
'label' => __( 'Login Field Icons', 'ultimate-member' ),
|
1683 |
+
'tooltip' => __( 'This controls the display of field icons in the login form', 'ultimate-member' ),
|
1684 |
+
'default' => um_get_metadefault( 'login_icons' ),
|
1685 |
+
'options' => array(
|
1686 |
+
'field' => __( 'Show inside text field', 'ultimate-member' ),
|
1687 |
+
'label' => __( 'Show with label', 'ultimate-member' ),
|
1688 |
+
'off' => __( 'Turn off', 'ultimate-member' ),
|
1689 |
+
),
|
1690 |
+
'size' => 'small',
|
1691 |
+
),
|
1692 |
+
array(
|
1693 |
+
'id' => 'login_primary_btn_word',
|
1694 |
+
'type' => 'text',
|
1695 |
+
'label' => __( 'Login Primary Button Text', 'ultimate-member' ),
|
1696 |
+
'default' => um_get_metadefault( 'login_primary_btn_word' ),
|
1697 |
+
'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
|
1698 |
+
'size' => 'medium',
|
1699 |
+
),
|
1700 |
+
array(
|
1701 |
+
'id' => 'login_secondary_btn',
|
1702 |
+
'type' => 'checkbox',
|
1703 |
+
'label' => __( 'Login Secondary Button', 'ultimate-member' ),
|
1704 |
+
'default' => 1,
|
1705 |
+
'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
|
1706 |
+
),
|
1707 |
+
array(
|
1708 |
+
'id' => 'login_secondary_btn_word',
|
1709 |
+
'type' => 'text',
|
1710 |
+
'label' => __( 'Login Secondary Button Text', 'ultimate-member' ),
|
1711 |
+
'default' => um_get_metadefault( 'login_secondary_btn_word' ),
|
1712 |
+
'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
|
1713 |
+
'conditional' => array( 'login_secondary_btn', '=', 1 ),
|
1714 |
+
'size' => 'medium',
|
1715 |
+
),
|
1716 |
+
array(
|
1717 |
+
'id' => 'login_secondary_btn_url',
|
1718 |
+
'type' => 'text',
|
1719 |
+
'label' => __( 'Login Secondary Button URL', 'ultimate-member' ),
|
1720 |
+
'default' => um_get_metadefault( 'login_secondary_btn_url' ),
|
1721 |
+
'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
|
1722 |
+
'conditional' => array( 'login_secondary_btn', '=', 1 ),
|
1723 |
+
'size' => 'medium',
|
1724 |
+
),
|
1725 |
+
array(
|
1726 |
+
'id' => 'login_forgot_pass_link',
|
1727 |
+
'type' => 'checkbox',
|
1728 |
+
'label' => __( 'Login Forgot Password Link', 'ultimate-member' ),
|
1729 |
+
'default' => 1,
|
1730 |
+
'tooltip' => __( 'Switch on/off the forgot password link in login form', 'ultimate-member' ),
|
1731 |
+
),
|
1732 |
+
array(
|
1733 |
+
'id' => 'login_show_rememberme',
|
1734 |
+
'type' => 'checkbox',
|
1735 |
+
'label' => __( 'Show "Remember Me"', 'ultimate-member' ),
|
1736 |
+
'default' => 1,
|
1737 |
+
'tooltip' => __( 'Allow users to choose If they want to stay signed in even after closing the browser. If you do not show this option, the default will be to not remember login session.', 'ultimate-member' ),
|
1738 |
+
),
|
1739 |
+
),
|
1740 |
+
),
|
1741 |
+
),
|
1742 |
+
),
|
1743 |
+
'extensions' => array(
|
1744 |
+
'title' => __( 'Extensions', 'ultimate-member' ),
|
1745 |
+
),
|
1746 |
+
'licenses' => array(
|
1747 |
+
'title' => __( 'Licenses', 'ultimate-member' ),
|
1748 |
+
),
|
1749 |
+
'misc' => array(
|
1750 |
+
'title' => __( 'Misc', 'ultimate-member' ),
|
1751 |
+
'fields' => array(
|
1752 |
+
array(
|
1753 |
+
'id' => 'form_asterisk',
|
1754 |
+
'type' => 'checkbox',
|
1755 |
+
'label' => __( 'Show an asterisk for required fields', 'ultimate-member' ),
|
1756 |
+
),
|
1757 |
+
array(
|
1758 |
+
'id' => 'profile_title',
|
1759 |
+
'type' => 'text',
|
1760 |
+
'label' => __( 'User Profile Title', 'ultimate-member' ),
|
1761 |
+
'tooltip' => __( 'This is the title that is displayed on a specific user profile', 'ultimate-member' ),
|
1762 |
+
'size' => 'medium',
|
1763 |
+
),
|
1764 |
+
array(
|
1765 |
+
'id' => 'profile_desc',
|
1766 |
+
'type' => 'textarea',
|
1767 |
+
'label' => __( 'User Profile Dynamic Meta Description', 'ultimate-member' ),
|
1768 |
+
'tooltip' => __( 'This will be used in the meta description that is available for search-engines.', 'ultimate-member' ),
|
1769 |
+
'args' => array(
|
1770 |
+
'textarea_rows' => 6,
|
1771 |
+
),
|
1772 |
+
),
|
1773 |
+
array(
|
1774 |
+
'id' => 'um_profile_object_cache_stop',
|
1775 |
+
'type' => 'checkbox',
|
1776 |
+
'label' => __( 'Disable Cache User Profile', 'ultimate-member' ),
|
1777 |
+
'tooltip' => __( 'Check this box if you would like to disable Ultimate Member user\'s cache.', 'ultimate-member' ),
|
1778 |
+
),
|
1779 |
+
array(
|
1780 |
+
'id' => 'enable_blocks',
|
1781 |
+
'type' => 'checkbox',
|
1782 |
+
'label' => __( 'Enable Gutenberg Blocks', 'ultimate-member' ),
|
1783 |
+
'tooltip' => __( 'Check this box if you would like to use Ultimate Member blocks in Gutenberg editor. Important some themes have the conflicts with Gutenberg editor.', 'ultimate-member' ),
|
1784 |
+
),
|
1785 |
+
array(
|
1786 |
+
'id' => 'rest_api_version',
|
1787 |
+
'type' => 'select',
|
1788 |
+
'label' => __( 'REST API version', 'ultimate-member' ),
|
1789 |
+
'tooltip' => __( 'This controls the REST API version, we recommend to use the last version', 'ultimate-member' ),
|
1790 |
+
'options' => array(
|
1791 |
+
'1.0' => __( '1.0 version', 'ultimate-member' ),
|
1792 |
+
'2.0' => __( '2.0 version', 'ultimate-member' ),
|
1793 |
+
),
|
1794 |
+
),
|
1795 |
+
// backward compatibility option leave it disabled for better security and ability to exclude posts/terms pre-query
|
1796 |
+
// otherwise we filtering only results and restricted posts/terms can be visible
|
1797 |
+
array(
|
1798 |
+
'id' => 'disable_restriction_pre_queries',
|
1799 |
+
'type' => 'checkbox',
|
1800 |
+
'label' => __( 'Disable pre-queries for restriction content logic (advanced)', 'ultimate-member' ),
|
1801 |
+
'tooltip' => __( 'Please enable this option only in the cases when you have big or unnecessary queries on your site with active restriction logic. If you want to exclude posts only from the results queries instead of pre_get_posts and fully-hidden post logic also please enable this option. It activates the restriction content logic until 2.2.x version without latest security enhancements', 'ultimate-member' ),
|
1802 |
+
),
|
1803 |
+
$same_page_update,
|
1804 |
+
array(
|
1805 |
+
'id' => 'uninstall_on_delete',
|
1806 |
+
'type' => 'checkbox',
|
1807 |
+
'label' => __( 'Remove Data on Uninstall?', 'ultimate-member' ),
|
1808 |
+
'tooltip' => __( 'Check this box if you would like Ultimate Member to completely remove all of its data when the plugin/extensions are deleted.', 'ultimate-member' ),
|
1809 |
+
),
|
1810 |
+
),
|
1811 |
+
),
|
1812 |
+
'install_info' => array(
|
1813 |
+
'title' => __( 'Install Info', 'ultimate-member' ),
|
1814 |
+
'fields' => array(
|
1815 |
+
array(
|
1816 |
+
'type' => 'install_info',
|
1817 |
+
),
|
1818 |
+
),
|
1819 |
+
),
|
1820 |
+
)
|
1821 |
+
);
|
1822 |
+
|
1823 |
+
}
|
1824 |
+
|
1825 |
+
|
1826 |
+
/**
|
1827 |
+
* @param array $settings
|
1828 |
+
*
|
1829 |
+
* @return array
|
1830 |
+
*/
|
1831 |
+
public function sorting_licenses_options( $settings ) {
|
1832 |
+
//sorting licenses
|
1833 |
+
if ( ! empty( $settings['licenses']['fields'] ) ) {
|
1834 |
+
$licenses = $settings['licenses']['fields'];
|
1835 |
+
@uasort( $licenses, function( $a, $b ) {
|
1836 |
+
return strnatcasecmp( $a['label'], $b['label'] );
|
1837 |
+
} );
|
1838 |
+
$settings['licenses']['fields'] = $licenses;
|
1839 |
+
}
|
1840 |
+
|
1841 |
+
//sorting extensions by the title
|
1842 |
+
if ( ! empty( $settings['extensions']['sections'] ) ) {
|
1843 |
+
$extensions = $settings['extensions']['sections'];
|
1844 |
+
|
1845 |
+
@uasort( $extensions, function( $a, $b ) {
|
1846 |
+
return strnatcasecmp( $a['title'], $b['title'] );
|
1847 |
+
} );
|
1848 |
+
|
1849 |
+
$keys = array_keys( $extensions );
|
1850 |
+
$temp = array(
|
1851 |
+
'' => $extensions[ $keys[0] ],
|
1852 |
+
);
|
1853 |
+
|
1854 |
+
unset( $extensions[ $keys[0] ] );
|
1855 |
+
$extensions = $temp + $extensions;
|
1856 |
+
|
1857 |
+
$settings['extensions']['sections'] = $extensions;
|
1858 |
+
}
|
1859 |
+
|
1860 |
+
return $settings;
|
1861 |
+
}
|
1862 |
+
|
1863 |
+
|
1864 |
+
/**
|
1865 |
+
* @param $tab
|
1866 |
+
* @param $section
|
1867 |
+
*
|
1868 |
+
* @return array
|
1869 |
+
*/
|
1870 |
+
function get_section_fields( $tab, $section ) {
|
1871 |
+
|
1872 |
+
if ( empty( $this->settings_structure[ $tab ] ) ) {
|
1873 |
+
return array();
|
1874 |
+
}
|
1875 |
+
|
1876 |
+
if ( ! empty( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) {
|
1877 |
+
return $this->settings_structure[ $tab ]['sections'][ $section ]['fields'];
|
1878 |
+
} elseif ( ! empty( $this->settings_structure[ $tab ]['fields'] ) ) {
|
1879 |
+
return $this->settings_structure[ $tab ]['fields'];
|
1880 |
+
}
|
1881 |
+
|
1882 |
+
return array();
|
1883 |
+
}
|
1884 |
+
|
1885 |
+
|
1886 |
+
/**
|
1887 |
+
* Setup admin menu
|
1888 |
+
*/
|
1889 |
+
function primary_admin_menu() {
|
1890 |
+
add_submenu_page( 'ultimatemember', __( 'Settings', 'ultimate-member' ), __( 'Settings', 'ultimate-member' ), 'manage_options', 'um_options', array( &$this, 'settings_page' ) );
|
1891 |
+
}
|
1892 |
+
|
1893 |
+
|
1894 |
+
/**
|
1895 |
+
* Settings page callback
|
1896 |
+
*/
|
1897 |
+
function settings_page() {
|
1898 |
+
$current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
|
1899 |
+
$current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
|
1900 |
+
|
1901 |
+
$settings_struct = $this->settings_structure[ $current_tab ];
|
1902 |
+
|
1903 |
+
//remove not option hidden fields
|
1904 |
+
if ( ! empty( $settings_struct['fields'] ) ) {
|
1905 |
+
foreach ( $settings_struct['fields'] as $field_key => $field_options ) {
|
1906 |
+
|
1907 |
+
if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) {
|
1908 |
+
unset( $settings_struct['fields'][ $field_key ] );
|
1909 |
+
}
|
1910 |
+
|
1911 |
+
}
|
1912 |
+
}
|
1913 |
+
|
1914 |
+
if ( empty( $settings_struct['fields'] ) && empty( $settings_struct['sections'] ) ) {
|
1915 |
+
um_js_redirect( add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) ) );
|
1916 |
+
}
|
1917 |
+
|
1918 |
+
if ( ! empty( $settings_struct['sections'] ) ) {
|
1919 |
+
if ( empty( $settings_struct['sections'][ $current_subtab ] ) ) {
|
1920 |
+
um_js_redirect( add_query_arg( array( 'page' => 'um_options', 'tab' => $current_tab ), admin_url( 'admin.php' ) ) );
|
1921 |
+
}
|
1922 |
+
}
|
1923 |
+
|
1924 |
+
echo '<div id="um-settings-wrap" class="wrap"><h2>' . __( 'Ultimate Member - Settings', 'ultimate-member' ) . '</h2>';
|
1925 |
+
|
1926 |
+
echo $this->generate_tabs_menu() . $this->generate_subtabs_menu( $current_tab );
|
1927 |
+
|
1928 |
+
/**
|
1929 |
+
* UM hook
|
1930 |
+
*
|
1931 |
+
* @type action
|
1932 |
+
* @title um_settings_page_before_{$current_tab}_{$current_subtab}_content
|
1933 |
+
* @description Show some content before settings page content
|
1934 |
+
* @change_log
|
1935 |
+
* ["Since: 2.0"]
|
1936 |
+
* @usage add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'function_name', 10 );
|
1937 |
+
* @example
|
1938 |
+
* <?php
|
1939 |
+
* add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'my_settings_page_before', 10 );
|
1940 |
+
* function my_settings_page_before() {
|
1941 |
+
* // your code here
|
1942 |
+
* }
|
1943 |
+
* ?>
|
1944 |
+
*/
|
1945 |
+
do_action( "um_settings_page_before_" . $current_tab . "_" . $current_subtab . "_content" );
|
1946 |
+
|
1947 |
+
if ( in_array( $current_tab, apply_filters('um_settings_custom_tabs', array( 'licenses', 'install_info' ) ) ) || in_array( $current_subtab, apply_filters( 'um_settings_custom_subtabs', array(), $current_tab ) ) ) {
|
1948 |
+
|
1949 |
+
/**
|
1950 |
+
* UM hook
|
1951 |
+
*
|
1952 |
+
* @type action
|
1953 |
+
* @title um_settings_page_{$current_tab}_{$current_subtab}_before_section
|
1954 |
+
* @description Show some content before section content at settings page
|
1955 |
+
* @change_log
|
1956 |
+
* ["Since: 2.0"]
|
1957 |
+
* @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 );
|
1958 |
+
* @example
|
1959 |
+
* <?php
|
1960 |
+
* add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'my_settings_page_before_section', 10 );
|
1961 |
+
* function my_settings_page_before_section() {
|
1962 |
+
* // your code here
|
1963 |
+
* }
|
1964 |
+
* ?>
|
1965 |
+
*/
|
1966 |
+
do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" );
|
1967 |
+
|
1968 |
+
$section_fields = $this->get_section_fields( $current_tab, $current_subtab );
|
1969 |
+
$settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab );
|
1970 |
+
|
1971 |
+
/**
|
1972 |
+
* UM hook
|
1973 |
+
*
|
1974 |
+
* @type filter
|
1975 |
+
* @title um_settings_section_{$current_tab}_{$current_subtab}_content
|
1976 |
+
*
|
1977 |
+
* @description Render settings section
|
1978 |
+
* @input_vars
|
1979 |
+
* [{"var":"$content","type":"string","desc":"Section content"},
|
1980 |
+
* {"var":"$section_fields","type":"array","desc":"Section Fields"}]
|
1981 |
+
* @change_log
|
1982 |
+
* ["Since: 2.0"]
|
1983 |
+
* @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 );
|
1984 |
+
* @example
|
1985 |
+
* <?php
|
1986 |
+
* add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'my_settings_section', 10, 2 );
|
1987 |
+
* function my_settings_section( $content ) {
|
1988 |
+
* // your code here
|
1989 |
+
* return $content;
|
1990 |
+
* }
|
1991 |
+
* ?>
|
1992 |
+
*/
|
1993 |
+
echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content',
|
1994 |
+
$settings_section,
|
1995 |
+
$section_fields
|
1996 |
+
);
|
1997 |
+
|
1998 |
+
} else { ?>
|
1999 |
+
|
2000 |
+
<form method="post" action="" name="um-settings-form" id="um-settings-form">
|
2001 |
+
<input type="hidden" value="save" name="um-settings-action" />
|
2002 |
+
|
2003 |
+
<?php
|
2004 |
+
/**
|
2005 |
+
* UM hook
|
2006 |
+
*
|
2007 |
+
* @type action
|
2008 |
+
* @title um_settings_page_{$current_tab}_{$current_subtab}_before_section
|
2009 |
+
* @description Show some content before section content at settings page
|
2010 |
+
* @change_log
|
2011 |
+
* ["Since: 2.0"]
|
2012 |
+
* @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 );
|
2013 |
+
* @example
|
2014 |
+
* <?php
|
2015 |
+
* add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'my_settings_page_before_section', 10 );
|
2016 |
+
* function my_settings_page_before_section() {
|
2017 |
+
* // your code here
|
2018 |
+
* }
|
2019 |
+
* ?>
|
2020 |
+
*/
|
2021 |
+
do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" );
|
2022 |
+
|
2023 |
+
$section_fields = $this->get_section_fields( $current_tab, $current_subtab );
|
2024 |
+
$settings_section = $this->render_settings_section( $section_fields, $current_tab, $current_subtab );
|
2025 |
+
|
2026 |
+
/**
|
2027 |
+
* UM hook
|
2028 |
+
*
|
2029 |
+
* @type filter
|
2030 |
+
* @title um_settings_section_{$current_tab}_{$current_subtab}_content
|
2031 |
+
* @description Render settings section
|
2032 |
+
* @input_vars
|
2033 |
+
* [{"var":"$content","type":"string","desc":"Section content"},
|
2034 |
+
* {"var":"$section_fields","type":"array","desc":"Section Fields"}]
|
2035 |
+
* @change_log
|
2036 |
+
* ["Since: 2.0"]
|
2037 |
+
* @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 );
|
2038 |
+
* @example
|
2039 |
+
* <?php
|
2040 |
+
* add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'my_settings_section', 10, 2 );
|
2041 |
+
* function my_settings_section( $content ) {
|
2042 |
+
* // your code here
|
2043 |
+
* return $content;
|
2044 |
+
* }
|
2045 |
+
* ?>
|
2046 |
+
*/
|
2047 |
+
echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content',
|
2048 |
+
$settings_section,
|
2049 |
+
$section_fields
|
2050 |
+
); ?>
|
2051 |
+
|
2052 |
+
|
2053 |
+
<p class="submit">
|
2054 |
+
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Save Changes', 'ultimate-member' ) ?>" />
|
2055 |
+
<?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
|
2056 |
+
<input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
|
2057 |
+
</p>
|
2058 |
+
</form>
|
2059 |
+
|
2060 |
+
<?php }
|
2061 |
+
}
|
2062 |
+
|
2063 |
+
|
2064 |
+
/**
|
2065 |
+
* Generate pages tabs
|
2066 |
+
*
|
2067 |
+
* @param string $page
|
2068 |
+
* @return string
|
2069 |
+
*/
|
2070 |
+
function generate_tabs_menu( $page = 'settings' ) {
|
2071 |
+
|
2072 |
+
$tabs = '<h2 class="nav-tab-wrapper um-nav-tab-wrapper">';
|
2073 |
+
|
2074 |
+
switch( $page ) {
|
2075 |
+
case 'settings':
|
2076 |
+
$menu_tabs = array();
|
2077 |
+
foreach ( $this->settings_structure as $slug => $tab ) {
|
2078 |
+
if ( ! empty( $tab['fields'] ) ) {
|
2079 |
+
foreach ( $tab['fields'] as $field_key => $field_options ) {
|
2080 |
+
if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) {
|
2081 |
+
unset( $tab['fields'][ $field_key ] );
|
2082 |
+
}
|
2083 |
+
}
|
2084 |
+
}
|
2085 |
+
|
2086 |
+
if ( ! empty( $tab['fields'] ) || ! empty( $tab['sections'] ) ) {
|
2087 |
+
$menu_tabs[ $slug ] = $tab['title'];
|
2088 |
+
}
|
2089 |
+
}
|
2090 |
+
|
2091 |
+
$current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
|
2092 |
+
foreach ( $menu_tabs as $name => $label ) {
|
2093 |
+
$active = ( $current_tab == $name ) ? 'nav-tab-active' : '';
|
2094 |
+
$tabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $name ) ? '' : '&tab=' . $name ) ) ) . '" class="nav-tab ' . esc_attr( $active ) . '">' .
|
2095 |
+
$label .
|
2096 |
+
'</a>';
|
2097 |
+
}
|
2098 |
+
|
2099 |
+
break;
|
2100 |
+
default:
|
2101 |
+
/**
|
2102 |
+
* UM hook
|
2103 |
+
*
|
2104 |
+
* @type filter
|
2105 |
+
* @title um_generate_tabs_menu_{$page}
|
2106 |
+
* @description Generate tabs menu
|
2107 |
+
* @input_vars
|
2108 |
+
* [{"var":"$tabs","type":"array","desc":"UM menu tabs"}]
|
2109 |
+
* @change_log
|
2110 |
+
* ["Since: 2.0"]
|
2111 |
+
* @usage add_filter( 'um_generate_tabs_menu_{$page}', 'function_name', 10, 1 );
|
2112 |
+
* @example
|
2113 |
+
* <?php
|
2114 |
+
* add_filter( 'um_generate_tabs_menu_{$page}', 'my_tabs_menu', 10, 1 );
|
2115 |
+
* function my_tabs_menu( $tabs ) {
|
2116 |
+
* // your code here
|
2117 |
+
* return $tabs;
|
2118 |
+
* }
|
2119 |
+
* ?>
|
2120 |
+
*/
|
2121 |
+
$tabs = apply_filters( 'um_generate_tabs_menu_' . $page, $tabs );
|
2122 |
+
break;
|
2123 |
+
}
|
2124 |
+
|
2125 |
+
return $tabs . '</h2>';
|
2126 |
+
}
|
2127 |
+
|
2128 |
+
|
2129 |
+
/**
|
2130 |
+
* @param string $tab
|
2131 |
+
*
|
2132 |
+
* @return string
|
2133 |
+
*/
|
2134 |
+
function generate_subtabs_menu( $tab = '' ) {
|
2135 |
+
if ( empty( $this->settings_structure[ $tab ]['sections'] ) ) {
|
2136 |
+
return '';
|
2137 |
+
}
|
2138 |
+
|
2139 |
+
$menu_subtabs = array();
|
2140 |
+
foreach ( $this->settings_structure[ $tab ]['sections'] as $slug => $subtab ) {
|
2141 |
+
$menu_subtabs[ $slug ] = $subtab['title'];
|
2142 |
+
}
|
2143 |
+
|
2144 |
+
$subtabs = '<div><ul class="subsubsub">';
|
2145 |
+
|
2146 |
+
$current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
|
2147 |
+
$current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
|
2148 |
+
foreach ( $menu_subtabs as $name => $label ) {
|
2149 |
+
$active = ( $current_subtab == $name ) ? 'current' : '';
|
2150 |
+
$subtabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $current_tab ) ? '' : '&tab=' . $current_tab ) . ( empty( $name ) ? '' : '§ion=' . $name ) ) ) . '" class="' . $active . '">'
|
2151 |
+
. $label .
|
2152 |
+
'</a> | ';
|
2153 |
+
}
|
2154 |
+
|
2155 |
+
return substr( $subtabs, 0, -3 ) . '</ul></div>';
|
2156 |
+
}
|
2157 |
+
|
2158 |
+
|
2159 |
+
/**
|
2160 |
+
* Handler for settings forms
|
2161 |
+
* when "Save Settings" button click
|
2162 |
+
*
|
2163 |
+
*/
|
2164 |
+
function save_settings_handler() {
|
2165 |
+
|
2166 |
+
if ( isset( $_POST['um-settings-action'] ) && 'save' === sanitize_key( $_POST['um-settings-action'] ) && ! empty( $_POST['um_options'] ) ) {
|
2167 |
+
|
2168 |
+
$nonce = ! empty( $_POST['__umnonce'] ) ? $_POST['__umnonce'] : '';
|
2169 |
+
|
2170 |
+
if ( ( ! wp_verify_nonce( $nonce, 'um-settings-nonce' ) || empty( $nonce ) ) || ! current_user_can( 'manage_options' ) ) {
|
2171 |
+
// This nonce is not valid.
|
2172 |
+
wp_die( __( 'Security Check', 'ultimate-member' ) );
|
2173 |
+
}
|
2174 |
+
|
2175 |
+
/**
|
2176 |
+
* UM hook
|
2177 |
+
*
|
2178 |
+
* @type action
|
2179 |
+
* @title um_settings_before_save
|
2180 |
+
* @description Before settings save action
|
2181 |
+
* @change_log
|
2182 |
+
* ["Since: 2.0"]
|
2183 |
+
* @usage add_action( 'um_settings_before_save', 'function_name', 10 );
|
2184 |
+
* @example
|
2185 |
+
* <?php
|
2186 |
+
* add_action( 'um_settings_before_save', 'my_settings_before_save', 10 );
|
2187 |
+
* function my_settings_before_save() {
|
2188 |
+
* // your code here
|
2189 |
+
* }
|
2190 |
+
* ?>
|
2191 |
+
*/
|
2192 |
+
do_action( "um_settings_before_save" );
|
2193 |
+
|
2194 |
+
/**
|
2195 |
+
* UM hook
|
2196 |
+
*
|
2197 |
+
* @type filter
|
2198 |
+
* @title um_change_settings_before_save
|
2199 |
+
* @description Change settings before save
|
2200 |
+
* @input_vars
|
2201 |
+
* [{"var":"$settings","type":"array","desc":"UM Settings on save"}]
|
2202 |
+
* @change_log
|
2203 |
+
* ["Since: 2.0"]
|
2204 |
+
* @usage add_filter( 'um_change_settings_before_save', 'function_name', 10, 1 );
|
2205 |
+
* @example
|
2206 |
+
* <?php
|
2207 |
+
* add_filter( 'um_change_settings_before_save', 'my_change_settings_before_save', 10, 1 );
|
2208 |
+
* function my_change_settings_before_save( $settings ) {
|
2209 |
+
* // your code here
|
2210 |
+
* return $settings;
|
2211 |
+
* }
|
2212 |
+
* ?>
|
2213 |
+
*/
|
2214 |
+
$settings = apply_filters( 'um_change_settings_before_save', $_POST['um_options'] );
|
2215 |
+
|
2216 |
+
$settings = UM()->admin()->sanitize_options( $settings );
|
2217 |
+
|
2218 |
+
foreach ( $settings as $key => $value ) {
|
2219 |
+
UM()->options()->update( $key, $value );
|
2220 |
+
}
|
2221 |
+
|
2222 |
+
/**
|
2223 |
+
* UM hook
|
2224 |
+
*
|
2225 |
+
* @type action
|
2226 |
+
* @title um_settings_save
|
2227 |
+
* @description After settings save action
|
2228 |
+
* @change_log
|
2229 |
+
* ["Since: 2.0"]
|
2230 |
+
* @usage add_action( 'um_settings_save', 'function_name', 10 );
|
2231 |
+
* @example
|
2232 |
+
* <?php
|
2233 |
+
* add_action( 'um_settings_save', 'my_settings_save', 10 );
|
2234 |
+
* function my_settings_save() {
|
2235 |
+
* // your code here
|
2236 |
+
* }
|
2237 |
+
* ?>
|
2238 |
+
*/
|
2239 |
+
do_action( 'um_settings_save' );
|
2240 |
+
|
2241 |
+
//redirect after save settings
|
2242 |
+
$arg = array(
|
2243 |
+
'page' => 'um_options',
|
2244 |
+
'update' => 'settings_updated',
|
2245 |
+
);
|
2246 |
+
|
2247 |
+
if ( ! empty( $_GET['tab'] ) ) {
|
2248 |
+
$arg['tab'] = sanitize_key( $_GET['tab'] );
|
2249 |
+
}
|
2250 |
+
|
2251 |
+
if ( ! empty( $_GET['section'] ) ) {
|
2252 |
+
$arg['section'] = sanitize_key( $_GET['section'] );
|
2253 |
+
}
|
2254 |
+
|
2255 |
+
um_js_redirect( add_query_arg( $arg, admin_url( 'admin.php' ) ) );
|
2256 |
+
}
|
2257 |
+
}
|
2258 |
+
|
2259 |
+
|
2260 |
+
function set_default_if_empty( $settings ) {
|
2261 |
+
$tab = '';
|
2262 |
+
if ( ! empty( $_GET['tab'] ) ) {
|
2263 |
+
$tab = sanitize_key( $_GET['tab'] );
|
2264 |
+
}
|
2265 |
+
|
2266 |
+
$section = '';
|
2267 |
+
if ( ! empty( $_GET['section'] ) ) {
|
2268 |
+
$section = sanitize_key( $_GET['section'] );
|
2269 |
+
}
|
2270 |
+
|
2271 |
+
|
2272 |
+
if ( 'access' === $tab && empty( $section ) ) {
|
2273 |
+
if ( ! array_key_exists( 'access_exclude_uris', $settings ) ) {
|
2274 |
+
$settings['access_exclude_uris'] = array();
|
2275 |
+
}
|
2276 |
+
}
|
2277 |
+
|
2278 |
+
return $settings;
|
2279 |
+
}
|
2280 |
+
|
2281 |
+
|
2282 |
+
/**
|
2283 |
+
* Remove empty values from multi text fields
|
2284 |
+
*
|
2285 |
+
* @param $settings
|
2286 |
+
* @return array
|
2287 |
+
*/
|
2288 |
+
function remove_empty_values( $settings ) {
|
2289 |
+
$tab = '';
|
2290 |
+
if ( ! empty( $_GET['tab'] ) ) {
|
2291 |
+
$tab = sanitize_key( $_GET['tab'] );
|
2292 |
+
}
|
2293 |
+
|
2294 |
+
$section = '';
|
2295 |
+
if ( ! empty( $_GET['section'] ) ) {
|
2296 |
+
$section = sanitize_key( $_GET['section'] );
|
2297 |
+
}
|
2298 |
+
|
2299 |
+
if ( isset( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) {
|
2300 |
+
$fields = $this->settings_structure[ $tab ]['sections'][ $section ]['fields'];
|
2301 |
+
} else {
|
2302 |
+
$fields = $this->settings_structure[ $tab ]['fields'];
|
2303 |
+
}
|
2304 |
+
|
2305 |
+
if ( empty( $fields ) ) {
|
2306 |
+
return $settings;
|
2307 |
+
}
|
2308 |
+
|
2309 |
+
|
2310 |
+
$filtered_settings = array();
|
2311 |
+
foreach ( $settings as $key => $value ) {
|
2312 |
+
|
2313 |
+
$filtered_settings[ $key ] = $value;
|
2314 |
+
|
2315 |
+
foreach ( $fields as $field ) {
|
2316 |
+
if ( $field['id'] == $key && isset( $field['type'] ) && $field['type'] == 'multi_text' ) {
|
2317 |
+
$filtered_settings[ $key ] = array_filter( $settings[ $key ] );
|
2318 |
+
}
|
2319 |
+
}
|
2320 |
+
}
|
2321 |
+
|
2322 |
+
return $filtered_settings;
|
2323 |
+
}
|
2324 |
+
|
2325 |
+
|
2326 |
+
/**
|
2327 |
+
*
|
2328 |
+
*/
|
2329 |
+
function check_permalinks_changes() {
|
2330 |
+
if ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
|
2331 |
+
if ( UM()->options()->get( 'permalink_base' ) !== $_POST['um_options']['permalink_base'] ) {
|
2332 |
+
$this->need_change_permalinks = true;
|
2333 |
+
}
|
2334 |
+
}
|
2335 |
+
|
2336 |
+
// set variable if gravatar settings were changed
|
2337 |
+
// update for um_member_directory_data metakey
|
2338 |
+
if ( isset( $_POST['um_options']['use_gravatars'] ) ) {
|
2339 |
+
$use_gravatar = UM()->options()->get( 'use_gravatars' );
|
2340 |
+
if ( ( empty( $use_gravatar ) && ! empty( $_POST['um_options']['use_gravatars'] ) ) || ( ! empty( $use_gravatar ) && empty( $_POST['um_options']['use_gravatars'] ) ) ) {
|
2341 |
+
$this->gravatar_changed = true;
|
2342 |
+
}
|
2343 |
+
}
|
2344 |
+
}
|
2345 |
+
|
2346 |
+
|
2347 |
+
/**
|
2348 |
+
*
|
2349 |
+
*/
|
2350 |
+
function on_settings_save() {
|
2351 |
+
if ( ! empty( $_POST['um_options'] ) ) {
|
2352 |
+
|
2353 |
+
if ( ! empty( $_POST['um_options']['pages_settings'] ) ) {
|
2354 |
+
$post_ids = new \WP_Query( array(
|
2355 |
+
'post_type' => 'page',
|
2356 |
+
'meta_query' => array(
|
2357 |
+
array(
|
2358 |
+
'key' => '_um_core',
|
2359 |
+
'compare' => 'EXISTS'
|
2360 |
+
)
|
2361 |
+
),
|
2362 |
+
'posts_per_page' => -1,
|
2363 |
+
'fields' => 'ids'
|
2364 |
+
) );
|
2365 |
+
|
2366 |
+
$post_ids = $post_ids->get_posts();
|
2367 |
+
|
2368 |
+
if ( ! empty( $post_ids ) ) {
|
2369 |
+
foreach ( $post_ids as $post_id ) {
|
2370 |
+
delete_post_meta( $post_id, '_um_core' );
|
2371 |
+
}
|
2372 |
+
}
|
2373 |
+
|
2374 |
+
foreach ( $_POST['um_options'] as $option_slug => $post_id ) {
|
2375 |
+
$slug = str_replace( 'core_', '', $option_slug );
|
2376 |
+
update_post_meta( $post_id, '_um_core', $slug );
|
2377 |
+
}
|
2378 |
+
|
2379 |
+
// reset rewrite rules after re-save pages
|
2380 |
+
UM()->rewrite()->reset_rules();
|
2381 |
+
|
2382 |
+
} elseif ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
|
2383 |
+
if ( ! empty( $this->need_change_permalinks ) ) {
|
2384 |
+
$users = get_users( array(
|
2385 |
+
'fields' => 'ids',
|
2386 |
+
) );
|
2387 |
+
if ( ! empty( $users ) ) {
|
2388 |
+
foreach ( $users as $user_id ) {
|
2389 |
+
UM()->user()->generate_profile_slug( $user_id );
|
2390 |
+
}
|
2391 |
+
}
|
2392 |
+
}
|
2393 |
+
|
2394 |
+
|
2395 |
+
// update for um_member_directory_data metakey
|
2396 |
+
if ( isset( $_POST['um_options']['use_gravatars'] ) ) {
|
2397 |
+
if ( $this->gravatar_changed ) {
|
2398 |
+
global $wpdb;
|
2399 |
+
|
2400 |
+
if ( ! empty( $_POST['um_options']['use_gravatars'] ) ) {
|
2401 |
+
|
2402 |
+
$results = $wpdb->get_col(
|
2403 |
+
"SELECT u.ID FROM {$wpdb->users} AS u
|
2404 |
+
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'synced_gravatar_hashed_id' )
|
2405 |
+
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2406 |
+
WHERE um.meta_value != '' AND um.meta_value IS NOT NULL AND
|
2407 |
+
um2.meta_value LIKE '%s:13:\"profile_photo\";b:0;%'"
|
2408 |
+
);
|
2409 |
+
|
2410 |
+
} else {
|
2411 |
+
|
2412 |
+
$results = $wpdb->get_col(
|
2413 |
+
"SELECT u.ID FROM {$wpdb->users} AS u
|
2414 |
+
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND ( um.meta_key = 'synced_profile_photo' || um.meta_key = 'profile_photo' ) )
|
2415 |
+
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2416 |
+
WHERE ( um.meta_value IS NULL OR um.meta_value = '' ) AND
|
2417 |
+
um2.meta_value LIKE '%s:13:\"profile_photo\";b:1;%'"
|
2418 |
+
);
|
2419 |
+
|
2420 |
+
}
|
2421 |
+
|
2422 |
+
if ( ! empty( $results ) ) {
|
2423 |
+
foreach ( $results as $user_id ) {
|
2424 |
+
$md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
|
2425 |
+
if ( ! empty( $md_data ) ) {
|
2426 |
+
$md_data['profile_photo'] = ! empty( $_POST['um_options']['use_gravatars'] );
|
2427 |
+
update_user_meta( $user_id, 'um_member_directory_data', $md_data );
|
2428 |
+
}
|
2429 |
+
}
|
2430 |
+
}
|
2431 |
+
}
|
2432 |
+
}
|
2433 |
+
|
2434 |
+
} elseif ( isset( $_POST['um_options']['member_directory_own_table'] ) ) {
|
2435 |
+
if ( empty( $_POST['um_options']['member_directory_own_table'] ) ) {
|
2436 |
+
global $wpdb;
|
2437 |
+
|
2438 |
+
$results = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}um_metadata LIMIT 1", ARRAY_A );
|
2439 |
+
|
2440 |
+
if ( ! empty( $results ) ) {
|
2441 |
+
$wpdb->query("TRUNCATE TABLE {$wpdb->prefix}um_metadata" );
|
2442 |
+
}
|
2443 |
+
|
2444 |
+
update_option( 'um_member_directory_truncated', time() );
|
2445 |
+
}
|
2446 |
+
} elseif ( isset( $_POST['um_options']['account_hide_in_directory_default'] ) ) {
|
2447 |
+
|
2448 |
+
global $wpdb;
|
2449 |
+
|
2450 |
+
if ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) {
|
2451 |
+
|
2452 |
+
$results = $wpdb->get_col(
|
2453 |
+
"SELECT u.ID FROM {$wpdb->users} AS u
|
2454 |
+
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'hide_in_members' )
|
2455 |
+
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2456 |
+
WHERE um.meta_value IS NULL AND
|
2457 |
+
um2.meta_value LIKE '%s:15:\"hide_in_members\";b:1;%'"
|
2458 |
+
);
|
2459 |
+
|
2460 |
+
} else {
|
2461 |
+
|
2462 |
+
$results = $wpdb->get_col(
|
2463 |
+
"SELECT u.ID FROM {$wpdb->users} AS u
|
2464 |
+
LEFT JOIN {$wpdb->usermeta} AS um ON ( um.user_id = u.ID AND um.meta_key = 'hide_in_members' )
|
2465 |
+
LEFT JOIN {$wpdb->usermeta} AS um2 ON ( um2.user_id = u.ID AND um2.meta_key = 'um_member_directory_data' )
|
2466 |
+
WHERE um.meta_value IS NULL AND
|
2467 |
+
um2.meta_value LIKE '%s:15:\"hide_in_members\";b:0;%'"
|
2468 |
+
);
|
2469 |
+
|
2470 |
+
}
|
2471 |
+
|
2472 |
+
if ( ! empty( $results ) ) {
|
2473 |
+
foreach ( $results as $user_id ) {
|
2474 |
+
$md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
|
2475 |
+
if ( ! empty( $md_data ) ) {
|
2476 |
+
$md_data['hide_in_members'] = ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) ? false : true;
|
2477 |
+
update_user_meta( $user_id, 'um_member_directory_data', $md_data );
|
2478 |
+
}
|
2479 |
+
}
|
2480 |
+
}
|
2481 |
+
|
2482 |
+
}
|
2483 |
+
}
|
2484 |
+
}
|
2485 |
+
|
2486 |
+
|
2487 |
+
/**
|
2488 |
+
*
|
2489 |
+
*/
|
2490 |
+
function before_licenses_save() {
|
2491 |
+
if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) {
|
2492 |
+
return;
|
2493 |
+
}
|
2494 |
+
|
2495 |
+
foreach ( $_POST['um_options'] as $key => $value ) {
|
2496 |
+
$this->previous_licenses[ sanitize_key( $key ) ] = UM()->options()->get( $key );
|
2497 |
+
}
|
2498 |
+
}
|
2499 |
+
|
2500 |
+
|
2501 |
+
/**
|
2502 |
+
*
|
2503 |
+
*/
|
2504 |
+
function licenses_save() {
|
2505 |
+
if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) {
|
2506 |
+
return;
|
2507 |
+
}
|
2508 |
+
|
2509 |
+
foreach ( $_POST['um_options'] as $key => $value ) {
|
2510 |
+
$key = sanitize_key( $key );
|
2511 |
+
$value = sanitize_text_field( $value );
|
2512 |
+
|
2513 |
+
$edd_action = '';
|
2514 |
+
$license_key = '';
|
2515 |
+
if ( empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) || ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) && $this->previous_licenses[ $key ] != $value ) ) {
|
2516 |
+
$edd_action = 'activate_license';
|
2517 |
+
$license_key = $value;
|
2518 |
+
} elseif ( ! empty( $this->previous_licenses[ $key ] ) && empty( $value ) ) {
|
2519 |
+
$edd_action = 'deactivate_license';
|
2520 |
+
$license_key = $this->previous_licenses[ $key ];
|
2521 |
+
} elseif ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) ) {
|
2522 |
+
$edd_action = 'check_license';
|
2523 |
+
$license_key = $value;
|
2524 |
+
}
|
2525 |
+
|
2526 |
+
if ( empty( $edd_action ) ) {
|
2527 |
+
continue;
|
2528 |
+
}
|
2529 |
+
|
2530 |
+
$item_name = false;
|
2531 |
+
$version = false;
|
2532 |
+
$author = false;
|
2533 |
+
foreach ( $this->settings_structure['licenses']['fields'] as $field_data ) {
|
2534 |
+
if ( $field_data['id'] == $key ) {
|
2535 |
+
$item_name = ! empty( $field_data['item_name'] ) ? $field_data['item_name'] : false;
|
2536 |
+
$version = ! empty( $field_data['version'] ) ? $field_data['version'] : false;
|
2537 |
+
$author = ! empty( $field_data['author'] ) ? $field_data['author'] : false;
|
2538 |
+
}
|
2539 |
+
}
|
2540 |
+
|
2541 |
+
$api_params = array(
|
2542 |
+
'edd_action' => $edd_action,
|
2543 |
+
'license' => $license_key,
|
2544 |
+
'item_name' => $item_name,
|
2545 |
+
'version' => $version,
|
2546 |
+
'author' => $author,
|
2547 |
+
'url' => home_url(),
|
2548 |
+
);
|
2549 |
+
|
2550 |
+
$request = wp_remote_post(
|
2551 |
+
UM()->store_url,
|
2552 |
+
array(
|
2553 |
+
'timeout' => UM()->request_timeout,
|
2554 |
+
'sslverify' => false,
|
2555 |
+
'body' => $api_params
|
2556 |
+
)
|
2557 |
+
);
|
2558 |
+
|
2559 |
+
if ( ! is_wp_error( $request ) ) {
|
2560 |
+
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
2561 |
+
} else {
|
2562 |
+
$request = wp_remote_post(
|
2563 |
+
UM()->store_url,
|
2564 |
+
array(
|
2565 |
+
'timeout' => UM()->request_timeout,
|
2566 |
+
'sslverify' => true,
|
2567 |
+
'body' => $api_params
|
2568 |
+
)
|
2569 |
+
);
|
2570 |
+
|
2571 |
+
if ( ! is_wp_error( $request ) ) {
|
2572 |
+
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
2573 |
+
}
|
2574 |
+
}
|
2575 |
+
|
2576 |
+
$request = ( $request ) ? maybe_unserialize( $request ) : false;
|
2577 |
+
|
2578 |
+
if ( $edd_action == 'activate_license' || $edd_action == 'check_license' ) {
|
2579 |
+
update_option( "{$key}_edd_answer", $request );
|
2580 |
+
} else {
|
2581 |
+
delete_option( "{$key}_edd_answer" );
|
2582 |
+
}
|
2583 |
+
|
2584 |
+
}
|
2585 |
+
}
|
2586 |
+
|
2587 |
+
|
2588 |
+
/**
|
2589 |
+
*
|
2590 |
+
*/
|
2591 |
+
function settings_before_email_tab() {
|
2592 |
+
$email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] );
|
2593 |
+
$emails = UM()->config()->email_notifications;
|
2594 |
+
|
2595 |
+
if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) {
|
2596 |
+
include_once um_path . 'includes/admin/core/list-tables/emails-list-table.php';
|
2597 |
+
}
|
2598 |
+
}
|
2599 |
+
|
2600 |
+
|
2601 |
+
/**
|
2602 |
+
* @param $section
|
2603 |
+
*
|
2604 |
+
* @return string
|
2605 |
+
*/
|
2606 |
+
function settings_email_tab( $section ) {
|
2607 |
+
$email_key = empty( $_GET['email'] ) ? '' : sanitize_key( $_GET['email'] );
|
2608 |
+
$emails = UM()->config()->email_notifications;
|
2609 |
+
|
2610 |
+
if ( empty( $email_key ) || empty( $emails[ $email_key ] ) ) {
|
2611 |
+
return $section;
|
2612 |
+
}
|
2613 |
+
|
2614 |
+
$in_theme = UM()->mail()->template_in_theme( $email_key );
|
2615 |
+
|
2616 |
+
/**
|
2617 |
+
* UM hook
|
2618 |
+
*
|
2619 |
+
* @type filter
|
2620 |
+
* @title um_admin_settings_email_section_fields
|
2621 |
+
* @description Extend UM Email Settings
|
2622 |
+
* @input_vars
|
2623 |
+
* [{"var":"$settings","type":"array","desc":"UM Email Settings"},
|
2624 |
+
* {"var":"$email_key","type":"string","desc":"Email Key"}]
|
2625 |
+
* @change_log
|
2626 |
+
* ["Since: 2.0"]
|
2627 |
+
* @usage add_filter( 'um_admin_settings_email_section_fields', 'function_name', 10, 2 );
|
2628 |
+
* @example
|
2629 |
+
* <?php
|
2630 |
+
* add_filter( 'um_admin_settings_email_section_fields', 'my_admin_settings_email_section', 10, 2 );
|
2631 |
+
* function my_admin_settings_email_section( $settings, $email_key ) {
|
2632 |
+
* // your code here
|
2633 |
+
* return $settings;
|
2634 |
+
* }
|
2635 |
+
* ?>
|
2636 |
+
*/
|
2637 |
+
$section_fields = apply_filters( 'um_admin_settings_email_section_fields', array(
|
2638 |
+
array(
|
2639 |
+
'id' => 'um_email_template',
|
2640 |
+
'type' => 'hidden',
|
2641 |
+
'value' => $email_key,
|
2642 |
+
),
|
2643 |
+
array(
|
2644 |
+
'id' => $email_key . '_on',
|
2645 |
+
'type' => 'checkbox',
|
2646 |
+
'label' => $emails[ $email_key ]['title'],
|
2647 |
+
'tooltip' => $emails[ $email_key ]['description'],
|
2648 |
+
),
|
2649 |
+
array(
|
2650 |
+
'id' => $email_key . '_sub',
|
2651 |
+
'type' => 'text',
|
2652 |
+
'label' => __( 'Subject Line', 'ultimate-member' ),
|
2653 |
+
'conditional' => array( $email_key . '_on', '=', 1 ),
|
2654 |
+
'tooltip' => __( 'This is the subject line of the e-mail', 'ultimate-member' ),
|
2655 |
+
),
|
2656 |
+
array(
|
2657 |
+
'id' => $email_key,
|
2658 |
+
'type' => 'email_template',
|
2659 |
+
'label' => __( 'Message Body', 'ultimate-member' ),
|
2660 |
+
'conditional' => array( $email_key . '_on', '=', 1 ),
|
2661 |
+
'tooltip' => __( 'This is the content of the e-mail', 'ultimate-member' ),
|
2662 |
+
'value' => UM()->mail()->get_email_template( $email_key ),
|
2663 |
+
'in_theme' => $in_theme
|
2664 |
+
),
|
2665 |
+
), $email_key );
|
2666 |
+
|
2667 |
+
return $this->render_settings_section( $section_fields, 'email', $email_key );
|
2668 |
+
}
|
2669 |
+
|
2670 |
+
|
2671 |
+
/**
|
2672 |
+
*
|
2673 |
+
*/
|
2674 |
+
function settings_appearance_profile_tab() {
|
2675 |
+
wp_enqueue_media();
|
2676 |
+
}
|
2677 |
+
|
2678 |
+
|
2679 |
+
/**
|
2680 |
+
* @param $html
|
2681 |
+
* @param $section_fields
|
2682 |
+
*
|
2683 |
+
* @return string
|
2684 |
+
*/
|
2685 |
+
function settings_licenses_tab( $html, $section_fields ) {
|
2686 |
+
ob_start(); ?>
|
2687 |
+
|
2688 |
+
<div class="wrap-licenses">
|
2689 |
+
<input type="hidden" id="licenses_settings" name="licenses_settings" value="1">
|
2690 |
+
<?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
|
2691 |
+
<input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
|
2692 |
+
<table class="form-table um-settings-section">
|
2693 |
+
<tbody>
|
2694 |
+
<?php foreach ( $section_fields as $field_data ) {
|
2695 |
+
$option_value = UM()->options()->get( $field_data['id'] );
|
2696 |
+
$value = isset( $option_value ) && ! empty( $option_value ) ? $option_value : ( isset( $field_data['default'] ) ? $field_data['default'] : '' );
|
2697 |
+
|
2698 |
+
$license = get_option( "{$field_data['id']}_edd_answer" );
|
2699 |
+
|
2700 |
+
if ( is_object( $license ) && ! empty( $value ) ) {
|
2701 |
+
// activate_license 'invalid' on anything other than valid, so if there was an error capture it
|
2702 |
+
if ( empty( $license->success ) ) {
|
2703 |
+
|
2704 |
+
if ( ! empty( $license->error ) ) {
|
2705 |
+
switch ( $license->error ) {
|
2706 |
+
|
2707 |
+
case 'expired' :
|
2708 |
+
|
2709 |
+
$class = 'expired';
|
2710 |
+
$messages[] = sprintf(
|
2711 |
+
__( 'Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'ultimate-member' ),
|
2712 |
+
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
|
2713 |
+
'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
|
2714 |
+
);
|
2715 |
+
|
2716 |
+
$license_status = 'license-' . $class . '-notice';
|
2717 |
+
|
2718 |
+
break;
|
2719 |
+
|
2720 |
+
case 'revoked' :
|
2721 |
+
|
2722 |
+
$class = 'error';
|
2723 |
+
$messages[] = sprintf(
|
2724 |
+
__( 'Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'ultimate-member' ),
|
2725 |
+
'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked'
|
2726 |
+
);
|
2727 |
+
|
2728 |
+
$license_status = 'license-' . $class . '-notice';
|
2729 |
+
|
2730 |
+
break;
|
2731 |
+
|
2732 |
+
case 'missing' :
|
2733 |
+
|
2734 |
+
$class = 'error';
|
2735 |
+
$messages[] = sprintf(
|
2736 |
+
__( 'Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'ultimate-member' ),
|
2737 |
+
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
|
2738 |
+
);
|
2739 |
+
|
2740 |
+
$license_status = 'license-' . $class . '-notice';
|
2741 |
+
|
2742 |
+
break;
|
2743 |
+
|
2744 |
+
case 'invalid' :
|
2745 |
+
case 'site_inactive' :
|
2746 |
+
|
2747 |
+
$class = 'error';
|
2748 |
+
$messages[] = sprintf(
|
2749 |
+
__( 'Your %s is not active for this URL. Please <a href="%s" target="_blank">visit your account page</a> to manage your license key URLs.', 'ultimate-member' ),
|
2750 |
+
$field_data['item_name'],
|
2751 |
+
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
|
2752 |
+
);
|
2753 |
+
|
2754 |
+
$license_status = 'license-' . $class . '-notice';
|
2755 |
+
|
2756 |
+
break;
|
2757 |
+
|
2758 |
+
case 'item_name_mismatch' :
|
2759 |
+
|
2760 |
+
$class = 'error';
|
2761 |
+
$messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] );
|
2762 |
+
|
2763 |
+
$license_status = 'license-' . $class . '-notice';
|
2764 |
+
|
2765 |
+
break;
|
2766 |
+
|
2767 |
+
case 'no_activations_left':
|
2768 |
+
|
2769 |
+
$class = 'error';
|
2770 |
+
$messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'ultimate-member' ), 'https://ultimatemember.com/account' );
|
2771 |
+
|
2772 |
+
$license_status = 'license-' . $class . '-notice';
|
2773 |
+
|
2774 |
+
break;
|
2775 |
+
|
2776 |
+
case 'license_not_activable':
|
2777 |
+
|
2778 |
+
$class = 'error';
|
2779 |
+
$messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' );
|
2780 |
+
|
2781 |
+
$license_status = 'license-' . $class . '-notice';
|
2782 |
+
break;
|
2783 |
+
|
2784 |
+
default :
|
2785 |
+
|
2786 |
+
$class = 'error';
|
2787 |
+
$error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' );
|
2788 |
+
$messages[] = sprintf( __( 'There was an error with this license key: %s. Please <a href="%s">contact our support team</a>.', 'ultimate-member' ), $error, 'https://ultimatemember.com/support' );
|
2789 |
+
|
2790 |
+
$license_status = 'license-' . $class . '-notice';
|
2791 |
+
break;
|
2792 |
+
}
|
2793 |
+
} else {
|
2794 |
+
$class = 'error';
|
2795 |
+
$error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' );
|
2796 |
+
$messages[] = sprintf( __( 'There was an error with this license key: %s. Please <a href="%s">contact our support team</a>.', 'ultimate-member' ), $error, 'https://ultimatemember.com/support' );
|
2797 |
+
|
2798 |
+
$license_status = 'license-' . $class . '-notice';
|
2799 |
+
}
|
2800 |
+
|
2801 |
+
} elseif ( ! empty( $license->errors ) ) {
|
2802 |
+
|
2803 |
+
$errors = array_keys( $license->errors );
|
2804 |
+
$errors_data = array_values( $license->errors );
|
2805 |
+
|
2806 |
+
$class = 'error';
|
2807 |
+
$error = ! empty( $errors[0] ) ? $errors[0] : __( 'unknown_error', 'ultimate-member' );
|
2808 |
+
$errors_data = ! empty( $errors_data[0][0] ) ? ', ' . $errors_data[0][0] : '';
|
2809 |
+
$messages[] = sprintf( __( 'There was an error with this license key: %s%s. Please <a href="%s">contact our support team</a>.', 'ultimate-member' ), $error, $errors_data, 'https://ultimatemember.com/support' );
|
2810 |
+
|
2811 |
+
$license_status = 'license-' . $class . '-notice';
|
2812 |
+
|
2813 |
+
} else {
|
2814 |
+
|
2815 |
+
switch( $license->license ) {
|
2816 |
+
|
2817 |
+
case 'expired' :
|
2818 |
+
|
2819 |
+
$class = 'expired';
|
2820 |
+
$messages[] = sprintf(
|
2821 |
+
__( 'Your license key expired on %s. Please <a href="%s" target="_blank">renew your license key</a>.', 'ultimate-member' ),
|
2822 |
+
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
|
2823 |
+
'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
|
2824 |
+
);
|
2825 |
+
|
2826 |
+
$license_status = 'license-' . $class . '-notice';
|
2827 |
+
|
2828 |
+
break;
|
2829 |
+
|
2830 |
+
case 'revoked' :
|
2831 |
+
|
2832 |
+
$class = 'error';
|
2833 |
+
$messages[] = sprintf(
|
2834 |
+
__( 'Your license key has been disabled. Please <a href="%s" target="_blank">contact support</a> for more information.', 'ultimate-member' ),
|
2835 |
+
'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked'
|
2836 |
+
);
|
2837 |
+
|
2838 |
+
$license_status = 'license-' . $class . '-notice';
|
2839 |
+
|
2840 |
+
break;
|
2841 |
+
|
2842 |
+
case 'missing' :
|
2843 |
+
|
2844 |
+
$class = 'error';
|
2845 |
+
$messages[] = sprintf(
|
2846 |
+
__( 'Invalid license. Please <a href="%s" target="_blank">visit your account page</a> and verify it.', 'ultimate-member' ),
|
2847 |
+
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
|
2848 |
+
);
|
2849 |
+
|
2850 |
+
$license_status = 'license-' . $class . '-notice';
|
2851 |
+
|
2852 |
+
break;
|
2853 |
+
|
2854 |
+
case 'invalid' :
|
2855 |
+
case 'site_inactive' :
|
2856 |
+
|
2857 |
+
$class = 'error';
|
2858 |
+
$messages[] = sprintf(
|
2859 |
+
__( 'Your %s is not active for this URL. Please <a href="%s" target="_blank">visit your account page</a> to manage your license key URLs.', 'ultimate-member' ),
|
2860 |
+
$field_data['item_name'],
|
2861 |
+
'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
|
2862 |
+
);
|
2863 |
+
|
2864 |
+
$license_status = 'license-' . $class . '-notice';
|
2865 |
+
|
2866 |
+
break;
|
2867 |
+
|
2868 |
+
case 'item_name_mismatch' :
|
2869 |
+
|
2870 |
+
$class = 'error';
|
2871 |
+
$messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] );
|
2872 |
+
|
2873 |
+
$license_status = 'license-' . $class . '-notice';
|
2874 |
+
|
2875 |
+
break;
|
2876 |
+
|
2877 |
+
case 'no_activations_left':
|
2878 |
+
|
2879 |
+
$class = 'error';
|
2880 |
+
$messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s">View possible upgrades</a> now.', 'ultimate-member' ), 'https://ultimatemember.com/account' );
|
2881 |
+
|
2882 |
+
$license_status = 'license-' . $class . '-notice';
|
2883 |
+
|
2884 |
+
break;
|
2885 |
+
|
2886 |
+
case 'license_not_activable':
|
2887 |
+
|
2888 |
+
$class = 'error';
|
2889 |
+
$messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' );
|
2890 |
+
|
2891 |
+
$license_status = 'license-' . $class . '-notice';
|
2892 |
+
break;
|
2893 |
+
|
2894 |
+
case 'valid' :
|
2895 |
+
default:
|
2896 |
+
|
2897 |
+
$class = 'valid';
|
2898 |
+
|
2899 |
+
$now = current_time( 'timestamp' );
|
2900 |
+
$expiration = strtotime( $license->expires, $now );
|
2901 |
+
|
2902 |
+
if( 'lifetime' === $license->expires ) {
|
2903 |
+
|
2904 |
+
$messages[] = __( 'License key never expires.', 'ultimate-member' );
|
2905 |
+
|
2906 |
+
$license_status = 'license-lifetime-notice';
|
2907 |
+
|
2908 |
+
} elseif( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) {
|
2909 |
+
|
2910 |
+
$messages[] = sprintf(
|
2911 |
+
__( 'Your license key expires soon! It expires on %s. <a href="%s" target="_blank">Renew your license key</a>.', 'ultimate-member' ),
|
2912 |
+
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
|
2913 |
+
'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=renew'
|
2914 |
+
);
|
2915 |
+
|
2916 |
+
$license_status = 'license-expires-soon-notice';
|
2917 |
+
|
2918 |
+
} else {
|
2919 |
+
|
2920 |
+
$messages[] = sprintf(
|
2921 |
+
__( 'Your license key expires on %s.', 'ultimate-member' ),
|
2922 |
+
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) )
|
2923 |
+
);
|
2924 |
+
|
2925 |
+
$license_status = 'license-expiration-date-notice';
|
2926 |
+
|
2927 |
+
}
|
2928 |
+
|
2929 |
+
break;
|
2930 |
+
|
2931 |
+
}
|
2932 |
+
|
2933 |
+
}
|
2934 |
+
|
2935 |
+
} else {
|
2936 |
+
$class = 'empty';
|
2937 |
+
|
2938 |
+
$messages[] = sprintf(
|
2939 |
+
__( 'To receive updates, please enter your valid %s license key.', 'ultimate-member' ),
|
2940 |
+
$field_data['item_name']
|
2941 |
+
);
|
2942 |
+
|
2943 |
+
$license_status = null;
|
2944 |
+
|
2945 |
+
} ?>
|
2946 |
+
|
2947 |
+
<tr class="um-settings-line">
|
2948 |
+
<th><label for="um_options_<?php echo esc_attr( $field_data['id'] ) ?>"><?php echo esc_html( $field_data['label'] ) ?></label></th>
|
2949 |
+
<td>
|
2950 |
+
<form method="post" action="" name="um-settings-form" class="um-settings-form">
|
2951 |
+
<input type="hidden" value="save" name="um-settings-action" />
|
2952 |
+
<input type="hidden" name="licenses_settings" value="1" />
|
2953 |
+
<?php $um_settings_nonce = wp_create_nonce( 'um-settings-nonce' ); ?>
|
2954 |
+
<input type="hidden" name="__umnonce" value="<?php echo esc_attr( $um_settings_nonce ); ?>" />
|
2955 |
+
<input type="text" id="um_options_<?php echo esc_attr( $field_data['id'] ) ?>" name="um_options[<?php echo esc_attr( $field_data['id'] ) ?>]" value="<?php echo $value ?>" class="um-option-field um-long-field" data-field_id="<?php echo esc_attr( $field_data['id'] ) ?>" />
|
2956 |
+
<?php if ( ! empty( $field_data['description'] ) ) { ?>
|
2957 |
+
<div class="description"><?php echo $field_data['description'] ?></div>
|
2958 |
+
<?php } ?>
|
2959 |
+
|
2960 |
+
<?php if ( ! empty( $value ) && ( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license ) ) { ?>
|
2961 |
+
<input type="button" class="button um_license_deactivate" id="<?php echo esc_attr( $field_data['id'] ) ?>_deactivate" value="<?php esc_attr_e( 'Clear License', 'ultimate-member' ) ?>"/>
|
2962 |
+
<?php } elseif ( empty( $value ) ) { ?>
|
2963 |
+
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Activate', 'ultimate-member' ) ?>" />
|
2964 |
+
<?php } else { ?>
|
2965 |
+
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Re-Activate', 'ultimate-member' ) ?>" />
|
2966 |
+
<input type="button" class="button um_license_deactivate" id="<?php echo esc_attr( $field_data['id'] ) ?>_deactivate" value="<?php esc_attr_e( 'Clear License', 'ultimate-member' ) ?>"/>
|
2967 |
+
<?php }
|
2968 |
+
|
2969 |
+
if ( ! empty( $messages ) ) {
|
2970 |
+
foreach ( $messages as $message ) { ?>
|
2971 |
+
<div class="edd-license-data edd-license-<?php echo esc_attr( $class . ' ' . $license_status ) ?>">
|
2972 |
+
<p><?php echo $message ?></p>
|
2973 |
+
</div>
|
2974 |
+
<?php }
|
2975 |
+
} ?>
|
2976 |
+
</form>
|
2977 |
+
</td>
|
2978 |
+
</tr>
|
2979 |
+
<?php } ?>
|
2980 |
+
</tbody>
|
2981 |
+
</table>
|
2982 |
+
</div>
|
2983 |
+
<?php $section = ob_get_clean();
|
2984 |
+
|
2985 |
+
return $section;
|
2986 |
+
}
|
2987 |
+
|
2988 |
+
|
2989 |
+
/**
|
2990 |
+
* @param $html
|
2991 |
+
* @param $section_fields
|
2992 |
+
*/
|
2993 |
+
function settings_install_info_tab( $html, $section_fields ) {
|
2994 |
+
global $wpdb;
|
2995 |
+
|
2996 |
+
if ( ! class_exists( '\Browser' ) )
|
2997 |
+
require_once um_path . 'includes/lib/browser.php';
|
2998 |
+
|
2999 |
+
// Detect browser
|
3000 |
+
$browser = new \Browser();
|
3001 |
+
|
3002 |
+
// Get theme info
|
3003 |
+
$theme_data = wp_get_theme();
|
3004 |
+
$theme = $theme_data->Name . ' ' . $theme_data->Version;
|
3005 |
+
|
3006 |
+
// Identify Hosting Provider
|
3007 |
+
$host = um_get_host();
|
3008 |
+
|
3009 |
+
um_fetch_user( get_current_user_id() );
|
3010 |
+
|
3011 |
+
if ( isset( $this->content ) ) {
|
3012 |
+
echo $this->content;
|
3013 |
+
} else { ?>
|
3014 |
+
|
3015 |
+
<h3>Install Info</h3>
|
3016 |
+
|
3017 |
+
<form action="" method="post" dir="ltr">
|
3018 |
+
<textarea style="width:70%; height:400px;" readonly="readonly" onclick="this.focus();this.select()" id="install-info-textarea" name="um-install-info" title="<?php _e( 'To copy the Install info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'ultimate-member' ); ?>">
|
3019 |
+
### Begin Install Info ###
|
3020 |
+
|
3021 |
+
## Please include this information when posting support requests ##
|
3022 |
+
|
3023 |
+
<?php
|
3024 |
+
/**
|
3025 |
+
* UM hook
|
3026 |
+
*
|
3027 |
+
* @type action
|
3028 |
+
* @title um_install_info_before
|
3029 |
+
* @description Before install info settings
|
3030 |
+
* @change_log
|
3031 |
+
* ["Since: 2.0"]
|
3032 |
+
* @usage add_action( 'um_install_info_before', 'function_name', 10 );
|
3033 |
+
* @example
|
3034 |
+
* <?php
|
3035 |
+
* add_action( 'um_install_info_before', 'my_install_info_before', 10 );
|
3036 |
+
* function my_install_info_before() {
|
3037 |
+
* // your code here
|
3038 |
+
* }
|
3039 |
+
* ?>
|
3040 |
+
*/
|
3041 |
+
do_action( 'um_install_info_before' ); ?>
|
3042 |
+
|
3043 |
+
--- Site Info ---
|
3044 |
+
|
3045 |
+
Site URL: <?php echo site_url() . "\n"; ?>
|
3046 |
+
Home URL: <?php echo home_url() . "\n"; ?>
|
3047 |
+
Multisite: <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n" ?>
|
3048 |
+
|
3049 |
+
--- Hosting Provider ---
|
3050 |
+
|
3051 |
+
<?php if( $host ) : ?>
|
3052 |
+
Host: <?php echo $host . "\n"; ?>
|
3053 |
+
<?php endif; ?>
|
3054 |
+
|
3055 |
+
--- User Browser ---
|
3056 |
+
|
3057 |
+
<?php echo $browser ; ?>
|
3058 |
+
|
3059 |
+
---- Current User Details --
|
3060 |
+
|
3061 |
+
<?php $user = wp_get_current_user(); ?>
|
3062 |
+
Role: <?php echo implode( ', ', um_user( 'roles' ) ). "\n"; ?>
|
3063 |
+
|
3064 |
+
|
3065 |
+
--- WordPress Configurations ---
|
3066 |
+
|
3067 |
+
Version: <?php echo get_bloginfo( 'version' ) . "\n"; ?>
|
3068 |
+
Language: <?php echo get_locale()."\n"; ?>
|
3069 |
+
Permalink Structure: <?php echo get_option( 'permalink_structure' ) . "\n"; ?>
|
3070 |
+
Active Theme: <?php echo $theme . "\n"; ?>
|
3071 |
+
<?php $show_on_front = get_option( 'show_on_front' ); ?>
|
3072 |
+
<?php if( $show_on_front == "posts" ): ?>
|
3073 |
+
Show On Front: <?php echo get_option( 'show_on_front' ) . "/static\n" ?>
|
3074 |
+
<?php elseif( $show_on_front == "page" ): ?>
|
3075 |
+
Page On Front: <?php $id = get_option( 'page_on_front' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
|
3076 |
+
Page For Posts: <?php $id = get_option( 'page_for_posts' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
|
3077 |
+
<?php endif; ?>
|
3078 |
+
ABSPATH: <?php echo ABSPATH."\n"; ?>
|
3079 |
+
<?php $wp_count_posts = wp_count_posts(); ?>
|
3080 |
+
All Posts/Pages: <?php echo array_sum((array)$wp_count_posts)."\n";?>
|
3081 |
+
<?php
|
3082 |
+
$request['cmd'] = '_notify-validate';
|
3083 |
+
|
3084 |
+
$params = array(
|
3085 |
+
'sslverify' => false,
|
3086 |
+
'timeout' => 60,
|
3087 |
+
'user-agent' => 'UltimateMember/' . ultimatemember_version,
|
3088 |
+
'body' => $request
|
3089 |
+
);
|
3090 |
+
|
3091 |
+
$response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
|
3092 |
+
|
3093 |
+
if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
|
3094 |
+
$WP_REMOTE_POST = 'wp_remote_post() works' . "\n";
|
3095 |
+
} else {
|
3096 |
+
$WP_REMOTE_POST = 'wp_remote_post() does not work' . "\n";
|
3097 |
+
}
|
3098 |
+
?>
|
3099 |
+
WP Remote Post: <?php echo $WP_REMOTE_POST; ?>
|
3100 |
+
WP_DEBUG: <?php echo defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n" ?>
|
3101 |
+
WP Table Prefix: <?php echo "Length: ". strlen( $wpdb->prefix ); echo ", Status:"; if ( strlen( $wpdb->prefix )>16 ) {echo " ERROR: Too Long";} else {echo " Acceptable";} echo "\n"; ?>
|
3102 |
+
Memory Limit: <?php echo ( um_let_to_num( WP_MEMORY_LIMIT )/( 1024 ) )."MB"; ?><?php echo "\n"; ?>
|
3103 |
+
|
3104 |
+
|
3105 |
+
--- UM Configurations ---
|
3106 |
+
|
3107 |
+
Version: <?php echo ultimatemember_version . "\n"; ?>
|
3108 |
+
Upgraded From: <?php echo get_option( 'um_last_version_upgrade', 'None' ) . "\n"; ?>
|
3109 |
+
Current URL Method: <?php echo UM()->options()->get( 'current_url_method' ). "\n"; ?>
|
3110 |
+
Cache User Profile: <?php if( UM()->options()->get( 'um_profile_object_cache_stop' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
|
3111 |
+
Generate Slugs on Directories: <?php if( UM()->options()->get( 'um_generate_slug_in_directory' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
|
3112 |
+
Force UTF-8 Encoding: <?php if( UM()->options()->get( 'um_force_utf8_strings' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3113 |
+
JS/CSS Compression: <?php if ( defined('SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3114 |
+
<?php if( is_multisite() ): ?>
|
3115 |
+
Network Structure: <?php echo UM()->options()->get( 'network_permalink_structure' ). "\n"; ?>
|
3116 |
+
<?php endif; ?>
|
3117 |
+
Port Forwarding in URL: <?php if( UM()->options()->get( 'um_port_forwarding_url' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3118 |
+
Exclude CSS/JS on Home: <?php if( UM()->options()->get( 'js_css_exlcude_home' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
|
3119 |
+
|
3120 |
+
|
3121 |
+
--- UM Pages Configuration ---
|
3122 |
+
|
3123 |
+
<?php
|
3124 |
+
/**
|
3125 |
+
* UM hook
|
3126 |
+
*
|
3127 |
+
* @type action
|
3128 |
+
* @title um_install_info_before_page_config
|
3129 |
+
* @description Before page config install info
|
3130 |
+
* @change_log
|
3131 |
+
* ["Since: 2.0"]
|
3132 |
+
* @usage add_action( 'um_install_info_before_page_config', 'function_name', 10 );
|
3133 |
+
* @example
|
3134 |
+
* <?php
|
3135 |
+
* add_action( 'um_install_info_before_page_config', 'my_install_info_before_page_config', 10 );
|
3136 |
+
* function my_install_info_before_page_config() {
|
3137 |
+
* // your code here
|
3138 |
+
* }
|
3139 |
+
* ?>
|
3140 |
+
*/
|
3141 |
+
do_action( "um_install_info_before_page_config" ); ?>
|
3142 |
+
User: <?php echo get_permalink( UM()->options()->get('core_user') ) . "\n"; ?>
|
3143 |
+
Account: <?php echo get_permalink( UM()->options()->get('core_account') ) . "\n"; ?>
|
3144 |
+
Members: <?php echo get_permalink( UM()->options()->get('core_members') ) . "\n"; ?>
|
3145 |
+
Register: <?php echo get_permalink( UM()->options()->get('core_register') ) . "\n"; ?>
|
3146 |
+
Login: <?php echo get_permalink( UM()->options()->get('core_login') ) . "\n"; ?>
|
3147 |
+
Logout: <?php echo get_permalink( UM()->options()->get('core_logout') ) . "\n"; ?>
|
3148 |
+
Password Reset: <?php echo get_permalink( UM()->options()->get('core_password-reset') ) . "\n"; ?>
|
3149 |
+
<?php
|
3150 |
+
/**
|
3151 |
+
* UM hook
|
3152 |
+
*
|
3153 |
+
* @type action
|
3154 |
+
* @title um_install_info_after_page_config
|
3155 |
+
* @description After page config install info
|
3156 |
+
* @change_log
|
3157 |
+
* ["Since: 2.0"]
|
3158 |
+
* @usage add_action( 'um_install_info_after_page_config', 'function_name', 10 );
|
3159 |
+
* @example
|
3160 |
+
* <?php
|
3161 |
+
* add_action( 'um_install_info_after_page_config', 'my_install_info_after_page_config', 10 );
|
3162 |
+
* function my_install_info_after_page_config() {
|
3163 |
+
* // your code here
|
3164 |
+
* }
|
3165 |
+
* ?>
|
3166 |
+
*/
|
3167 |
+
do_action( "um_install_info_after_page_config" ); ?>
|
3168 |
+
|
3169 |
+
|
3170 |
+
--- UM Users Configuration ---
|
3171 |
+
|
3172 |
+
Default New User Role: <?php echo UM()->options()->get('register_role') . "\n"; ?>
|
3173 |
+
Profile Permalink Base: <?php echo UM()->options()->get('permalink_base') . "\n"; ?>
|
3174 |
+
User Display Name: <?php echo UM()->options()->get('display_name') . "\n"; ?>
|
3175 |
+
Redirect author to profile: <?php echo $this->info_value( UM()->options()->get('author_redirect'), 'yesno', true ); ?>
|
3176 |
+
Enable Members Directory: <?php echo $this->info_value( UM()->options()->get('members_page'), 'yesno', true ); ?>
|
3177 |
+
Use Gravatars: <?php echo $this->info_value( UM()->options()->get('use_gravatars'), 'yesno', true ); ?>
|
3178 |
+
<?php if( UM()->options()->get('use_gravatars') ): ?>Gravatar builtin image: <?php echo UM()->options()->get('use_um_gravatar_default_builtin_image') . "\n"; ?>
|
3179 |
+
UM Avatar as blank Gravatar: <?php echo $this->info_value( UM()->options()->get('use_um_gravatar_default_image'), 'yesno', true ); ?><?php endif; ?>
|
3180 |
+
Require a strong password: <?php echo $this->info_value( UM()->options()->get('require_strongpass'), 'onoff', true ); ?>
|
3181 |
+
|
3182 |
+
|
3183 |
+
--- UM Access Configuration ---
|
3184 |
+
|
3185 |
+
Panic Key: <?php echo UM()->options()->get('panic_key') . "\n"; ?>
|
3186 |
+
Global Site Access: <?php $arr = array('Site accessible to Everyone','','Site accessible to Logged In Users'); echo $arr[ (int) UM()->options()->get('accessible') ] . "\n"; ?>
|
3187 |
+
<?php if( UM()->options()->get('accessible') == 2 ) { ?>
|
3188 |
+
Custom Redirect URL: <?php echo UM()->options()->get('access_redirect')."\n";?>
|
3189 |
+
Exclude the following URLs:<?php echo "\t\t\t\t".implode("\t\n\t\t\t\t\t\t\t\t\t\t",UM()->options()->get('access_exclude_uris') )."\n";?>
|
3190 |
+
<?php } ?>
|
3191 |
+
Backend Login Screen for Guests: <?php echo $this->info_value( UM()->options()->get('wpadmin_login'), 'yesno', true ); ?>
|
3192 |
+
<?php if( ! UM()->options()->get('wpadmin_login') ) { ?>
|
3193 |
+
Redirect to alternative login page: <?php if( UM()->options()->get('wpadmin_login_redirect') == 'um_login_page' ){ echo um_get_core_page('login')."\n"; }else{ echo UM()->options()->get('wpadmin_login_redirect_url')."\n"; }?>
|
3194 |
+
<?php } ?>
|
3195 |
+
Backend Register Screen for Guests: <?php echo $this->info_value( UM()->options()->get('wpadmin_register'), 'yesno', true ); ?>
|
3196 |
+
<?php if( ! UM()->options()->get('wpadmin_register') ) { ?>
|
3197 |
+
Redirect to alternative register page: <?php if( UM()->options()->get('wpadmin_register_redirect') == 'um_register_page' ){ echo um_get_core_page('register')."\n"; }else{ echo UM()->options()->get('wpadmin_register_redirect_url')."\n"; }?>
|
3198 |
+
<?php } ?>
|
3199 |
+
Access Control widget for Admins only: <?php echo $this->info_value( UM()->options()->get('access_widget_admin_only'), 'yesno', true ); ?>
|
3200 |
+
Enable the Reset Password Limit: <?php echo $this->info_value( UM()->options()->get('enable_reset_password_limit'), 'yesno', true ); ?>
|
3201 |
+
<?php if( UM()->options()->get('enable_reset_password_limit') ) { ?>
|
3202 |
+
Reset Password Limit: <?php echo UM()->options()->get('reset_password_limit_number') ?>
|
3203 |
+
Disable Reset Password Limit for Admins: <?php echo $this->info_value( UM()->options()->get('disable_admin_reset_password_limit'), 'yesno', true ) ?>
|
3204 |
+
<?php } ?>
|
3205 |
+
<?php $blocked_ips = UM()->options()->get('blocked_ips'); if( ! empty( $blocked_ips ) ){ ?>
|
3206 |
+
Blocked IP Addresses: <?php echo count( explode("\n",UM()->options()->get('blocked_ips') ) )."\n"; ?>
|
3207 |
+
<?php } ?>
|
3208 |
+
<?php $blocked_emails = UM()->options()->get('blocked_emails'); if( ! empty( $blocked_emails ) ){ ?>
|
3209 |
+
Blocked Email Addresses: <?php echo count( explode("\n",UM()->options()->get('blocked_emails') ) )."\n"; ?>
|
3210 |
+
<?php } ?>
|
3211 |
+
<?php $blocked_words = UM()->options()->get('blocked_words'); if( ! empty( $blocked_words ) ){ ?>
|
3212 |
+
Blacklist Words: <?php echo count( explode("\n",UM()->options()->get('blocked_words') ) )."\n"; ?>
|
3213 |
+
<?php } ?>
|
3214 |
+
|
3215 |
+
|
3216 |
+
--- UM Email Configurations ---
|
3217 |
+
|
3218 |
+
Mail appears from: <?php $mail_from = UM()->options()->get('mail_from'); if( ! empty( $mail_from ) ){echo UM()->options()->get('mail_from');}else{echo "-";}; echo "\n";?>
|
3219 |
+
Mail appears from address: <?php $mail_from_addr = UM()->options()->get('mail_from_addr'); if( ! empty( $mail_from_addr ) ){echo UM()->options()->get('mail_from_addr');}else{echo "-";}; echo "\n";?>
|
3220 |
+
Use HTML for E-mails: <?php echo $this->info_value( UM()->options()->get('email_html'), 'yesno', true ); ?>
|
3221 |
+
Account Welcome Email: <?php echo $this->info_value( UM()->options()->get('welcome_email_on'), 'yesno', true ); ?>
|
3222 |
+
Account Activation Email: <?php echo $this->info_value( UM()->options()->get('checkmail_email_on'), 'yesno', true ); ?>
|
3223 |
+
Pending Review Email: <?php echo $this->info_value( UM()->options()->get('pending_email_on'), 'yesno', true ); ?>
|
3224 |
+
Account Approved Email: <?php echo $this->info_value( UM()->options()->get('approved_email_on'), 'yesno', true ); ?>
|
3225 |
+
Account Rejected Email: <?php echo $this->info_value( UM()->options()->get('rejected_email_on'), 'yesno', true ); ?>
|
3226 |
+
Account Deactivated Email: <?php echo $this->info_value( UM()->options()->get('inactive_email_on'), 'yesno', true ); ?>
|
3227 |
+
Account Deleted Email: <?php echo $this->info_value( UM()->options()->get('deletion_email_on'), 'yesno', true ); ?>
|
3228 |
+
Password Reset Email: <?php echo $this->info_value( UM()->options()->get('resetpw_email_on'), 'yesno', true ); ?>
|
3229 |
+
Password Changed Email: <?php echo $this->info_value( UM()->options()->get('changedpw_email_on'), 'yesno', true ); ?>
|
3230 |
+
|
3231 |
+
|
3232 |
+
--- UM Total Users ---
|
3233 |
+
|
3234 |
+
<?php $result = count_users();
|
3235 |
+
echo 'All Users('.$result['total_users'].")\n";
|
3236 |
+
foreach( $result['avail_roles'] as $role => $count ) {
|
3237 |
+
echo $role."(".$count.")\n";
|
3238 |
+
} ?>
|
3239 |
+
|
3240 |
+
|
3241 |
+
--- UM Roles ---
|
3242 |
+
|
3243 |
+
<?php foreach( UM()->roles()->get_roles() as $role_id => $role ) {
|
3244 |
+
echo $role." ({$role_id})\n";
|
3245 |
+
} ?>
|
3246 |
+
|
3247 |
+
|
3248 |
+
--- UM Custom Templates ---
|
3249 |
+
|
3250 |
+
<?php // Show templates that have been copied to the theme's edd_templates dir
|
3251 |
+
$dir = get_stylesheet_directory() . '/ultimate-member/templates/*.php';
|
3252 |
+
if ( ! empty( $dir ) ) {
|
3253 |
+
$found = glob( $dir );
|
3254 |
+
if ( ! empty( $found ) ) {
|
3255 |
+
foreach ( glob( $dir ) as $file ) {
|
3256 |
+
echo "File: " . $file . "\n";
|
3257 |
+
}
|
3258 |
+
} else {
|
3259 |
+
echo 'N/A'."\n";
|
3260 |
+
}
|
3261 |
+
} ?>
|
3262 |
+
|
3263 |
+
|
3264 |
+
--- UM Email HTML Templates ---
|
3265 |
+
|
3266 |
+
<?php $dir = get_stylesheet_directory() . '/ultimate-member/templates/emails/*.html';
|
3267 |
+
|
3268 |
+
if ( ! empty( $dir ) ) {
|
3269 |
+
$found = glob( $dir );
|
3270 |
+
if ( ! empty( $found ) ){
|
3271 |
+
foreach ( glob( $dir ) as $file ) {
|
3272 |
+
echo "File: ". $file . "\n";
|
3273 |
+
}
|
3274 |
+
} else {
|
3275 |
+
echo 'N/A'."\n";
|
3276 |
+
}
|
3277 |
+
} ?>
|
3278 |
+
|
3279 |
+
|
3280 |
+
--- Web Server Configurations ---
|
3281 |
+
|
3282 |
+
PHP Version: <?php echo PHP_VERSION . "\n"; ?>
|
3283 |
+
MySQL Version: <?php echo $wpdb->db_version() . "\n"; ?>
|
3284 |
+
Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?>
|
3285 |
+
|
3286 |
+
|
3287 |
+
--- PHP Configurations ---
|
3288 |
+
|
3289 |
+
PHP Memory Limit: <?php echo ini_get( 'memory_limit' ) . "\n"; ?>
|
3290 |
+
PHP Upload Max Size: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
|
3291 |
+
PHP Post Max Size: <?php echo ini_get( 'post_max_size' ) . "\n"; ?>
|
3292 |
+
PHP Upload Max Filesize: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
|
3293 |
+
PHP Time Limit: <?php echo ini_get( 'max_execution_time' ) . "\n"; ?>
|
3294 |
+
PHP Max Input Vars: <?php echo ini_get( 'max_input_vars' ) . "\n"; ?>
|
3295 |
+
PHP Arg Separator: <?php echo ini_get( 'arg_separator.output' ) . "\n"; ?>
|
3296 |
+
PHP Allow URL File Open: <?php echo ini_get( 'allow_url_fopen' ) ? "Yes\n" : "No\n"; ?>
|
3297 |
+
|
3298 |
+
|
3299 |
+
--- Web Server Extensions/Modules ---
|
3300 |
+
|
3301 |
+
DISPLAY ERRORS: <?php echo ( ini_get( 'display_errors' ) ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A'; ?><?php echo "\n"; ?>
|
3302 |
+
FSOCKOPEN: <?php echo ( function_exists( 'fsockopen' ) ) ? 'Your server supports fsockopen.' : 'Your server does not support fsockopen.'; ?><?php echo "\n"; ?>
|
3303 |
+
cURL: <?php echo ( function_exists( 'curl_init' ) ) ? 'Your server supports cURL.' : 'Your server does not support cURL.'; ?><?php echo "\n"; ?>
|
3304 |
+
SOAP Client: <?php echo ( class_exists( 'SoapClient' ) ) ? 'Your server has the SOAP Client enabled.' : 'Your server does not have the SOAP Client enabled.'; ?><?php echo "\n"; ?>
|
3305 |
+
SUHOSIN: <?php echo ( extension_loaded( 'suhosin' ) ) ? 'Your server has SUHOSIN installed.' : 'Your server does not have SUHOSIN installed.'; ?><?php echo "\n"; ?>
|
3306 |
+
GD Library: <?php echo ( extension_loaded( 'gd' ) && function_exists('gd_info') ) ? 'PHP GD library is installed on your web server.' : 'PHP GD library is NOT installed on your web server.'; ?><?php echo "\n"; ?>
|
3307 |
+
Mail: <?php echo ( function_exists('mail') ) ? 'PHP mail function exist on your web server.' : 'PHP mail function doesn\'t exist on your web server.'; ?><?php echo "\n"; ?>
|
3308 |
+
Exif: <?php echo ( extension_loaded( 'exif' ) && function_exists('exif_imagetype') ) ? 'PHP Exif library is installed on your web server.' : 'PHP Exif library is NOT installed on your web server.'; ?><?php echo "\n"; ?>
|
3309 |
+
|
3310 |
+
|
3311 |
+
--- Session Configurations ---
|
3312 |
+
|
3313 |
+
Session: <?php echo isset( $_SESSION ) ? 'Enabled' : 'Disabled'; ?><?php echo "\n"; ?>
|
3314 |
+
Session Name: <?php echo esc_html( ini_get( 'session.name' ) ); ?><?php echo "\n"; ?>
|
3315 |
+
Cookie Path: <?php echo esc_html( ini_get( 'session.cookie_path' ) ); ?><?php echo "\n"; ?>
|
3316 |
+
Save Path: <?php echo esc_html( ini_get( 'session.save_path' ) ); ?><?php echo "\n"; ?>
|
3317 |
+
Use Cookies: <?php echo ini_get( 'session.use_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
|
3318 |
+
Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
|
3319 |
+
|
3320 |
+
|
3321 |
+
--- WordPress Active Plugins ---
|
3322 |
+
|
3323 |
+
<?php $plugins = get_plugins();
|
3324 |
+
$active_plugins = get_option( 'active_plugins', array() );
|
3325 |
+
|
3326 |
+
foreach ( $plugins as $plugin_path => $plugin ) {
|
3327 |
+
// If the plugin isn't active, don't show it.
|
3328 |
+
if ( ! in_array( $plugin_path, $active_plugins ) )
|
3329 |
+
continue;
|
3330 |
+
|
3331 |
+
echo $plugin['Name'] . ': ' . $plugin['Version'] ."\n";
|
3332 |
+
}
|
3333 |
+
|
3334 |
+
if ( is_multisite() ) { ?>
|
3335 |
+
|
3336 |
+
--- WordPress Network Active Plugins ---
|
3337 |
+
|
3338 |
+
<?php $plugins = wp_get_active_network_plugins();
|
3339 |
+
$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
|
3340 |
+
|
3341 |
+
foreach ( $plugins as $plugin_path ) {
|
3342 |
+
$plugin_base = plugin_basename( $plugin_path );
|
3343 |
+
|
3344 |
+
// If the plugin isn't active, don't show it.
|
3345 |
+
if ( ! array_key_exists( $plugin_base, $active_plugins ) )
|
3346 |
+
continue;
|
3347 |
+
|
3348 |
+
$plugin = get_plugin_data( $plugin_path );
|
3349 |
+
|
3350 |
+
echo $plugin['Name'] . ' :' . $plugin['Version'] . "\n";
|
3351 |
+
}
|
3352 |
+
|
3353 |
+
}
|
3354 |
+
|
3355 |
+
/**
|
3356 |
+
* UM hook
|
3357 |
+
*
|
3358 |
+
* @type action
|
3359 |
+
* @title um_install_info_after
|
3360 |
+
* @description After install info
|
3361 |
+
* @change_log
|
3362 |
+
* ["Since: 2.0"]
|
3363 |
+
* @usage add_action( 'um_install_info_after', 'function_name', 10 );
|
3364 |
+
* @example
|
3365 |
+
* <?php
|
3366 |
+
* add_action( 'um_install_info_after', 'my_install_info_after', 10 );
|
3367 |
+
* function my_install_info_after() {
|
3368 |
+
* // your code here
|
3369 |
+
* }
|
3370 |
+
* ?>
|
3371 |
+
*/
|
3372 |
+
do_action( 'um_install_info_after' ); ?>
|
3373 |
+
|
3374 |
+
### End Install Info ###
|
3375 |
+
</textarea>
|
3376 |
+
<p class="submit">
|
3377 |
+
<input type="hidden" name="um-addon-hook" value="download_install_info" />
|
3378 |
+
<?php submit_button( 'Download Install Info File', 'primary', 'download_install_info', false ); ?>
|
3379 |
+
</p>
|
3380 |
+
</form>
|
3381 |
+
|
3382 |
+
<?php }
|
3383 |
+
}
|
3384 |
+
|
3385 |
+
|
3386 |
+
/**
|
3387 |
+
*
|
3388 |
+
*/
|
3389 |
+
function um_download_install_info() {
|
3390 |
+
if ( ! empty( $_POST['download_install_info'] ) ) {
|
3391 |
+
nocache_headers();
|
3392 |
+
|
3393 |
+
header( "Content-type: text/plain" );
|
3394 |
+
header( 'Content-Disposition: attachment; filename="ultimatemember-install-info.txt"' );
|
3395 |
+
|
3396 |
+
echo wp_strip_all_tags( sanitize_textarea_field( $_POST['um-install-info'] ) );
|
3397 |
+
exit;
|
3398 |
+
}
|
3399 |
+
}
|
3400 |
+
|
3401 |
+
|
3402 |
+
/**
|
3403 |
+
* @param string $raw_value
|
3404 |
+
* @param string $type
|
3405 |
+
* @param string $default
|
3406 |
+
*
|
3407 |
+
* @return string
|
3408 |
+
*/
|
3409 |
+
function info_value( $raw_value = '', $type = 'yesno', $default = '' ) {
|
3410 |
+
|
3411 |
+
if ( $type == 'yesno' ) {
|
3412 |
+
$raw_value = ( $default == $raw_value ) ? "Yes" : "No";
|
3413 |
+
} elseif( $type == 'onoff' ) {
|
3414 |
+
$raw_value = ( $default == $raw_value ) ? "On" : "Off";
|
3415 |
+
}
|
3416 |
+
|
3417 |
+
return $raw_value."\n";
|
3418 |
+
}
|
3419 |
+
|
3420 |
+
|
3421 |
+
/**
|
3422 |
+
* Render settings section
|
3423 |
+
*
|
3424 |
+
* @param array $section_fields
|
3425 |
+
* @param string $current_tab
|
3426 |
+
* @param string $current_subtab
|
3427 |
+
*
|
3428 |
+
* @return string
|
3429 |
+
*/
|
3430 |
+
function render_settings_section( $section_fields, $current_tab, $current_subtab ) {
|
3431 |
+
ob_start();
|
3432 |
+
|
3433 |
+
UM()->admin_forms_settings( array(
|
3434 |
+
'class' => 'um_options-' . $current_tab . '-' . $current_subtab . ' um-third-column',
|
3435 |
+
'prefix_id' => 'um_options',
|
3436 |
+
'fields' => $section_fields
|
3437 |
+
) )->render_form(); ?>
|
3438 |
+
|
3439 |
+
<?php $section = ob_get_clean();
|
3440 |
+
|
3441 |
+
return $section;
|
3442 |
+
}
|
3443 |
+
|
3444 |
+
|
3445 |
+
/**
|
3446 |
+
* @param array $settings
|
3447 |
+
*
|
3448 |
+
* @return array
|
3449 |
+
*/
|
3450 |
+
function save_email_templates( $settings ) {
|
3451 |
+
|
3452 |
+
if ( empty( $settings['um_email_template'] ) ) {
|
3453 |
+
return $settings;
|
3454 |
+
}
|
3455 |
+
|
3456 |
+
$template = $settings['um_email_template'];
|
3457 |
+
$content = wp_kses_post( stripslashes( $settings[ $template ] ) );
|
3458 |
+
|
3459 |
+
$theme_template_path = UM()->mail()->get_template_file( 'theme', $template );
|
3460 |
+
|
3461 |
+
if ( ! file_exists( $theme_template_path ) ) {
|
3462 |
+
UM()->mail()->copy_email_template( $template );
|
3463 |
+
}
|
3464 |
+
|
3465 |
+
$fp = fopen( $theme_template_path, "w" );
|
3466 |
+
$result = fputs( $fp, $content );
|
3467 |
+
fclose( $fp );
|
3468 |
+
|
3469 |
+
if ( $result !== false ) {
|
3470 |
+
unset( $settings['um_email_template'] );
|
3471 |
+
unset( $settings[ $template ] );
|
3472 |
+
}
|
3473 |
+
|
3474 |
+
return $settings;
|
3475 |
+
}
|
3476 |
+
}
|
3477 |
+
}
|
|
includes/admin/core/class-admin-upgrade.php
CHANGED
@@ -356,10 +356,20 @@ if ( ! class_exists( 'um\admin\core\Admin_Upgrade' ) ) {
|
|
356 |
if ( empty( $_POST['pack'] ) ) {
|
357 |
exit('');
|
358 |
} else {
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
363 |
}
|
364 |
}
|
365 |
|
@@ -407,4 +417,4 @@ if ( ! class_exists( 'um\admin\core\Admin_Upgrade' ) ) {
|
|
407 |
}
|
408 |
|
409 |
}
|
410 |
-
}
|
356 |
if ( empty( $_POST['pack'] ) ) {
|
357 |
exit('');
|
358 |
} else {
|
359 |
+
$pack = sanitize_text_field( $_POST['pack'] );
|
360 |
+
if ( in_array( $pack, $this->necessary_packages, true ) ) {
|
361 |
+
$file = $this->packages_dir . $pack . DIRECTORY_SEPARATOR . 'init.php';
|
362 |
+
if ( file_exists( $file ) ) {
|
363 |
+
ob_start();
|
364 |
+
include_once $file;
|
365 |
+
ob_get_flush();
|
366 |
+
exit;
|
367 |
+
} else {
|
368 |
+
exit('');
|
369 |
+
}
|
370 |
+
} else {
|
371 |
+
exit('');
|
372 |
+
}
|
373 |
}
|
374 |
}
|
375 |
|
417 |
}
|
418 |
|
419 |
}
|
420 |
+
}
|
includes/core/class-access.php
CHANGED
@@ -1,2136 +1,2141 @@
|
|
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 |
-
add_filter( '
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
//
|
60 |
-
add_filter( '
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
add_filter( '
|
74 |
-
|
75 |
-
// filter
|
76 |
-
add_filter( '
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
// there
|
95 |
-
//
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
//
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
//
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
remove_filter( '
|
125 |
-
remove_filter( '
|
126 |
-
remove_filter( '
|
127 |
-
|
128 |
-
remove_filter( '
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
*
|
137 |
-
*
|
138 |
-
*
|
139 |
-
* @
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
$
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
//
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
$
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
'
|
206 |
-
'
|
207 |
-
'
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
$
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
$
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
array(
|
284 |
-
'key' => 'um_content_restriction',
|
285 |
-
'value' => 's:26:"_um_custom_access_settings";
|
286 |
-
'compare' => 'NOT LIKE',
|
287 |
-
),
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
}
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
$restricted_taxonomies
|
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 |
-
if ( ! empty( $
|
424 |
-
|
425 |
-
}
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
$
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
if (
|
457 |
-
$
|
458 |
-
}
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
$
|
465 |
-
}
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
*
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
*
|
508 |
-
*
|
509 |
-
* @
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
$
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
if (
|
530 |
-
$cache[ $cache_key ]
|
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 |
-
if (
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
if (
|
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 |
-
if (
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
*
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
if ( $
|
689 |
-
|
690 |
-
}
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
$title
|
695 |
-
}
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
if (
|
715 |
-
return $content;
|
716 |
-
}
|
717 |
-
|
718 |
-
$
|
719 |
-
if ( $
|
720 |
-
return $content;
|
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 |
-
if (
|
759 |
-
return $post_excerpt;
|
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 |
-
if (
|
814 |
-
$has_thumbnail = false;
|
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 |
-
if (
|
843 |
-
$
|
844 |
-
}
|
845 |
-
|
846 |
-
|
847 |
-
if (
|
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 |
-
if (
|
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 |
-
$exclude_posts =
|
947 |
-
if (
|
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 |
-
$where .= ' AND comment_post_ID
|
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 |
-
$comment_count['
|
1024 |
-
$comment_count['
|
1025 |
-
break;
|
1026 |
-
case '
|
1027 |
-
$comment_count['
|
1028 |
-
$comment_count['total_comments']
|
1029 |
-
$comment_count['all']
|
1030 |
-
break;
|
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 |
-
return $open;
|
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 |
-
return $
|
1094 |
-
}
|
1095 |
-
|
1096 |
-
$
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
if
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
if ( ! $this->
|
1132 |
-
$filtered_items[] = $menu_item;
|
1133 |
-
continue;
|
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 |
-
if (
|
1171 |
-
return $block_content;
|
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 |
-
if ( $
|
1265 |
-
return $post;
|
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 |
-
if ( $
|
1295 |
-
return $nav_item;
|
1296 |
-
}
|
1297 |
-
|
1298 |
-
$
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
*
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
if (
|
1320 |
-
return $posts;
|
1321 |
-
}
|
1322 |
-
|
1323 |
-
//
|
1324 |
-
if ( empty( $
|
1325 |
-
return $posts;
|
1326 |
-
}
|
1327 |
-
|
1328 |
-
if
|
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 |
-
if ( $
|
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 |
-
if
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
}
|
1449 |
-
|
1450 |
-
//
|
1451 |
-
if (
|
1452 |
-
return;
|
1453 |
-
}
|
1454 |
-
|
1455 |
-
//also skip if we currently at
|
1456 |
-
if (
|
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 |
-
if ( is_tag() ) {
|
1519 |
-
|
1520 |
-
}
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
$
|
1527 |
-
|
1528 |
-
$
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
}
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
$
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
*
|
1602 |
-
*
|
1603 |
-
*
|
1604 |
-
* @
|
1605 |
-
*
|
1606 |
-
* @
|
1607 |
-
*
|
1608 |
-
*
|
1609 |
-
*
|
1610 |
-
*
|
1611 |
-
*
|
1612 |
-
*
|
1613 |
-
*
|
1614 |
-
*
|
1615 |
-
*
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
$
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
$
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
$
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
$
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
}
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
*
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
*
|
1739 |
-
*
|
1740 |
-
* @
|
1741 |
-
*
|
1742 |
-
* @
|
1743 |
-
* @
|
1744 |
-
*
|
1745 |
-
*
|
1746 |
-
*
|
1747 |
-
*
|
1748 |
-
*
|
1749 |
-
*
|
1750 |
-
*
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
$
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
*
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
if (
|
1790 |
-
$
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
'
|
1867 |
-
'
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
*
|
1958 |
-
*
|
1959 |
-
*
|
1960 |
-
* @
|
1961 |
-
*
|
1962 |
-
* @
|
1963 |
-
*
|
1964 |
-
*
|
1965 |
-
*
|
1966 |
-
*
|
1967 |
-
*
|
1968 |
-
*
|
1969 |
-
*
|
1970 |
-
*
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
return
|
1997 |
-
}
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
$
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
2018 |
-
|
2019 |
-
} elseif ( '
|
2020 |
-
//if post for logged in users and user is not logged in
|
2021 |
-
if ( is_user_logged_in() ) {
|
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 |
-
return
|
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 |
-
if (
|
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 |
-
|
|
|
|
|
|
|
|
|
|
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 |
+
// Navigation line below the post content, change query to exclude restricted
|
52 |
+
add_filter( 'get_next_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 );
|
53 |
+
add_filter( 'get_previous_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 );
|
54 |
+
|
55 |
+
// change the title of the post
|
56 |
+
add_filter( 'the_title', array( &$this, 'filter_restricted_post_title' ), 10, 2 );
|
57 |
+
// change the content of the restricted post
|
58 |
+
add_filter( 'the_content', array( &$this, 'filter_restricted_post_content' ), 999999, 1 );
|
59 |
+
// change the excerpt of the restricted post
|
60 |
+
add_filter( 'get_the_excerpt', array( &$this, 'filter_restricted_post_excerpt' ), 999999, 2 );
|
61 |
+
|
62 |
+
// filter attachment
|
63 |
+
add_filter( 'wp_get_attachment_url', array( &$this, 'filter_attachment' ), 99, 2 );
|
64 |
+
add_filter( 'has_post_thumbnail', array( &$this, 'filter_post_thumbnail' ), 99, 3 );
|
65 |
+
|
66 |
+
// comments queries
|
67 |
+
add_action( 'pre_get_comments', array( &$this, 'exclude_posts_comments' ), 99, 1 );
|
68 |
+
add_filter( 'wp_count_comments', array( &$this, 'custom_comments_count_handler' ), 99, 2 );
|
69 |
+
// comments RSS
|
70 |
+
add_filter( 'comment_feed_where', array( &$this, 'exclude_posts_comments_feed' ), 99, 2 );
|
71 |
+
// Disable comments if user has not permission to access current post
|
72 |
+
add_filter( 'comments_open', array( $this, 'disable_comments_open' ), 99, 2 );
|
73 |
+
add_filter( 'get_comments_number', array( $this, 'disable_comments_open_number' ), 99, 2 );
|
74 |
+
|
75 |
+
// filter menu items
|
76 |
+
add_filter( 'wp_nav_menu_objects', array( &$this, 'filter_menu' ), 99, 2 );
|
77 |
+
|
78 |
+
// Gutenberg blocks restrictions
|
79 |
+
add_filter( 'render_block', array( $this, 'restrict_blocks' ), 10, 2 );
|
80 |
+
|
81 |
+
// check the site's accessible more priority have Individual Post/Term Restriction settings
|
82 |
+
add_action( 'template_redirect', array( &$this, 'template_redirect' ), 1000 );
|
83 |
+
add_action( 'um_access_check_individual_term_settings', array( &$this, 'um_access_check_individual_term_settings' ) );
|
84 |
+
add_action( 'um_access_check_global_settings', array( &$this, 'um_access_check_global_settings' ) );
|
85 |
+
|
86 |
+
add_action( 'plugins_loaded', array( &$this, 'disable_restriction_pre_queries' ), 1 );
|
87 |
+
}
|
88 |
+
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Rollback function for old business logic to avoid security enhancements with 404 errors
|
92 |
+
*/
|
93 |
+
function disable_restriction_pre_queries() {
|
94 |
+
// Using inside plugins_loaded hook because of there can be earlier direct queries without hooks.
|
95 |
+
// Avoid using to not getting fatal error for not exists WordPress native functions.
|
96 |
+
|
97 |
+
// Change recent posts widget query.
|
98 |
+
add_filter( 'widget_posts_args', array( &$this, 'exclude_restricted_posts_widget' ), 99, 1 );
|
99 |
+
// Exclude pages displayed by wp_list_pages function.
|
100 |
+
add_filter( 'wp_list_pages_excludes', array( &$this, 'exclude_restricted_pages' ), 10, 1 );
|
101 |
+
// Archives list change where based on restricted posts.
|
102 |
+
add_filter( 'getarchives_where', array( &$this, 'exclude_restricted_posts_archives_widget' ), 99, 2 );
|
103 |
+
|
104 |
+
// Callbacks for changing posts query.
|
105 |
+
add_action( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99, 1 );
|
106 |
+
add_filter( 'posts_where', array( &$this, 'exclude_posts_where' ), 10, 2 );
|
107 |
+
add_filter( 'wp_count_posts', array( &$this, 'custom_count_posts_handler' ), 99, 3 );
|
108 |
+
|
109 |
+
// Callbacks for changing terms query.
|
110 |
+
add_action( 'pre_get_terms', array( &$this, 'exclude_hidden_terms_query' ), 99, 1 );
|
111 |
+
|
112 |
+
// there is posts (Posts/Page/CPT) filtration if site is accessible
|
113 |
+
// there also will be redirects if they need
|
114 |
+
// protect posts types
|
115 |
+
add_filter( 'the_posts', array( &$this, 'filter_protected_posts' ), 99, 2 );
|
116 |
+
// protect pages for wp_list_pages func
|
117 |
+
add_filter( 'get_pages', array( &$this, 'filter_protected_posts' ), 99, 2 );
|
118 |
+
|
119 |
+
if ( ! UM()->options()->get( 'disable_restriction_pre_queries' ) ) {
|
120 |
+
return;
|
121 |
+
}
|
122 |
+
|
123 |
+
remove_action( 'pre_get_terms', array( &$this, 'exclude_hidden_terms_query' ), 99 );
|
124 |
+
remove_filter( 'widget_posts_args', array( &$this, 'exclude_restricted_posts_widget' ), 99 );
|
125 |
+
remove_filter( 'wp_list_pages_excludes', array( &$this, 'exclude_restricted_pages' ), 10 );
|
126 |
+
remove_filter( 'getarchives_where', array( &$this, 'exclude_restricted_posts_archives_widget' ), 99 );
|
127 |
+
remove_filter( 'get_next_post_where', array( &$this, 'exclude_navigation_posts' ), 99 );
|
128 |
+
remove_filter( 'get_previous_post_where', array( &$this, 'exclude_navigation_posts' ), 99 );
|
129 |
+
remove_action( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99 );
|
130 |
+
remove_filter( 'posts_where', array( &$this, 'exclude_posts_where' ), 10 );
|
131 |
+
remove_filter( 'wp_count_posts', array( &$this, 'custom_count_posts_handler' ), 99 );
|
132 |
+
}
|
133 |
+
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Get array with restricted posts
|
137 |
+
*
|
138 |
+
* @param bool $force
|
139 |
+
* @param bool|array|string $post_types
|
140 |
+
*
|
141 |
+
* @return array
|
142 |
+
*/
|
143 |
+
function exclude_posts_array( $force = false, $post_types = false ) {
|
144 |
+
if ( $this->ignore_exclude ) {
|
145 |
+
return array();
|
146 |
+
}
|
147 |
+
|
148 |
+
static $cache = array();
|
149 |
+
|
150 |
+
$cache_key = $force ? 'force' : 'default';
|
151 |
+
|
152 |
+
// `force` cache contains all restricted post IDs we can get them all from cache instead new queries
|
153 |
+
$force_cache_key = '';
|
154 |
+
if ( 'default' === $cache_key ) {
|
155 |
+
$force_cache_key = 'force';
|
156 |
+
}
|
157 |
+
|
158 |
+
// make $post_types as array if string
|
159 |
+
if ( ! empty( $post_types ) ) {
|
160 |
+
$post_types = is_array( $post_types ) ? $post_types : array( $post_types );
|
161 |
+
$cache_key .= md5( serialize( $post_types ) );
|
162 |
+
if ( ! empty( $force_cache_key ) ) {
|
163 |
+
$force_cache_key .= md5( serialize( $post_types ) );
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
if ( array_key_exists( $cache_key, $cache ) ) {
|
168 |
+
return $cache[ $cache_key ];
|
169 |
+
}
|
170 |
+
|
171 |
+
$exclude_posts = array();
|
172 |
+
if ( current_user_can( 'administrator' ) ) {
|
173 |
+
$cache[ $cache_key ] = $exclude_posts;
|
174 |
+
return $exclude_posts;
|
175 |
+
}
|
176 |
+
|
177 |
+
// @todo using Object Cache `wp_cache_get()` `wp_cache_set()` functions
|
178 |
+
|
179 |
+
// `force` cache contains all restricted post IDs we can get them all from cache instead new queries
|
180 |
+
if ( ! empty( $force_cache_key ) && array_key_exists( $force_cache_key, $cache ) ) {
|
181 |
+
$post_ids = $cache[ $force_cache_key ];
|
182 |
+
|
183 |
+
if ( ! empty( $post_ids ) ) {
|
184 |
+
foreach ( $post_ids as $post_id ) {
|
185 |
+
$content_restriction = $this->get_post_privacy_settings( $post_id );
|
186 |
+
if ( ! empty( $content_restriction['_um_access_hide_from_queries'] ) ) {
|
187 |
+
array_push( $exclude_posts, $post_id );
|
188 |
+
}
|
189 |
+
}
|
190 |
+
}
|
191 |
+
} else {
|
192 |
+
$restricted_posts = UM()->options()->get( 'restricted_access_post_metabox' );
|
193 |
+
if ( ! empty( $restricted_posts ) ) {
|
194 |
+
$restricted_posts = array_keys( $restricted_posts );
|
195 |
+
if ( ! empty( $post_types ) ) {
|
196 |
+
$restricted_posts = array_intersect( $post_types, $restricted_posts );
|
197 |
+
}
|
198 |
+
}
|
199 |
+
|
200 |
+
if ( ! empty( $restricted_posts ) ) {
|
201 |
+
$this->ignore_exclude = true;
|
202 |
+
// exclude all posts assigned to current term without individual restriction settings
|
203 |
+
$post_ids = get_posts(
|
204 |
+
array(
|
205 |
+
'fields' => 'ids',
|
206 |
+
'post_status' => 'any',
|
207 |
+
'post_type' => $restricted_posts,
|
208 |
+
'numberposts' => -1,
|
209 |
+
'meta_query' => array(
|
210 |
+
array(
|
211 |
+
'key' => 'um_content_restriction',
|
212 |
+
'compare' => 'EXISTS',
|
213 |
+
),
|
214 |
+
),
|
215 |
+
)
|
216 |
+
);
|
217 |
+
|
218 |
+
$this->ignore_exclude = false;
|
219 |
+
}
|
220 |
+
|
221 |
+
$post_ids = empty( $post_ids ) ? array() : $post_ids;
|
222 |
+
|
223 |
+
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
224 |
+
|
225 |
+
if ( ! empty( $restricted_taxonomies ) ) {
|
226 |
+
$restricted_taxonomies = array_keys( $restricted_taxonomies );
|
227 |
+
foreach ( $restricted_taxonomies as $k => $taxonomy ) {
|
228 |
+
if ( ! taxonomy_exists( $taxonomy ) ) {
|
229 |
+
unset( $restricted_taxonomies[ $k ] );
|
230 |
+
}
|
231 |
+
}
|
232 |
+
$restricted_taxonomies = array_values( $restricted_taxonomies );
|
233 |
+
|
234 |
+
if ( ! empty( $post_types ) ) {
|
235 |
+
$taxonomies = array();
|
236 |
+
foreach ( $post_types as $p_t ) {
|
237 |
+
$taxonomies = array_merge( $taxonomies, get_object_taxonomies( $p_t ) );
|
238 |
+
}
|
239 |
+
$restricted_taxonomies = array_intersect( $taxonomies, $restricted_taxonomies );
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
if ( ! empty( $restricted_taxonomies ) ) {
|
244 |
+
global $wpdb;
|
245 |
+
|
246 |
+
$terms = $wpdb->get_results(
|
247 |
+
"SELECT tm.term_id AS term_id,
|
248 |
+
tt.taxonomy AS taxonomy
|
249 |
+
FROM {$wpdb->termmeta} tm
|
250 |
+
LEFT JOIN {$wpdb->term_taxonomy} tt ON tt.term_id = tm.term_id
|
251 |
+
WHERE tm.meta_key = 'um_content_restriction' AND
|
252 |
+
tt.taxonomy IN('" . implode( "','", $restricted_taxonomies ) . "')",
|
253 |
+
ARRAY_A
|
254 |
+
);
|
255 |
+
|
256 |
+
if ( ! empty( $terms ) ) {
|
257 |
+
foreach ( $terms as $term ) {
|
258 |
+
if ( ! $this->is_restricted_term( $term['term_id'] ) ) {
|
259 |
+
continue;
|
260 |
+
}
|
261 |
+
|
262 |
+
$taxonomy_data = get_taxonomy( $term['taxonomy'] );
|
263 |
+
|
264 |
+
$this->ignore_exclude = true;
|
265 |
+
// exclude all posts assigned to current term without individual restriction settings
|
266 |
+
$posts = get_posts(
|
267 |
+
array(
|
268 |
+
'fields' => 'ids',
|
269 |
+
'post_status' => 'any',
|
270 |
+
'post_type' => $taxonomy_data->object_type,
|
271 |
+
'numberposts' => -1,
|
272 |
+
'tax_query' => array(
|
273 |
+
array(
|
274 |
+
'taxonomy' => $term['taxonomy'],
|
275 |
+
'field' => 'id',
|
276 |
+
'terms' => $term['term_id'],
|
277 |
+
),
|
278 |
+
),
|
279 |
+
'meta_query' => array(
|
280 |
+
'relation' => 'OR',
|
281 |
+
array(
|
282 |
+
'relation' => 'AND',
|
283 |
+
array(
|
284 |
+
'key' => 'um_content_restriction',
|
285 |
+
'value' => 's:26:"_um_custom_access_settings";s:1:"1"',
|
286 |
+
'compare' => 'NOT LIKE',
|
287 |
+
),
|
288 |
+
array(
|
289 |
+
'key' => 'um_content_restriction',
|
290 |
+
'value' => 's:26:"_um_custom_access_settings";b:1',
|
291 |
+
'compare' => 'NOT LIKE',
|
292 |
+
),
|
293 |
+
),
|
294 |
+
array(
|
295 |
+
'key' => 'um_content_restriction',
|
296 |
+
'compare' => 'NOT EXISTS',
|
297 |
+
),
|
298 |
+
),
|
299 |
+
)
|
300 |
+
);
|
301 |
+
$this->ignore_exclude = false;
|
302 |
+
|
303 |
+
if ( empty( $posts ) ) {
|
304 |
+
continue;
|
305 |
+
}
|
306 |
+
|
307 |
+
$post_ids = array_merge( $post_ids, $posts );
|
308 |
+
}
|
309 |
+
}
|
310 |
+
}
|
311 |
+
|
312 |
+
if ( ! empty( $post_ids ) ) {
|
313 |
+
$post_ids = array_unique( $post_ids );
|
314 |
+
|
315 |
+
foreach ( $post_ids as $post_id ) {
|
316 |
+
// handle every post privacy setting based on post type maybe it's inactive for now
|
317 |
+
// if individual restriction is enabled then get post terms restriction settings
|
318 |
+
if ( $this->is_restricted( $post_id ) ) {
|
319 |
+
if ( true === $force ) {
|
320 |
+
array_push( $exclude_posts, $post_id );
|
321 |
+
} else {
|
322 |
+
$content_restriction = $this->get_post_privacy_settings( $post_id );
|
323 |
+
if ( ! empty( $content_restriction['_um_access_hide_from_queries'] ) ) {
|
324 |
+
array_push( $exclude_posts, $post_id );
|
325 |
+
}
|
326 |
+
}
|
327 |
+
}
|
328 |
+
}
|
329 |
+
}
|
330 |
+
}
|
331 |
+
|
332 |
+
$exclude_posts = apply_filters( 'um_exclude_restricted_posts_ids', $exclude_posts, $force );
|
333 |
+
|
334 |
+
$cache[ $cache_key ] = $exclude_posts;
|
335 |
+
return $exclude_posts;
|
336 |
+
}
|
337 |
+
|
338 |
+
|
339 |
+
|
340 |
+
/**
|
341 |
+
* Get array with restricted terms
|
342 |
+
*
|
343 |
+
* @param \WP_Term_Query $query
|
344 |
+
*
|
345 |
+
* @return array
|
346 |
+
*/
|
347 |
+
function exclude_terms_array( $query ) {
|
348 |
+
$exclude = array();
|
349 |
+
|
350 |
+
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
351 |
+
if ( ! empty( $restricted_taxonomies ) ) {
|
352 |
+
$restricted_taxonomies = array_keys( $restricted_taxonomies );
|
353 |
+
foreach ( $restricted_taxonomies as $k => $taxonomy ) {
|
354 |
+
if ( ! taxonomy_exists( $taxonomy ) ) {
|
355 |
+
unset( $restricted_taxonomies[ $k ] );
|
356 |
+
}
|
357 |
+
}
|
358 |
+
$restricted_taxonomies = array_values( $restricted_taxonomies );
|
359 |
+
|
360 |
+
if ( ! empty( $restricted_taxonomies ) ) {
|
361 |
+
if ( isset( $query->query_vars['taxonomy'] ) && is_array( $query->query_vars['taxonomy'] ) ) {
|
362 |
+
$restricted_taxonomies = array_intersect( $query->query_vars['taxonomy'], $restricted_taxonomies );
|
363 |
+
} elseif ( ! empty( $query->query_vars['term_taxonomy_id'] ) ) {
|
364 |
+
$term_taxonomy_ids = is_array( $query->query_vars['term_taxonomy_id'] ) ? $query->query_vars['term_taxonomy_id'] : array( $query->query_vars['term_taxonomy_id'] );
|
365 |
+
|
366 |
+
global $wpdb;
|
367 |
+
$tax_in_query = $wpdb->get_col( "SELECT DISTINCT taxonomy FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id IN('" . implode( "','", $term_taxonomy_ids ) . "')" );
|
368 |
+
if ( ! empty( $tax_in_query ) ) {
|
369 |
+
$restricted_taxonomies = array_intersect( $tax_in_query, $restricted_taxonomies );
|
370 |
+
} else {
|
371 |
+
$restricted_taxonomies = array();
|
372 |
+
}
|
373 |
+
}
|
374 |
+
}
|
375 |
+
}
|
376 |
+
|
377 |
+
if ( empty( $restricted_taxonomies ) ) {
|
378 |
+
return $exclude;
|
379 |
+
}
|
380 |
+
|
381 |
+
$cache_key = md5( serialize( $restricted_taxonomies ) );
|
382 |
+
|
383 |
+
static $cache = array();
|
384 |
+
|
385 |
+
if ( array_key_exists( $cache_key, $cache ) ) {
|
386 |
+
return $cache[ $cache_key ];
|
387 |
+
}
|
388 |
+
|
389 |
+
$term_ids = get_terms(
|
390 |
+
array(
|
391 |
+
'taxonomy' => $restricted_taxonomies,
|
392 |
+
'hide_empty' => false,
|
393 |
+
'fields' => 'ids',
|
394 |
+
'meta_query' => array(
|
395 |
+
'key' => 'um_content_restriction',
|
396 |
+
'compare' => 'EXISTS',
|
397 |
+
),
|
398 |
+
'um_ignore_exclude' => true,
|
399 |
+
)
|
400 |
+
);
|
401 |
+
|
402 |
+
if ( empty( $term_ids ) || is_wp_error( $term_ids ) ) {
|
403 |
+
$cache[ $cache_key ] = $exclude;
|
404 |
+
return $exclude;
|
405 |
+
}
|
406 |
+
|
407 |
+
foreach ( $term_ids as $term_id ) {
|
408 |
+
if ( $this->is_restricted_term( $term_id ) ) {
|
409 |
+
$exclude[] = $term_id;
|
410 |
+
}
|
411 |
+
}
|
412 |
+
|
413 |
+
$exclude = apply_filters( 'um_exclude_restricted_terms_ids', $exclude );
|
414 |
+
$cache[ $cache_key ] = $exclude;
|
415 |
+
return $exclude;
|
416 |
+
}
|
417 |
+
|
418 |
+
|
419 |
+
/**
|
420 |
+
* @param \WP_Term_Query $query
|
421 |
+
*/
|
422 |
+
function exclude_hidden_terms_query( $query ) {
|
423 |
+
if ( current_user_can( 'administrator' ) || ! empty( $query->query_vars['um_ignore_exclude'] ) ) {
|
424 |
+
return;
|
425 |
+
}
|
426 |
+
|
427 |
+
$exclude = $this->exclude_terms_array( $query );
|
428 |
+
if ( ! empty( $exclude ) ) {
|
429 |
+
$query->query_vars['exclude'] = ! empty( $query->query_vars['exclude'] ) ? wp_parse_id_list( $query->query_vars['exclude'] ) : $exclude;
|
430 |
+
}
|
431 |
+
}
|
432 |
+
|
433 |
+
|
434 |
+
/**
|
435 |
+
* @param \WP_Query $query
|
436 |
+
*/
|
437 |
+
function exclude_posts( $query ) {
|
438 |
+
if ( current_user_can( 'administrator' ) ) {
|
439 |
+
return;
|
440 |
+
}
|
441 |
+
|
442 |
+
// use these functions is_search() || is_admin() for getting force hide all posts
|
443 |
+
// don't handle `hide from WP_Query` and show 404 option for searching and wp-admin query
|
444 |
+
if ( $query->is_main_query() || ! empty( $query->query_vars['um_main_query'] ) ) {
|
445 |
+
$force = is_feed() || is_search() || is_admin();
|
446 |
+
|
447 |
+
if ( is_object( $query ) ) {
|
448 |
+
$is_singular = $query->is_singular();
|
449 |
+
} else {
|
450 |
+
$is_singular = ! empty( $query->is_singular ) ? true : false;
|
451 |
+
}
|
452 |
+
|
453 |
+
if ( ! $is_singular ) {
|
454 |
+
// need to know what post type is here
|
455 |
+
$q_values = ! empty( $query->query_vars['post_type'] ) ? $query->query_vars['post_type'] : array();
|
456 |
+
if ( ! is_array( $q_values ) ) {
|
457 |
+
$q_values = explode( ',', $query->query_vars['post_type'] );
|
458 |
+
}
|
459 |
+
|
460 |
+
// 'any' will cause the query var to be ignored.
|
461 |
+
if ( in_array( 'any', $q_values, true ) || empty( $q_values ) ) {
|
462 |
+
$exclude_posts = $this->exclude_posts_array( $force );
|
463 |
+
} else {
|
464 |
+
$exclude_posts = $this->exclude_posts_array( $force, $q_values );
|
465 |
+
}
|
466 |
+
|
467 |
+
if ( ! empty( $exclude_posts ) ) {
|
468 |
+
$post__not_in = $query->get( 'post__not_in', array() );
|
469 |
+
$query->set( 'post__not_in', array_merge( wp_parse_id_list( $post__not_in ), $exclude_posts ) );
|
470 |
+
}
|
471 |
+
}
|
472 |
+
}
|
473 |
+
}
|
474 |
+
|
475 |
+
|
476 |
+
/**
|
477 |
+
* Exclude restricted post from query if there is a single query that exclude post_not_in by default in \WP_Query
|
478 |
+
*
|
479 |
+
* @param string $where
|
480 |
+
* @param \WP_Query $query
|
481 |
+
*
|
482 |
+
* @return mixed
|
483 |
+
*/
|
484 |
+
function exclude_posts_where( $where, $query ) {
|
485 |
+
if ( current_user_can( 'administrator' ) ) {
|
486 |
+
return $where;
|
487 |
+
}
|
488 |
+
|
489 |
+
if ( ! $query->is_main_query() ) {
|
490 |
+
return $where;
|
491 |
+
}
|
492 |
+
|
493 |
+
if ( ! empty( $query->query_vars['p'] ) && $this->is_restricted( $query->query_vars['p'] ) ) {
|
494 |
+
$restriction_settings = $this->get_post_privacy_settings( $query->query_vars['p'] );
|
495 |
+
if ( ! empty( $restriction_settings['_um_access_hide_from_queries'] ) && ! empty( $query->query_vars['post__not_in'] ) ) {
|
496 |
+
global $wpdb;
|
497 |
+
$post__not_in = implode( ',', array_map( 'absint', $query->query_vars['post__not_in'] ) );
|
498 |
+
$where .= " AND {$wpdb->posts}.ID NOT IN ($post__not_in)";
|
499 |
+
}
|
500 |
+
}
|
501 |
+
|
502 |
+
return $where;
|
503 |
+
}
|
504 |
+
|
505 |
+
|
506 |
+
/**
|
507 |
+
* Change the posts count based on restriction settings
|
508 |
+
*
|
509 |
+
* @param object $counts Post counts
|
510 |
+
* @param string $type Post type
|
511 |
+
* @param string $perm The permission to determine if the posts are 'readable'
|
512 |
+
* by the current user.
|
513 |
+
*
|
514 |
+
* @return object
|
515 |
+
*/
|
516 |
+
function custom_count_posts_handler( $counts, $type = 'post', $perm = '' ) {
|
517 |
+
if ( current_user_can( 'administrator' ) ) {
|
518 |
+
return $counts;
|
519 |
+
}
|
520 |
+
|
521 |
+
global $wpdb;
|
522 |
+
|
523 |
+
static $cache = array();
|
524 |
+
|
525 |
+
$cache_key = _count_posts_cache_key( $type, $perm );
|
526 |
+
$force = is_feed() || is_search() || is_admin();
|
527 |
+
$cache_key .= $force ? 'force' : '';
|
528 |
+
|
529 |
+
if ( array_key_exists( $cache_key, $cache ) ) {
|
530 |
+
return $cache[ $cache_key ];
|
531 |
+
}
|
532 |
+
|
533 |
+
$exclude_posts = $this->exclude_posts_array( $force, array( $type ) );
|
534 |
+
if ( empty( $exclude_posts ) ) {
|
535 |
+
$cache[ $cache_key ] = $counts;
|
536 |
+
return $counts;
|
537 |
+
}
|
538 |
+
|
539 |
+
$query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s";
|
540 |
+
|
541 |
+
if ( 'readable' === $perm && is_user_logged_in() ) {
|
542 |
+
$post_type_object = get_post_type_object( $type );
|
543 |
+
if ( ! current_user_can( $post_type_object->cap->read_private_posts ) ) {
|
544 |
+
$query .= $wpdb->prepare(
|
545 |
+
" AND (post_status != 'private' OR ( post_author = %d AND post_status = 'private' ))",
|
546 |
+
get_current_user_id()
|
547 |
+
);
|
548 |
+
}
|
549 |
+
}
|
550 |
+
|
551 |
+
$query .= " AND ID NOT IN('" . implode( "','", $exclude_posts ) . "')";
|
552 |
+
|
553 |
+
$query .= ' GROUP BY post_status';
|
554 |
+
|
555 |
+
$results = (array) $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A );
|
556 |
+
$counts = array_fill_keys( get_post_stati(), 0 );
|
557 |
+
|
558 |
+
foreach ( $results as $row ) {
|
559 |
+
$counts[ $row['post_status'] ] = $row['num_posts'];
|
560 |
+
}
|
561 |
+
|
562 |
+
$counts = (object) $counts;
|
563 |
+
|
564 |
+
$cache[ $cache_key ] = $counts;
|
565 |
+
return $counts;
|
566 |
+
}
|
567 |
+
|
568 |
+
|
569 |
+
/**
|
570 |
+
* Exclude restricted posts in Recent Posts widget
|
571 |
+
*
|
572 |
+
* @param array $array Query args
|
573 |
+
*
|
574 |
+
* @return array
|
575 |
+
*/
|
576 |
+
function exclude_restricted_posts_widget( $array ) {
|
577 |
+
if ( current_user_can( 'administrator' ) ) {
|
578 |
+
return $array;
|
579 |
+
}
|
580 |
+
|
581 |
+
$exclude_posts = $this->exclude_posts_array( false, 'post' );
|
582 |
+
if ( ! empty( $exclude_posts ) ) {
|
583 |
+
$post__not_in = ! empty( $array['post__not_in'] ) ? $array['post__not_in'] : array();
|
584 |
+
$array['post__not_in'] = array_merge( wp_parse_id_list( $post__not_in ), $exclude_posts );
|
585 |
+
}
|
586 |
+
|
587 |
+
return $array;
|
588 |
+
}
|
589 |
+
|
590 |
+
|
591 |
+
/**
|
592 |
+
* Exclude restricted posts in Recent Posts widget
|
593 |
+
*
|
594 |
+
* @param array $array Query args
|
595 |
+
*
|
596 |
+
* @return array
|
597 |
+
*/
|
598 |
+
function exclude_restricted_pages( $array ) {
|
599 |
+
if ( current_user_can( 'administrator' ) ) {
|
600 |
+
return $array;
|
601 |
+
}
|
602 |
+
|
603 |
+
$exclude_posts = $this->exclude_posts_array( false, 'page' );
|
604 |
+
if ( ! empty( $exclude_posts ) ) {
|
605 |
+
$array = array_merge( $array, $exclude_posts );
|
606 |
+
}
|
607 |
+
|
608 |
+
return $array;
|
609 |
+
}
|
610 |
+
|
611 |
+
|
612 |
+
/**
|
613 |
+
* Exclude restricted posts in widgets
|
614 |
+
*
|
615 |
+
* @param string $sql_where
|
616 |
+
* @param array $parsed_args
|
617 |
+
*
|
618 |
+
* @return string
|
619 |
+
*/
|
620 |
+
function exclude_restricted_posts_archives_widget( $sql_where, $parsed_args = array() ) {
|
621 |
+
if ( current_user_can( 'administrator' ) ) {
|
622 |
+
return $sql_where;
|
623 |
+
}
|
624 |
+
|
625 |
+
$post_type = ! empty( $parsed_args['post_type'] ) ? $parsed_args['post_type'] : false;
|
626 |
+
|
627 |
+
$exclude_posts = $this->exclude_posts_array( false, $post_type );
|
628 |
+
if ( ! empty( $exclude_posts ) ) {
|
629 |
+
$exclude_string = implode( ',', $exclude_posts );
|
630 |
+
$sql_where .= ' AND ID NOT IN ( ' . $exclude_string . ' )';
|
631 |
+
}
|
632 |
+
|
633 |
+
return $sql_where;
|
634 |
+
}
|
635 |
+
|
636 |
+
|
637 |
+
/**
|
638 |
+
* Exclude posts from next, previous navigation
|
639 |
+
*
|
640 |
+
* @param string $where
|
641 |
+
* @param bool $in_same_term
|
642 |
+
* @param string|array $excluded_terms
|
643 |
+
* @param string $taxonomy
|
644 |
+
* @param null|\WP_Post $post
|
645 |
+
*
|
646 |
+
* @return string
|
647 |
+
*/
|
648 |
+
function exclude_navigation_posts( $where, $in_same_term = false, $excluded_terms = '', $taxonomy = 'category', $post = null ) {
|
649 |
+
if ( current_user_can( 'administrator' ) ) {
|
650 |
+
return $where;
|
651 |
+
}
|
652 |
+
|
653 |
+
if ( empty( $post ) ) {
|
654 |
+
return $where;
|
655 |
+
}
|
656 |
+
|
657 |
+
$exclude_posts = $this->exclude_posts_array( false, $post->post_type );
|
658 |
+
if ( ! empty( $exclude_posts ) ) {
|
659 |
+
$exclude_string = implode( ',', $exclude_posts );
|
660 |
+
$where .= ' AND ID NOT IN ( ' . $exclude_string . ' )';
|
661 |
+
}
|
662 |
+
|
663 |
+
return $where;
|
664 |
+
}
|
665 |
+
|
666 |
+
|
667 |
+
/**
|
668 |
+
* Replace titles of restricted posts
|
669 |
+
*
|
670 |
+
* @param string $title
|
671 |
+
* @param int|null $id
|
672 |
+
*
|
673 |
+
* @return string
|
674 |
+
*/
|
675 |
+
function filter_restricted_post_title( $title, $id = null ) {
|
676 |
+
if ( ! UM()->options()->get( 'restricted_post_title_replace' ) ) {
|
677 |
+
return $title;
|
678 |
+
}
|
679 |
+
|
680 |
+
if ( current_user_can( 'administrator' ) ) {
|
681 |
+
return $title;
|
682 |
+
}
|
683 |
+
|
684 |
+
if ( ! isset( $id ) ) {
|
685 |
+
return $title;
|
686 |
+
}
|
687 |
+
|
688 |
+
if ( ! is_numeric( $id ) ) {
|
689 |
+
$id = absint( $id );
|
690 |
+
}
|
691 |
+
|
692 |
+
$ignore = apply_filters( 'um_ignore_restricted_title', false, $id );
|
693 |
+
if ( $ignore ) {
|
694 |
+
return $title;
|
695 |
+
}
|
696 |
+
|
697 |
+
if ( $this->is_restricted( $id ) ) {
|
698 |
+
$restricted_global_title = UM()->options()->get( 'restricted_access_post_title' );
|
699 |
+
$title = stripslashes( $restricted_global_title );
|
700 |
+
}
|
701 |
+
|
702 |
+
return $title;
|
703 |
+
}
|
704 |
+
|
705 |
+
|
706 |
+
/**
|
707 |
+
* Replace content of restricted posts
|
708 |
+
*
|
709 |
+
* @param string $content
|
710 |
+
*
|
711 |
+
* @return string
|
712 |
+
*/
|
713 |
+
function filter_restricted_post_content( $content ) {
|
714 |
+
if ( current_user_can( 'administrator' ) ) {
|
715 |
+
return $content;
|
716 |
+
}
|
717 |
+
|
718 |
+
$id = get_the_ID();
|
719 |
+
if ( ! $id || is_admin() ) {
|
720 |
+
return $content;
|
721 |
+
}
|
722 |
+
|
723 |
+
$ignore = apply_filters( 'um_ignore_restricted_content', false, $id );
|
724 |
+
if ( $ignore ) {
|
725 |
+
return $content;
|
726 |
+
}
|
727 |
+
|
728 |
+
if ( $this->is_restricted( $id ) ) {
|
729 |
+
$restriction = $this->get_post_privacy_settings( $id );
|
730 |
+
|
731 |
+
if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) {
|
732 |
+
$content = stripslashes( UM()->options()->get( 'restricted_access_message' ) );
|
733 |
+
} elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) {
|
734 |
+
$content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : '';
|
735 |
+
}
|
736 |
+
|
737 |
+
// translators: %s: Restricted post message.
|
738 |
+
$content = sprintf( __( '%s', 'ultimate-member' ), $content );
|
739 |
+
}
|
740 |
+
|
741 |
+
return $content;
|
742 |
+
}
|
743 |
+
|
744 |
+
|
745 |
+
/**
|
746 |
+
* Replace excerpt of restricted posts
|
747 |
+
*
|
748 |
+
* @param string $post_excerpt
|
749 |
+
* @param \WP_Post $post
|
750 |
+
*
|
751 |
+
* @return string
|
752 |
+
*/
|
753 |
+
function filter_restricted_post_excerpt( $post_excerpt = '', $post = null ) {
|
754 |
+
if ( empty( $post ) ) {
|
755 |
+
return $post_excerpt;
|
756 |
+
}
|
757 |
+
|
758 |
+
if ( current_user_can( 'administrator' ) || is_admin() ) {
|
759 |
+
return $post_excerpt;
|
760 |
+
}
|
761 |
+
|
762 |
+
$ignore = apply_filters( 'um_ignore_restricted_excerpt', false, $post->ID );
|
763 |
+
if ( $ignore ) {
|
764 |
+
return $post_excerpt;
|
765 |
+
}
|
766 |
+
|
767 |
+
if ( $this->is_restricted( $post->ID ) ) {
|
768 |
+
$post_excerpt = '';
|
769 |
+
}
|
770 |
+
|
771 |
+
return $post_excerpt;
|
772 |
+
}
|
773 |
+
|
774 |
+
|
775 |
+
/**
|
776 |
+
* Hide attachment if the post is restricted
|
777 |
+
*
|
778 |
+
* @param string $url
|
779 |
+
* @param int $attachment_id
|
780 |
+
*
|
781 |
+
* @return boolean|string
|
782 |
+
*/
|
783 |
+
function filter_attachment( $url, $attachment_id ) {
|
784 |
+
if ( current_user_can( 'administrator' ) ) {
|
785 |
+
return $url;
|
786 |
+
}
|
787 |
+
|
788 |
+
return ( $attachment_id && $this->is_restricted( $attachment_id ) ) ? false : $url;
|
789 |
+
}
|
790 |
+
|
791 |
+
|
792 |
+
/**
|
793 |
+
* Hide attachment if the post is restricted
|
794 |
+
*
|
795 |
+
* @param $has_thumbnail
|
796 |
+
* @param $post
|
797 |
+
* @param $thumbnail_id
|
798 |
+
*
|
799 |
+
* @return bool
|
800 |
+
*/
|
801 |
+
function filter_post_thumbnail( $has_thumbnail, $post = null, $thumbnail_id = false ) {
|
802 |
+
if ( empty( $thumbnail_id ) ) {
|
803 |
+
return $has_thumbnail;
|
804 |
+
}
|
805 |
+
|
806 |
+
if ( current_user_can( 'administrator' ) ) {
|
807 |
+
return $has_thumbnail;
|
808 |
+
}
|
809 |
+
|
810 |
+
if ( $this->is_restricted( $thumbnail_id ) ) {
|
811 |
+
$has_thumbnail = false;
|
812 |
+
} elseif ( ! empty( $post ) && ! empty( $post->ID ) ) {
|
813 |
+
if ( $this->is_restricted( $post->ID ) ) {
|
814 |
+
$has_thumbnail = false;
|
815 |
+
}
|
816 |
+
} else {
|
817 |
+
$post_id = get_the_ID();
|
818 |
+
if ( false !== $post_id && $this->is_restricted( $post_id ) ) {
|
819 |
+
$has_thumbnail = false;
|
820 |
+
}
|
821 |
+
}
|
822 |
+
|
823 |
+
$has_thumbnail = apply_filters( 'um_restrict_post_thumbnail', $has_thumbnail, $post, $thumbnail_id );
|
824 |
+
|
825 |
+
return $has_thumbnail;
|
826 |
+
}
|
827 |
+
|
828 |
+
|
829 |
+
|
830 |
+
/**
|
831 |
+
* Exclude comments from restricted posts in widgets
|
832 |
+
*
|
833 |
+
* @param \WP_Comment_Query $query
|
834 |
+
*/
|
835 |
+
function exclude_posts_comments( $query ) {
|
836 |
+
if ( current_user_can( 'administrator' ) ) {
|
837 |
+
return;
|
838 |
+
}
|
839 |
+
|
840 |
+
if ( ! empty( $query->query_vars['post_id'] ) ) {
|
841 |
+
$exclude_posts = array();
|
842 |
+
if ( $this->is_restricted( $query->query_vars['post_id'] ) ) {
|
843 |
+
$exclude_posts[] = $query->query_vars['post_id'];
|
844 |
+
}
|
845 |
+
} else {
|
846 |
+
$q_values = ! empty( $query->query_vars['post_type'] ) ? $query->query_vars['post_type'] : array();
|
847 |
+
if ( ! is_array( $q_values ) ) {
|
848 |
+
$q_values = explode( ',', $query->query_vars['post_type'] );
|
849 |
+
}
|
850 |
+
|
851 |
+
// 'any' will cause the query var to be ignored.
|
852 |
+
if ( in_array( 'any', $q_values, true ) || empty( $q_values ) ) {
|
853 |
+
$exclude_posts = $this->exclude_posts_array( true, $this->get_available_comments_post_types() );
|
854 |
+
} else {
|
855 |
+
$exclude_posts = $this->exclude_posts_array( true, $q_values );
|
856 |
+
}
|
857 |
+
}
|
858 |
+
|
859 |
+
if ( ! empty( $exclude_posts ) ) {
|
860 |
+
$post__not_in = ! empty( $query->query_vars['post__not_in'] ) ? $query->query_vars['post__not_in'] : array();
|
861 |
+
$query->query_vars['post__not_in'] = array_merge( wp_parse_id_list( $post__not_in ), $exclude_posts );
|
862 |
+
}
|
863 |
+
}
|
864 |
+
|
865 |
+
|
866 |
+
/**
|
867 |
+
* @return array
|
868 |
+
*/
|
869 |
+
function get_available_comments_post_types() {
|
870 |
+
global $wp_taxonomies, $wpdb;
|
871 |
+
|
872 |
+
$restricted_posts = UM()->options()->get( 'restricted_access_post_metabox' );
|
873 |
+
if ( empty( $restricted_posts ) ) {
|
874 |
+
$restricted_posts = array();
|
875 |
+
}
|
876 |
+
$restricted_posts = array_keys( $restricted_posts );
|
877 |
+
|
878 |
+
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
879 |
+
if ( ! empty( $restricted_taxonomies ) ) {
|
880 |
+
$restricted_taxonomies = array_keys( $restricted_taxonomies );
|
881 |
+
foreach ( $restricted_taxonomies as $k => $taxonomy ) {
|
882 |
+
if ( taxonomy_exists( $taxonomy ) ) {
|
883 |
+
$restricted_posts = array_merge( $restricted_posts, $wp_taxonomies[ $taxonomy ]->object_type );
|
884 |
+
}
|
885 |
+
}
|
886 |
+
}
|
887 |
+
|
888 |
+
$restricted_posts = array_unique( $restricted_posts );
|
889 |
+
foreach ( $restricted_posts as $k => $post_type ) {
|
890 |
+
if ( 'closed' === get_default_comment_status( $post_type ) ) {
|
891 |
+
$open_comments = $wpdb->get_var( $wpdb->prepare(
|
892 |
+
"SELECT ID
|
893 |
+
FROM {$wpdb->posts}
|
894 |
+
WHERE post_type = %s AND
|
895 |
+
comment_status != 'closed'",
|
896 |
+
$post_type
|
897 |
+
) );
|
898 |
+
|
899 |
+
if ( empty( $open_comments ) ) {
|
900 |
+
unset( $restricted_posts[ $k ] );
|
901 |
+
}
|
902 |
+
}
|
903 |
+
}
|
904 |
+
|
905 |
+
$restricted_posts = array_values( $restricted_posts );
|
906 |
+
|
907 |
+
return $restricted_posts;
|
908 |
+
}
|
909 |
+
|
910 |
+
|
911 |
+
/**
|
912 |
+
* Exclude comments from comments feed
|
913 |
+
*
|
914 |
+
* @param string $where
|
915 |
+
* @param \WP_Query $query
|
916 |
+
*
|
917 |
+
* @return string
|
918 |
+
*/
|
919 |
+
function exclude_posts_comments_feed( $where, $query ) {
|
920 |
+
if ( current_user_can( 'administrator' ) ) {
|
921 |
+
return $where;
|
922 |
+
}
|
923 |
+
|
924 |
+
$exclude_posts = $this->exclude_posts_array( true, $this->get_available_comments_post_types() );
|
925 |
+
if ( ! empty( $exclude_posts ) ) {
|
926 |
+
$exclude_string = implode( ',', $exclude_posts );
|
927 |
+
$where .= ' AND comment_post_ID NOT IN ( ' . $exclude_string . ' )';
|
928 |
+
}
|
929 |
+
|
930 |
+
return $where;
|
931 |
+
}
|
932 |
+
|
933 |
+
|
934 |
+
/**
|
935 |
+
* @param array|object $stats
|
936 |
+
* @param int $post_id Post ID. Can be 0 for the whole website
|
937 |
+
*
|
938 |
+
* @return object
|
939 |
+
*/
|
940 |
+
function custom_comments_count_handler( $stats = array(), $post_id = 0 ) {
|
941 |
+
if ( ! empty( $stats ) || current_user_can( 'administrator' ) ) {
|
942 |
+
return $stats;
|
943 |
+
}
|
944 |
+
|
945 |
+
if ( $post_id === 0 ) {
|
946 |
+
$exclude_posts = $this->exclude_posts_array( true, $this->get_available_comments_post_types() );
|
947 |
+
if ( empty( $exclude_posts ) ) {
|
948 |
+
return $stats;
|
949 |
+
}
|
950 |
+
} else {
|
951 |
+
$exclude_posts = array();
|
952 |
+
if ( $this->is_restricted( $post_id ) ) {
|
953 |
+
$exclude_posts[] = $post_id;
|
954 |
+
}
|
955 |
+
}
|
956 |
+
|
957 |
+
$stats = $this->get_comment_count( $post_id, $exclude_posts );
|
958 |
+
$stats['moderated'] = $stats['awaiting_moderation'];
|
959 |
+
unset( $stats['awaiting_moderation'] );
|
960 |
+
|
961 |
+
$stats_object = (object) $stats;
|
962 |
+
|
963 |
+
return $stats_object;
|
964 |
+
}
|
965 |
+
|
966 |
+
|
967 |
+
/**
|
968 |
+
* @param int $post_id
|
969 |
+
* @param array $exclude_posts
|
970 |
+
*
|
971 |
+
* @return array
|
972 |
+
*/
|
973 |
+
function get_comment_count( $post_id = 0, $exclude_posts = array() ) {
|
974 |
+
static $cache = array();
|
975 |
+
|
976 |
+
if ( isset( $cache[ $post_id ] ) ) {
|
977 |
+
return $cache[ $post_id ];
|
978 |
+
}
|
979 |
+
|
980 |
+
global $wpdb;
|
981 |
+
|
982 |
+
$post_id = (int) $post_id;
|
983 |
+
|
984 |
+
$where = 'WHERE 1=1';
|
985 |
+
if ( $post_id > 0 ) {
|
986 |
+
$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
|
987 |
+
}
|
988 |
+
|
989 |
+
if ( ! empty( $exclude_posts ) ) {
|
990 |
+
$exclude_string = implode( ',', $exclude_posts );
|
991 |
+
$where .= ' AND comment_post_ID NOT IN ( ' . $exclude_string . ' )';
|
992 |
+
}
|
993 |
+
|
994 |
+
$totals = (array) $wpdb->get_results(
|
995 |
+
"
|
996 |
+
SELECT comment_approved, COUNT( * ) AS total
|
997 |
+
FROM {$wpdb->comments}
|
998 |
+
{$where}
|
999 |
+
GROUP BY comment_approved
|
1000 |
+
",
|
1001 |
+
ARRAY_A
|
1002 |
+
);
|
1003 |
+
|
1004 |
+
$comment_count = array(
|
1005 |
+
'approved' => 0,
|
1006 |
+
'awaiting_moderation' => 0,
|
1007 |
+
'spam' => 0,
|
1008 |
+
'trash' => 0,
|
1009 |
+
'post-trashed' => 0,
|
1010 |
+
'total_comments' => 0,
|
1011 |
+
'all' => 0,
|
1012 |
+
);
|
1013 |
+
|
1014 |
+
foreach ( $totals as $row ) {
|
1015 |
+
switch ( $row['comment_approved'] ) {
|
1016 |
+
case 'trash':
|
1017 |
+
$comment_count['trash'] = $row['total'];
|
1018 |
+
break;
|
1019 |
+
case 'post-trashed':
|
1020 |
+
$comment_count['post-trashed'] = $row['total'];
|
1021 |
+
break;
|
1022 |
+
case 'spam':
|
1023 |
+
$comment_count['spam'] = $row['total'];
|
1024 |
+
$comment_count['total_comments'] += $row['total'];
|
1025 |
+
break;
|
1026 |
+
case '1':
|
1027 |
+
$comment_count['approved'] = $row['total'];
|
1028 |
+
$comment_count['total_comments'] += $row['total'];
|
1029 |
+
$comment_count['all'] += $row['total'];
|
1030 |
+
break;
|
1031 |
+
case '0':
|
1032 |
+
$comment_count['awaiting_moderation'] = $row['total'];
|
1033 |
+
$comment_count['total_comments'] += $row['total'];
|
1034 |
+
$comment_count['all'] += $row['total'];
|
1035 |
+
break;
|
1036 |
+
default:
|
1037 |
+
break;
|
1038 |
+
}
|
1039 |
+
}
|
1040 |
+
|
1041 |
+
$comment_count = array_map( 'intval', $comment_count );
|
1042 |
+
$cache[ $post_id ] = $comment_count;
|
1043 |
+
|
1044 |
+
return $comment_count;
|
1045 |
+
}
|
1046 |
+
|
1047 |
+
|
1048 |
+
/**
|
1049 |
+
* Disable comments if user has not permission to access this post
|
1050 |
+
*
|
1051 |
+
* @param mixed $open
|
1052 |
+
* @param int $post_id
|
1053 |
+
* @return boolean
|
1054 |
+
*/
|
1055 |
+
function disable_comments_open( $open, $post_id ) {
|
1056 |
+
if ( current_user_can( 'administrator' ) ) {
|
1057 |
+
return $open;
|
1058 |
+
}
|
1059 |
+
|
1060 |
+
static $cache = array();
|
1061 |
+
|
1062 |
+
if ( isset( $cache[ $post_id ] ) ) {
|
1063 |
+
return $cache[ $post_id ] ? $open : false;
|
1064 |
+
}
|
1065 |
+
|
1066 |
+
if ( ! $this->is_restricted( $post_id ) ) {
|
1067 |
+
$cache[ $post_id ] = $open;
|
1068 |
+
return $open;
|
1069 |
+
}
|
1070 |
+
|
1071 |
+
$open = false;
|
1072 |
+
|
1073 |
+
$cache[ $post_id ] = $open;
|
1074 |
+
return $open;
|
1075 |
+
}
|
1076 |
+
|
1077 |
+
|
1078 |
+
/**
|
1079 |
+
* Disable comments if user has not permission to access this post
|
1080 |
+
*
|
1081 |
+
* @param int $count
|
1082 |
+
* @param int $post_id
|
1083 |
+
* @return boolean
|
1084 |
+
*/
|
1085 |
+
function disable_comments_open_number( $count, $post_id = 0 ) {
|
1086 |
+
if ( current_user_can( 'administrator' ) ) {
|
1087 |
+
return $count;
|
1088 |
+
}
|
1089 |
+
|
1090 |
+
static $cache_number = array();
|
1091 |
+
|
1092 |
+
if ( isset( $cache_number[ $post_id ] ) ) {
|
1093 |
+
return $cache_number[ $post_id ];
|
1094 |
+
}
|
1095 |
+
|
1096 |
+
if ( ! $this->is_restricted( $post_id ) ) {
|
1097 |
+
$cache_number[ $post_id ] = $count;
|
1098 |
+
return $count;
|
1099 |
+
}
|
1100 |
+
|
1101 |
+
$count = 0;
|
1102 |
+
|
1103 |
+
$cache_number[ $post_id ] = $count;
|
1104 |
+
return $count;
|
1105 |
+
}
|
1106 |
+
|
1107 |
+
|
1108 |
+
/**
|
1109 |
+
* Protect Post Types in menu query
|
1110 |
+
* Restrict content new logic
|
1111 |
+
* @param array $menu_items
|
1112 |
+
* @param array $args
|
1113 |
+
* @return array
|
1114 |
+
*/
|
1115 |
+
function filter_menu( $menu_items, $args = array() ) {
|
1116 |
+
//if empty
|
1117 |
+
if ( empty( $menu_items ) ) {
|
1118 |
+
return $menu_items;
|
1119 |
+
}
|
1120 |
+
|
1121 |
+
if ( current_user_can( 'administrator' ) ) {
|
1122 |
+
return $menu_items;
|
1123 |
+
}
|
1124 |
+
|
1125 |
+
$filtered_items = array();
|
1126 |
+
|
1127 |
+
//other filter
|
1128 |
+
foreach ( $menu_items as $menu_item ) {
|
1129 |
+
if ( ! empty( $menu_item->object_id ) && ! empty( $menu_item->object ) ) {
|
1130 |
+
if ( isset( $menu_item->type ) && 'taxonomy' === $menu_item->type ) {
|
1131 |
+
if ( ! $this->is_restricted_term( $menu_item->object_id ) ) {
|
1132 |
+
$filtered_items[] = $menu_item;
|
1133 |
+
continue;
|
1134 |
+
}
|
1135 |
+
} elseif ( isset( $menu_item->type ) && 'post_type' === $menu_item->type ) {
|
1136 |
+
if ( ! $this->is_restricted( $menu_item->object_id ) ) {
|
1137 |
+
$filtered_items[] = $menu_item;
|
1138 |
+
continue;
|
1139 |
+
} else {
|
1140 |
+
$restriction_settings = $this->get_post_privacy_settings( $menu_item->object_id );
|
1141 |
+
if ( empty( $restriction_settings['_um_access_hide_from_queries'] ) || UM()->options()->get( 'disable_restriction_pre_queries' ) ) {
|
1142 |
+
$filtered_items[] = $this->maybe_replace_nav_menu_title( $menu_item );
|
1143 |
+
continue;
|
1144 |
+
}
|
1145 |
+
}
|
1146 |
+
} elseif ( isset( $menu_item->type ) && 'custom' === $menu_item->type ) {
|
1147 |
+
$filtered_items[] = $menu_item;
|
1148 |
+
continue;
|
1149 |
+
} else {
|
1150 |
+
$filtered_items[] = $menu_item;
|
1151 |
+
continue;
|
1152 |
+
}
|
1153 |
+
} else {
|
1154 |
+
//add all other posts
|
1155 |
+
$filtered_items[] = $menu_item;
|
1156 |
+
}
|
1157 |
+
}
|
1158 |
+
|
1159 |
+
return $filtered_items;
|
1160 |
+
}
|
1161 |
+
|
1162 |
+
|
1163 |
+
/**
|
1164 |
+
* @param $block_content
|
1165 |
+
* @param $block
|
1166 |
+
*
|
1167 |
+
* @return string
|
1168 |
+
*/
|
1169 |
+
function restrict_blocks( $block_content, $block ) {
|
1170 |
+
if ( is_admin() ) {
|
1171 |
+
return $block_content;
|
1172 |
+
}
|
1173 |
+
|
1174 |
+
$restricted_blocks = UM()->options()->get( 'restricted_blocks' );
|
1175 |
+
if ( empty( $restricted_blocks ) ) {
|
1176 |
+
return $block_content;
|
1177 |
+
}
|
1178 |
+
|
1179 |
+
if ( is_user_logged_in() && current_user_can( 'administrator' ) ) {
|
1180 |
+
return $block_content;
|
1181 |
+
}
|
1182 |
+
|
1183 |
+
if ( ! isset( $block['attrs']['um_is_restrict'] ) || $block['attrs']['um_is_restrict'] !== true ) {
|
1184 |
+
return $block_content;
|
1185 |
+
}
|
1186 |
+
|
1187 |
+
if ( empty( $block['attrs']['um_who_access'] ) ) {
|
1188 |
+
return $block_content;
|
1189 |
+
}
|
1190 |
+
|
1191 |
+
$default_message = UM()->options()->get( 'restricted_block_message' );
|
1192 |
+
switch ( $block['attrs']['um_who_access'] ) {
|
1193 |
+
case '1': {
|
1194 |
+
if ( ! is_user_logged_in() ) {
|
1195 |
+
$block_content = '';
|
1196 |
+
if ( isset( $block['attrs']['um_message_type'] ) ) {
|
1197 |
+
if ( $block['attrs']['um_message_type'] == '1' ) {
|
1198 |
+
$block_content = $default_message;
|
1199 |
+
} elseif ( $block['attrs']['um_message_type'] == '2' ) {
|
1200 |
+
$block_content = $block['attrs']['um_message_content'];
|
1201 |
+
}
|
1202 |
+
}
|
1203 |
+
} else {
|
1204 |
+
$display = true;
|
1205 |
+
|
1206 |
+
// What roles can access this content?
|
1207 |
+
if ( ! empty( $block['attrs']['um_roles_access'] ) ) {
|
1208 |
+
$display = false;
|
1209 |
+
foreach ( $block['attrs']['um_roles_access'] as $role ) {
|
1210 |
+
if ( current_user_can( $role ) ) {
|
1211 |
+
$display = true;
|
1212 |
+
}
|
1213 |
+
}
|
1214 |
+
}
|
1215 |
+
|
1216 |
+
$display = apply_filters( 'um_loggedin_block_restriction', $display, $block );
|
1217 |
+
|
1218 |
+
if ( ! $display ) {
|
1219 |
+
$block_content = '';
|
1220 |
+
if ( isset( $block['attrs']['um_message_type'] ) ) {
|
1221 |
+
if ( $block['attrs']['um_message_type'] == '1' ) {
|
1222 |
+
$block_content = $default_message;
|
1223 |
+
} elseif ( $block['attrs']['um_message_type'] == '2' ) {
|
1224 |
+
$block_content = $block['attrs']['um_message_content'];
|
1225 |
+
}
|
1226 |
+
}
|
1227 |
+
}
|
1228 |
+
}
|
1229 |
+
break;
|
1230 |
+
}
|
1231 |
+
case '2': {
|
1232 |
+
if ( is_user_logged_in() ) {
|
1233 |
+
$block_content = '';
|
1234 |
+
if ( isset( $block['attrs']['um_message_type'] ) ) {
|
1235 |
+
if ( $block['attrs']['um_message_type'] == '1' ) {
|
1236 |
+
$block_content = $default_message;
|
1237 |
+
} elseif ( $block['attrs']['um_message_type'] == '2' ) {
|
1238 |
+
$block_content = $block['attrs']['um_message_content'];
|
1239 |
+
}
|
1240 |
+
}
|
1241 |
+
}
|
1242 |
+
break;
|
1243 |
+
}
|
1244 |
+
}
|
1245 |
+
|
1246 |
+
return $block_content;
|
1247 |
+
}
|
1248 |
+
|
1249 |
+
|
1250 |
+
/**
|
1251 |
+
* @param \WP_Post $post
|
1252 |
+
*
|
1253 |
+
* @return \WP_Post
|
1254 |
+
*/
|
1255 |
+
function maybe_replace_title( $post ) {
|
1256 |
+
if ( ! UM()->options()->get( 'restricted_post_title_replace' ) ) {
|
1257 |
+
return $post;
|
1258 |
+
}
|
1259 |
+
|
1260 |
+
if ( current_user_can( 'administrator' ) ) {
|
1261 |
+
return $post;
|
1262 |
+
}
|
1263 |
+
|
1264 |
+
if ( ! is_a( $post, '\WP_Post' ) ) {
|
1265 |
+
return $post;
|
1266 |
+
}
|
1267 |
+
|
1268 |
+
$ignore = apply_filters( 'um_ignore_restricted_title', false, $post->ID );
|
1269 |
+
if ( $ignore ) {
|
1270 |
+
return $post;
|
1271 |
+
}
|
1272 |
+
|
1273 |
+
$restricted_global_title = UM()->options()->get( 'restricted_access_post_title' );
|
1274 |
+
$post->post_title = stripslashes( $restricted_global_title );
|
1275 |
+
|
1276 |
+
return $post;
|
1277 |
+
}
|
1278 |
+
|
1279 |
+
|
1280 |
+
/**
|
1281 |
+
* @param \WP_Post $nav_item
|
1282 |
+
*
|
1283 |
+
* @return \WP_Post
|
1284 |
+
*/
|
1285 |
+
function maybe_replace_nav_menu_title( $nav_item ) {
|
1286 |
+
if ( ! UM()->options()->get( 'restricted_post_title_replace' ) ) {
|
1287 |
+
return $nav_item;
|
1288 |
+
}
|
1289 |
+
|
1290 |
+
if ( current_user_can( 'administrator' ) ) {
|
1291 |
+
return $nav_item;
|
1292 |
+
}
|
1293 |
+
|
1294 |
+
if ( ! is_a( $nav_item, '\WP_Post' ) ) {
|
1295 |
+
return $nav_item;
|
1296 |
+
}
|
1297 |
+
|
1298 |
+
$ignore = apply_filters( 'um_ignore_restricted_title', false, $nav_item->ID );
|
1299 |
+
if ( $ignore ) {
|
1300 |
+
return $nav_item;
|
1301 |
+
}
|
1302 |
+
|
1303 |
+
$restricted_global_title = UM()->options()->get( 'restricted_access_post_title' );
|
1304 |
+
$nav_item->title = stripslashes( $restricted_global_title );
|
1305 |
+
|
1306 |
+
return $nav_item;
|
1307 |
+
}
|
1308 |
+
|
1309 |
+
|
1310 |
+
/**
|
1311 |
+
* Protect Post Types in query
|
1312 |
+
* Restrict content new logic
|
1313 |
+
*
|
1314 |
+
* @param array $posts
|
1315 |
+
* @param array|\WP_Query $query
|
1316 |
+
* @return array
|
1317 |
+
*/
|
1318 |
+
function filter_protected_posts( $posts, $query ) {
|
1319 |
+
if ( current_user_can( 'administrator' ) ) {
|
1320 |
+
return $posts;
|
1321 |
+
}
|
1322 |
+
|
1323 |
+
//Woocommerce AJAX fixes....remove filtration on wc-ajax which goes to Front Page
|
1324 |
+
if ( ! empty( $_GET['wc-ajax'] ) && defined( 'WC_DOING_AJAX' ) && WC_DOING_AJAX ) {
|
1325 |
+
return $posts;
|
1326 |
+
}
|
1327 |
+
|
1328 |
+
//if empty
|
1329 |
+
if ( empty( $posts ) || is_admin() ) {
|
1330 |
+
return $posts;
|
1331 |
+
}
|
1332 |
+
|
1333 |
+
if ( is_object( $query ) ) {
|
1334 |
+
$is_singular = $query->is_singular();
|
1335 |
+
} else {
|
1336 |
+
$is_singular = ! empty( $query->is_singular ) ? true : false;
|
1337 |
+
}
|
1338 |
+
|
1339 |
+
if ( is_object( $query ) && is_a( $query, '\WP_Query' ) &&
|
1340 |
+
( $query->is_main_query() || ! empty( $query->query_vars['um_main_query'] ) ) ) {
|
1341 |
+
if ( $is_singular ) {
|
1342 |
+
if ( ! UM()->options()->get( 'disable_restriction_pre_queries' ) && $this->is_restricted( $posts[0]->ID ) ) {
|
1343 |
+
$content_restriction = $this->get_post_privacy_settings( $posts[0]->ID );
|
1344 |
+
if ( ! empty( $content_restriction['_um_access_hide_from_queries'] ) ) {
|
1345 |
+
unset( $posts[0] );
|
1346 |
+
return $posts;
|
1347 |
+
}
|
1348 |
+
}
|
1349 |
+
}
|
1350 |
+
}
|
1351 |
+
|
1352 |
+
$filtered_posts = array();
|
1353 |
+
|
1354 |
+
//other filter
|
1355 |
+
foreach ( $posts as $post ) {
|
1356 |
+
if ( is_user_logged_in() && isset( $post->post_author ) && $post->post_author == get_current_user_id() ) {
|
1357 |
+
$filtered_posts[] = $post;
|
1358 |
+
continue;
|
1359 |
+
}
|
1360 |
+
|
1361 |
+
$restriction = $this->get_post_privacy_settings( $post );
|
1362 |
+
if ( ! $restriction ) {
|
1363 |
+
$filtered_posts[] = $post;
|
1364 |
+
continue;
|
1365 |
+
}
|
1366 |
+
|
1367 |
+
if ( $is_singular ) {
|
1368 |
+
$this->singular_page = true;
|
1369 |
+
}
|
1370 |
+
|
1371 |
+
if ( ! $this->is_restricted( $post->ID ) ) {
|
1372 |
+
$filtered_posts[] = $post;
|
1373 |
+
continue;
|
1374 |
+
} else {
|
1375 |
+
if ( $is_singular ) {
|
1376 |
+
if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) {
|
1377 |
+
if ( UM()->options()->get( 'disable_restriction_pre_queries' ) || empty( $restriction['_um_access_hide_from_queries'] ) ) {
|
1378 |
+
/**
|
1379 |
+
* UM hook
|
1380 |
+
*
|
1381 |
+
* @type action
|
1382 |
+
* @title um_access_fix_external_post_content
|
1383 |
+
* @description Hook for 3-d party content filtration
|
1384 |
+
* @change_log
|
1385 |
+
* ["Since: 2.0"]
|
1386 |
+
* @usage add_action( 'um_access_fix_external_post_content', 'function_name', 10 );
|
1387 |
+
* @example
|
1388 |
+
* <?php
|
1389 |
+
* add_action( 'um_access_fix_external_post_content', 'my_access_fix_external_post_content', 10 );
|
1390 |
+
* function my_access_fix_external_post_content() {
|
1391 |
+
* // your code here
|
1392 |
+
* }
|
1393 |
+
* ?>
|
1394 |
+
*/
|
1395 |
+
do_action( 'um_access_fix_external_post_content' );
|
1396 |
+
|
1397 |
+
$filtered_posts[] = $this->maybe_replace_title( $post );
|
1398 |
+
continue;
|
1399 |
+
}
|
1400 |
+
} elseif ( '1' == $restriction['_um_noaccess_action'] ) {
|
1401 |
+
$curr = UM()->permalinks()->get_current_url();
|
1402 |
+
|
1403 |
+
if ( ! isset( $restriction['_um_access_redirect'] ) || '0' == $restriction['_um_access_redirect'] ) {
|
1404 |
+
|
1405 |
+
exit( wp_redirect( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) ) ) );
|
1406 |
+
|
1407 |
+
} elseif ( '1' == $restriction['_um_access_redirect'] ) {
|
1408 |
+
|
1409 |
+
if ( ! empty( $restriction['_um_access_redirect_url'] ) ) {
|
1410 |
+
$redirect = $restriction['_um_access_redirect_url'];
|
1411 |
+
} else {
|
1412 |
+
$redirect = esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) );
|
1413 |
+
}
|
1414 |
+
|
1415 |
+
exit( wp_redirect( $redirect ) );
|
1416 |
+
}
|
1417 |
+
}
|
1418 |
+
} else {
|
1419 |
+
if ( empty( $restriction['_um_access_hide_from_queries'] ) || UM()->options()->get( 'disable_restriction_pre_queries' ) ) {
|
1420 |
+
$filtered_posts[] = $this->maybe_replace_title( $post );
|
1421 |
+
continue;
|
1422 |
+
}
|
1423 |
+
}
|
1424 |
+
}
|
1425 |
+
}
|
1426 |
+
|
1427 |
+
return $filtered_posts;
|
1428 |
+
}
|
1429 |
+
|
1430 |
+
|
1431 |
+
/**
|
1432 |
+
* Set custom access actions and redirection
|
1433 |
+
*
|
1434 |
+
* Old global restrict content logic
|
1435 |
+
*/
|
1436 |
+
function template_redirect() {
|
1437 |
+
global $post, $wp_query;
|
1438 |
+
|
1439 |
+
//if we logged by administrator it can access to all content
|
1440 |
+
if ( current_user_can( 'administrator' ) ) {
|
1441 |
+
return;
|
1442 |
+
}
|
1443 |
+
|
1444 |
+
if ( is_object( $wp_query ) ) {
|
1445 |
+
$is_singular = $wp_query->is_singular();
|
1446 |
+
} else {
|
1447 |
+
$is_singular = ! empty( $wp_query->is_singular ) ? true : false;
|
1448 |
+
}
|
1449 |
+
|
1450 |
+
//if we use individual restrict content options skip this function
|
1451 |
+
if ( $is_singular && $this->singular_page ) {
|
1452 |
+
return;
|
1453 |
+
}
|
1454 |
+
|
1455 |
+
//also skip if we currently at wp-admin or 404 page
|
1456 |
+
if ( is_admin() || is_404() ) {
|
1457 |
+
return;
|
1458 |
+
}
|
1459 |
+
|
1460 |
+
//also skip if we currently at UM Register|Login|Reset Password pages
|
1461 |
+
if ( um_is_core_post( $post, 'register' ) ||
|
1462 |
+
um_is_core_post( $post, 'password-reset' ) ||
|
1463 |
+
um_is_core_post( $post, 'login' ) ) {
|
1464 |
+
return;
|
1465 |
+
}
|
1466 |
+
|
1467 |
+
/**
|
1468 |
+
* UM hook
|
1469 |
+
*
|
1470 |
+
* @type action
|
1471 |
+
* @title um_roles_add_meta_boxes_um_role_meta
|
1472 |
+
* @description Check terms individual restrict options
|
1473 |
+
* @change_log
|
1474 |
+
* ["Since: 2.0"]
|
1475 |
+
* @usage add_action( 'um_access_check_individual_term_settings', 'function_name', 10 );
|
1476 |
+
* @example
|
1477 |
+
* <?php
|
1478 |
+
* add_action( 'um_access_check_individual_term_settings', 'my_access_check_individual_term_settings', 10 );
|
1479 |
+
* function my_access_check_individual_term_settings() {
|
1480 |
+
* // your code here
|
1481 |
+
* }
|
1482 |
+
* ?>
|
1483 |
+
*/
|
1484 |
+
do_action( 'um_access_check_individual_term_settings' );
|
1485 |
+
//exit from function if term page is accessible
|
1486 |
+
if ( $this->check_access() ) {
|
1487 |
+
return;
|
1488 |
+
}
|
1489 |
+
|
1490 |
+
/**
|
1491 |
+
* UM hook
|
1492 |
+
*
|
1493 |
+
* @type action
|
1494 |
+
* @title um_access_check_global_settings
|
1495 |
+
* @description Check global restrict content options
|
1496 |
+
* @change_log
|
1497 |
+
* ["Since: 2.0"]
|
1498 |
+
* @usage add_action( 'um_access_check_global_settings', 'function_name', 10 );
|
1499 |
+
* @example
|
1500 |
+
* <?php
|
1501 |
+
* add_action( 'um_access_check_global_settings', 'my_access_check_global_settings', 10 );
|
1502 |
+
* function my_access_check_global_settings() {
|
1503 |
+
* // your code here
|
1504 |
+
* }
|
1505 |
+
* ?>
|
1506 |
+
*/
|
1507 |
+
do_action( 'um_access_check_global_settings' );
|
1508 |
+
|
1509 |
+
$this->check_access();
|
1510 |
+
}
|
1511 |
+
|
1512 |
+
|
1513 |
+
/**
|
1514 |
+
* Check individual term Content Restriction settings
|
1515 |
+
*/
|
1516 |
+
function um_access_check_individual_term_settings() {
|
1517 |
+
//check only tax|tags|categories - skip archive, author, and date lists
|
1518 |
+
if ( ! ( is_tax() || is_tag() || is_category() ) ) {
|
1519 |
+
return;
|
1520 |
+
}
|
1521 |
+
|
1522 |
+
$term_id = null;
|
1523 |
+
if ( is_tag() ) {
|
1524 |
+
$term_id = get_query_var( 'tag_id' );
|
1525 |
+
} elseif ( is_category() ) {
|
1526 |
+
$term_id = get_query_var( 'cat' );
|
1527 |
+
} elseif ( is_tax() ) {
|
1528 |
+
$tax_name = get_query_var( 'taxonomy' );
|
1529 |
+
|
1530 |
+
$term_name = get_query_var( 'term' );
|
1531 |
+
$term = get_term_by( 'slug', $term_name, $tax_name );
|
1532 |
+
|
1533 |
+
$term_id = ! empty( $term->term_id ) ? $term->term_id : $term_id;
|
1534 |
+
}
|
1535 |
+
|
1536 |
+
if ( ! isset( $term_id ) ) {
|
1537 |
+
return;
|
1538 |
+
}
|
1539 |
+
|
1540 |
+
if ( $this->is_restricted_term( $term_id, true ) ) {
|
1541 |
+
$restriction = get_term_meta( $term_id, 'um_content_restriction', true );
|
1542 |
+
if ( '1' == $restriction['_um_noaccess_action'] ) {
|
1543 |
+
$curr = UM()->permalinks()->get_current_url();
|
1544 |
+
|
1545 |
+
if ( ! isset( $restriction['_um_access_redirect'] ) || '0' == $restriction['_um_access_redirect'] ) {
|
1546 |
+
|
1547 |
+
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) ), 'individual_term' );
|
1548 |
+
|
1549 |
+
} elseif ( '1' == $restriction['_um_access_redirect'] ) {
|
1550 |
+
|
1551 |
+
if ( ! empty( $restriction['_um_access_redirect_url'] ) ) {
|
1552 |
+
$redirect = $restriction['_um_access_redirect_url'];
|
1553 |
+
} else {
|
1554 |
+
$redirect = esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) );
|
1555 |
+
}
|
1556 |
+
|
1557 |
+
$this->redirect_handler = $this->set_referer( $redirect, 'individual_term' );
|
1558 |
+
|
1559 |
+
}
|
1560 |
+
} else {
|
1561 |
+
add_filter( 'tag_template', array( &$this, 'taxonomy_message' ), 10, 3 );
|
1562 |
+
add_filter( 'archive_template', array( &$this, 'taxonomy_message' ), 10, 3 );
|
1563 |
+
add_filter( 'category_template', array( &$this, 'taxonomy_message' ), 10, 3 );
|
1564 |
+
add_filter( 'taxonomy_template', array( &$this, 'taxonomy_message' ), 10, 3 );
|
1565 |
+
}
|
1566 |
+
}
|
1567 |
+
}
|
1568 |
+
|
1569 |
+
|
1570 |
+
/**
|
1571 |
+
* @param $template
|
1572 |
+
* @param $type
|
1573 |
+
* @param $templates
|
1574 |
+
*
|
1575 |
+
* @return string
|
1576 |
+
*/
|
1577 |
+
function taxonomy_message( $template, $type, $templates ) {
|
1578 |
+
return UM()->locate_template( 'restricted-taxonomy.php' );
|
1579 |
+
}
|
1580 |
+
|
1581 |
+
|
1582 |
+
/**
|
1583 |
+
* Check global accessible settings
|
1584 |
+
*/
|
1585 |
+
function um_access_check_global_settings() {
|
1586 |
+
global $post;
|
1587 |
+
|
1588 |
+
$curr = UM()->permalinks()->get_current_url();
|
1589 |
+
$ms_empty_role_access = is_multisite() && is_user_logged_in() && ! UM()->roles()->get_priority_user_role( um_user( 'ID' ) );
|
1590 |
+
|
1591 |
+
if ( is_front_page() ) {
|
1592 |
+
if ( is_user_logged_in() && ! $ms_empty_role_access ) {
|
1593 |
+
|
1594 |
+
$user_default_homepage = um_user( 'default_homepage' );
|
1595 |
+
if ( ! empty( $user_default_homepage ) ) {
|
1596 |
+
return;
|
1597 |
+
}
|
1598 |
+
|
1599 |
+
$redirect_homepage = um_user( 'redirect_homepage' );
|
1600 |
+
/**
|
1601 |
+
* UM hook
|
1602 |
+
*
|
1603 |
+
* @type filter
|
1604 |
+
* @title um_custom_homepage_redirect_url
|
1605 |
+
* @description Change custom homepage redirect
|
1606 |
+
* @input_vars
|
1607 |
+
* [{"var":"$url","type":"string","desc":"Redirect URL"},
|
1608 |
+
* {"var":"$id","type":"int","desc":"User ID"}]
|
1609 |
+
* @change_log
|
1610 |
+
* ["Since: 2.0"]
|
1611 |
+
* @usage
|
1612 |
+
* <?php add_filter( 'um_custom_homepage_redirect_url', 'function_name', 10, 2 ); ?>
|
1613 |
+
* @example
|
1614 |
+
* <?php
|
1615 |
+
* add_filter( 'um_custom_homepage_redirect_url', 'my_custom_homepage_redirect_url', 10, 2 );
|
1616 |
+
* function my_custom_homepage_redirect_url( $url, $id ) {
|
1617 |
+
* // your code here
|
1618 |
+
* return $url;
|
1619 |
+
* }
|
1620 |
+
* ?>
|
1621 |
+
*/
|
1622 |
+
$redirect_homepage = apply_filters( 'um_custom_homepage_redirect_url', $redirect_homepage, um_user( 'ID' ) );
|
1623 |
+
$redirect_to = ! empty( $redirect_homepage ) ? $redirect_homepage : um_get_core_page( 'user' );
|
1624 |
+
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), $redirect_to ) ), 'custom_homepage' );
|
1625 |
+
|
1626 |
+
} else {
|
1627 |
+
$access = UM()->options()->get( 'accessible' );
|
1628 |
+
|
1629 |
+
if ( $access == 2 ) {
|
1630 |
+
//global settings for accessible home page
|
1631 |
+
$home_page_accessible = UM()->options()->get( 'home_page_accessible' );
|
1632 |
+
|
1633 |
+
if ( $home_page_accessible == 0 ) {
|
1634 |
+
//get redirect URL if not set get login page by default
|
1635 |
+
$redirect = UM()->options()->get( 'access_redirect' );
|
1636 |
+
if ( ! $redirect ) {
|
1637 |
+
$redirect = um_get_core_page( 'login' );
|
1638 |
+
}
|
1639 |
+
|
1640 |
+
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), $redirect ) ), 'global' );
|
1641 |
+
} else {
|
1642 |
+
$this->allow_access = true;
|
1643 |
+
return;
|
1644 |
+
}
|
1645 |
+
}
|
1646 |
+
}
|
1647 |
+
} elseif ( is_category() ) {
|
1648 |
+
if ( ! is_user_logged_in() || $ms_empty_role_access ) {
|
1649 |
+
|
1650 |
+
$access = UM()->options()->get( 'accessible' );
|
1651 |
+
|
1652 |
+
if ( $access == 2 ) {
|
1653 |
+
//global settings for accessible home page
|
1654 |
+
$category_page_accessible = UM()->options()->get( 'category_page_accessible' );
|
1655 |
+
if ( $category_page_accessible == 0 ) {
|
1656 |
+
//get redirect URL if not set get login page by default
|
1657 |
+
$redirect = UM()->options()->get( 'access_redirect' );
|
1658 |
+
if ( ! $redirect ) {
|
1659 |
+
$redirect = um_get_core_page( 'login' );
|
1660 |
+
}
|
1661 |
+
|
1662 |
+
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), $redirect ) ), 'global' );
|
1663 |
+
} else {
|
1664 |
+
$this->allow_access = true;
|
1665 |
+
return;
|
1666 |
+
}
|
1667 |
+
}
|
1668 |
+
}
|
1669 |
+
}
|
1670 |
+
|
1671 |
+
$access = UM()->options()->get( 'accessible' );
|
1672 |
+
|
1673 |
+
if ( $access == 2 && ( ! is_user_logged_in() || $ms_empty_role_access ) ) {
|
1674 |
+
|
1675 |
+
//build exclude URLs pages
|
1676 |
+
$redirects = array();
|
1677 |
+
$redirects[] = trim( untrailingslashit( UM()->options()->get( 'access_redirect' ) ) );
|
1678 |
+
|
1679 |
+
$exclude_uris = UM()->options()->get( 'access_exclude_uris' );
|
1680 |
+
if ( ! empty( $exclude_uris ) ) {
|
1681 |
+
$exclude_uris = array_map( 'trim', $exclude_uris );
|
1682 |
+
$redirects = array_merge( $redirects, $exclude_uris );
|
1683 |
+
}
|
1684 |
+
|
1685 |
+
$redirects = array_unique( $redirects );
|
1686 |
+
|
1687 |
+
$current_url = UM()->permalinks()->get_current_url( get_option( 'permalink_structure' ) );
|
1688 |
+
$current_url = untrailingslashit( $current_url );
|
1689 |
+
$current_url_slash = trailingslashit( $current_url );
|
1690 |
+
|
1691 |
+
if ( ! ( isset( $post->ID ) && ( in_array( $current_url, $redirects ) || in_array( $current_url_slash, $redirects ) ) ) ) {
|
1692 |
+
//if current page not in exclude URLs
|
1693 |
+
//get redirect URL if not set get login page by default
|
1694 |
+
$redirect = UM()->options()->get( 'access_redirect' );
|
1695 |
+
if ( ! $redirect ) {
|
1696 |
+
$redirect = um_get_core_page( 'login' );
|
1697 |
+
}
|
1698 |
+
|
1699 |
+
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), $redirect ) ), 'global' );
|
1700 |
+
} else {
|
1701 |
+
$this->redirect_handler = false;
|
1702 |
+
$this->allow_access = true;
|
1703 |
+
}
|
1704 |
+
}
|
1705 |
+
}
|
1706 |
+
|
1707 |
+
|
1708 |
+
/**
|
1709 |
+
* Check access
|
1710 |
+
*
|
1711 |
+
* @return bool
|
1712 |
+
*/
|
1713 |
+
function check_access() {
|
1714 |
+
if ( $this->allow_access === true ) {
|
1715 |
+
return true;
|
1716 |
+
}
|
1717 |
+
|
1718 |
+
if ( $this->redirect_handler ) {
|
1719 |
+
wp_redirect( $this->redirect_handler );
|
1720 |
+
exit;
|
1721 |
+
}
|
1722 |
+
|
1723 |
+
return false;
|
1724 |
+
}
|
1725 |
+
|
1726 |
+
|
1727 |
+
/**
|
1728 |
+
* Sets a custom access referer in a redirect URL
|
1729 |
+
*
|
1730 |
+
* @param string $url
|
1731 |
+
* @param string $referer
|
1732 |
+
*
|
1733 |
+
* @return string
|
1734 |
+
*/
|
1735 |
+
function set_referer( $url, $referer ) {
|
1736 |
+
|
1737 |
+
/**
|
1738 |
+
* UM hook
|
1739 |
+
*
|
1740 |
+
* @type filter
|
1741 |
+
* @title um_access_enable_referer
|
1742 |
+
* @description Access Referrer Enable/Disable
|
1743 |
+
* @input_vars
|
1744 |
+
* [{"var":"$referrer","type":"bool","desc":"Access referrer"}]
|
1745 |
+
* @change_log
|
1746 |
+
* ["Since: 2.0"]
|
1747 |
+
* @usage add_filter( 'um_access_enable_referer', 'function_name', 10, 1 );
|
1748 |
+
* @example
|
1749 |
+
* <?php
|
1750 |
+
* add_filter( 'um_access_enable_referer', 'my_access_enable_referer', 10, 1 );
|
1751 |
+
* function my_access_enable_referer( $referrer ) {
|
1752 |
+
* // your code here
|
1753 |
+
* return $referrer;
|
1754 |
+
* }
|
1755 |
+
* ?>
|
1756 |
+
*/
|
1757 |
+
$enable_referer = apply_filters( 'um_access_enable_referer', false );
|
1758 |
+
if ( ! $enable_referer ) {
|
1759 |
+
return $url;
|
1760 |
+
}
|
1761 |
+
|
1762 |
+
$url = add_query_arg( 'um_ref', $referer, $url );
|
1763 |
+
return $url;
|
1764 |
+
}
|
1765 |
+
|
1766 |
+
|
1767 |
+
/**
|
1768 |
+
* Get privacy settings for post
|
1769 |
+
* return false if post is not private
|
1770 |
+
* Restrict content new logic
|
1771 |
+
*
|
1772 |
+
* @param \WP_Post|int $post Post ID or object
|
1773 |
+
* @return bool|array
|
1774 |
+
*/
|
1775 |
+
function get_post_privacy_settings( $post ) {
|
1776 |
+
// break for incorrect post
|
1777 |
+
if ( empty( $post ) ) {
|
1778 |
+
return false;
|
1779 |
+
}
|
1780 |
+
|
1781 |
+
static $cache = array();
|
1782 |
+
|
1783 |
+
$cache_key = is_numeric( $post ) ? $post : $post->ID;
|
1784 |
+
|
1785 |
+
if ( isset( $cache[ $cache_key ] ) ) {
|
1786 |
+
return $cache[ $cache_key ];
|
1787 |
+
}
|
1788 |
+
|
1789 |
+
if ( is_numeric( $post ) ) {
|
1790 |
+
$post = get_post( $post );
|
1791 |
+
}
|
1792 |
+
|
1793 |
+
//if logged in administrator all pages are visible
|
1794 |
+
if ( current_user_can( 'administrator' ) ) {
|
1795 |
+
$cache[ $cache_key ] = false;
|
1796 |
+
return false;
|
1797 |
+
}
|
1798 |
+
|
1799 |
+
$exclude = false;
|
1800 |
+
//exclude from privacy UM default pages (except Members list and User(Profile) page)
|
1801 |
+
if ( ! empty( $post->post_type ) && $post->post_type === 'page' ) {
|
1802 |
+
|
1803 |
+
if ( um_is_core_post( $post, 'login' ) || um_is_core_post( $post, 'register' ) ||
|
1804 |
+
um_is_core_post( $post, 'account' ) || um_is_core_post( $post, 'logout' ) ||
|
1805 |
+
um_is_core_post( $post, 'password-reset' ) || ( is_user_logged_in() && um_is_core_post( $post, 'user' ) ) )
|
1806 |
+
$exclude = true;
|
1807 |
+
}
|
1808 |
+
|
1809 |
+
$exclude = apply_filters( 'um_exclude_posts_from_privacy', $exclude, $post );
|
1810 |
+
if ( $exclude ) {
|
1811 |
+
$cache[ $cache_key ] = false;
|
1812 |
+
return false;
|
1813 |
+
}
|
1814 |
+
|
1815 |
+
$restricted_posts = UM()->options()->get( 'restricted_access_post_metabox' );
|
1816 |
+
|
1817 |
+
if ( ! empty( $post->post_type ) && ! empty( $restricted_posts[ $post->post_type ] ) ) {
|
1818 |
+
$restriction = get_post_meta( $post->ID, 'um_content_restriction', true );
|
1819 |
+
|
1820 |
+
if ( ! empty( $restriction['_um_custom_access_settings'] ) ) {
|
1821 |
+
if ( ! isset( $restriction['_um_accessible'] ) ) {
|
1822 |
+
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
1823 |
+
|
1824 |
+
//get all taxonomies for current post type
|
1825 |
+
$taxonomies = get_object_taxonomies( $post );
|
1826 |
+
|
1827 |
+
//get all post terms
|
1828 |
+
$terms = array();
|
1829 |
+
if ( ! empty( $taxonomies ) ) {
|
1830 |
+
foreach ( $taxonomies as $taxonomy ) {
|
1831 |
+
if ( empty( $restricted_taxonomies[ $taxonomy ] ) ) {
|
1832 |
+
continue;
|
1833 |
+
}
|
1834 |
+
|
1835 |
+
$terms = array_merge( $terms, wp_get_post_terms( $post->ID, $taxonomy, array( 'fields' => 'ids', 'um_ignore_exclude' => true, ) ) );
|
1836 |
+
}
|
1837 |
+
}
|
1838 |
+
|
1839 |
+
//get restriction options for first term with privacy settigns
|
1840 |
+
foreach ( $terms as $term_id ) {
|
1841 |
+
$restriction = get_term_meta( $term_id, 'um_content_restriction', true );
|
1842 |
+
|
1843 |
+
if ( ! empty( $restriction['_um_custom_access_settings'] ) ) {
|
1844 |
+
if ( ! isset( $restriction['_um_accessible'] ) ) {
|
1845 |
+
continue;
|
1846 |
+
} else {
|
1847 |
+
$cache[ $cache_key ] = $restriction;
|
1848 |
+
return $restriction;
|
1849 |
+
}
|
1850 |
+
}
|
1851 |
+
}
|
1852 |
+
|
1853 |
+
$cache[ $cache_key ] = false;
|
1854 |
+
return false;
|
1855 |
+
} else {
|
1856 |
+
|
1857 |
+
// set default redirect if Profile page is restricted for not-logged in users and showing message instead of redirect
|
1858 |
+
// this snippet was added to make the same action for {site_url}/user and {site_url}/user/{user_slug} URLs
|
1859 |
+
// 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
|
1860 |
+
if ( ! is_user_logged_in() && um_is_core_post( $post, 'user' ) && $restriction['_um_accessible'] == '2' && $restriction['_um_noaccess_action'] == '0' ) {
|
1861 |
+
if ( isset( $restriction['_um_access_roles'] ) ) {
|
1862 |
+
$restriction = array(
|
1863 |
+
'_um_accessible' => '2',
|
1864 |
+
'_um_access_roles' => $restriction['_um_access_roles'],
|
1865 |
+
'_um_noaccess_action' => '1',
|
1866 |
+
'_um_access_redirect' => '1',
|
1867 |
+
'_um_access_redirect_url' => get_home_url( get_current_blog_id() )
|
1868 |
+
);
|
1869 |
+
} else {
|
1870 |
+
$restriction = array(
|
1871 |
+
'_um_accessible' => '2',
|
1872 |
+
'_um_noaccess_action' => '1',
|
1873 |
+
'_um_access_redirect' => '1',
|
1874 |
+
'_um_access_redirect_url' => get_home_url( get_current_blog_id() )
|
1875 |
+
);
|
1876 |
+
}
|
1877 |
+
}
|
1878 |
+
|
1879 |
+
$restriction = apply_filters( 'um_post_content_restriction_settings', $restriction, $post );
|
1880 |
+
|
1881 |
+
$cache[ $cache_key ] = $restriction;
|
1882 |
+
return $restriction;
|
1883 |
+
}
|
1884 |
+
}
|
1885 |
+
}
|
1886 |
+
|
1887 |
+
//post hasn't privacy settings....check all terms of this post
|
1888 |
+
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
1889 |
+
|
1890 |
+
//get all taxonomies for current post type
|
1891 |
+
$taxonomies = get_object_taxonomies( $post );
|
1892 |
+
|
1893 |
+
//get all post terms
|
1894 |
+
$terms = array();
|
1895 |
+
if ( ! empty( $taxonomies ) ) {
|
1896 |
+
foreach ( $taxonomies as $taxonomy ) {
|
1897 |
+
if ( empty( $restricted_taxonomies[ $taxonomy ] ) ) {
|
1898 |
+
continue;
|
1899 |
+
}
|
1900 |
+
|
1901 |
+
$terms = array_merge( $terms, wp_get_post_terms( $post->ID, $taxonomy, array( 'fields' => 'ids', 'um_ignore_exclude' => true, ) ) );
|
1902 |
+
}
|
1903 |
+
}
|
1904 |
+
|
1905 |
+
//get restriction options for first term with privacy settings
|
1906 |
+
foreach ( $terms as $term_id ) {
|
1907 |
+
$restriction = get_term_meta( $term_id, 'um_content_restriction', true );
|
1908 |
+
|
1909 |
+
if ( ! empty( $restriction['_um_custom_access_settings'] ) ) {
|
1910 |
+
if ( ! isset( $restriction['_um_accessible'] ) ) {
|
1911 |
+
continue;
|
1912 |
+
} else {
|
1913 |
+
$cache[ $cache_key ] = $restriction;
|
1914 |
+
return $restriction;
|
1915 |
+
}
|
1916 |
+
}
|
1917 |
+
}
|
1918 |
+
|
1919 |
+
$cache[ $cache_key ] = false;
|
1920 |
+
//post is public
|
1921 |
+
return false;
|
1922 |
+
}
|
1923 |
+
|
1924 |
+
|
1925 |
+
/**
|
1926 |
+
* Helper for checking if the user can some of the roles array
|
1927 |
+
*
|
1928 |
+
* @param $user_id
|
1929 |
+
* @param $roles
|
1930 |
+
* @return bool
|
1931 |
+
*/
|
1932 |
+
function user_can( $user_id, $roles ) {
|
1933 |
+
$user_can = false;
|
1934 |
+
|
1935 |
+
if ( ! empty( $roles ) ) {
|
1936 |
+
foreach ( $roles as $key => $value ) {
|
1937 |
+
if ( ! empty( $value ) && user_can( $user_id, $key ) ) {
|
1938 |
+
$user_can = true;
|
1939 |
+
break;
|
1940 |
+
}
|
1941 |
+
}
|
1942 |
+
}
|
1943 |
+
|
1944 |
+
return $user_can;
|
1945 |
+
}
|
1946 |
+
|
1947 |
+
|
1948 |
+
/**
|
1949 |
+
* Helper for 3rd-party integrations with content restriction settings
|
1950 |
+
*
|
1951 |
+
* @param array $restriction
|
1952 |
+
*
|
1953 |
+
* @return bool
|
1954 |
+
*/
|
1955 |
+
function um_custom_restriction( $restriction ) {
|
1956 |
+
/**
|
1957 |
+
* UM hook
|
1958 |
+
*
|
1959 |
+
* @type filter
|
1960 |
+
* @title um_custom_restriction
|
1961 |
+
* @description Extend Sort Types for Member Directory
|
1962 |
+
* @input_vars
|
1963 |
+
* [{"var":"$custom_restriction","type":"bool","desc":"Custom Restriction"},
|
1964 |
+
* {"var":"$restriction","type":"array","desc":"Restriction settings"}]
|
1965 |
+
* @change_log
|
1966 |
+
* ["Since: 2.0"]
|
1967 |
+
* @usage add_filter( 'um_custom_restriction', 'function_name', 10, 2 );
|
1968 |
+
* @example
|
1969 |
+
* <?php
|
1970 |
+
* add_filter( 'um_custom_restriction', 'my_custom_restriction', 10, 2 );
|
1971 |
+
* function my_directory_sort_users_select( $custom_restriction, $restriction ) {
|
1972 |
+
* // your code here
|
1973 |
+
* return $custom_restriction;
|
1974 |
+
* }
|
1975 |
+
* ?>
|
1976 |
+
*/
|
1977 |
+
return apply_filters( 'um_custom_restriction', true, $restriction );
|
1978 |
+
}
|
1979 |
+
|
1980 |
+
|
1981 |
+
/**
|
1982 |
+
* Is post restricted?
|
1983 |
+
*
|
1984 |
+
* @param int $post_id
|
1985 |
+
* @return bool
|
1986 |
+
*/
|
1987 |
+
function is_restricted( $post_id ) {
|
1988 |
+
// break for incorrect post
|
1989 |
+
if ( empty( $post_id ) ) {
|
1990 |
+
return false;
|
1991 |
+
}
|
1992 |
+
|
1993 |
+
static $cache = array();
|
1994 |
+
|
1995 |
+
if ( isset( $cache[ $post_id ] ) ) {
|
1996 |
+
return $cache[ $post_id ];
|
1997 |
+
}
|
1998 |
+
|
1999 |
+
if ( current_user_can( 'administrator' ) ) {
|
2000 |
+
$cache[ $post_id ] = false;
|
2001 |
+
return false;
|
2002 |
+
}
|
2003 |
+
|
2004 |
+
$post = get_post( $post_id );
|
2005 |
+
if ( is_user_logged_in() && isset( $post->post_author ) && $post->post_author == get_current_user_id() ) {
|
2006 |
+
$cache[ $post_id ] = false;
|
2007 |
+
return false;
|
2008 |
+
}
|
2009 |
+
|
2010 |
+
$restricted = true;
|
2011 |
+
|
2012 |
+
$restriction = $this->get_post_privacy_settings( $post_id );
|
2013 |
+
if ( ! $restriction ) {
|
2014 |
+
$restricted = false;
|
2015 |
+
} else {
|
2016 |
+
if ( '0' == $restriction['_um_accessible'] ) {
|
2017 |
+
//post is private
|
2018 |
+
$restricted = false;
|
2019 |
+
} elseif ( '1' == $restriction['_um_accessible'] ) {
|
2020 |
+
//if post for not logged in users and user is not logged in
|
2021 |
+
if ( ! is_user_logged_in() ) {
|
2022 |
+
$restricted = false;
|
2023 |
+
}
|
2024 |
+
} elseif ( '2' == $restriction['_um_accessible'] ) {
|
2025 |
+
//if post for logged in users and user is not logged in
|
2026 |
+
if ( is_user_logged_in() ) {
|
2027 |
+
$custom_restrict = $this->um_custom_restriction( $restriction );
|
2028 |
+
|
2029 |
+
if ( empty( $restriction['_um_access_roles'] ) || false === array_search( '1', $restriction['_um_access_roles'] ) ) {
|
2030 |
+
if ( $custom_restrict ) {
|
2031 |
+
$restricted = false;
|
2032 |
+
}
|
2033 |
+
} else {
|
2034 |
+
$user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] );
|
2035 |
+
|
2036 |
+
if ( $user_can && $custom_restrict ) {
|
2037 |
+
$restricted = false;
|
2038 |
+
}
|
2039 |
+
}
|
2040 |
+
}
|
2041 |
+
}
|
2042 |
+
}
|
2043 |
+
|
2044 |
+
$restricted = apply_filters( 'um_is_restricted_post', $restricted, $post_id );
|
2045 |
+
|
2046 |
+
$cache[ $post_id ] = $restricted;
|
2047 |
+
|
2048 |
+
return $restricted;
|
2049 |
+
}
|
2050 |
+
|
2051 |
+
|
2052 |
+
/**
|
2053 |
+
* Is term restricted?
|
2054 |
+
*
|
2055 |
+
* @param int $term_id
|
2056 |
+
* @param bool $on_term_page
|
2057 |
+
* @return bool
|
2058 |
+
*/
|
2059 |
+
function is_restricted_term( $term_id, $on_term_page = false ) {
|
2060 |
+
static $cache = array();
|
2061 |
+
|
2062 |
+
if ( isset( $cache[ $term_id ] ) ) {
|
2063 |
+
return $cache[ $term_id ];
|
2064 |
+
}
|
2065 |
+
|
2066 |
+
if ( current_user_can( 'administrator' ) ) {
|
2067 |
+
$cache[ $term_id ] = false;
|
2068 |
+
return false;
|
2069 |
+
}
|
2070 |
+
|
2071 |
+
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
2072 |
+
if ( empty( $restricted_taxonomies ) ) {
|
2073 |
+
$cache[ $term_id ] = false;
|
2074 |
+
return false;
|
2075 |
+
}
|
2076 |
+
|
2077 |
+
$term = get_term( $term_id );
|
2078 |
+
if ( empty( $term->taxonomy ) || empty( $restricted_taxonomies[ $term->taxonomy ] ) ) {
|
2079 |
+
$cache[ $term_id ] = false;
|
2080 |
+
return false;
|
2081 |
+
}
|
2082 |
+
|
2083 |
+
$restricted = true;
|
2084 |
+
|
2085 |
+
// $this->allow_access = true only in case if the
|
2086 |
+
|
2087 |
+
$restriction = get_term_meta( $term_id, 'um_content_restriction', true );
|
2088 |
+
if ( empty( $restriction ) ) {
|
2089 |
+
$restricted = false;
|
2090 |
+
} else {
|
2091 |
+
if ( empty( $restriction['_um_custom_access_settings'] ) ) {
|
2092 |
+
$restricted = false;
|
2093 |
+
} else {
|
2094 |
+
if ( '0' == $restriction['_um_accessible'] ) {
|
2095 |
+
//term is private
|
2096 |
+
$restricted = false;
|
2097 |
+
if ( $on_term_page ) {
|
2098 |
+
$this->allow_access = true;
|
2099 |
+
}
|
2100 |
+
} elseif ( '1' == $restriction['_um_accessible'] ) {
|
2101 |
+
//if term for not logged in users and user is not logged in
|
2102 |
+
if ( ! is_user_logged_in() ) {
|
2103 |
+
$restricted = false;
|
2104 |
+
if ( $on_term_page ) {
|
2105 |
+
$this->allow_access = true;
|
2106 |
+
}
|
2107 |
+
}
|
2108 |
+
} elseif ( '2' == $restriction['_um_accessible'] ) {
|
2109 |
+
//if term for logged in users and user is not logged in
|
2110 |
+
if ( is_user_logged_in() ) {
|
2111 |
+
$custom_restrict = $this->um_custom_restriction( $restriction );
|
2112 |
+
|
2113 |
+
if ( empty( $restriction['_um_access_roles'] ) || false === array_search( '1', $restriction['_um_access_roles'] ) ) {
|
2114 |
+
if ( $custom_restrict ) {
|
2115 |
+
$restricted = false;
|
2116 |
+
if ( $on_term_page ) {
|
2117 |
+
$this->allow_access = true;
|
2118 |
+
}
|
2119 |
+
}
|
2120 |
+
} else {
|
2121 |
+
$user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] );
|
2122 |
+
|
2123 |
+
if ( $user_can && $custom_restrict ) {
|
2124 |
+
$restricted = false;
|
2125 |
+
if ( $on_term_page ) {
|
2126 |
+
$this->allow_access = true;
|
2127 |
+
}
|
2128 |
+
}
|
2129 |
+
}
|
2130 |
+
}
|
2131 |
+
}
|
2132 |
+
}
|
2133 |
+
}
|
2134 |
+
|
2135 |
+
$restricted = apply_filters( 'um_is_restricted_term', $restricted, $term_id, $on_term_page );
|
2136 |
+
|
2137 |
+
$cache[ $term_id ] = $restricted;
|
2138 |
+
return $restricted;
|
2139 |
+
}
|
2140 |
+
}
|
2141 |
+
}
|
includes/core/class-builtin.php
CHANGED
@@ -1058,21 +1058,24 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
|
1058 |
),
|
1059 |
|
1060 |
'youtube' => array(
|
1061 |
-
'title'
|
1062 |
-
'metakey'
|
1063 |
-
'type'
|
1064 |
-
'label'
|
1065 |
-
'required'
|
1066 |
-
'public'
|
1067 |
-
'editable'
|
1068 |
'url_target' => '_blank',
|
1069 |
-
'url_rel'
|
1070 |
-
'icon'
|
1071 |
-
'validate'
|
1072 |
-
'url_text'
|
1073 |
-
'advanced'
|
1074 |
-
'color'
|
1075 |
-
'match'
|
|
|
|
|
|
|
1076 |
),
|
1077 |
|
1078 |
'soundcloud' => array(
|
1058 |
),
|
1059 |
|
1060 |
'youtube' => array(
|
1061 |
+
'title' => __( 'YouTube', 'ultimate-member' ),
|
1062 |
+
'metakey' => 'youtube',
|
1063 |
+
'type' => 'url',
|
1064 |
+
'label' => __( 'YouTube', 'ultimate-member' ),
|
1065 |
+
'required' => 0,
|
1066 |
+
'public' => 1,
|
1067 |
+
'editable' => 1,
|
1068 |
'url_target' => '_blank',
|
1069 |
+
'url_rel' => 'nofollow',
|
1070 |
+
'icon' => 'um-faicon-youtube',
|
1071 |
+
'validate' => 'youtube_url',
|
1072 |
+
'url_text' => __( 'YouTube', 'ultimate-member' ),
|
1073 |
+
'advanced' => 'social',
|
1074 |
+
'color' => '#e52d27',
|
1075 |
+
'match' => array(
|
1076 |
+
'https://youtube.com/',
|
1077 |
+
'https://youtu.be/',
|
1078 |
+
),
|
1079 |
),
|
1080 |
|
1081 |
'soundcloud' => array(
|
includes/core/class-fields.php
CHANGED
@@ -86,9 +86,10 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
|
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, $
|
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 |
|
@@ -146,17 +147,19 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
|
146 |
|
147 |
if ( array_key_exists( 'custom_dropdown_options_source', $args ) ) {
|
148 |
if ( function_exists( wp_unslash( $args['custom_dropdown_options_source'] ) ) ) {
|
149 |
-
$
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
|
|
158 |
|
159 |
-
|
|
|
160 |
}
|
161 |
}
|
162 |
|
@@ -201,19 +204,21 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
|
201 |
|
202 |
if ( array_key_exists( 'custom_dropdown_options_source', $args ) ) {
|
203 |
if ( function_exists( wp_unslash( $args['custom_dropdown_options_source'] ) ) ) {
|
204 |
-
$
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
|
|
213 |
|
214 |
-
|
215 |
|
216 |
-
|
|
|
217 |
}
|
218 |
}
|
219 |
|
@@ -1291,6 +1296,18 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
|
1291 |
return '';
|
1292 |
}
|
1293 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1294 |
|
1295 |
/**
|
1296 |
* Gets selected option value from a callback function
|
@@ -1305,6 +1322,10 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
|
1305 |
|
1306 |
if ( in_array( $type, array( 'select', 'multiselect' ) ) && ! empty( $data['custom_dropdown_options_source'] ) ) {
|
1307 |
|
|
|
|
|
|
|
|
|
1308 |
$has_custom_source = apply_filters( "um_has_dropdown_options_source__{$data['metakey']}", false );
|
1309 |
|
1310 |
if ( $has_custom_source ) {
|
@@ -1372,6 +1393,10 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
|
1372 |
|
1373 |
if ( in_array( $type, array( 'select', 'multiselect' ) ) && ! empty( $data['custom_dropdown_options_source'] ) ) {
|
1374 |
|
|
|
|
|
|
|
|
|
1375 |
if ( function_exists( $data['custom_dropdown_options_source'] ) ) {
|
1376 |
if ( isset( $data['parent_dropdown_relationship'] ) ) {
|
1377 |
$arr_options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
@@ -3037,7 +3062,9 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
|
3037 |
if ( ! empty( $data['custom_dropdown_options_source'] ) && $has_parent_option && function_exists( $data['custom_dropdown_options_source'] ) &&
|
3038 |
um_user( $data['parent_dropdown_relationship'] )
|
3039 |
) {
|
3040 |
-
|
|
|
|
|
3041 |
|
3042 |
$disabled_by_parent_option = '';
|
3043 |
if ( um_user( $form_key ) ) {
|
@@ -3053,10 +3080,11 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
|
3053 |
|
3054 |
// Child dropdown
|
3055 |
if ( $has_parent_option ) {
|
3056 |
-
|
3057 |
if ( ! empty( $data['custom_dropdown_options_source'] ) && $has_parent_option &&
|
3058 |
function_exists( $data['custom_dropdown_options_source'] ) && isset( UM()->form()->post_form[ $form_key ] ) ) {
|
3059 |
-
|
|
|
|
|
3060 |
}
|
3061 |
}
|
3062 |
|
@@ -3576,7 +3604,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
|
3576 |
|
3577 |
$i++;
|
3578 |
if ($i % 2 == 0) {
|
3579 |
-
$col_class = 'right';
|
3580 |
} else {
|
3581 |
$col_class = '';
|
3582 |
}
|
@@ -3703,7 +3731,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
|
3703 |
|
3704 |
$i++;
|
3705 |
if ( $i % 2 == 0 ) {
|
3706 |
-
$col_class = 'right';
|
3707 |
} else {
|
3708 |
$col_class = '';
|
3709 |
}
|
86 |
}
|
87 |
|
88 |
foreach ( $social as $k => $arr ) {
|
89 |
+
if ( um_profile( $k ) ) {
|
90 |
+
$match = is_array( $arr['match'] ) ? $arr['match'][0] : $arr['match']; ?>
|
91 |
|
92 |
+
<a href="<?php echo esc_url( um_filtered_social_link( $k, $match ) ); ?>"
|
93 |
style="background: <?php echo esc_attr( $arr['color'] ); ?>;" target="_blank" class="um-tip-n"
|
94 |
title="<?php echo esc_attr( $arr['title'] ); ?>"><i class="<?php echo esc_attr( $arr['icon'] ); ?>"></i></a>
|
95 |
|
147 |
|
148 |
if ( array_key_exists( 'custom_dropdown_options_source', $args ) ) {
|
149 |
if ( function_exists( wp_unslash( $args['custom_dropdown_options_source'] ) ) ) {
|
150 |
+
if ( ! in_array( $args['custom_dropdown_options_source'], UM()->fields()->dropdown_options_source_blacklist(), true ) ) {
|
151 |
+
$allowed_callbacks = UM()->options()->get( 'allowed_choice_callbacks' );
|
152 |
+
if ( ! empty( $allowed_callbacks ) ) {
|
153 |
+
$allowed_callbacks = array_map( 'rtrim', explode( "\n", $allowed_callbacks ) );
|
154 |
+
$allowed_callbacks[] = $args['custom_dropdown_options_source'];
|
155 |
+
} else {
|
156 |
+
$allowed_callbacks = array( $args['custom_dropdown_options_source'] );
|
157 |
+
}
|
158 |
+
$allowed_callbacks = array_unique( $allowed_callbacks );
|
159 |
+
$allowed_callbacks = implode( "\r\n", $allowed_callbacks );
|
160 |
|
161 |
+
UM()->options()->update( 'allowed_choice_callbacks', $allowed_callbacks );
|
162 |
+
}
|
163 |
}
|
164 |
}
|
165 |
|
204 |
|
205 |
if ( array_key_exists( 'custom_dropdown_options_source', $args ) ) {
|
206 |
if ( function_exists( wp_unslash( $args['custom_dropdown_options_source'] ) ) ) {
|
207 |
+
if ( ! in_array( $args['custom_dropdown_options_source'], UM()->fields()->dropdown_options_source_blacklist(), true ) ) {
|
208 |
+
$allowed_callbacks = UM()->options()->get( 'allowed_choice_callbacks' );
|
209 |
+
if ( ! empty( $allowed_callbacks ) ) {
|
210 |
+
$allowed_callbacks = array_map( 'rtrim', explode( "\n", $allowed_callbacks ) );
|
211 |
+
$allowed_callbacks[] = $args['custom_dropdown_options_source'];
|
212 |
+
} else {
|
213 |
+
$allowed_callbacks = array( $args['custom_dropdown_options_source'] );
|
214 |
+
}
|
215 |
+
$allowed_callbacks = array_unique( $allowed_callbacks );
|
216 |
+
$allowed_callbacks = implode( "\r\n", $allowed_callbacks );
|
217 |
|
218 |
+
UM()->options()->update( 'allowed_choice_callbacks', $allowed_callbacks );
|
219 |
|
220 |
+
$args['custom_dropdown_options_source'] = wp_unslash( $args['custom_dropdown_options_source'] );
|
221 |
+
}
|
222 |
}
|
223 |
}
|
224 |
|
1296 |
return '';
|
1297 |
}
|
1298 |
|
1299 |
+
/**
|
1300 |
+
* Getting the blacklist of the functions that cannot be used as callback.
|
1301 |
+
* All internal PHP functions are insecure for using inside callback functions.
|
1302 |
+
*
|
1303 |
+
* @return array
|
1304 |
+
*/
|
1305 |
+
public function dropdown_options_source_blacklist() {
|
1306 |
+
$list = get_defined_functions();
|
1307 |
+
$blacklist = ! empty( $list['internal'] ) ? $list['internal'] : array();
|
1308 |
+
$blacklist = apply_filters( 'um_dropdown_options_source_blacklist', $blacklist );
|
1309 |
+
return $blacklist;
|
1310 |
+
}
|
1311 |
|
1312 |
/**
|
1313 |
* Gets selected option value from a callback function
|
1322 |
|
1323 |
if ( in_array( $type, array( 'select', 'multiselect' ) ) && ! empty( $data['custom_dropdown_options_source'] ) ) {
|
1324 |
|
1325 |
+
if ( in_array( $data['custom_dropdown_options_source'], $this->dropdown_options_source_blacklist(), true ) ) {
|
1326 |
+
return $value;
|
1327 |
+
}
|
1328 |
+
|
1329 |
$has_custom_source = apply_filters( "um_has_dropdown_options_source__{$data['metakey']}", false );
|
1330 |
|
1331 |
if ( $has_custom_source ) {
|
1393 |
|
1394 |
if ( in_array( $type, array( 'select', 'multiselect' ) ) && ! empty( $data['custom_dropdown_options_source'] ) ) {
|
1395 |
|
1396 |
+
if ( in_array( $data['custom_dropdown_options_source'], $this->dropdown_options_source_blacklist(), true ) ) {
|
1397 |
+
return $arr_options;
|
1398 |
+
}
|
1399 |
+
|
1400 |
if ( function_exists( $data['custom_dropdown_options_source'] ) ) {
|
1401 |
if ( isset( $data['parent_dropdown_relationship'] ) ) {
|
1402 |
$arr_options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
3062 |
if ( ! empty( $data['custom_dropdown_options_source'] ) && $has_parent_option && function_exists( $data['custom_dropdown_options_source'] ) &&
|
3063 |
um_user( $data['parent_dropdown_relationship'] )
|
3064 |
) {
|
3065 |
+
if ( ! in_array( $data['custom_dropdown_options_source'], $this->dropdown_options_source_blacklist(), true ) ) {
|
3066 |
+
$options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
3067 |
+
}
|
3068 |
|
3069 |
$disabled_by_parent_option = '';
|
3070 |
if ( um_user( $form_key ) ) {
|
3080 |
|
3081 |
// Child dropdown
|
3082 |
if ( $has_parent_option ) {
|
|
|
3083 |
if ( ! empty( $data['custom_dropdown_options_source'] ) && $has_parent_option &&
|
3084 |
function_exists( $data['custom_dropdown_options_source'] ) && isset( UM()->form()->post_form[ $form_key ] ) ) {
|
3085 |
+
if ( ! in_array( $data['custom_dropdown_options_source'], $this->dropdown_options_source_blacklist(), true ) ) {
|
3086 |
+
$options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
3087 |
+
}
|
3088 |
}
|
3089 |
}
|
3090 |
|
3604 |
|
3605 |
$i++;
|
3606 |
if ($i % 2 == 0) {
|
3607 |
+
$col_class = ' right ';
|
3608 |
} else {
|
3609 |
$col_class = '';
|
3610 |
}
|
3731 |
|
3732 |
$i++;
|
3733 |
if ( $i % 2 == 0 ) {
|
3734 |
+
$col_class = ' right ';
|
3735 |
} else {
|
3736 |
$col_class = '';
|
3737 |
}
|
includes/core/class-form.php
CHANGED
@@ -1,837 +1,872 @@
|
|
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 (
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
if ( isset( $
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
*
|
197 |
-
*
|
198 |
-
* @
|
199 |
-
*
|
200 |
-
* @
|
201 |
-
*
|
202 |
-
*
|
203 |
-
*
|
204 |
-
*
|
205 |
-
*
|
206 |
-
*
|
207 |
-
*
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
if (
|
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 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
*
|
269 |
-
*
|
270 |
-
*
|
271 |
-
* @
|
272 |
-
*
|
273 |
-
* @
|
274 |
-
*
|
275 |
-
*
|
276 |
-
*
|
277 |
-
*
|
278 |
-
*
|
279 |
-
*
|
280 |
-
*
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
*
|
302 |
-
*
|
303 |
-
*
|
304 |
-
* @
|
305 |
-
*
|
306 |
-
* @
|
307 |
-
*
|
308 |
-
*
|
309 |
-
*
|
310 |
-
*
|
311 |
-
*
|
312 |
-
*
|
313 |
-
*
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
$
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
*
|
409 |
-
*
|
410 |
-
*
|
411 |
-
*
|
412 |
-
*
|
413 |
-
*
|
414 |
-
*
|
415 |
-
*
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
*
|
422 |
-
*
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
*
|
429 |
-
*
|
430 |
-
* @
|
431 |
-
*
|
432 |
-
* @
|
433 |
-
*
|
434 |
-
*
|
435 |
-
*
|
436 |
-
*
|
437 |
-
*
|
438 |
-
*
|
439 |
-
*
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
$this->post_form
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
$
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
*
|
526 |
-
*
|
527 |
-
*
|
528 |
-
* @
|
529 |
-
*
|
530 |
-
* @
|
531 |
-
*
|
532 |
-
*
|
533 |
-
*
|
534 |
-
*
|
535 |
-
*
|
536 |
-
*
|
537 |
-
*
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
*
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
*
|
552 |
-
*
|
553 |
-
* @
|
554 |
-
* @
|
555 |
-
*
|
556 |
-
*
|
557 |
-
*
|
558 |
-
*
|
559 |
-
*
|
560 |
-
*
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
*
|
565 |
-
*
|
566 |
-
*
|
567 |
-
*
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
*
|
572 |
-
*
|
573 |
-
* @
|
574 |
-
* @
|
575 |
-
*
|
576 |
-
*
|
577 |
-
*
|
578 |
-
*
|
579 |
-
*
|
580 |
-
*
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
break;
|
646 |
-
case '
|
647 |
-
$
|
648 |
-
|
649 |
-
|
650 |
-
$
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
$
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
}
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 ( in_array( $ajax_source_func, UM()->fields()->dropdown_options_source_blacklist(), true ) ) {
|
152 |
+
$arr_options['status'] = 'error';
|
153 |
+
$arr_options['message'] = __( 'This is not possible for security reasons.', 'ultimate-member' );
|
154 |
+
|
155 |
+
wp_send_json( $arr_options );
|
156 |
+
}
|
157 |
+
|
158 |
+
if ( isset( $_POST['form_id'] ) ) {
|
159 |
+
UM()->fields()->set_id = absint( $_POST['form_id'] );
|
160 |
+
}
|
161 |
+
UM()->fields()->set_mode = 'profile';
|
162 |
+
$form_fields = UM()->fields()->get_fields();
|
163 |
+
$arr_options['fields'] = $form_fields;
|
164 |
+
|
165 |
+
if ( isset( $arr_options['post']['members_directory'] ) && 'yes' === $arr_options['post']['members_directory'] ) {
|
166 |
+
global $wpdb;
|
167 |
+
|
168 |
+
$values_array = $wpdb->get_col(
|
169 |
+
$wpdb->prepare(
|
170 |
+
"SELECT DISTINCT meta_value
|
171 |
+
FROM $wpdb->usermeta
|
172 |
+
WHERE meta_key = %s AND
|
173 |
+
meta_value != ''",
|
174 |
+
$arr_options['post']['child_name']
|
175 |
+
)
|
176 |
+
);
|
177 |
+
|
178 |
+
if ( ! empty( $values_array ) ) {
|
179 |
+
$parent_dropdown = isset( $arr_options['field']['parent_dropdown_relationship'] ) ? $arr_options['field']['parent_dropdown_relationship'] : '';
|
180 |
+
$arr_options['items'] = call_user_func( $ajax_source_func, $parent_dropdown );
|
181 |
+
|
182 |
+
if ( array_keys( $arr_options['items'] ) !== range( 0, count( $arr_options['items'] ) - 1 ) ) {
|
183 |
+
// array with dropdown items is associative
|
184 |
+
$arr_options['items'] = array_intersect_key( array_map( 'trim', $arr_options['items'] ), array_flip( $values_array ) );
|
185 |
+
} else {
|
186 |
+
// array with dropdown items has sequential numeric keys, starting from 0 and there are intersected values with $values_array
|
187 |
+
$arr_options['items'] = array_intersect( $arr_options['items'], $values_array );
|
188 |
+
}
|
189 |
+
} else {
|
190 |
+
$arr_options['items'] = array();
|
191 |
+
}
|
192 |
+
|
193 |
+
wp_send_json( $arr_options );
|
194 |
+
} else {
|
195 |
+
/**
|
196 |
+
* UM hook
|
197 |
+
*
|
198 |
+
* @type filter
|
199 |
+
* @title um_ajax_select_options__debug_mode
|
200 |
+
* @description Activate debug mode for AJAX select options
|
201 |
+
* @input_vars
|
202 |
+
* [{"var":"$debug_mode","type":"bool","desc":"Enable Debug mode"}]
|
203 |
+
* @change_log
|
204 |
+
* ["Since: 2.0"]
|
205 |
+
* @usage
|
206 |
+
* <?php add_filter( 'um_ajax_select_options__debug_mode', 'function_name', 10, 1 ); ?>
|
207 |
+
* @example
|
208 |
+
* <?php
|
209 |
+
* add_filter( 'um_ajax_select_options__debug_mode', 'my_ajax_select_options__debug_mode', 10, 1 );
|
210 |
+
* function my_ajax_select_options__debug_mode( $debug_mode ) {
|
211 |
+
* // your code here
|
212 |
+
* return $debug_mode;
|
213 |
+
* }
|
214 |
+
* ?>
|
215 |
+
*/
|
216 |
+
$debug = apply_filters( 'um_ajax_select_options__debug_mode', false );
|
217 |
+
if ( $debug ) {
|
218 |
+
$arr_options['debug'] = array(
|
219 |
+
$_POST,
|
220 |
+
$form_fields,
|
221 |
+
);
|
222 |
+
}
|
223 |
+
|
224 |
+
if ( ! empty( $_POST['child_callback'] ) && isset( $form_fields[ $_POST['child_name'] ] ) ) {
|
225 |
+
// If the requested callback function is added in the form or added in the field option, execute it with call_user_func.
|
226 |
+
if ( isset( $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] ) &&
|
227 |
+
! empty( $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] ) &&
|
228 |
+
$form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] === $ajax_source_func ) {
|
229 |
+
|
230 |
+
$arr_options['field'] = $form_fields[ $_POST['child_name'] ];
|
231 |
+
|
232 |
+
$arr_options['items'] = call_user_func( $ajax_source_func, $arr_options['field']['parent_dropdown_relationship'] );
|
233 |
+
} else {
|
234 |
+
$arr_options['status'] = 'error';
|
235 |
+
$arr_options['message'] = __( 'This is not possible for security reasons.', 'ultimate-member' );
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
wp_send_json( $arr_options );
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
|
244 |
+
/**
|
245 |
+
* Count the form errors.
|
246 |
+
* @return integer
|
247 |
+
*/
|
248 |
+
public function count_errors() {
|
249 |
+
$errors = $this->errors;
|
250 |
+
|
251 |
+
if ( $errors && is_array( $errors ) ) {
|
252 |
+
return count( $errors );
|
253 |
+
}
|
254 |
+
|
255 |
+
return 0;
|
256 |
+
}
|
257 |
+
|
258 |
+
|
259 |
+
/**
|
260 |
+
* Appends field errors
|
261 |
+
*
|
262 |
+
* @param string $key
|
263 |
+
* @param string $error
|
264 |
+
*/
|
265 |
+
public function add_error( $key, $error ) {
|
266 |
+
if ( ! isset( $this->errors[ $key ] ) ) {
|
267 |
+
/**
|
268 |
+
* UM hook
|
269 |
+
*
|
270 |
+
* @type filter
|
271 |
+
* @title um_submit_form_error
|
272 |
+
* @description Change error text on submit form
|
273 |
+
* @input_vars
|
274 |
+
* [{"var":"$error","type":"string","desc":"Error String"},
|
275 |
+
* {"var":"$key","type":"string","desc":"Error Key"}]
|
276 |
+
* @change_log
|
277 |
+
* ["Since: 2.0"]
|
278 |
+
* @usage
|
279 |
+
* <?php add_filter( 'um_submit_form_error', 'function_name', 10, 2 ); ?>
|
280 |
+
* @example
|
281 |
+
* <?php
|
282 |
+
* add_filter( 'um_submit_form_error', 'my_submit_form_error', 10, 2 );
|
283 |
+
* function my_submit_form_error( $error, $key ) {
|
284 |
+
* // your code here
|
285 |
+
* return $error;
|
286 |
+
* }
|
287 |
+
* ?>
|
288 |
+
*/
|
289 |
+
$this->errors[ $key ] = apply_filters( 'um_submit_form_error', $error, $key );
|
290 |
+
}
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* Appends field notices
|
295 |
+
* @param string $key
|
296 |
+
* @param string $notice
|
297 |
+
*/
|
298 |
+
public function add_notice( $key, $notice ) {
|
299 |
+
if ( ! isset( $this->notices[ $key ] ) ) {
|
300 |
+
/**
|
301 |
+
* UM hook
|
302 |
+
*
|
303 |
+
* @type filter
|
304 |
+
* @title um_submit_form_notice
|
305 |
+
* @description Change notice text on submit form
|
306 |
+
* @input_vars
|
307 |
+
* [{"var":"$notice","type":"string","desc":"notice String"},
|
308 |
+
* {"var":"$key","type":"string","desc":"notice Key"}]
|
309 |
+
* @change_log
|
310 |
+
* ["Since: 2.0"]
|
311 |
+
* @usage
|
312 |
+
* <?php add_filter( 'um_submit_form_notice', 'function_name', 10, 2 ); ?>
|
313 |
+
* @example
|
314 |
+
* <?php
|
315 |
+
* add_filter( 'um_submit_form_notice', 'my_submit_form_notice', 10, 2 );
|
316 |
+
* function my_submit_form_notice( $notice, $key ) {
|
317 |
+
* // your code here
|
318 |
+
* return $notice;
|
319 |
+
* }
|
320 |
+
* ?>
|
321 |
+
*/
|
322 |
+
$this->notices[ $key ] = apply_filters( 'um_submit_form_notice', $notice, $key );
|
323 |
+
}
|
324 |
+
}
|
325 |
+
|
326 |
+
|
327 |
+
/**
|
328 |
+
* If a form has errors
|
329 |
+
*
|
330 |
+
* @param string $key
|
331 |
+
* @return boolean
|
332 |
+
*/
|
333 |
+
public function has_error( $key ) {
|
334 |
+
if ( isset( $this->errors[ $key ] ) ) {
|
335 |
+
return true;
|
336 |
+
}
|
337 |
+
return false;
|
338 |
+
}
|
339 |
+
|
340 |
+
|
341 |
+
/**
|
342 |
+
* If a form has notices/info
|
343 |
+
*
|
344 |
+
* @param string $key
|
345 |
+
* @return boolean
|
346 |
+
*/
|
347 |
+
public function has_notice( $key ) {
|
348 |
+
if ( isset( $this->notices[ $key ] ) ) {
|
349 |
+
return true;
|
350 |
+
}
|
351 |
+
return false;
|
352 |
+
}
|
353 |
+
|
354 |
+
|
355 |
+
/**
|
356 |
+
* Return the errors as a WordPress Error object
|
357 |
+
*
|
358 |
+
* @return \WP_Error
|
359 |
+
*/
|
360 |
+
function get_wp_error() {
|
361 |
+
$wp_error = new \WP_Error();
|
362 |
+
if ( $this->count_errors() > 0 ) {
|
363 |
+
foreach ( $this->errors as $key => $value ) {
|
364 |
+
$wp_error->add( $key, $value );
|
365 |
+
}
|
366 |
+
}
|
367 |
+
return $wp_error;
|
368 |
+
}
|
369 |
+
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Declare all fields
|
373 |
+
*/
|
374 |
+
public function field_declare() {
|
375 |
+
if ( isset( UM()->builtin()->custom_fields ) ) {
|
376 |
+
$this->all_fields = UM()->builtin()->custom_fields;
|
377 |
+
} else {
|
378 |
+
$this->all_fields = null;
|
379 |
+
}
|
380 |
+
}
|
381 |
+
|
382 |
+
|
383 |
+
/**
|
384 |
+
* Validate form on submit
|
385 |
+
*/
|
386 |
+
public function form_init() {
|
387 |
+
if ( isset( $_SERVER['REQUEST_METHOD'] ) ) {
|
388 |
+
$http_post = ( 'POST' === $_SERVER['REQUEST_METHOD'] );
|
389 |
+
} else {
|
390 |
+
$http_post = 'POST';
|
391 |
+
}
|
392 |
+
|
393 |
+
if ( $http_post && ! is_admin() && isset( $_POST['form_id'] ) && is_numeric( $_POST['form_id'] ) ) {
|
394 |
+
|
395 |
+
$this->form_id = absint( $_POST['form_id'] );
|
396 |
+
if ( 'um_form' !== get_post_type( $this->form_id ) ) {
|
397 |
+
return;
|
398 |
+
}
|
399 |
+
|
400 |
+
$this->form_status = get_post_status( $this->form_id );
|
401 |
+
if ( 'publish' !== $this->form_status ) {
|
402 |
+
return;
|
403 |
+
}
|
404 |
+
|
405 |
+
$this->form_data = UM()->query()->post_data( $this->form_id );
|
406 |
+
|
407 |
+
/**
|
408 |
+
* UM hook
|
409 |
+
*
|
410 |
+
* @type action
|
411 |
+
* @title um_before_submit_form_post
|
412 |
+
* @description Before submit form
|
413 |
+
* @change_log
|
414 |
+
* ["Since: 2.0"]
|
415 |
+
* @usage add_action( 'um_before_submit_form_post', 'function_name', 10, 1 );
|
416 |
+
* @example
|
417 |
+
* <?php
|
418 |
+
* add_action( 'um_before_submit_form_post', 'my_before_submit_form_post', 10, 1 );
|
419 |
+
* function my_run_ajax_function( $post ) {
|
420 |
+
* // your code here
|
421 |
+
* }
|
422 |
+
* ?>
|
423 |
+
*/
|
424 |
+
do_action( 'um_before_submit_form_post' );
|
425 |
+
|
426 |
+
/* save entire form as global */
|
427 |
+
/**
|
428 |
+
* UM hook
|
429 |
+
*
|
430 |
+
* @type filter
|
431 |
+
* @title um_submit_post_form
|
432 |
+
* @description Change submitted data on form submit
|
433 |
+
* @input_vars
|
434 |
+
* [{"var":"$data","type":"array","desc":"Submitted data"}]
|
435 |
+
* @change_log
|
436 |
+
* ["Since: 2.0"]
|
437 |
+
* @usage
|
438 |
+
* <?php add_filter( 'um_submit_post_form', 'function_name', 10, 1 ); ?>
|
439 |
+
* @example
|
440 |
+
* <?php
|
441 |
+
* add_filter( 'um_submit_post_form', 'my_submit_post_form', 10, 1 );
|
442 |
+
* function my_submit_post_form( $data ) {
|
443 |
+
* // your code here
|
444 |
+
* return $data;
|
445 |
+
* }
|
446 |
+
* ?>
|
447 |
+
*/
|
448 |
+
$this->post_form = apply_filters( 'um_submit_post_form', wp_unslash( $_POST ) );
|
449 |
+
|
450 |
+
if ( isset( $this->post_form[ UM()->honeypot ] ) && '' !== $this->post_form[ UM()->honeypot ] ) {
|
451 |
+
wp_die( esc_html__( 'Hello, spam bot!', 'ultimate-member' ) );
|
452 |
+
}
|
453 |
+
|
454 |
+
$this->post_form = $this->beautify( $this->post_form );
|
455 |
+
$this->post_form = $this->sanitize( $this->post_form );
|
456 |
+
$this->post_form['submitted'] = $this->post_form;
|
457 |
+
|
458 |
+
$this->post_form = array_merge( $this->form_data, $this->post_form );
|
459 |
+
|
460 |
+
// Remove role from post_form at first if role ! empty and there aren't custom fields with role name
|
461 |
+
if ( ! empty( $_POST['role'] ) ) {
|
462 |
+
if ( ! isset( $this->form_data['custom_fields'] ) || ! strstr( $this->form_data['custom_fields'], 'role_' ) ) {
|
463 |
+
unset( $this->post_form['role'] );
|
464 |
+
unset( $this->post_form['submitted']['role'] );
|
465 |
+
}
|
466 |
+
}
|
467 |
+
|
468 |
+
// Secure sanitize of the submitted data
|
469 |
+
if ( ! empty( $this->post_form ) ) {
|
470 |
+
$this->post_form = array_diff_key( $this->post_form, array_flip( UM()->user()->banned_keys ) );
|
471 |
+
}
|
472 |
+
if ( ! empty( $this->post_form['submitted'] ) ) {
|
473 |
+
$this->post_form['submitted'] = array_diff_key( $this->post_form['submitted'], array_flip( UM()->user()->banned_keys ) );
|
474 |
+
}
|
475 |
+
|
476 |
+
// set default role from settings on registration form
|
477 |
+
if ( isset( $this->post_form['mode'] ) && 'register' === $this->post_form['mode'] ) {
|
478 |
+
$role = $this->assigned_role( $this->form_id );
|
479 |
+
$this->post_form['role'] = $role;
|
480 |
+
}
|
481 |
+
|
482 |
+
if ( isset( $this->form_data['custom_fields'] ) && strstr( $this->form_data['custom_fields'], 'role_' ) ) { // Secure selected role
|
483 |
+
|
484 |
+
if ( ! empty( $_POST['role'] ) ) {
|
485 |
+
$custom_field_roles = $this->custom_field_roles( $this->form_data['custom_fields'] );
|
486 |
+
|
487 |
+
if ( ! empty( $custom_field_roles ) ) {
|
488 |
+
if ( is_array( $_POST['role'] ) ) {
|
489 |
+
$role = current( $_POST['role'] );
|
490 |
+
$role = sanitize_key( $role );
|
491 |
+
} else {
|
492 |
+
$role = sanitize_key( $_POST['role'] );
|
493 |
+
}
|
494 |
+
|
495 |
+
global $wp_roles;
|
496 |
+
$role_keys = array_map(
|
497 |
+
function( $item ) {
|
498 |
+
return 'um_' . $item;
|
499 |
+
},
|
500 |
+
get_option( 'um_roles', array() )
|
501 |
+
);
|
502 |
+
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
503 |
+
|
504 |
+
if ( ! empty( $role ) &&
|
505 |
+
( ! in_array( $role, $custom_field_roles, true ) || in_array( $role, $exclude_roles, true ) ) ) {
|
506 |
+
wp_die( esc_html__( 'This is not possible for security reasons.', 'ultimate-member' ) );
|
507 |
+
}
|
508 |
+
|
509 |
+
$this->post_form['role'] = $role;
|
510 |
+
$this->post_form['submitted']['role'] = $role;
|
511 |
+
} else {
|
512 |
+
unset( $this->post_form['role'] );
|
513 |
+
unset( $this->post_form['submitted']['role'] );
|
514 |
+
|
515 |
+
// set default role for registration form if custom field hasn't proper value
|
516 |
+
if ( isset( $this->post_form['mode'] ) && 'register' === $this->post_form['mode'] ) {
|
517 |
+
$role = $this->assigned_role( $this->form_id );
|
518 |
+
$this->post_form['role'] = $role;
|
519 |
+
}
|
520 |
+
}
|
521 |
+
}
|
522 |
+
}
|
523 |
+
|
524 |
+
/**
|
525 |
+
* UM hook
|
526 |
+
*
|
527 |
+
* @type filter
|
528 |
+
* @title um_submit_form_data
|
529 |
+
* @description Change submitted data on form submit
|
530 |
+
* @input_vars
|
531 |
+
* [{"var":"$data","type":"array","desc":"Submitted data"},
|
532 |
+
* {"var":"$mode","type":"string","desc":"Form mode"}]
|
533 |
+
* @change_log
|
534 |
+
* ["Since: 2.0"]
|
535 |
+
* @usage
|
536 |
+
* <?php add_filter( 'um_submit_form_data', 'function_name', 10, 2 ); ?>
|
537 |
+
* @example
|
538 |
+
* <?php
|
539 |
+
* add_filter( 'um_submit_form_data', 'my_submit_form_data', 10, 2 );
|
540 |
+
* function my_submit_form_data( $data ) {
|
541 |
+
* // your code here
|
542 |
+
* return $data;
|
543 |
+
* }
|
544 |
+
* ?>
|
545 |
+
*/
|
546 |
+
$this->post_form = apply_filters( 'um_submit_form_data', $this->post_form, $this->post_form['mode'] );
|
547 |
+
|
548 |
+
/* Continue based on form mode - pre-validation */
|
549 |
+
|
550 |
+
/**
|
551 |
+
* UM hook
|
552 |
+
*
|
553 |
+
* @type action
|
554 |
+
* @title um_submit_form_errors_hook
|
555 |
+
* @description Action on submit form
|
556 |
+
* @input_vars
|
557 |
+
* [{"var":"$post","type":"int","desc":"Post data"}]
|
558 |
+
* @change_log
|
559 |
+
* ["Since: 2.0"]
|
560 |
+
* @usage add_action( 'um_submit_form_errors_hook', 'function_name', 10, 1 );
|
561 |
+
* @example
|
562 |
+
* <?php
|
563 |
+
* add_action( 'um_submit_form_errors_hook', 'my_submit_form_errors', 10, 1 );
|
564 |
+
* function my_submit_form_errors( $post ) {
|
565 |
+
* // your code here
|
566 |
+
* }
|
567 |
+
* ?>
|
568 |
+
*/
|
569 |
+
do_action( 'um_submit_form_errors_hook', $this->post_form );
|
570 |
+
/**
|
571 |
+
* UM hook
|
572 |
+
*
|
573 |
+
* @type action
|
574 |
+
* @title um_submit_form_{$mode}
|
575 |
+
* @description Action on submit form
|
576 |
+
* @input_vars
|
577 |
+
* [{"var":"$post","type":"int","desc":"Post data"}]
|
578 |
+
* @change_log
|
579 |
+
* ["Since: 2.0"]
|
580 |
+
* @usage add_action( 'um_submit_form_{$mode}', 'function_name', 10, 1 );
|
581 |
+
* @example
|
582 |
+
* <?php
|
583 |
+
* add_action( 'um_submit_form_{$mode}', 'my_submit_form', 10, 1 );
|
584 |
+
* function my_submit_form( $post ) {
|
585 |
+
* // your code here
|
586 |
+
* }
|
587 |
+
* ?>
|
588 |
+
*/
|
589 |
+
do_action( "um_submit_form_{$this->post_form['mode']}", $this->post_form );
|
590 |
+
|
591 |
+
}
|
592 |
+
}
|
593 |
+
|
594 |
+
|
595 |
+
/**
|
596 |
+
* Beautify form data
|
597 |
+
*
|
598 |
+
* @param array $form
|
599 |
+
*
|
600 |
+
* @return array $form
|
601 |
+
*/
|
602 |
+
public function beautify( $form ) {
|
603 |
+
if ( isset( $form['form_id'] ) ) {
|
604 |
+
$this->form_suffix = '-' . $form['form_id'];
|
605 |
+
$this->processing = $form['form_id'];
|
606 |
+
|
607 |
+
foreach ( $form as $key => $value ) {
|
608 |
+
if ( strstr( $key, $this->form_suffix ) ) {
|
609 |
+
$a_key = str_replace( $this->form_suffix, '', $key );
|
610 |
+
$form[ $a_key ] = $value;
|
611 |
+
unset( $form[ $key ] );
|
612 |
+
}
|
613 |
+
}
|
614 |
+
}
|
615 |
+
|
616 |
+
return $form;
|
617 |
+
}
|
618 |
+
|
619 |
+
|
620 |
+
/**
|
621 |
+
* Beautify form data
|
622 |
+
*
|
623 |
+
* @param array $form
|
624 |
+
*
|
625 |
+
* @return array $form
|
626 |
+
*/
|
627 |
+
public function sanitize( $form ) {
|
628 |
+
|
629 |
+
if ( isset( $form['form_id'] ) ) {
|
630 |
+
if ( isset( $this->form_data['custom_fields'] ) ) {
|
631 |
+
$custom_fields = maybe_unserialize( $this->form_data['custom_fields'] );
|
632 |
+
|
633 |
+
if ( is_array( $custom_fields ) ) {
|
634 |
+
foreach ( $custom_fields as $k => $field ) {
|
635 |
+
|
636 |
+
if ( isset( $field['type'] ) ) {
|
637 |
+
if ( isset( $form[ $k ] ) ) {
|
638 |
+
|
639 |
+
switch ( $field['type'] ) {
|
640 |
+
default:
|
641 |
+
$form[ $k ] = apply_filters( 'um_sanitize_form_field', $form[ $k ], $field );
|
642 |
+
break;
|
643 |
+
case 'number':
|
644 |
+
$form[ $k ] = (int) $form[ $k ];
|
645 |
+
break;
|
646 |
+
case 'textarea':
|
647 |
+
if ( ! empty( $field['html'] ) || ( UM()->profile()->get_show_bio_key( $form ) === $k && UM()->options()->get( 'profile_show_html_bio' ) ) ) {
|
648 |
+
$form[ $k ] = wp_kses_post( $form[ $k ] );
|
649 |
+
} else {
|
650 |
+
$form[ $k ] = sanitize_textarea_field( $form[ $k ] );
|
651 |
+
}
|
652 |
+
break;
|
653 |
+
case 'url':
|
654 |
+
$f = UM()->builtin()->get_a_field( $k );
|
655 |
+
|
656 |
+
if ( array_key_exists( 'match', $f ) && array_key_exists( 'advanced', $f ) && 'social' === $f['advanced'] ) {
|
657 |
+
$v = sanitize_text_field( $form[ $k ] );
|
658 |
+
|
659 |
+
// Make a proper social link
|
660 |
+
if ( ! empty( $v ) ) {
|
661 |
+
$replace_match = is_array( $f['match'] ) ? $f['match'][0] : $f['match'];
|
662 |
+
|
663 |
+
$need_replace = false;
|
664 |
+
if ( is_array( $f['match'] ) ) {
|
665 |
+
$need_replace = true;
|
666 |
+
foreach ( $f['match'] as $arr_match ) {
|
667 |
+
if ( strstr( $v, $arr_match ) ) {
|
668 |
+
$need_replace = false;
|
669 |
+
}
|
670 |
+
}
|
671 |
+
}
|
672 |
+
|
673 |
+
if ( ! is_array( $f['match'] ) || $need_replace ) {
|
674 |
+
if ( ! strstr( $v, $replace_match ) ) {
|
675 |
+
$domain = trim(
|
676 |
+
strtr(
|
677 |
+
$replace_match,
|
678 |
+
array(
|
679 |
+
'https://' => '',
|
680 |
+
'http://' => '',
|
681 |
+
)
|
682 |
+
),
|
683 |
+
' /'
|
684 |
+
);
|
685 |
+
|
686 |
+
if ( ! strstr( $v, $domain ) ) {
|
687 |
+
$v = $replace_match . $v;
|
688 |
+
} else {
|
689 |
+
$v = 'https://' . trim(
|
690 |
+
strtr(
|
691 |
+
$v,
|
692 |
+
array(
|
693 |
+
'https://' => '',
|
694 |
+
'http://' => '',
|
695 |
+
)
|
696 |
+
),
|
697 |
+
' /'
|
698 |
+
);
|
699 |
+
}
|
700 |
+
}
|
701 |
+
}
|
702 |
+
}
|
703 |
+
|
704 |
+
$form[ $k ] = $v;
|
705 |
+
} else {
|
706 |
+
$form[ $k ] = esc_url_raw( $form[ $k ] );
|
707 |
+
}
|
708 |
+
break;
|
709 |
+
case 'password':
|
710 |
+
$form[ $k ] = trim( $form[ $k ] );
|
711 |
+
if ( array_key_exists( 'confirm_' . $k, $form ) ) {
|
712 |
+
$form[ 'confirm_' . $k ] = trim( $form[ 'confirm_' . $k ] );
|
713 |
+
}
|
714 |
+
break;
|
715 |
+
case 'text':
|
716 |
+
case 'select':
|
717 |
+
case 'image':
|
718 |
+
case 'file':
|
719 |
+
case 'date':
|
720 |
+
case 'time':
|
721 |
+
case 'rating':
|
722 |
+
case 'googlemap':
|
723 |
+
case 'youtube_video':
|
724 |
+
case 'vimeo_video':
|
725 |
+
case 'soundcloud_track':
|
726 |
+
$form[ $k ] = sanitize_text_field( $form[ $k ] );
|
727 |
+
break;
|
728 |
+
case 'multiselect':
|
729 |
+
case 'radio':
|
730 |
+
case 'checkbox':
|
731 |
+
$form[ $k ] = is_array( $form[ $k ] ) ? array_map( 'sanitize_text_field', $form[ $k ] ) : sanitize_text_field( $form[ $k ] );
|
732 |
+
break;
|
733 |
+
}
|
734 |
+
}
|
735 |
+
}
|
736 |
+
}
|
737 |
+
}
|
738 |
+
}
|
739 |
+
}
|
740 |
+
|
741 |
+
return $form;
|
742 |
+
}
|
743 |
+
|
744 |
+
|
745 |
+
/**
|
746 |
+
* Display form type as Title
|
747 |
+
* @param string $mode
|
748 |
+
* @param integer $post_id
|
749 |
+
* @return string $output
|
750 |
+
*/
|
751 |
+
public function display_form_type( $mode, $post_id ) {
|
752 |
+
$output = null;
|
753 |
+
switch ( $mode ) {
|
754 |
+
case 'login':
|
755 |
+
$output = __( 'Login', 'ultimate-member' );
|
756 |
+
break;
|
757 |
+
case 'profile':
|
758 |
+
$output = __( 'Profile', 'ultimate-member' );
|
759 |
+
break;
|
760 |
+
case 'register':
|
761 |
+
$output = __( 'Register', 'ultimate-member' );
|
762 |
+
break;
|
763 |
+
}
|
764 |
+
return $output;
|
765 |
+
}
|
766 |
+
|
767 |
+
|
768 |
+
/**
|
769 |
+
* Assigned roles to a form
|
770 |
+
* @param integer $post_id
|
771 |
+
* @return string $role
|
772 |
+
*/
|
773 |
+
public function assigned_role( $post_id ) {
|
774 |
+
|
775 |
+
$global_role = get_option( 'default_role' ); // WP Global settings
|
776 |
+
|
777 |
+
$um_global_role = UM()->options()->get( 'register_role' ); // UM Settings Global settings
|
778 |
+
if ( ! empty( $um_global_role ) ) {
|
779 |
+
$global_role = $um_global_role; // Form Global settings
|
780 |
+
}
|
781 |
+
|
782 |
+
$mode = $this->form_type( $post_id );
|
783 |
+
|
784 |
+
/**
|
785 |
+
* @todo WPML integration to get role from original if it's empty
|
786 |
+
*/
|
787 |
+
$use_custom = get_post_meta( $post_id, "_um_{$mode}_use_custom_settings", true );
|
788 |
+
if ( $use_custom ) { // Custom Form settings
|
789 |
+
$role = get_post_meta( $post_id, "_um_{$mode}_role", true );
|
790 |
+
}
|
791 |
+
|
792 |
+
if ( empty( $role ) ) { // custom role is default, return default role's slug
|
793 |
+
$role = $global_role;
|
794 |
+
}
|
795 |
+
|
796 |
+
return $role;
|
797 |
+
}
|
798 |
+
|
799 |
+
|
800 |
+
/**
|
801 |
+
* Get form type
|
802 |
+
* @param integer $post_id
|
803 |
+
* @return string
|
804 |
+
*/
|
805 |
+
public function form_type( $post_id ) {
|
806 |
+
$mode = get_post_meta( $post_id, '_um_mode', true );
|
807 |
+
return $mode;
|
808 |
+
}
|
809 |
+
|
810 |
+
|
811 |
+
/**
|
812 |
+
* Get custom field roles
|
813 |
+
*
|
814 |
+
* @param string $custom_fields serialized
|
815 |
+
* @return bool|array roles
|
816 |
+
*/
|
817 |
+
public function custom_field_roles( $custom_fields ) {
|
818 |
+
|
819 |
+
$fields = maybe_unserialize( $custom_fields );
|
820 |
+
if ( ! is_array( $fields ) ) {
|
821 |
+
return false;
|
822 |
+
}
|
823 |
+
|
824 |
+
// role field
|
825 |
+
global $wp_roles;
|
826 |
+
$role_keys = array_map(
|
827 |
+
function( $item ) {
|
828 |
+
return 'um_' . $item;
|
829 |
+
},
|
830 |
+
get_option( 'um_roles', array() )
|
831 |
+
);
|
832 |
+
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
|
833 |
+
|
834 |
+
$roles = UM()->roles()->get_roles( false, $exclude_roles );
|
835 |
+
$roles = array_map(
|
836 |
+
function( $item ) {
|
837 |
+
return html_entity_decode( $item, ENT_QUOTES );
|
838 |
+
},
|
839 |
+
$roles
|
840 |
+
);
|
841 |
+
|
842 |
+
foreach ( $fields as $field_key => $field_settings ) {
|
843 |
+
|
844 |
+
if ( strstr( $field_key, 'role_' ) && is_array( $field_settings['options'] ) ) {
|
845 |
+
|
846 |
+
if ( isset( $this->post_form['mode'] ) && 'profile' === $this->post_form['mode'] &&
|
847 |
+
isset( $field_settings['editable'] ) && $field_settings['editable'] == 0 ) {
|
848 |
+
continue;
|
849 |
+
}
|
850 |
+
|
851 |
+
if ( ! um_can_view_field( $field_settings ) ) {
|
852 |
+
continue;
|
853 |
+
}
|
854 |
+
|
855 |
+
$intersected_options = array();
|
856 |
+
foreach ( $field_settings['options'] as $key => $title ) {
|
857 |
+
if ( false !== $search_key = array_search( $title, $roles ) ) {
|
858 |
+
$intersected_options[ $search_key ] = $title;
|
859 |
+
} elseif ( isset( $roles[ $key ] ) ) {
|
860 |
+
$intersected_options[ $key ] = $title;
|
861 |
+
}
|
862 |
+
}
|
863 |
+
|
864 |
+
// getting roles only from the first role fields
|
865 |
+
return array_keys( $intersected_options );
|
866 |
+
}
|
867 |
+
}
|
868 |
+
|
869 |
+
return false;
|
870 |
+
}
|
871 |
+
}
|
872 |
+
}
|
includes/core/class-shortcodes.php
CHANGED
@@ -283,7 +283,12 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
|
|
283 |
}
|
284 |
|
285 |
if ( file_exists( $file ) ) {
|
286 |
-
|
|
|
|
|
|
|
|
|
|
|
287 |
}
|
288 |
}
|
289 |
|
283 |
}
|
284 |
|
285 |
if ( file_exists( $file ) ) {
|
286 |
+
// Avoid Directory Traversal vulnerability by the checking the realpath.
|
287 |
+
// Templates can be situated only in the get_stylesheet_directory() or plugindir templates.
|
288 |
+
$real_file = wp_normalize_path( realpath( $file ) );
|
289 |
+
if ( 0 === strpos( $real_file, wp_normalize_path( um_path . "templates" . DIRECTORY_SEPARATOR ) ) || 0 === strpos( $real_file, wp_normalize_path( get_stylesheet_directory() . DIRECTORY_SEPARATOR . 'ultimate-member' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR ) ) ) {
|
290 |
+
include $file;
|
291 |
+
}
|
292 |
}
|
293 |
}
|
294 |
|
includes/core/class-uploader.php
CHANGED
@@ -786,14 +786,14 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
|
|
786 |
|
787 |
if ( isset( $image_info['invalid_image'] ) && $image_info['invalid_image'] == true ) {
|
788 |
$error = sprintf(__('Your image is invalid or too large!','ultimate-member') );
|
789 |
-
} elseif ( isset($data['min_size']) && ( $image_info['size'] < $data['min_size'] ) ) {
|
790 |
$error = $data['min_size_error'];
|
791 |
-
} elseif ( isset($data['max_file_size']) && ( $image_info['size'] > $data['max_file_size'] ) ) {
|
792 |
$error = $data['max_file_size_error'];
|
793 |
-
} elseif ( isset($data['min_width']) && ( $image_info['width'] < $data['min_width'] ) ) {
|
794 |
-
$error = sprintf(__('Your photo is too small. It must be at least %spx wide.','ultimate-member'), $data['min_width']);
|
795 |
-
} elseif ( isset($data['min_height']) && ( $image_info['height'] < $data['min_height'] ) ) {
|
796 |
-
$error = sprintf(__('Your photo is too small. It must be at least %spx
|
797 |
}
|
798 |
|
799 |
return $error;
|
786 |
|
787 |
if ( isset( $image_info['invalid_image'] ) && $image_info['invalid_image'] == true ) {
|
788 |
$error = sprintf(__('Your image is invalid or too large!','ultimate-member') );
|
789 |
+
} elseif ( isset( $data['min_size'] ) && ( $image_info['size'] < $data['min_size'] ) ) {
|
790 |
$error = $data['min_size_error'];
|
791 |
+
} elseif ( isset( $data['max_file_size'] ) && ( $image_info['size'] > $data['max_file_size'] ) ) {
|
792 |
$error = $data['max_file_size_error'];
|
793 |
+
} elseif ( isset( $data['min_width'] ) && ( $image_info['width'] < $data['min_width'] ) ) {
|
794 |
+
$error = sprintf( __( 'Your photo is too small. It must be at least %spx wide.', 'ultimate-member' ), $data['min_width'] );
|
795 |
+
} elseif ( isset( $data['min_height'] ) && ( $image_info['height'] < $data['min_height'] ) ) {
|
796 |
+
$error = sprintf( __( 'Your photo is too small. It must be at least %spx high.', 'ultimate-member' ), $data['min_height'] );
|
797 |
}
|
798 |
|
799 |
return $error;
|
includes/core/class-user.php
CHANGED
@@ -1641,6 +1641,11 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
|
1641 |
function email_pending() {
|
1642 |
$this->assign_secretkey();
|
1643 |
$this->set_status( 'awaiting_email_confirmation' );
|
|
|
|
|
|
|
|
|
|
|
1644 |
UM()->mail()->send( um_user( 'user_email' ), 'checkmail_email' );
|
1645 |
}
|
1646 |
|
@@ -1662,6 +1667,11 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
|
1662 |
*/
|
1663 |
function pending() {
|
1664 |
$this->set_status( 'awaiting_admin_review' );
|
|
|
|
|
|
|
|
|
|
|
1665 |
UM()->mail()->send( um_user( 'user_email' ), 'pending_email' );
|
1666 |
}
|
1667 |
|
@@ -1684,6 +1694,11 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
|
1684 |
*/
|
1685 |
function reject() {
|
1686 |
$this->set_status( 'rejected' );
|
|
|
|
|
|
|
|
|
|
|
1687 |
UM()->mail()->send( um_user( 'user_email' ), 'rejected_email' );
|
1688 |
}
|
1689 |
|
@@ -1705,6 +1720,11 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
|
1705 |
*/
|
1706 |
function deactivate() {
|
1707 |
$this->set_status( 'inactive' );
|
|
|
|
|
|
|
|
|
|
|
1708 |
/**
|
1709 |
* UM hook
|
1710 |
*
|
@@ -2087,7 +2107,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
|
2087 |
update_user_meta( $this->id, $key, $value );
|
2088 |
}
|
2089 |
} else {
|
2090 |
-
$args[ $key ] =
|
2091 |
}
|
2092 |
}
|
2093 |
|
1641 |
function email_pending() {
|
1642 |
$this->assign_secretkey();
|
1643 |
$this->set_status( 'awaiting_email_confirmation' );
|
1644 |
+
|
1645 |
+
//clear all sessions for email confirmation pending users
|
1646 |
+
$user = \WP_Session_Tokens::get_instance( um_user( 'ID' ) );
|
1647 |
+
$user->destroy_all();
|
1648 |
+
|
1649 |
UM()->mail()->send( um_user( 'user_email' ), 'checkmail_email' );
|
1650 |
}
|
1651 |
|
1667 |
*/
|
1668 |
function pending() {
|
1669 |
$this->set_status( 'awaiting_admin_review' );
|
1670 |
+
|
1671 |
+
//clear all sessions for awaiting admin confirmation users
|
1672 |
+
$user = \WP_Session_Tokens::get_instance( um_user( 'ID' ) );
|
1673 |
+
$user->destroy_all();
|
1674 |
+
|
1675 |
UM()->mail()->send( um_user( 'user_email' ), 'pending_email' );
|
1676 |
}
|
1677 |
|
1694 |
*/
|
1695 |
function reject() {
|
1696 |
$this->set_status( 'rejected' );
|
1697 |
+
|
1698 |
+
//clear all sessions for rejected users
|
1699 |
+
$user = \WP_Session_Tokens::get_instance( um_user( 'ID' ) );
|
1700 |
+
$user->destroy_all();
|
1701 |
+
|
1702 |
UM()->mail()->send( um_user( 'user_email' ), 'rejected_email' );
|
1703 |
}
|
1704 |
|
1720 |
*/
|
1721 |
function deactivate() {
|
1722 |
$this->set_status( 'inactive' );
|
1723 |
+
|
1724 |
+
//clear all sessions for inactive users
|
1725 |
+
$user = \WP_Session_Tokens::get_instance( um_user( 'ID' ) );
|
1726 |
+
$user->destroy_all();
|
1727 |
+
|
1728 |
/**
|
1729 |
* UM hook
|
1730 |
*
|
2107 |
update_user_meta( $this->id, $key, $value );
|
2108 |
}
|
2109 |
} else {
|
2110 |
+
$args[ $key ] = $changes[ $key ];
|
2111 |
}
|
2112 |
}
|
2113 |
|
includes/core/class-validation.php
CHANGED
@@ -1,420 +1,422 @@
|
|
1 |
-
<?php
|
2 |
-
namespace um\core;
|
3 |
-
|
4 |
-
// Exit if accessed directly
|
5 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
-
|
7 |
-
if ( ! class_exists( 'um\core\Validation' ) ) {
|
8 |
-
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class Validation
|
12 |
-
* @package um\core
|
13 |
-
*/
|
14 |
-
class Validation {
|
15 |
-
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Validation constructor.
|
19 |
-
*/
|
20 |
-
function __construct() {
|
21 |
-
$this->regex_safe = '/\A[\w\-\.]+\z/';
|
22 |
-
$this->regex_username_safe = '|[^a-z0-9 _.\-@]|i';
|
23 |
-
$this->regex_phone_number = '/\A[\d\-\.\+\(\)\ ]+\z/';
|
24 |
-
|
25 |
-
|
26 |
-
add_filter( 'um_user_pre_updating_files_array', array( $this, 'validate_files' ), 10, 1 );
|
27 |
-
add_filter( 'um_before_save_filter_submitted', array( $this, 'validate_fields_values' ), 10, 2 );
|
28 |
-
}
|
29 |
-
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Validate files before upload
|
33 |
-
*
|
34 |
-
* @param $files
|
35 |
-
*
|
36 |
-
* @return mixed
|
37 |
-
*/
|
38 |
-
function validate_files( $files ) {
|
39 |
-
if ( ! empty( $files ) ) {
|
40 |
-
foreach ( $files as $key => $filename ) {
|
41 |
-
if ( validate_file( $filename ) !== 0 ) {
|
42 |
-
unset( $files[ $key ] );
|
43 |
-
}
|
44 |
-
}
|
45 |
-
}
|
46 |
-
|
47 |
-
return $files;
|
48 |
-
}
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
function validate_fields_values( $changes, $args ) {
|
53 |
-
$fields = array();
|
54 |
-
if ( ! empty( $args['custom_fields'] ) ) {
|
55 |
-
$fields = unserialize( $args['custom_fields'] );
|
56 |
-
}
|
57 |
-
|
58 |
-
foreach ( $changes as $key => $value ) {
|
59 |
-
if ( ! isset( $fields[ $key ] ) ) {
|
60 |
-
continue;
|
61 |
-
}
|
62 |
-
|
63 |
-
//rating field validation
|
64 |
-
if ( isset( $fields[ $key ]['type'] ) && $fields[ $key ]['type'] == 'rating' ) {
|
65 |
-
if ( ! is_numeric( $value ) ) {
|
66 |
-
unset( $changes[ $key ] );
|
67 |
-
} else {
|
68 |
-
if ( $fields[ $key ]['number'] == 5 ) {
|
69 |
-
if ( ! in_array( $value, range( 1, 5 ) ) ) {
|
70 |
-
unset( $changes[ $key ] );
|
71 |
-
}
|
72 |
-
} elseif ( $fields[ $key ]['number'] == 10 ) {
|
73 |
-
if ( ! in_array( $value, range( 1, 10 ) ) ) {
|
74 |
-
unset( $changes[ $key ] );
|
75 |
-
}
|
76 |
-
}
|
77 |
-
}
|
78 |
-
}
|
79 |
-
|
80 |
-
//validation of correct values from options in wp-admin
|
81 |
-
$stripslashes = $value;
|
82 |
-
if ( is_string( $value ) ) {
|
83 |
-
$stripslashes = stripslashes( $value );
|
84 |
-
}
|
85 |
-
|
86 |
-
// Dynamic dropdown options population
|
87 |
-
$has_custom_source = apply_filters("um_has_dropdown_options_source__{$key}", false );
|
88 |
-
if ( in_array( $fields[ $key ]['type'], array( 'select','multiselect' ) ) && $has_custom_source ){
|
89 |
-
$arr_options = apply_filters("um_get_field__{$key}", $fields[ $key ]['options'] );
|
90 |
-
$fields[ $key ]['options'] = array_keys( $arr_options['options'] );
|
91 |
-
}
|
92 |
-
|
93 |
-
// Dropdown options source from callback function
|
94 |
-
if ( in_array( $fields[ $key ]['type'], array( 'select','multiselect' ) ) &&
|
95 |
-
isset( $fields[ $key ]['custom_dropdown_options_source'] ) &&
|
96 |
-
! empty( $fields[ $key ]['custom_dropdown_options_source'] ) &&
|
97 |
-
function_exists( $fields[ $key ]['custom_dropdown_options_source'] ) ) {
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
*
|
127 |
-
*
|
128 |
-
* @
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
*
|
139 |
-
*
|
140 |
-
* @
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
*
|
152 |
-
*
|
153 |
-
* @
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
$name =
|
159 |
-
$name =
|
160 |
-
$name =
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
*
|
169 |
-
*
|
170 |
-
* @
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
'/[\p{
|
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 |
-
* <?php
|
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 |
-
* <?php
|
253 |
-
*
|
254 |
-
*
|
255 |
-
*
|
256 |
-
*
|
257 |
-
*
|
258 |
-
*
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
*
|
273 |
-
*
|
274 |
-
* @
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
*
|
291 |
-
*
|
292 |
-
* @
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
*
|
312 |
-
*
|
313 |
-
*
|
314 |
-
* @
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
*
|
343 |
-
*
|
344 |
-
* @
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
*
|
360 |
-
*
|
361 |
-
* @
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
*
|
372 |
-
*
|
373 |
-
* @
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
*
|
399 |
-
*
|
400 |
-
*
|
401 |
-
* @
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace um\core;
|
3 |
+
|
4 |
+
// Exit if accessed directly
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
+
if ( ! class_exists( 'um\core\Validation' ) ) {
|
8 |
+
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Validation
|
12 |
+
* @package um\core
|
13 |
+
*/
|
14 |
+
class Validation {
|
15 |
+
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Validation constructor.
|
19 |
+
*/
|
20 |
+
function __construct() {
|
21 |
+
$this->regex_safe = '/\A[\w\-\.]+\z/';
|
22 |
+
$this->regex_username_safe = '|[^a-z0-9 _.\-@]|i';
|
23 |
+
$this->regex_phone_number = '/\A[\d\-\.\+\(\)\ ]+\z/';
|
24 |
+
|
25 |
+
|
26 |
+
add_filter( 'um_user_pre_updating_files_array', array( $this, 'validate_files' ), 10, 1 );
|
27 |
+
add_filter( 'um_before_save_filter_submitted', array( $this, 'validate_fields_values' ), 10, 2 );
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Validate files before upload
|
33 |
+
*
|
34 |
+
* @param $files
|
35 |
+
*
|
36 |
+
* @return mixed
|
37 |
+
*/
|
38 |
+
function validate_files( $files ) {
|
39 |
+
if ( ! empty( $files ) ) {
|
40 |
+
foreach ( $files as $key => $filename ) {
|
41 |
+
if ( validate_file( $filename ) !== 0 ) {
|
42 |
+
unset( $files[ $key ] );
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
return $files;
|
48 |
+
}
|
49 |
+
|
50 |
+
|
51 |
+
|
52 |
+
function validate_fields_values( $changes, $args ) {
|
53 |
+
$fields = array();
|
54 |
+
if ( ! empty( $args['custom_fields'] ) ) {
|
55 |
+
$fields = unserialize( $args['custom_fields'] );
|
56 |
+
}
|
57 |
+
|
58 |
+
foreach ( $changes as $key => $value ) {
|
59 |
+
if ( ! isset( $fields[ $key ] ) ) {
|
60 |
+
continue;
|
61 |
+
}
|
62 |
+
|
63 |
+
//rating field validation
|
64 |
+
if ( isset( $fields[ $key ]['type'] ) && $fields[ $key ]['type'] == 'rating' ) {
|
65 |
+
if ( ! is_numeric( $value ) ) {
|
66 |
+
unset( $changes[ $key ] );
|
67 |
+
} else {
|
68 |
+
if ( $fields[ $key ]['number'] == 5 ) {
|
69 |
+
if ( ! in_array( $value, range( 1, 5 ) ) ) {
|
70 |
+
unset( $changes[ $key ] );
|
71 |
+
}
|
72 |
+
} elseif ( $fields[ $key ]['number'] == 10 ) {
|
73 |
+
if ( ! in_array( $value, range( 1, 10 ) ) ) {
|
74 |
+
unset( $changes[ $key ] );
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
//validation of correct values from options in wp-admin
|
81 |
+
$stripslashes = $value;
|
82 |
+
if ( is_string( $value ) ) {
|
83 |
+
$stripslashes = stripslashes( $value );
|
84 |
+
}
|
85 |
+
|
86 |
+
// Dynamic dropdown options population
|
87 |
+
$has_custom_source = apply_filters("um_has_dropdown_options_source__{$key}", false );
|
88 |
+
if ( in_array( $fields[ $key ]['type'], array( 'select','multiselect' ) ) && $has_custom_source ){
|
89 |
+
$arr_options = apply_filters("um_get_field__{$key}", $fields[ $key ]['options'] );
|
90 |
+
$fields[ $key ]['options'] = array_keys( $arr_options['options'] );
|
91 |
+
}
|
92 |
+
|
93 |
+
// Dropdown options source from callback function
|
94 |
+
if ( in_array( $fields[ $key ]['type'], array( 'select','multiselect' ) ) &&
|
95 |
+
isset( $fields[ $key ]['custom_dropdown_options_source'] ) &&
|
96 |
+
! empty( $fields[ $key ]['custom_dropdown_options_source'] ) &&
|
97 |
+
function_exists( $fields[ $key ]['custom_dropdown_options_source'] ) ) {
|
98 |
+
if ( ! in_array( $fields[ $key ]['custom_dropdown_options_source'], UM()->fields()->dropdown_options_source_blacklist(), true ) ) {
|
99 |
+
$arr_options = call_user_func( $fields[ $key ]['custom_dropdown_options_source'] );
|
100 |
+
$fields[ $key ]['options'] = array_keys( $arr_options );
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
// Unset changed value that doesn't match the option list
|
105 |
+
if ( in_array( $fields[ $key ]['type'], array( 'select' ) ) &&
|
106 |
+
! empty( $stripslashes ) && ! empty( $fields[ $key ]['options'] ) &&
|
107 |
+
! in_array( $stripslashes, array_map( 'trim', $fields[ $key ]['options'] ) ) ) {
|
108 |
+
unset( $changes[ $key ] );
|
109 |
+
}
|
110 |
+
|
111 |
+
//validation of correct values from options in wp-admin
|
112 |
+
//the user cannot set invalid value in the hidden input at the page
|
113 |
+
if ( in_array( $fields[ $key ]['type'], array( 'multiselect', 'checkbox', 'radio' ) ) &&
|
114 |
+
! empty( $value ) && ! empty( $fields[ $key ]['options'] ) ) {
|
115 |
+
$value = array_map( 'stripslashes', array_map( 'trim', $value ) );
|
116 |
+
$changes[ $key ] = array_intersect( $value, array_map( 'trim', $fields[ $key ]['options'] ) );
|
117 |
+
}
|
118 |
+
|
119 |
+
}
|
120 |
+
|
121 |
+
return $changes;
|
122 |
+
}
|
123 |
+
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Removes html from any string
|
127 |
+
*
|
128 |
+
* @param $string
|
129 |
+
*
|
130 |
+
* @return string
|
131 |
+
*/
|
132 |
+
function remove_html( $string ) {
|
133 |
+
return wp_strip_all_tags( $string );
|
134 |
+
}
|
135 |
+
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Normalize a string
|
139 |
+
*
|
140 |
+
* @param $string
|
141 |
+
*
|
142 |
+
* @return mixed
|
143 |
+
*/
|
144 |
+
function normalize( $string ) {
|
145 |
+
$string = preg_replace('~&([a-z]{1,2})(acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities($string, ENT_QUOTES, 'UTF-8'));
|
146 |
+
return $string;
|
147 |
+
}
|
148 |
+
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Safe name usage ( for url purposes )
|
152 |
+
*
|
153 |
+
* @param $name
|
154 |
+
*
|
155 |
+
* @return mixed|string
|
156 |
+
*/
|
157 |
+
function safe_name_in_url( $name ) {
|
158 |
+
$name = strtolower( $name );
|
159 |
+
$name = preg_replace("/'/","", $name );
|
160 |
+
$name = stripslashes( $name );
|
161 |
+
$name = $this->normalize($name);
|
162 |
+
$name = rawurldecode( $name );
|
163 |
+
return $name;
|
164 |
+
}
|
165 |
+
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Password strength test
|
169 |
+
*
|
170 |
+
* @param string $candidate
|
171 |
+
*
|
172 |
+
* @return bool
|
173 |
+
*/
|
174 |
+
function strong_pass( $candidate ) {
|
175 |
+
// are used Unicode Regular Expressions
|
176 |
+
$regexps = [
|
177 |
+
'/[\p{Lu}]/u', // any Letter Uppercase symbol
|
178 |
+
'/[\p{Ll}]/u', // any Letter Lowercase symbol
|
179 |
+
'/[\p{N}]/u', // any Number symbol
|
180 |
+
];
|
181 |
+
foreach ( $regexps as $regexp ) {
|
182 |
+
if ( preg_match_all( $regexp, $candidate, $o ) < 1 ) {
|
183 |
+
return false;
|
184 |
+
}
|
185 |
+
}
|
186 |
+
return true;
|
187 |
+
}
|
188 |
+
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Space, dash, underscore
|
192 |
+
*
|
193 |
+
* @param $string
|
194 |
+
*
|
195 |
+
* @return bool
|
196 |
+
*/
|
197 |
+
function safe_username( $string ) {
|
198 |
+
|
199 |
+
/**
|
200 |
+
* UM hook
|
201 |
+
*
|
202 |
+
* @type filter
|
203 |
+
* @title um_validation_safe_username_regex
|
204 |
+
* @description Change validation regex for username
|
205 |
+
* @input_vars
|
206 |
+
* [{"var":"$regex_safe","type":"string","desc":"Regex"}]
|
207 |
+
* @change_log
|
208 |
+
* ["Since: 2.0"]
|
209 |
+
* @usage
|
210 |
+
* <?php add_filter( 'um_validation_safe_username_regex', 'function_name', 10, 1 ); ?>
|
211 |
+
* @example
|
212 |
+
* <?php
|
213 |
+
* add_filter( 'um_validation_safe_username_regex', 'my_validation_safe_username', 10, 1 );
|
214 |
+
* function my_validation_safe_username( $regex_safe ) {
|
215 |
+
* // your code here
|
216 |
+
* return $regex_safe;
|
217 |
+
* }
|
218 |
+
* ?>
|
219 |
+
*/
|
220 |
+
$regex_safe_username = apply_filters( 'um_validation_safe_username_regex', $this->regex_username_safe );
|
221 |
+
|
222 |
+
if ( is_email( $string ) ) {
|
223 |
+
return true;
|
224 |
+
}
|
225 |
+
if ( ! is_email( $string ) && preg_match( $regex_safe_username, $string ) ) {
|
226 |
+
return false;
|
227 |
+
}
|
228 |
+
return true;
|
229 |
+
}
|
230 |
+
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Dash and underscore (metakey)
|
234 |
+
*
|
235 |
+
* @param $string
|
236 |
+
*
|
237 |
+
* @return bool
|
238 |
+
*/
|
239 |
+
function safe_string( $string ) {
|
240 |
+
|
241 |
+
/**
|
242 |
+
* UM hook
|
243 |
+
*
|
244 |
+
* @type filter
|
245 |
+
* @title um_validation_safe_string_regex
|
246 |
+
* @description Change validation regex for each string
|
247 |
+
* @input_vars
|
248 |
+
* [{"var":"$regex_safe","type":"string","desc":"Regex"}]
|
249 |
+
* @change_log
|
250 |
+
* ["Since: 2.0"]
|
251 |
+
* @usage
|
252 |
+
* <?php add_filter( 'um_validation_safe_string_regex', 'function_name', 10, 1 ); ?>
|
253 |
+
* @example
|
254 |
+
* <?php
|
255 |
+
* add_filter( 'um_validation_safe_string_regex', 'my_validation_safe_string', 10, 1 );
|
256 |
+
* function my_validation_safe_string( $regex_safe ) {
|
257 |
+
* // your code here
|
258 |
+
* return $regex_safe;
|
259 |
+
* }
|
260 |
+
* ?>
|
261 |
+
*/
|
262 |
+
$regex_safe_string = apply_filters( 'um_validation_safe_string_regex', $this->regex_safe );
|
263 |
+
|
264 |
+
if ( ! preg_match( $regex_safe_string, $string ) ) {
|
265 |
+
return false;
|
266 |
+
}
|
267 |
+
return true;
|
268 |
+
}
|
269 |
+
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Ss phone number
|
273 |
+
*
|
274 |
+
* @param $string
|
275 |
+
*
|
276 |
+
* @return bool
|
277 |
+
*/
|
278 |
+
function is_phone_number( $string ) {
|
279 |
+
if ( ! $string ) {
|
280 |
+
return true;
|
281 |
+
}
|
282 |
+
if ( ! preg_match( $this->regex_phone_number, $string ) ) {
|
283 |
+
return false;
|
284 |
+
}
|
285 |
+
return true;
|
286 |
+
}
|
287 |
+
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Is Discord ID?
|
291 |
+
*
|
292 |
+
* @param $string
|
293 |
+
*
|
294 |
+
* @return bool
|
295 |
+
*/
|
296 |
+
public function is_discord_id( $string ) {
|
297 |
+
if ( ! $string ) {
|
298 |
+
return true;
|
299 |
+
}
|
300 |
+
if ( substr_count( $string, '#' ) > 1 ) {
|
301 |
+
return false;
|
302 |
+
}
|
303 |
+
if ( ! preg_match( '/^(.+)#(\d+)$/', trim( $string ) ) ) {
|
304 |
+
return false;
|
305 |
+
}
|
306 |
+
return true;
|
307 |
+
}
|
308 |
+
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Is url
|
312 |
+
*
|
313 |
+
* @param $url
|
314 |
+
* @param bool $social
|
315 |
+
*
|
316 |
+
* @return bool
|
317 |
+
*/
|
318 |
+
function is_url( $url, $social = false ) {
|
319 |
+
if ( ! $url ) {
|
320 |
+
return true;
|
321 |
+
}
|
322 |
+
|
323 |
+
if ( $social ) {
|
324 |
+
|
325 |
+
if ( strstr( $url, $social ) && '' != str_replace( $social, '', $url ) ) {
|
326 |
+
return true;
|
327 |
+
}
|
328 |
+
|
329 |
+
} else {
|
330 |
+
|
331 |
+
if ( strstr( $url, 'http://' ) || strstr( $url, 'https://' ) ) {
|
332 |
+
return true;
|
333 |
+
}
|
334 |
+
|
335 |
+
}
|
336 |
+
|
337 |
+
return false;
|
338 |
+
}
|
339 |
+
|
340 |
+
|
341 |
+
/**
|
342 |
+
* Get a random string
|
343 |
+
*
|
344 |
+
* @param int $length
|
345 |
+
*
|
346 |
+
* @return string
|
347 |
+
*/
|
348 |
+
function randomize( $length = 10 ) {
|
349 |
+
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
350 |
+
$result = '';
|
351 |
+
for ( $i = 0; $i < $length; $i++ ) {
|
352 |
+
$result .= $characters[ rand( 0, strlen( $characters ) - 1 ) ];
|
353 |
+
}
|
354 |
+
return $result;
|
355 |
+
}
|
356 |
+
|
357 |
+
|
358 |
+
/**
|
359 |
+
* Generate a password, hash, or similar
|
360 |
+
*
|
361 |
+
* @param int $length
|
362 |
+
*
|
363 |
+
* @return string
|
364 |
+
*/
|
365 |
+
function generate( $length = 40 ) {
|
366 |
+
return wp_generate_password( $length, false );
|
367 |
+
}
|
368 |
+
|
369 |
+
|
370 |
+
/**
|
371 |
+
* Random numbers only
|
372 |
+
*
|
373 |
+
* @param bool $len
|
374 |
+
*
|
375 |
+
* @return int|string
|
376 |
+
*/
|
377 |
+
function random_number( $len = false ) {
|
378 |
+
$ints = array();
|
379 |
+
$len = $len ? $len : rand( 2, 9 );
|
380 |
+
if ( $len > 9 ) {
|
381 |
+
trigger_error( 'Maximum length should not exceed 9' );
|
382 |
+
return 0;
|
383 |
+
}
|
384 |
+
|
385 |
+
while( true ) {
|
386 |
+
$current = rand(0,9);
|
387 |
+
if ( ! in_array( $current, $ints ) ) {
|
388 |
+
$ints[] = $current;
|
389 |
+
}
|
390 |
+
if ( count( $ints ) == $len ) {
|
391 |
+
return implode( $ints );
|
392 |
+
}
|
393 |
+
}
|
394 |
+
}
|
395 |
+
|
396 |
+
|
397 |
+
/**
|
398 |
+
* To validate given date input
|
399 |
+
*
|
400 |
+
* @param $date
|
401 |
+
* @param string $format
|
402 |
+
*
|
403 |
+
* @return bool
|
404 |
+
*/
|
405 |
+
function validate_date( $date, $format = 'YYYY/MM/D' ) {
|
406 |
+
if ( strlen( $date ) < strlen( $format ) ) {
|
407 |
+
return false;
|
408 |
+
}
|
409 |
+
if ( $date[4] != '/' ) {
|
410 |
+
return false;
|
411 |
+
}
|
412 |
+
if ( $date[7] != '/' ) {
|
413 |
+
return false;
|
414 |
+
}
|
415 |
+
if ( false === strtotime( $date ) ) {
|
416 |
+
return false;
|
417 |
+
}
|
418 |
+
return true;
|
419 |
+
}
|
420 |
+
|
421 |
+
}
|
422 |
+
}
|
includes/core/um-actions-form.php
CHANGED
@@ -1,934 +1,934 @@
|
|
1 |
-
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
2 |
-
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Error handling: blocked emails
|
6 |
-
*
|
7 |
-
* @param $args
|
8 |
-
*/
|
9 |
-
function um_submit_form_errors_hook__blockedemails( $args ) {
|
10 |
-
$emails = UM()->options()->get( 'blocked_emails' );
|
11 |
-
if ( ! $emails ) {
|
12 |
-
return;
|
13 |
-
}
|
14 |
-
|
15 |
-
$emails = strtolower( $emails );
|
16 |
-
$emails = array_map( 'rtrim', explode( "\n", $emails ) );
|
17 |
-
|
18 |
-
if ( isset( $args['user_email'] ) && is_email( $args['user_email'] ) ) {
|
19 |
-
if ( in_array( strtolower( $args['user_email'] ), $emails ) ) {
|
20 |
-
exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_email' ) ) ) );
|
21 |
-
}
|
22 |
-
|
23 |
-
$domain = explode( '@', $args['user_email'] );
|
24 |
-
$check_domain = str_replace( $domain[0], '*', $args['user_email'] );
|
25 |
-
|
26 |
-
if ( in_array( strtolower( $check_domain ), $emails ) ) {
|
27 |
-
exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_domain' ) ) ) );
|
28 |
-
}
|
29 |
-
}
|
30 |
-
|
31 |
-
if ( isset( $args['username'] ) && is_email( $args['username'] ) ) {
|
32 |
-
if ( in_array( strtolower( $args['username'] ), $emails ) ) {
|
33 |
-
exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_email' ) ) ) );
|
34 |
-
}
|
35 |
-
|
36 |
-
$domain = explode( '@', $args['username'] );
|
37 |
-
$check_domain = str_replace( $domain[0], '*', $args['username'] );
|
38 |
-
|
39 |
-
if ( in_array( strtolower( $check_domain ), $emails ) ) {
|
40 |
-
exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_domain' ) ) ) );
|
41 |
-
}
|
42 |
-
}
|
43 |
-
}
|
44 |
-
add_action( 'um_submit_form_errors_hook__blockedemails', 'um_submit_form_errors_hook__blockedemails', 10 );
|
45 |
-
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Error handling: blocked IPs
|
49 |
-
*
|
50 |
-
* @param $args
|
51 |
-
*/
|
52 |
-
function um_submit_form_errors_hook__blockedips( $args ) {
|
53 |
-
$ips = UM()->options()->get( 'blocked_ips' );
|
54 |
-
if ( ! $ips ) {
|
55 |
-
return;
|
56 |
-
}
|
57 |
-
|
58 |
-
$ips = array_map( 'rtrim', explode( "\n", $ips ) );
|
59 |
-
$user_ip = um_user_ip();
|
60 |
-
|
61 |
-
foreach ( $ips as $ip ) {
|
62 |
-
$ip = str_replace( '*', '', $ip );
|
63 |
-
if ( ! empty( $ip ) && strpos( $user_ip, $ip ) === 0 ) {
|
64 |
-
exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_ip' ) ) ) );
|
65 |
-
}
|
66 |
-
}
|
67 |
-
}
|
68 |
-
add_action( 'um_submit_form_errors_hook__blockedips', 'um_submit_form_errors_hook__blockedips', 10 );
|
69 |
-
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Error handling: blocked words during sign up
|
73 |
-
*
|
74 |
-
* @param $args
|
75 |
-
*/
|
76 |
-
function um_submit_form_errors_hook__blockedwords( $args ) {
|
77 |
-
$words = UM()->options()->get( 'blocked_words' );
|
78 |
-
if ( empty( $words ) ) {
|
79 |
-
return;
|
80 |
-
}
|
81 |
-
|
82 |
-
$form_id = $args['form_id'];
|
83 |
-
$mode = $args['mode'];
|
84 |
-
$fields = unserialize( $args['custom_fields'] );
|
85 |
-
|
86 |
-
$words = strtolower( $words );
|
87 |
-
$words = array_map( 'rtrim', explode( "\n", $words ) );
|
88 |
-
if ( ! empty( $fields ) && is_array( $fields ) ) {
|
89 |
-
foreach ( $fields as $key => $array ) {
|
90 |
-
if ( isset( $array['validate'] ) && in_array( $array['validate'], array( 'unique_username', 'unique_email', 'unique_username_or_email' ) ) ) {
|
91 |
-
if ( ! UM()->form()->has_error( $key ) && isset( $args[ $key ] ) && in_array( strtolower( $args[ $key ] ), $words ) ) {
|
92 |
-
UM()->form()->add_error( $key, __( 'You are not allowed to use this word as your username.', 'ultimate-member' ) );
|
93 |
-
}
|
94 |
-
}
|
95 |
-
}
|
96 |
-
}
|
97 |
-
}
|
98 |
-
add_action( 'um_submit_form_errors_hook__blockedwords', 'um_submit_form_errors_hook__blockedwords', 10 );
|
99 |
-
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Error handling
|
103 |
-
*
|
104 |
-
* @param $args
|
105 |
-
*/
|
106 |
-
function um_submit_form_errors_hook( $args ) {
|
107 |
-
$mode = $args['mode'];
|
108 |
-
|
109 |
-
/**
|
110 |
-
* UM hook
|
111 |
-
*
|
112 |
-
* @type action
|
113 |
-
* @title um_submit_form_errors_hook__blockedips
|
114 |
-
* @description Submit form validation
|
115 |
-
* @input_vars
|
116 |
-
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
117 |
-
* @change_log
|
118 |
-
* ["Since: 2.0"]
|
119 |
-
* @usage add_action( 'um_submit_form_errors_hook__blockedips', 'function_name', 10, 1 );
|
120 |
-
* @example
|
121 |
-
* <?php
|
122 |
-
* add_action( 'um_submit_form_errors_hook__blockedips', 'my_submit_form_errors_hook__blockedips', 10, 1 );
|
123 |
-
* function my_submit_form_errors_hook__blockedips( $args ) {
|
124 |
-
* // your code here
|
125 |
-
* }
|
126 |
-
* ?>
|
127 |
-
*/
|
128 |
-
do_action( 'um_submit_form_errors_hook__blockedips', $args );
|
129 |
-
|
130 |
-
|
131 |
-
/**
|
132 |
-
* UM hook
|
133 |
-
*
|
134 |
-
* @type action
|
135 |
-
* @title um_submit_form_errors_hook__blockedemails
|
136 |
-
* @description Submit form validation
|
137 |
-
* @input_vars
|
138 |
-
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
139 |
-
* @change_log
|
140 |
-
* ["Since: 2.0"]
|
141 |
-
* @usage add_action( 'um_submit_form_errors_hook__blockedemails', 'function_name', 10, 1 );
|
142 |
-
* @example
|
143 |
-
* <?php
|
144 |
-
* add_action( 'um_submit_form_errors_hook__blockedemails', 'my_submit_form_errors_hook__blockedemails', 10, 1 );
|
145 |
-
* function my_submit_form_errors_hook__blockedemails( $args ) {
|
146 |
-
* // your code here
|
147 |
-
* }
|
148 |
-
* ?>
|
149 |
-
*/
|
150 |
-
do_action( 'um_submit_form_errors_hook__blockedemails', $args );
|
151 |
-
|
152 |
-
if ( $mode == 'register' ) {
|
153 |
-
|
154 |
-
|
155 |
-
/**
|
156 |
-
* UM hook
|
157 |
-
*
|
158 |
-
* @type action
|
159 |
-
* @title um_submit_form_errors_hook__registration
|
160 |
-
* @description Submit registration form validation
|
161 |
-
* @input_vars
|
162 |
-
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
163 |
-
* @change_log
|
164 |
-
* ["Since: 2.0"]
|
165 |
-
* @usage add_action( 'um_submit_form_errors_hook__registration', 'function_name', 10, 1 );
|
166 |
-
* @example
|
167 |
-
* <?php
|
168 |
-
* add_action( 'um_submit_form_errors_hook__registration', 'my_submit_form_errors_registration', 10, 1 );
|
169 |
-
* function my_submit_form_errors_registration( $args ) {
|
170 |
-
* // your code here
|
171 |
-
* }
|
172 |
-
* ?>
|
173 |
-
*/
|
174 |
-
do_action( 'um_submit_form_errors_hook__registration', $args );
|
175 |
-
|
176 |
-
} elseif ( $mode == 'profile' ) {
|
177 |
-
|
178 |
-
|
179 |
-
/**
|
180 |
-
* UM hook
|
181 |
-
*
|
182 |
-
* @type action
|
183 |
-
* @title um_submit_form_errors_hook__registration
|
184 |
-
* @description Submit registration form validation
|
185 |
-
* @input_vars
|
186 |
-
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
187 |
-
* @change_log
|
188 |
-
* ["Since: 2.0"]
|
189 |
-
* @usage add_action( 'um_submit_form_errors_hook__registration', 'function_name', 10, 1 );
|
190 |
-
* @example
|
191 |
-
* <?php
|
192 |
-
* add_action( 'um_submit_form_errors_hook__profile', 'my_submit_form_errors_hook__profile', 10, 1 );
|
193 |
-
* function my_submit_form_errors_registration( $args ) {
|
194 |
-
* // your code here
|
195 |
-
* }
|
196 |
-
* ?>
|
197 |
-
*/
|
198 |
-
do_action( 'um_submit_form_errors_hook__profile', $args );
|
199 |
-
|
200 |
-
} elseif ( $mode == 'login' ) {
|
201 |
-
|
202 |
-
|
203 |
-
/**
|
204 |
-
* UM hook
|
205 |
-
*
|
206 |
-
* @type action
|
207 |
-
* @title um_submit_form_errors_hook_login
|
208 |
-
* @description Submit login form validation
|
209 |
-
* @input_vars
|
210 |
-
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
211 |
-
* @change_log
|
212 |
-
* ["Since: 2.0"]
|
213 |
-
* @usage add_action( 'um_submit_form_errors_hook_login', 'function_name', 10, 1 );
|
214 |
-
* @example
|
215 |
-
* <?php
|
216 |
-
* add_action( 'um_submit_form_errors_hook_login', 'my_submit_form_errors_hook_login', 10, 1 );
|
217 |
-
* function my_submit_form_errors_hook_login( $args ) {
|
218 |
-
* // your code here
|
219 |
-
* }
|
220 |
-
* ?>
|
221 |
-
*/
|
222 |
-
do_action( 'um_submit_form_errors_hook_login', $args );
|
223 |
-
|
224 |
-
|
225 |
-
/**
|
226 |
-
* UM hook
|
227 |
-
*
|
228 |
-
* @type action
|
229 |
-
* @title um_submit_form_errors_hook_logincheck
|
230 |
-
* @description Submit login form validation
|
231 |
-
* @input_vars
|
232 |
-
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
233 |
-
* @change_log
|
234 |
-
* ["Since: 2.0"]
|
235 |
-
* @usage add_action( 'um_submit_form_errors_hook_logincheck', 'function_name', 10, 1 );
|
236 |
-
* @example
|
237 |
-
* <?php
|
238 |
-
* add_action( 'um_submit_form_errors_hook_logincheck', 'my_submit_form_errors_hook_logincheck', 10, 1 );
|
239 |
-
* function my_submit_form_errors_hook_logincheck( $args ) {
|
240 |
-
* // your code here
|
241 |
-
* }
|
242 |
-
* ?>
|
243 |
-
*/
|
244 |
-
do_action( 'um_submit_form_errors_hook_logincheck', $args );
|
245 |
-
|
246 |
-
}
|
247 |
-
|
248 |
-
|
249 |
-
if ( $mode != 'login' ) {
|
250 |
-
|
251 |
-
|
252 |
-
/**
|
253 |
-
* UM hook
|
254 |
-
*
|
255 |
-
* @type action
|
256 |
-
* @title um_submit_form_errors_hook__blockedwords
|
257 |
-
* @description Submit form validation
|
258 |
-
* @input_vars
|
259 |
-
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
260 |
-
* @change_log
|
261 |
-
* ["Since: 2.0"]
|
262 |
-
* @usage add_action( 'um_submit_form_errors_hook__blockedwords', 'function_name', 10, 1 );
|
263 |
-
* @example
|
264 |
-
* <?php
|
265 |
-
* add_action( 'um_submit_form_errors_hook__blockedwords', 'my_submit_form_errors_hook__blockedwords', 10, 1 );
|
266 |
-
* function my_submit_form_errors_hook__blockedwords( $args ) {
|
267 |
-
* // your code here
|
268 |
-
* }
|
269 |
-
* ?>
|
270 |
-
*/
|
271 |
-
do_action( 'um_submit_form_errors_hook__blockedwords', $args );
|
272 |
-
|
273 |
-
|
274 |
-
/**
|
275 |
-
* UM hook
|
276 |
-
*
|
277 |
-
* @type action
|
278 |
-
* @title um_submit_form_errors_hook_
|
279 |
-
* @description Submit form validation
|
280 |
-
* @input_vars
|
281 |
-
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
282 |
-
* @change_log
|
283 |
-
* ["Since: 2.0"]
|
284 |
-
* @usage add_action( 'um_submit_form_errors_hook_', 'function_name', 10, 1 );
|
285 |
-
* @example
|
286 |
-
* <?php
|
287 |
-
* add_action( 'um_submit_form_errors_hook_', 'my_submit_form_errors_hook', 10, 1 );
|
288 |
-
* function my_submit_form_errors_hook( $args ) {
|
289 |
-
* // your code here
|
290 |
-
* }
|
291 |
-
* ?>
|
292 |
-
*/
|
293 |
-
do_action( 'um_submit_form_errors_hook_', $args );
|
294 |
-
|
295 |
-
}
|
296 |
-
|
297 |
-
}
|
298 |
-
add_action( 'um_submit_form_errors_hook', 'um_submit_form_errors_hook', 10 );
|
299 |
-
|
300 |
-
|
301 |
-
/**
|
302 |
-
* Error processing: Conditions
|
303 |
-
* @staticvar int $counter
|
304 |
-
* @param array $condition
|
305 |
-
* @param array $fields
|
306 |
-
* @param array $args
|
307 |
-
* @param boolean $reset
|
308 |
-
* @return boolean
|
309 |
-
* @throws Exception
|
310 |
-
*/
|
311 |
-
function um_check_conditions_on_submit( $condition, $fields, $args, $reset = false ) {
|
312 |
-
static $counter = 0;
|
313 |
-
if ( $reset ) {
|
314 |
-
$counter = 0;
|
315 |
-
}
|
316 |
-
$continue = false;
|
317 |
-
|
318 |
-
list( $visibility, $parent_key, $op, $parent_value ) = $condition;
|
319 |
-
|
320 |
-
if ( ! isset( $args[ $parent_key ] ) ) {
|
321 |
-
$continue = true;
|
322 |
-
return $continue;
|
323 |
-
}
|
324 |
-
|
325 |
-
if ( ! empty( $fields[ $parent_key ]['conditions'] ) ) {
|
326 |
-
foreach ( $fields[ $parent_key ]['conditions'] as $parent_condition ) {
|
327 |
-
if ( 64 > $counter++ ) {
|
328 |
-
$continue = um_check_conditions_on_submit( $parent_condition, $fields, $args );
|
329 |
-
} else {
|
330 |
-
throw new Exception( 'Endless recursion in the function ' . __FUNCTION__, 512 );
|
331 |
-
}
|
332 |
-
if ( ! empty( $continue ) ) {
|
333 |
-
return $continue;
|
334 |
-
}
|
335 |
-
}
|
336 |
-
}
|
337 |
-
|
338 |
-
$cond_value = ( $fields[ $parent_key ]['type'] == 'radio' ) ? $args[ $parent_key ][0] : $args[ $parent_key ];
|
339 |
-
|
340 |
-
if ( $visibility == 'hide' ) {
|
341 |
-
if ( $op == 'empty' ) {
|
342 |
-
if ( empty( $cond_value ) ) {
|
343 |
-
$continue = true;
|
344 |
-
}
|
345 |
-
} elseif ( $op == 'not empty' ) {
|
346 |
-
if ( ! empty( $cond_value ) ) {
|
347 |
-
$continue = true;
|
348 |
-
}
|
349 |
-
} elseif ( $op == 'equals to' ) {
|
350 |
-
if ( $cond_value == $parent_value ) {
|
351 |
-
$continue = true;
|
352 |
-
}
|
353 |
-
} elseif ( $op == 'not equals' ) {
|
354 |
-
if ( $cond_value != $parent_value ) {
|
355 |
-
$continue = true;
|
356 |
-
}
|
357 |
-
} elseif ( $op == 'greater than' ) {
|
358 |
-
if ( $cond_value > $parent_value ) {
|
359 |
-
$continue = true;
|
360 |
-
}
|
361 |
-
} elseif ( $op == 'less than' ) {
|
362 |
-
if ( $cond_value < $parent_value ) {
|
363 |
-
$continue = true;
|
364 |
-
}
|
365 |
-
} elseif ( $op == 'contains' ) {
|
366 |
-
if ( is_string( $cond_value ) && strstr( $cond_value, $parent_value ) ) {
|
367 |
-
$continue = true;
|
368 |
-
}
|
369 |
-
if( is_array( $cond_value ) && in_array( $parent_value, $cond_value ) ) {
|
370 |
-
$continue = true;
|
371 |
-
}
|
372 |
-
}
|
373 |
-
} elseif ( $visibility == 'show' ) {
|
374 |
-
if ( $op == 'empty' ) {
|
375 |
-
if ( ! empty( $cond_value ) ) {
|
376 |
-
$continue = true;
|
377 |
-
}
|
378 |
-
} elseif ( $op == 'not empty' ) {
|
379 |
-
if ( empty( $cond_value ) ) {
|
380 |
-
$continue = true;
|
381 |
-
}
|
382 |
-
} elseif ( $op == 'equals to' ) {
|
383 |
-
if ( $cond_value != $parent_value ) {
|
384 |
-
$continue = true;
|
385 |
-
}
|
386 |
-
} elseif ( $op == 'not equals' ) {
|
387 |
-
if ( $cond_value == $parent_value ) {
|
388 |
-
$continue = true;
|
389 |
-
}
|
390 |
-
} elseif ( $op == 'greater than' ) {
|
391 |
-
if ( $cond_value <= $parent_value ) {
|
392 |
-
$continue = true;
|
393 |
-
}
|
394 |
-
} elseif ( $op == 'less than' ) {
|
395 |
-
if ( $cond_value >= $parent_value ) {
|
396 |
-
$continue = true;
|
397 |
-
}
|
398 |
-
} elseif ( $op == 'contains' ) {
|
399 |
-
if ( is_string( $cond_value ) && ! strstr( $cond_value, $parent_value ) ) {
|
400 |
-
$continue = true;
|
401 |
-
}
|
402 |
-
if( is_array( $cond_value ) && !in_array( $parent_value, $cond_value ) ) {
|
403 |
-
$continue = true;
|
404 |
-
}
|
405 |
-
}
|
406 |
-
}
|
407 |
-
|
408 |
-
return $continue;
|
409 |
-
}
|
410 |
-
|
411 |
-
|
412 |
-
/**
|
413 |
-
* Error processing hook : standard
|
414 |
-
*
|
415 |
-
* @param $args
|
416 |
-
*/
|
417 |
-
function um_submit_form_errors_hook_( $args ) {
|
418 |
-
$form_id = $args['form_id'];
|
419 |
-
$mode = $args['mode'];
|
420 |
-
$fields = unserialize( $args['custom_fields'] );
|
421 |
-
|
422 |
-
$um_profile_photo = um_profile('profile_photo');
|
423 |
-
if ( get_post_meta( $form_id, '_um_profile_photo_required', true ) && ( empty( $args['profile_photo'] ) && empty( $um_profile_photo ) ) ) {
|
424 |
-
UM()->form()->add_error('profile_photo', __( 'Profile Photo is required.', 'ultimate-member' ) );
|
425 |
-
}
|
426 |
-
|
427 |
-
if ( ! empty( $fields ) ) {
|
428 |
-
|
429 |
-
$can_edit = false;
|
430 |
-
$current_user_roles = [];
|
431 |
-
if ( is_user_logged_in() ) {
|
432 |
-
|
433 |
-
$can_edit = UM()->roles()->um_current_user_can( 'edit', $args['user_id'] );
|
434 |
-
|
435 |
-
um_fetch_user( get_current_user_id() );
|
436 |
-
$current_user_roles = um_user( 'roles' );
|
437 |
-
um_reset_user();
|
438 |
-
}
|
439 |
-
|
440 |
-
foreach ( $fields as $key => $array ) {
|
441 |
-
|
442 |
-
if ( $mode == 'profile' ) {
|
443 |
-
$restricted_fields = UM()->fields()->get_restricted_fields_for_edit();
|
444 |
-
if ( is_array( $restricted_fields ) && in_array( $key, $restricted_fields ) ) {
|
445 |
-
continue;
|
446 |
-
}
|
447 |
-
}
|
448 |
-
|
449 |
-
$can_view = true;
|
450 |
-
if ( isset( $array['public'] ) && $mode != 'register' ) {
|
451 |
-
|
452 |
-
switch ( $array['public'] ) {
|
453 |
-
case '1': // Everyone
|
454 |
-
break;
|
455 |
-
case '2': // Members
|
456 |
-
if ( ! is_user_logged_in() ) {
|
457 |
-
$can_view = false;
|
458 |
-
}
|
459 |
-
break;
|
460 |
-
case '-1': // Only visible to profile owner and admins
|
461 |
-
if ( ! is_user_logged_in() ) {
|
462 |
-
$can_view = false;
|
463 |
-
} elseif ( $args['user_id'] != get_current_user_id() && ! $can_edit ) {
|
464 |
-
$can_view = false;
|
465 |
-
}
|
466 |
-
break;
|
467 |
-
case '-2': // Only specific member roles
|
468 |
-
if ( ! is_user_logged_in() ) {
|
469 |
-
$can_view = false;
|
470 |
-
} elseif ( ! empty( $array['roles'] ) && count( array_intersect( $current_user_roles, $array['roles'] ) ) <= 0 ) {
|
471 |
-
$can_view = false;
|
472 |
-
}
|
473 |
-
break;
|
474 |
-
case '-3': // Only visible to profile owner and specific roles
|
475 |
-
if ( ! is_user_logged_in() ) {
|
476 |
-
$can_view = false;
|
477 |
-
} elseif ( $args['user_id'] != get_current_user_id() && ! empty( $array['roles'] ) && count( array_intersect( $current_user_roles, $array['roles'] ) ) <= 0 ) {
|
478 |
-
$can_view = false;
|
479 |
-
}
|
480 |
-
break;
|
481 |
-
default:
|
482 |
-
$can_view = apply_filters( 'um_can_view_field_custom', $can_view, $array );
|
483 |
-
break;
|
484 |
-
}
|
485 |
-
|
486 |
-
}
|
487 |
-
|
488 |
-
$can_view = apply_filters( 'um_can_view_field', $can_view, $array );
|
489 |
-
|
490 |
-
if ( ! $can_view ) {
|
491 |
-
continue;
|
492 |
-
}
|
493 |
-
|
494 |
-
|
495 |
-
/**
|
496 |
-
* UM hook
|
497 |
-
*
|
498 |
-
* @type filter
|
499 |
-
* @title um_get_custom_field_array
|
500 |
-
* @description Extend custom field data on submit form error
|
501 |
-
* @input_vars
|
502 |
-
* [{"var":"$array","type":"array","desc":"Field data"},
|
503 |
-
* {"var":"$fields","type":"array","desc":"All fields"}]
|
504 |
-
* @change_log
|
505 |
-
* ["Since: 2.0"]
|
506 |
-
* @usage
|
507 |
-
* <?php add_filter( 'um_get_custom_field_array', 'function_name', 10, 2 ); ?>
|
508 |
-
* @example
|
509 |
-
* <?php
|
510 |
-
* add_filter( 'um_get_custom_field_array', 'my_get_custom_field_array', 10, 2 );
|
511 |
-
* function my_get_custom_field_array( $array, $fields ) {
|
512 |
-
* // your code here
|
513 |
-
* return $array;
|
514 |
-
* }
|
515 |
-
* ?>
|
516 |
-
*/
|
517 |
-
$array = apply_filters( 'um_get_custom_field_array', $array, $fields );
|
518 |
-
|
519 |
-
if ( ! empty( $array['conditions'] ) ) {
|
520 |
-
try {
|
521 |
-
foreach ( $array['conditions'] as $condition ) {
|
522 |
-
$continue = um_check_conditions_on_submit( $condition, $fields, $args, true );
|
523 |
-
if ( $continue === true ) {
|
524 |
-
continue 2;
|
525 |
-
}
|
526 |
-
}
|
527 |
-
} catch ( Exception $e ) {
|
528 |
-
UM()->form()->add_error( $key, sprintf( __( '%s - wrong conditions.', 'ultimate-member' ), $array['title'] ) );
|
529 |
-
$notice = '<div class="um-field-error">' . sprintf( __( '%s - wrong conditions.', 'ultimate-member' ), $array['title'] ) . '</div><!-- ' . $e->getMessage() . ' -->';
|
530 |
-
add_action( 'um_after_profile_fields', function() use ( $notice ) {
|
531 |
-
echo $notice;
|
532 |
-
}, 900 );
|
533 |
-
}
|
534 |
-
}
|
535 |
-
|
536 |
-
if ( isset( $array['type'] ) && $array['type'] == 'checkbox' && isset( $array['required'] ) && $array['required'] == 1 && ! isset( $args[ $key ] ) ) {
|
537 |
-
UM()->form()->add_error( $key, sprintf( __( '%s is required.', 'ultimate-member' ), $array['title'] ) );
|
538 |
-
}
|
539 |
-
|
540 |
-
if ( isset( $array['type'] ) && $array['type'] == 'radio' && isset( $array['required'] ) && $array['required'] == 1 && ! isset( $args[ $key ] ) && ! in_array( $key, array( 'role_radio', 'role_select' ) ) ) {
|
541 |
-
UM()->form()->add_error( $key, sprintf( __( '%s is required.', 'ultimate-member'), $array['title'] ) );
|
542 |
-
}
|
543 |
-
|
544 |
-
if ( isset( $array['type'] ) && $array['type'] == 'multiselect' && isset( $array['required'] ) && $array['required'] == 1 && ! isset( $args[ $key ] ) && ! in_array( $key, array( 'role_radio', 'role_select' ) ) ) {
|
545 |
-
UM()->form()->add_error( $key, sprintf( __( '%s is required.', 'ultimate-member' ), $array['title'] ) );
|
546 |
-
}
|
547 |
-
|
548 |
-
/* WordPress uses the default user role if the role wasn't chosen in the registration form. That is why we should use submitted data to validate fields Roles (Radio) and Roles (Dropdown). */
|
549 |
-
if ( in_array( $key, array( 'role_radio', 'role_select' ) ) && isset( $array['required'] ) && $array['required'] == 1 && empty( UM()->form()->post_form['submitted']['role'] ) ) {
|
550 |
-
UM()->form()->add_error( 'role', __( 'Please specify account type.', 'ultimate-member' ) );
|
551 |
-
UM()->form()->post_form[ $key ] = '';
|
552 |
-
}
|
553 |
-
|
554 |
-
/**
|
555 |
-
* UM hook
|
556 |
-
*
|
557 |
-
* @type action
|
558 |
-
* @title um_add_error_on_form_submit_validation
|
559 |
-
* @description Submit form validation
|
560 |
-
* @input_vars
|
561 |
-
* [{"var":"$field","type":"array","desc":"Field Data"},
|
562 |
-
* {"var":"$key","type":"string","desc":"Field Key"},
|
563 |
-
* {"var":"$args","type":"array","desc":"Form Arguments"}]
|
564 |
-
* @change_log
|
565 |
-
* ["Since: 2.0"]
|
566 |
-
* @usage add_action( 'um_add_error_on_form_submit_validation', 'function_name', 10, 3 );
|
567 |
-
* @example
|
568 |
-
* <?php
|
569 |
-
* add_action( 'um_add_error_on_form_submit_validation', 'my_add_error_on_form_submit_validation', 10, 3 );
|
570 |
-
* function my_add_error_on_form_submit_validation( $field, $key, $args ) {
|
571 |
-
* // your code here
|
572 |
-
* }
|
573 |
-
* ?>
|
574 |
-
*/
|
575 |
-
do_action( 'um_add_error_on_form_submit_validation', $array, $key, $args );
|
576 |
-
|
577 |
-
if ( ! empty( $array['required'] ) ) {
|
578 |
-
if ( ! isset( $args[ $key ] ) || $args[ $key ] == '' || $args[ $key ] == 'empty_file' ) {
|
579 |
-
if ( empty( $array['label'] ) ) {
|
580 |
-
UM()->form()->add_error( $key, __( 'This field is required', 'ultimate-member' ) );
|
581 |
-
} else {
|
582 |
-
UM()->form()->add_error( $key, sprintf( __( '%s is required', 'ultimate-member' ), $array['label'] ) );
|
583 |
-
}
|
584 |
-
}
|
585 |
-
}
|
586 |
-
|
587 |
-
if ( isset( $args[ $key ] ) ) {
|
588 |
-
|
589 |
-
if ( isset( $array['max_words'] ) && $array['max_words'] > 0 ) {
|
590 |
-
if ( str_word_count( $args[ $key ], 0, "éèàôù" ) > $array['max_words'] ) {
|
591 |
-
UM()->form()->add_error( $key, sprintf( __( 'You are only allowed to enter a maximum of %s words', 'ultimate-member' ), $array['max_words'] ) );
|
592 |
-
}
|
593 |
-
}
|
594 |
-
|
595 |
-
if ( isset( $array['min_chars'] ) && $array['min_chars'] > 0 ) {
|
596 |
-
if ( $args[ $key ] && mb_strlen( $args[ $key ] ) < $array['min_chars'] ) {
|
597 |
-
if ( empty( $array['label'] ) ) {
|
598 |
-
UM()->form()->add_error( $key, sprintf( __( 'This field must contain at least %s characters', 'ultimate-member' ), $array['min_chars'] ) );
|
599 |
-
} else {
|
600 |
-
UM()->form()->add_error( $key, sprintf( __( 'Your %s must contain at least %s characters', 'ultimate-member' ), $array['label'], $array['min_chars'] ) );
|
601 |
-
}
|
602 |
-
}
|
603 |
-
}
|
604 |
-
|
605 |
-
if ( isset( $array['max_chars'] ) && $array['max_chars'] > 0 ) {
|
606 |
-
if ( $args[ $key ] && mb_strlen( $args[ $key ] ) > $array['max_chars'] ) {
|
607 |
-
if ( empty( $array['label'] ) ) {
|
608 |
-
UM()->form()->add_error( $key, sprintf( __( 'This field must contain less than %s characters', 'ultimate-member' ), $array['max_chars'] ) );
|
609 |
-
} else {
|
610 |
-
UM()->form()->add_error( $key, sprintf( __( 'Your %s must contain less than %s characters', 'ultimate-member' ), $array['label'], $array['max_chars'] ) );
|
611 |
-
}
|
612 |
-
}
|
613 |
-
}
|
614 |
-
|
615 |
-
if ( isset( $array['type'] ) && $array['type'] == 'textarea' && UM()->profile()->get_show_bio_key( $args ) !== $key ) {
|
616 |
-
if ( ! isset( $array['html'] ) || $array['html'] == 0 ) {
|
617 |
-
if ( wp_strip_all_tags( $args[ $key ] ) != trim( $args[ $key ] ) ) {
|
618 |
-
UM()->form()->add_error( $key, __( 'You can not use HTML tags here', 'ultimate-member' ) );
|
619 |
-
}
|
620 |
-
}
|
621 |
-
}
|
622 |
-
|
623 |
-
if ( isset( $array['force_good_pass'] ) && $array['force_good_pass'] == 1 ) {
|
624 |
-
if ( ! UM()->validation()->strong_pass( $args[ $key ] ) ) {
|
625 |
-
UM()->form()->add_error( $key, __( 'Your password must contain at least one lowercase letter, one capital letter and one number', 'ultimate-member' ) );
|
626 |
-
}
|
627 |
-
}
|
628 |
-
|
629 |
-
if ( isset( $array['force_confirm_pass'] ) && $array['force_confirm_pass'] == 1 ) {
|
630 |
-
if ( $args[ 'confirm_' . $key ] == '' && ! UM()->form()->has_error( $key ) ) {
|
631 |
-
UM()->form()->add_error( 'confirm_' . $key , __( 'Please confirm your password', 'ultimate-member' ) );
|
632 |
-
}
|
633 |
-
if ( $args[ 'confirm_' . $key ] != $args[$key] && !UM()->form()->has_error( $key ) ) {
|
634 |
-
UM()->form()->add_error( 'confirm_' . $key , __( 'Your passwords do not match', 'ultimate-member' ) );
|
635 |
-
}
|
636 |
-
}
|
637 |
-
|
638 |
-
if ( isset( $array['min_selections'] ) && $array['min_selections'] > 0 ) {
|
639 |
-
if ( ( ! isset( $args[ $key ] ) ) || ( isset( $args[ $key ] ) && is_array( $args[ $key ] ) && count( $args[ $key ] ) < $array['min_selections'] ) ) {
|
640 |
-
UM()->form()->add_error($key, sprintf( __( 'Please select at least %s choices', 'ultimate-member' ), $array['min_selections'] ) );
|
641 |
-
}
|
642 |
-
}
|
643 |
-
|
644 |
-
if ( isset( $array['max_selections'] ) && $array['max_selections'] > 0 ) {
|
645 |
-
if ( isset( $args[ $key ] ) && is_array( $args[ $key ] ) && count( $args[ $key ] ) > $array['max_selections'] ) {
|
646 |
-
UM()->form()->add_error( $key, sprintf( __( 'You can only select up to %s choices', 'ultimate-member' ), $array['max_selections'] ) );
|
647 |
-
}
|
648 |
-
}
|
649 |
-
|
650 |
-
if ( isset( $array['min'] ) && is_numeric( $args[ $key ] ) ) {
|
651 |
-
if ( isset( $args[ $key ] ) && $args[ $key ] < $array['min'] ) {
|
652 |
-
UM()->form()->add_error( $key, sprintf( __( 'Minimum number limit is %s', 'ultimate-member' ), $array['min'] ) );
|
653 |
-
}
|
654 |
-
}
|
655 |
-
|
656 |
-
if ( isset( $array['max'] ) && is_numeric( $args[ $key ] ) ) {
|
657 |
-
if ( isset( $args[ $key ] ) && $args[ $key ] > $array['max'] ) {
|
658 |
-
UM()->form()->add_error( $key, sprintf( __( 'Maximum number limit is %s', 'ultimate-member' ), $array['max'] ) );
|
659 |
-
}
|
660 |
-
}
|
661 |
-
|
662 |
-
if ( ! empty( $array['validate'] ) ) {
|
663 |
-
|
664 |
-
switch( $array['validate'] ) {
|
665 |
-
|
666 |
-
case 'custom':
|
667 |
-
$custom = $array['custom_validate'];
|
668 |
-
/**
|
669 |
-
* UM hook
|
670 |
-
*
|
671 |
-
* @type action
|
672 |
-
* @title um_custom_field_validation_{$custom}
|
673 |
-
* @description Submit form validation for custom field
|
674 |
-
* @input_vars
|
675 |
-
* [{"var":"$key","type":"string","desc":"Field Key"},
|
676 |
-
* {"var":"$field","type":"array","desc":"Field Data"},
|
677 |
-
* {"var":"$args","type":"array","desc":"Form Arguments"}]
|
678 |
-
* @change_log
|
679 |
-
* ["Since: 2.0"]
|
680 |
-
* @usage add_action( 'um_custom_field_validation_{$custom}', 'function_name', 10, 3 );
|
681 |
-
* @example
|
682 |
-
* <?php
|
683 |
-
* add_action( 'um_custom_field_validation_{$custom}', 'my_custom_field_validation', 10, 3 );
|
684 |
-
* function my_custom_field_validation( $key, $field, $args ) {
|
685 |
-
* // your code here
|
686 |
-
* }
|
687 |
-
* ?>
|
688 |
-
*/
|
689 |
-
do_action( "um_custom_field_validation_{$custom}", $key, $array, $args );
|
690 |
-
break;
|
691 |
-
|
692 |
-
case 'numeric':
|
693 |
-
if ( $args[ $key ] && ! is_numeric( $args[ $key ] ) ) {
|
694 |
-
UM()->form()->add_error( $key, __( 'Please enter numbers only in this field', 'ultimate-member' ) );
|
695 |
-
}
|
696 |
-
break;
|
697 |
-
|
698 |
-
case 'phone_number':
|
699 |
-
if ( ! UM()->validation()->is_phone_number( $args[ $key ] ) ) {
|
700 |
-
UM()->form()->add_error( $key, __( 'Please enter a valid phone number', 'ultimate-member' ) );
|
701 |
-
}
|
702 |
-
break;
|
703 |
-
|
704 |
-
case 'youtube_url':
|
705 |
-
if ( ! UM()->validation()->is_url( $args[ $key ], 'youtube.com' ) ) {
|
706 |
-
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
707 |
-
}
|
708 |
-
break;
|
709 |
-
|
710 |
-
case 'telegram_url':
|
711 |
-
if ( ! UM()->validation()->is_url( $args[ $key ], 't.me' ) ) {
|
712 |
-
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
713 |
-
}
|
714 |
-
break;
|
715 |
-
|
716 |
-
case 'soundcloud_url':
|
717 |
-
if ( ! UM()->validation()->is_url( $args[ $key ], 'soundcloud.com' ) ) {
|
718 |
-
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL','ultimate-member'), $array['label'] ) );
|
719 |
-
}
|
720 |
-
break;
|
721 |
-
|
722 |
-
case 'facebook_url':
|
723 |
-
if ( ! UM()->validation()->is_url( $args[ $key ], 'facebook.com' ) ) {
|
724 |
-
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
725 |
-
}
|
726 |
-
break;
|
727 |
-
|
728 |
-
case 'twitter_url':
|
729 |
-
if ( ! UM()->validation()->is_url( $args[ $key ], 'twitter.com' ) ) {
|
730 |
-
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
731 |
-
}
|
732 |
-
break;
|
733 |
-
|
734 |
-
case 'instagram_url':
|
735 |
-
|
736 |
-
if ( ! UM()->validation()->is_url( $args[ $key ], 'instagram.com' ) ) {
|
737 |
-
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s profile URL', 'ultimate-member' ), $array['label'] ) );
|
738 |
-
}
|
739 |
-
break;
|
740 |
-
|
741 |
-
case 'google_url':
|
742 |
-
if ( ! UM()->validation()->is_url( $args[ $key ], 'plus.google.com' ) ) {
|
743 |
-
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
744 |
-
}
|
745 |
-
break;
|
746 |
-
|
747 |
-
case 'linkedin_url':
|
748 |
-
if ( ! UM()->validation()->is_url( $args[ $key ], 'linkedin.com' ) ) {
|
749 |
-
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
750 |
-
}
|
751 |
-
break;
|
752 |
-
|
753 |
-
case 'vk_url':
|
754 |
-
if ( ! UM()->validation()->is_url( $args[ $key ], 'vk.com' ) ) {
|
755 |
-
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
756 |
-
}
|
757 |
-
break;
|
758 |
-
|
759 |
-
case 'discord':
|
760 |
-
if ( ! UM()->validation()->is_discord_id( $args[ $key ] ) ) {
|
761 |
-
UM()->form()->add_error( $key, __( 'Please enter a valid Discord ID', 'ultimate-member' ) );
|
762 |
-
}
|
763 |
-
break;
|
764 |
-
|
765 |
-
case 'url':
|
766 |
-
if ( ! UM()->validation()->is_url( $args[ $key ] ) ) {
|
767 |
-
UM()->form()->add_error( $key, __( 'Please enter a valid URL', 'ultimate-member' ) );
|
768 |
-
}
|
769 |
-
break;
|
770 |
-
|
771 |
-
case 'unique_username':
|
772 |
-
|
773 |
-
if ( $args[ $key ] == '' ) {
|
774 |
-
UM()->form()->add_error( $key, __( 'You must provide a username', 'ultimate-member' ) );
|
775 |
-
} elseif ( $mode == 'register' && username_exists( sanitize_user( $args[ $key ] ) ) ) {
|
776 |
-
UM()->form()->add_error( $key, __( 'The username you entered is incorrect', 'ultimate-member' ) );
|
777 |
-
} elseif ( is_email( $args[ $key ] ) ) {
|
778 |
-
UM()->form()->add_error( $key, __( 'Username cannot be an email', 'ultimate-member' ) );
|
779 |
-
} elseif ( ! UM()->validation()->safe_username( $args[ $key ] ) ) {
|
780 |
-
UM()->form()->add_error( $key, __( 'Your username contains invalid characters', 'ultimate-member' ) );
|
781 |
-
}
|
782 |
-
|
783 |
-
break;
|
784 |
-
|
785 |
-
case 'unique_username_or_email':
|
786 |
-
|
787 |
-
if ( $args[ $key ] == '' ) {
|
788 |
-
UM()->form()->add_error( $key, __( 'You must provide a username or email', 'ultimate-member' ) );
|
789 |
-
} elseif ( $mode == 'register' && username_exists( sanitize_user( $args[ $key ] ) ) ) {
|
790 |
-
UM()->form()->add_error( $key, __( 'The username you entered is incorrect', 'ultimate-member' ) );
|
791 |
-
} elseif ( $mode == 'register' && email_exists( $args[ $key ] ) ) {
|
792 |
-
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
793 |
-
} elseif ( ! UM()->validation()->safe_username( $args[ $key ] ) ) {
|
794 |
-
UM()->form()->add_error( $key, __( 'Your username contains invalid characters', 'ultimate-member' ) );
|
795 |
-
}
|
796 |
-
|
797 |
-
break;
|
798 |
-
|
799 |
-
case 'unique_email':
|
800 |
-
|
801 |
-
$args[ $key ] = trim( $args[ $key ] );
|
802 |
-
|
803 |
-
if ( in_array( $key, array( 'user_email' ) ) ) {
|
804 |
-
|
805 |
-
if ( ! isset( $args['user_id'] ) ){
|
806 |
-
$args['user_id'] = um_get_requested_user();
|
807 |
-
}
|
808 |
-
|
809 |
-
$email_exists =
|
810 |
-
|
811 |
-
if ( $args[ $key ] == '' && in_array( $key, array( 'user_email' ) ) ) {
|
812 |
-
UM()->form()->add_error( $key, __( 'You must provide your email', 'ultimate-member' ) );
|
813 |
-
} elseif ( in_array( $mode, array( 'register' ) ) && $email_exists ) {
|
814 |
-
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
815 |
-
} elseif ( in_array( $mode, array( 'profile' ) ) && $email_exists && $email_exists != $args['user_id'] ) {
|
816 |
-
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
817 |
-
} elseif ( ! is_email( $args[ $key ] ) ) {
|
818 |
-
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member') );
|
819 |
-
} elseif ( ! UM()->validation()->safe_username( $args[ $key ] ) ) {
|
820 |
-
UM()->form()->add_error( $key, __( 'Your email contains invalid characters', 'ultimate-member' ) );
|
821 |
-
}
|
822 |
-
|
823 |
-
} else {
|
824 |
-
|
825 |
-
if ( $args[ $key ] != '' && ! is_email( $args[ $key ] ) ) {
|
826 |
-
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
827 |
-
} elseif ( $args[ $key ] != '' && email_exists( $args[ $key ] ) ) {
|
828 |
-
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
829 |
-
} elseif ( $args[ $key ] != '' ) {
|
830 |
-
|
831 |
-
$users = get_users( 'meta_value=' . $args[ $key ] );
|
832 |
-
|
833 |
-
foreach ( $users as $user ) {
|
834 |
-
if ( $user->ID != $args['user_id'] ) {
|
835 |
-
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
836 |
-
}
|
837 |
-
}
|
838 |
-
|
839 |
-
}
|
840 |
-
|
841 |
-
}
|
842 |
-
|
843 |
-
break;
|
844 |
-
|
845 |
-
case 'is_email':
|
846 |
-
|
847 |
-
$args[ $key ] = trim( $args[ $key ] );
|
848 |
-
|
849 |
-
if ( $args[ $key ] != '' && ! is_email( $args[ $key ] ) ) {
|
850 |
-
UM()->form()->add_error( $key, __( 'This is not a valid email', 'ultimate-member' ) );
|
851 |
-
}
|
852 |
-
|
853 |
-
break;
|
854 |
-
|
855 |
-
case 'unique_value':
|
856 |
-
|
857 |
-
if ( $args[ $key ] != '' ) {
|
858 |
-
|
859 |
-
$args_unique_meta = array(
|
860 |
-
'meta_key' => $key,
|
861 |
-
'meta_value' => $args[ $key ],
|
862 |
-
'compare' => '=',
|
863 |
-
'exclude' => array( $args['user_id'] ),
|
864 |
-
);
|
865 |
-
|
866 |
-
$meta_key_exists = get_users( $args_unique_meta );
|
867 |
-
|
868 |
-
if ( $meta_key_exists ) {
|
869 |
-
UM()->form()->add_error( $key , __( 'You must provide a unique value', 'ultimate-member' ) );
|
870 |
-
}
|
871 |
-
}
|
872 |
-
break;
|
873 |
-
|
874 |
-
case 'alphabetic':
|
875 |
-
|
876 |
-
if ( $args[ $key ] != '' ) {
|
877 |
-
|
878 |
-
if ( ! preg_match( '/^\p{L}+$/u', str_replace( ' ', '', $args[ $key ] ) ) ) {
|
879 |
-
UM()->form()->add_error( $key, __( 'You must provide alphabetic letters', 'ultimate-member' ) );
|
880 |
-
}
|
881 |
-
|
882 |
-
}
|
883 |
-
|
884 |
-
break;
|
885 |
-
|
886 |
-
case 'lowercase':
|
887 |
-
|
888 |
-
if ( $args[ $key ] != '' ) {
|
889 |
-
|
890 |
-
if ( ! ctype_lower( str_replace(' ', '', $args[ $key ] ) ) ) {
|
891 |
-
UM()->form()->add_error( $key , __( 'You must provide lowercase letters.', 'ultimate-member' ) );
|
892 |
-
}
|
893 |
-
}
|
894 |
-
|
895 |
-
break;
|
896 |
-
|
897 |
-
}
|
898 |
-
|
899 |
-
}
|
900 |
-
|
901 |
-
}
|
902 |
-
|
903 |
-
if ( isset( $args['description'] ) ) {
|
904 |
-
$max_chars = UM()->options()->get( 'profile_bio_maxchars' );
|
905 |
-
$profile_show_bio = UM()->options()->get( 'profile_show_bio' );
|
906 |
-
|
907 |
-
if ( $profile_show_bio ) {
|
908 |
-
if ( mb_strlen( str_replace( array( "\r\n", "\n", "\r\t", "\t" ), ' ', $args['description'] ) ) > $max_chars && $max_chars ) {
|
909 |
-
UM()->form()->add_error( 'description', sprintf( __( 'Your user description must contain less than %s characters', 'ultimate-member' ), $max_chars ) );
|
910 |
-
}
|
911 |
-
}
|
912 |
-
|
913 |
-
}
|
914 |
-
|
915 |
-
} // end if ( isset in args array )
|
916 |
-
}
|
917 |
-
}
|
918 |
-
add_action( 'um_submit_form_errors_hook_', 'um_submit_form_errors_hook_', 10 );
|
919 |
-
|
920 |
-
|
921 |
-
/**
|
922 |
-
* @param string $url
|
923 |
-
*
|
924 |
-
* @return string
|
925 |
-
*/
|
926 |
-
function um_invalid_nonce_redirect_url( $url ) {
|
927 |
-
$url = add_query_arg( [
|
928 |
-
'um-hash' => substr( md5( rand() ), 0, 6 ),
|
929 |
-
], remove_query_arg( 'um-hash', $url ) );
|
930 |
-
|
931 |
-
return $url;
|
932 |
-
}
|
933 |
-
add_filter( 'um_login_invalid_nonce_redirect_url', 'um_invalid_nonce_redirect_url', 10, 1 );
|
934 |
-
add_filter( 'um_register_invalid_nonce_redirect_url', 'um_invalid_nonce_redirect_url', 10, 1 );
|
1 |
+
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
2 |
+
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Error handling: blocked emails
|
6 |
+
*
|
7 |
+
* @param $args
|
8 |
+
*/
|
9 |
+
function um_submit_form_errors_hook__blockedemails( $args ) {
|
10 |
+
$emails = UM()->options()->get( 'blocked_emails' );
|
11 |
+
if ( ! $emails ) {
|
12 |
+
return;
|
13 |
+
}
|
14 |
+
|
15 |
+
$emails = strtolower( $emails );
|
16 |
+
$emails = array_map( 'rtrim', explode( "\n", $emails ) );
|
17 |
+
|
18 |
+
if ( isset( $args['user_email'] ) && is_email( $args['user_email'] ) ) {
|
19 |
+
if ( in_array( strtolower( $args['user_email'] ), $emails ) ) {
|
20 |
+
exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_email' ) ) ) );
|
21 |
+
}
|
22 |
+
|
23 |
+
$domain = explode( '@', $args['user_email'] );
|
24 |
+
$check_domain = str_replace( $domain[0], '*', $args['user_email'] );
|
25 |
+
|
26 |
+
if ( in_array( strtolower( $check_domain ), $emails ) ) {
|
27 |
+
exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_domain' ) ) ) );
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
if ( isset( $args['username'] ) && is_email( $args['username'] ) ) {
|
32 |
+
if ( in_array( strtolower( $args['username'] ), $emails ) ) {
|
33 |
+
exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_email' ) ) ) );
|
34 |
+
}
|
35 |
+
|
36 |
+
$domain = explode( '@', $args['username'] );
|
37 |
+
$check_domain = str_replace( $domain[0], '*', $args['username'] );
|
38 |
+
|
39 |
+
if ( in_array( strtolower( $check_domain ), $emails ) ) {
|
40 |
+
exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_domain' ) ) ) );
|
41 |
+
}
|
42 |
+
}
|
43 |
+
}
|
44 |
+
add_action( 'um_submit_form_errors_hook__blockedemails', 'um_submit_form_errors_hook__blockedemails', 10 );
|
45 |
+
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Error handling: blocked IPs
|
49 |
+
*
|
50 |
+
* @param $args
|
51 |
+
*/
|
52 |
+
function um_submit_form_errors_hook__blockedips( $args ) {
|
53 |
+
$ips = UM()->options()->get( 'blocked_ips' );
|
54 |
+
if ( ! $ips ) {
|
55 |
+
return;
|
56 |
+
}
|
57 |
+
|
58 |
+
$ips = array_map( 'rtrim', explode( "\n", $ips ) );
|
59 |
+
$user_ip = um_user_ip();
|
60 |
+
|
61 |
+
foreach ( $ips as $ip ) {
|
62 |
+
$ip = str_replace( '*', '', $ip );
|
63 |
+
if ( ! empty( $ip ) && strpos( $user_ip, $ip ) === 0 ) {
|
64 |
+
exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_ip' ) ) ) );
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
68 |
+
add_action( 'um_submit_form_errors_hook__blockedips', 'um_submit_form_errors_hook__blockedips', 10 );
|
69 |
+
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Error handling: blocked words during sign up
|
73 |
+
*
|
74 |
+
* @param $args
|
75 |
+
*/
|
76 |
+
function um_submit_form_errors_hook__blockedwords( $args ) {
|
77 |
+
$words = UM()->options()->get( 'blocked_words' );
|
78 |
+
if ( empty( $words ) ) {
|
79 |
+
return;
|
80 |
+
}
|
81 |
+
|
82 |
+
$form_id = $args['form_id'];
|
83 |
+
$mode = $args['mode'];
|
84 |
+
$fields = unserialize( $args['custom_fields'] );
|
85 |
+
|
86 |
+
$words = strtolower( $words );
|
87 |
+
$words = array_map( 'rtrim', explode( "\n", $words ) );
|
88 |
+
if ( ! empty( $fields ) && is_array( $fields ) ) {
|
89 |
+
foreach ( $fields as $key => $array ) {
|
90 |
+
if ( isset( $array['validate'] ) && in_array( $array['validate'], array( 'unique_username', 'unique_email', 'unique_username_or_email' ) ) ) {
|
91 |
+
if ( ! UM()->form()->has_error( $key ) && isset( $args[ $key ] ) && in_array( strtolower( $args[ $key ] ), $words ) ) {
|
92 |
+
UM()->form()->add_error( $key, __( 'You are not allowed to use this word as your username.', 'ultimate-member' ) );
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}
|
98 |
+
add_action( 'um_submit_form_errors_hook__blockedwords', 'um_submit_form_errors_hook__blockedwords', 10 );
|
99 |
+
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Error handling
|
103 |
+
*
|
104 |
+
* @param $args
|
105 |
+
*/
|
106 |
+
function um_submit_form_errors_hook( $args ) {
|
107 |
+
$mode = $args['mode'];
|
108 |
+
|
109 |
+
/**
|
110 |
+
* UM hook
|
111 |
+
*
|
112 |
+
* @type action
|
113 |
+
* @title um_submit_form_errors_hook__blockedips
|
114 |
+
* @description Submit form validation
|
115 |
+
* @input_vars
|
116 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
117 |
+
* @change_log
|
118 |
+
* ["Since: 2.0"]
|
119 |
+
* @usage add_action( 'um_submit_form_errors_hook__blockedips', 'function_name', 10, 1 );
|
120 |
+
* @example
|
121 |
+
* <?php
|
122 |
+
* add_action( 'um_submit_form_errors_hook__blockedips', 'my_submit_form_errors_hook__blockedips', 10, 1 );
|
123 |
+
* function my_submit_form_errors_hook__blockedips( $args ) {
|
124 |
+
* // your code here
|
125 |
+
* }
|
126 |
+
* ?>
|
127 |
+
*/
|
128 |
+
do_action( 'um_submit_form_errors_hook__blockedips', $args );
|
129 |
+
|
130 |
+
|
131 |
+
/**
|
132 |
+
* UM hook
|
133 |
+
*
|
134 |
+
* @type action
|
135 |
+
* @title um_submit_form_errors_hook__blockedemails
|
136 |
+
* @description Submit form validation
|
137 |
+
* @input_vars
|
138 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
139 |
+
* @change_log
|
140 |
+
* ["Since: 2.0"]
|
141 |
+
* @usage add_action( 'um_submit_form_errors_hook__blockedemails', 'function_name', 10, 1 );
|
142 |
+
* @example
|
143 |
+
* <?php
|
144 |
+
* add_action( 'um_submit_form_errors_hook__blockedemails', 'my_submit_form_errors_hook__blockedemails', 10, 1 );
|
145 |
+
* function my_submit_form_errors_hook__blockedemails( $args ) {
|
146 |
+
* // your code here
|
147 |
+
* }
|
148 |
+
* ?>
|
149 |
+
*/
|
150 |
+
do_action( 'um_submit_form_errors_hook__blockedemails', $args );
|
151 |
+
|
152 |
+
if ( $mode == 'register' ) {
|
153 |
+
|
154 |
+
|
155 |
+
/**
|
156 |
+
* UM hook
|
157 |
+
*
|
158 |
+
* @type action
|
159 |
+
* @title um_submit_form_errors_hook__registration
|
160 |
+
* @description Submit registration form validation
|
161 |
+
* @input_vars
|
162 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
163 |
+
* @change_log
|
164 |
+
* ["Since: 2.0"]
|
165 |
+
* @usage add_action( 'um_submit_form_errors_hook__registration', 'function_name', 10, 1 );
|
166 |
+
* @example
|
167 |
+
* <?php
|
168 |
+
* add_action( 'um_submit_form_errors_hook__registration', 'my_submit_form_errors_registration', 10, 1 );
|
169 |
+
* function my_submit_form_errors_registration( $args ) {
|
170 |
+
* // your code here
|
171 |
+
* }
|
172 |
+
* ?>
|
173 |
+
*/
|
174 |
+
do_action( 'um_submit_form_errors_hook__registration', $args );
|
175 |
+
|
176 |
+
} elseif ( $mode == 'profile' ) {
|
177 |
+
|
178 |
+
|
179 |
+
/**
|
180 |
+
* UM hook
|
181 |
+
*
|
182 |
+
* @type action
|
183 |
+
* @title um_submit_form_errors_hook__registration
|
184 |
+
* @description Submit registration form validation
|
185 |
+
* @input_vars
|
186 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
187 |
+
* @change_log
|
188 |
+
* ["Since: 2.0"]
|
189 |
+
* @usage add_action( 'um_submit_form_errors_hook__registration', 'function_name', 10, 1 );
|
190 |
+
* @example
|
191 |
+
* <?php
|
192 |
+
* add_action( 'um_submit_form_errors_hook__profile', 'my_submit_form_errors_hook__profile', 10, 1 );
|
193 |
+
* function my_submit_form_errors_registration( $args ) {
|
194 |
+
* // your code here
|
195 |
+
* }
|
196 |
+
* ?>
|
197 |
+
*/
|
198 |
+
do_action( 'um_submit_form_errors_hook__profile', $args );
|
199 |
+
|
200 |
+
} elseif ( $mode == 'login' ) {
|
201 |
+
|
202 |
+
|
203 |
+
/**
|
204 |
+
* UM hook
|
205 |
+
*
|
206 |
+
* @type action
|
207 |
+
* @title um_submit_form_errors_hook_login
|
208 |
+
* @description Submit login form validation
|
209 |
+
* @input_vars
|
210 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
211 |
+
* @change_log
|
212 |
+
* ["Since: 2.0"]
|
213 |
+
* @usage add_action( 'um_submit_form_errors_hook_login', 'function_name', 10, 1 );
|
214 |
+
* @example
|
215 |
+
* <?php
|
216 |
+
* add_action( 'um_submit_form_errors_hook_login', 'my_submit_form_errors_hook_login', 10, 1 );
|
217 |
+
* function my_submit_form_errors_hook_login( $args ) {
|
218 |
+
* // your code here
|
219 |
+
* }
|
220 |
+
* ?>
|
221 |
+
*/
|
222 |
+
do_action( 'um_submit_form_errors_hook_login', $args );
|
223 |
+
|
224 |
+
|
225 |
+
/**
|
226 |
+
* UM hook
|
227 |
+
*
|
228 |
+
* @type action
|
229 |
+
* @title um_submit_form_errors_hook_logincheck
|
230 |
+
* @description Submit login form validation
|
231 |
+
* @input_vars
|
232 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
233 |
+
* @change_log
|
234 |
+
* ["Since: 2.0"]
|
235 |
+
* @usage add_action( 'um_submit_form_errors_hook_logincheck', 'function_name', 10, 1 );
|
236 |
+
* @example
|
237 |
+
* <?php
|
238 |
+
* add_action( 'um_submit_form_errors_hook_logincheck', 'my_submit_form_errors_hook_logincheck', 10, 1 );
|
239 |
+
* function my_submit_form_errors_hook_logincheck( $args ) {
|
240 |
+
* // your code here
|
241 |
+
* }
|
242 |
+
* ?>
|
243 |
+
*/
|
244 |
+
do_action( 'um_submit_form_errors_hook_logincheck', $args );
|
245 |
+
|
246 |
+
}
|
247 |
+
|
248 |
+
|
249 |
+
if ( $mode != 'login' ) {
|
250 |
+
|
251 |
+
|
252 |
+
/**
|
253 |
+
* UM hook
|
254 |
+
*
|
255 |
+
* @type action
|
256 |
+
* @title um_submit_form_errors_hook__blockedwords
|
257 |
+
* @description Submit form validation
|
258 |
+
* @input_vars
|
259 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
260 |
+
* @change_log
|
261 |
+
* ["Since: 2.0"]
|
262 |
+
* @usage add_action( 'um_submit_form_errors_hook__blockedwords', 'function_name', 10, 1 );
|
263 |
+
* @example
|
264 |
+
* <?php
|
265 |
+
* add_action( 'um_submit_form_errors_hook__blockedwords', 'my_submit_form_errors_hook__blockedwords', 10, 1 );
|
266 |
+
* function my_submit_form_errors_hook__blockedwords( $args ) {
|
267 |
+
* // your code here
|
268 |
+
* }
|
269 |
+
* ?>
|
270 |
+
*/
|
271 |
+
do_action( 'um_submit_form_errors_hook__blockedwords', $args );
|
272 |
+
|
273 |
+
|
274 |
+
/**
|
275 |
+
* UM hook
|
276 |
+
*
|
277 |
+
* @type action
|
278 |
+
* @title um_submit_form_errors_hook_
|
279 |
+
* @description Submit form validation
|
280 |
+
* @input_vars
|
281 |
+
* [{"var":"$args","type":"array","desc":"Form Arguments"}]
|
282 |
+
* @change_log
|
283 |
+
* ["Since: 2.0"]
|
284 |
+
* @usage add_action( 'um_submit_form_errors_hook_', 'function_name', 10, 1 );
|
285 |
+
* @example
|
286 |
+
* <?php
|
287 |
+
* add_action( 'um_submit_form_errors_hook_', 'my_submit_form_errors_hook', 10, 1 );
|
288 |
+
* function my_submit_form_errors_hook( $args ) {
|
289 |
+
* // your code here
|
290 |
+
* }
|
291 |
+
* ?>
|
292 |
+
*/
|
293 |
+
do_action( 'um_submit_form_errors_hook_', $args );
|
294 |
+
|
295 |
+
}
|
296 |
+
|
297 |
+
}
|
298 |
+
add_action( 'um_submit_form_errors_hook', 'um_submit_form_errors_hook', 10 );
|
299 |
+
|
300 |
+
|
301 |
+
/**
|
302 |
+
* Error processing: Conditions
|
303 |
+
* @staticvar int $counter
|
304 |
+
* @param array $condition
|
305 |
+
* @param array $fields
|
306 |
+
* @param array $args
|
307 |
+
* @param boolean $reset
|
308 |
+
* @return boolean
|
309 |
+
* @throws Exception
|
310 |
+
*/
|
311 |
+
function um_check_conditions_on_submit( $condition, $fields, $args, $reset = false ) {
|
312 |
+
static $counter = 0;
|
313 |
+
if ( $reset ) {
|
314 |
+
$counter = 0;
|
315 |
+
}
|
316 |
+
$continue = false;
|
317 |
+
|
318 |
+
list( $visibility, $parent_key, $op, $parent_value ) = $condition;
|
319 |
+
|
320 |
+
if ( ! isset( $args[ $parent_key ] ) ) {
|
321 |
+
$continue = true;
|
322 |
+
return $continue;
|
323 |
+
}
|
324 |
+
|
325 |
+
if ( ! empty( $fields[ $parent_key ]['conditions'] ) ) {
|
326 |
+
foreach ( $fields[ $parent_key ]['conditions'] as $parent_condition ) {
|
327 |
+
if ( 64 > $counter++ ) {
|
328 |
+
$continue = um_check_conditions_on_submit( $parent_condition, $fields, $args );
|
329 |
+
} else {
|
330 |
+
throw new Exception( 'Endless recursion in the function ' . __FUNCTION__, 512 );
|
331 |
+
}
|
332 |
+
if ( ! empty( $continue ) ) {
|
333 |
+
return $continue;
|
334 |
+
}
|
335 |
+
}
|
336 |
+
}
|
337 |
+
|
338 |
+
$cond_value = ( $fields[ $parent_key ]['type'] == 'radio' ) ? $args[ $parent_key ][0] : $args[ $parent_key ];
|
339 |
+
|
340 |
+
if ( $visibility == 'hide' ) {
|
341 |
+
if ( $op == 'empty' ) {
|
342 |
+
if ( empty( $cond_value ) ) {
|
343 |
+
$continue = true;
|
344 |
+
}
|
345 |
+
} elseif ( $op == 'not empty' ) {
|
346 |
+
if ( ! empty( $cond_value ) ) {
|
347 |
+
$continue = true;
|
348 |
+
}
|
349 |
+
} elseif ( $op == 'equals to' ) {
|
350 |
+
if ( $cond_value == $parent_value ) {
|
351 |
+
$continue = true;
|
352 |
+
}
|
353 |
+
} elseif ( $op == 'not equals' ) {
|
354 |
+
if ( $cond_value != $parent_value ) {
|
355 |
+
$continue = true;
|
356 |
+
}
|
357 |
+
} elseif ( $op == 'greater than' ) {
|
358 |
+
if ( $cond_value > $parent_value ) {
|
359 |
+
$continue = true;
|
360 |
+
}
|
361 |
+
} elseif ( $op == 'less than' ) {
|
362 |
+
if ( $cond_value < $parent_value ) {
|
363 |
+
$continue = true;
|
364 |
+
}
|
365 |
+
} elseif ( $op == 'contains' ) {
|
366 |
+
if ( is_string( $cond_value ) && strstr( $cond_value, $parent_value ) ) {
|
367 |
+
$continue = true;
|
368 |
+
}
|
369 |
+
if( is_array( $cond_value ) && in_array( $parent_value, $cond_value ) ) {
|
370 |
+
$continue = true;
|
371 |
+
}
|
372 |
+
}
|
373 |
+
} elseif ( $visibility == 'show' ) {
|
374 |
+
if ( $op == 'empty' ) {
|
375 |
+
if ( ! empty( $cond_value ) ) {
|
376 |
+
$continue = true;
|
377 |
+
}
|
378 |
+
} elseif ( $op == 'not empty' ) {
|
379 |
+
if ( empty( $cond_value ) ) {
|
380 |
+
$continue = true;
|
381 |
+
}
|
382 |
+
} elseif ( $op == 'equals to' ) {
|
383 |
+
if ( $cond_value != $parent_value ) {
|
384 |
+
$continue = true;
|
385 |
+
}
|
386 |
+
} elseif ( $op == 'not equals' ) {
|
387 |
+
if ( $cond_value == $parent_value ) {
|
388 |
+
$continue = true;
|
389 |
+
}
|
390 |
+
} elseif ( $op == 'greater than' ) {
|
391 |
+
if ( $cond_value <= $parent_value ) {
|
392 |
+
$continue = true;
|
393 |
+
}
|
394 |
+
} elseif ( $op == 'less than' ) {
|
395 |
+
if ( $cond_value >= $parent_value ) {
|
396 |
+
$continue = true;
|
397 |
+
}
|
398 |
+
} elseif ( $op == 'contains' ) {
|
399 |
+
if ( is_string( $cond_value ) && ! strstr( $cond_value, $parent_value ) ) {
|
400 |
+
$continue = true;
|
401 |
+
}
|
402 |
+
if( is_array( $cond_value ) && !in_array( $parent_value, $cond_value ) ) {
|
403 |
+
$continue = true;
|
404 |
+
}
|
405 |
+
}
|
406 |
+
}
|
407 |
+
|
408 |
+
return $continue;
|
409 |
+
}
|
410 |
+
|
411 |
+
|
412 |
+
/**
|
413 |
+
* Error processing hook : standard
|
414 |
+
*
|
415 |
+
* @param $args
|
416 |
+
*/
|
417 |
+
function um_submit_form_errors_hook_( $args ) {
|
418 |
+
$form_id = $args['form_id'];
|
419 |
+
$mode = $args['mode'];
|
420 |
+
$fields = unserialize( $args['custom_fields'] );
|
421 |
+
|
422 |
+
$um_profile_photo = um_profile('profile_photo');
|
423 |
+
if ( get_post_meta( $form_id, '_um_profile_photo_required', true ) && ( empty( $args['profile_photo'] ) && empty( $um_profile_photo ) ) ) {
|
424 |
+
UM()->form()->add_error('profile_photo', __( 'Profile Photo is required.', 'ultimate-member' ) );
|
425 |
+
}
|
426 |
+
|
427 |
+
if ( ! empty( $fields ) ) {
|
428 |
+
|
429 |
+
$can_edit = false;
|
430 |
+
$current_user_roles = [];
|
431 |
+
if ( is_user_logged_in() ) {
|
432 |
+
|
433 |
+
$can_edit = UM()->roles()->um_current_user_can( 'edit', $args['user_id'] );
|
434 |
+
|
435 |
+
um_fetch_user( get_current_user_id() );
|
436 |
+
$current_user_roles = um_user( 'roles' );
|
437 |
+
um_reset_user();
|
438 |
+
}
|
439 |
+
|
440 |
+
foreach ( $fields as $key => $array ) {
|
441 |
+
|
442 |
+
if ( $mode == 'profile' ) {
|
443 |
+
$restricted_fields = UM()->fields()->get_restricted_fields_for_edit();
|
444 |
+
if ( is_array( $restricted_fields ) && in_array( $key, $restricted_fields ) ) {
|
445 |
+
continue;
|
446 |
+
}
|
447 |
+
}
|
448 |
+
|
449 |
+
$can_view = true;
|
450 |
+
if ( isset( $array['public'] ) && $mode != 'register' ) {
|
451 |
+
|
452 |
+
switch ( $array['public'] ) {
|
453 |
+
case '1': // Everyone
|
454 |
+
break;
|
455 |
+
case '2': // Members
|
456 |
+
if ( ! is_user_logged_in() ) {
|
457 |
+
$can_view = false;
|
458 |
+
}
|
459 |
+
break;
|
460 |
+
case '-1': // Only visible to profile owner and admins
|
461 |
+
if ( ! is_user_logged_in() ) {
|
462 |
+
$can_view = false;
|
463 |
+
} elseif ( $args['user_id'] != get_current_user_id() && ! $can_edit ) {
|
464 |
+
$can_view = false;
|
465 |
+
}
|
466 |
+
break;
|
467 |
+
case '-2': // Only specific member roles
|
468 |
+
if ( ! is_user_logged_in() ) {
|
469 |
+
$can_view = false;
|
470 |
+
} elseif ( ! empty( $array['roles'] ) && count( array_intersect( $current_user_roles, $array['roles'] ) ) <= 0 ) {
|
471 |
+
$can_view = false;
|
472 |
+
}
|
473 |
+
break;
|
474 |
+
case '-3': // Only visible to profile owner and specific roles
|
475 |
+
if ( ! is_user_logged_in() ) {
|
476 |
+
$can_view = false;
|
477 |
+
} elseif ( $args['user_id'] != get_current_user_id() && ! empty( $array['roles'] ) && count( array_intersect( $current_user_roles, $array['roles'] ) ) <= 0 ) {
|
478 |
+
$can_view = false;
|
479 |
+
}
|
480 |
+
break;
|
481 |
+
default:
|
482 |
+
$can_view = apply_filters( 'um_can_view_field_custom', $can_view, $array );
|
483 |
+
break;
|
484 |
+
}
|
485 |
+
|
486 |
+
}
|
487 |
+
|
488 |
+
$can_view = apply_filters( 'um_can_view_field', $can_view, $array );
|
489 |
+
|
490 |
+
if ( ! $can_view ) {
|
491 |
+
continue;
|
492 |
+
}
|
493 |
+
|
494 |
+
|
495 |
+
/**
|
496 |
+
* UM hook
|
497 |
+
*
|
498 |
+
* @type filter
|
499 |
+
* @title um_get_custom_field_array
|
500 |
+
* @description Extend custom field data on submit form error
|
501 |
+
* @input_vars
|
502 |
+
* [{"var":"$array","type":"array","desc":"Field data"},
|
503 |
+
* {"var":"$fields","type":"array","desc":"All fields"}]
|
504 |
+
* @change_log
|
505 |
+
* ["Since: 2.0"]
|
506 |
+
* @usage
|
507 |
+
* <?php add_filter( 'um_get_custom_field_array', 'function_name', 10, 2 ); ?>
|
508 |
+
* @example
|
509 |
+
* <?php
|
510 |
+
* add_filter( 'um_get_custom_field_array', 'my_get_custom_field_array', 10, 2 );
|
511 |
+
* function my_get_custom_field_array( $array, $fields ) {
|
512 |
+
* // your code here
|
513 |
+
* return $array;
|
514 |
+
* }
|
515 |
+
* ?>
|
516 |
+
*/
|
517 |
+
$array = apply_filters( 'um_get_custom_field_array', $array, $fields );
|
518 |
+
|
519 |
+
if ( ! empty( $array['conditions'] ) ) {
|
520 |
+
try {
|
521 |
+
foreach ( $array['conditions'] as $condition ) {
|
522 |
+
$continue = um_check_conditions_on_submit( $condition, $fields, $args, true );
|
523 |
+
if ( $continue === true ) {
|
524 |
+
continue 2;
|
525 |
+
}
|
526 |
+
}
|
527 |
+
} catch ( Exception $e ) {
|
528 |
+
UM()->form()->add_error( $key, sprintf( __( '%s - wrong conditions.', 'ultimate-member' ), $array['title'] ) );
|
529 |
+
$notice = '<div class="um-field-error">' . sprintf( __( '%s - wrong conditions.', 'ultimate-member' ), $array['title'] ) . '</div><!-- ' . $e->getMessage() . ' -->';
|
530 |
+
add_action( 'um_after_profile_fields', function() use ( $notice ) {
|
531 |
+
echo $notice;
|
532 |
+
}, 900 );
|
533 |
+
}
|
534 |
+
}
|
535 |
+
|
536 |
+
if ( isset( $array['type'] ) && $array['type'] == 'checkbox' && isset( $array['required'] ) && $array['required'] == 1 && ! isset( $args[ $key ] ) ) {
|
537 |
+
UM()->form()->add_error( $key, sprintf( __( '%s is required.', 'ultimate-member' ), $array['title'] ) );
|
538 |
+
}
|
539 |
+
|
540 |
+
if ( isset( $array['type'] ) && $array['type'] == 'radio' && isset( $array['required'] ) && $array['required'] == 1 && ! isset( $args[ $key ] ) && ! in_array( $key, array( 'role_radio', 'role_select' ) ) ) {
|
541 |
+
UM()->form()->add_error( $key, sprintf( __( '%s is required.', 'ultimate-member'), $array['title'] ) );
|
542 |
+
}
|
543 |
+
|
544 |
+
if ( isset( $array['type'] ) && $array['type'] == 'multiselect' && isset( $array['required'] ) && $array['required'] == 1 && ! isset( $args[ $key ] ) && ! in_array( $key, array( 'role_radio', 'role_select' ) ) ) {
|
545 |
+
UM()->form()->add_error( $key, sprintf( __( '%s is required.', 'ultimate-member' ), $array['title'] ) );
|
546 |
+
}
|
547 |
+
|
548 |
+
/* WordPress uses the default user role if the role wasn't chosen in the registration form. That is why we should use submitted data to validate fields Roles (Radio) and Roles (Dropdown). */
|
549 |
+
if ( in_array( $key, array( 'role_radio', 'role_select' ) ) && isset( $array['required'] ) && $array['required'] == 1 && empty( UM()->form()->post_form['submitted']['role'] ) ) {
|
550 |
+
UM()->form()->add_error( 'role', __( 'Please specify account type.', 'ultimate-member' ) );
|
551 |
+
UM()->form()->post_form[ $key ] = '';
|
552 |
+
}
|
553 |
+
|
554 |
+
/**
|
555 |
+
* UM hook
|
556 |
+
*
|
557 |
+
* @type action
|
558 |
+
* @title um_add_error_on_form_submit_validation
|
559 |
+
* @description Submit form validation
|
560 |
+
* @input_vars
|
561 |
+
* [{"var":"$field","type":"array","desc":"Field Data"},
|
562 |
+
* {"var":"$key","type":"string","desc":"Field Key"},
|
563 |
+
* {"var":"$args","type":"array","desc":"Form Arguments"}]
|
564 |
+
* @change_log
|
565 |
+
* ["Since: 2.0"]
|
566 |
+
* @usage add_action( 'um_add_error_on_form_submit_validation', 'function_name', 10, 3 );
|
567 |
+
* @example
|
568 |
+
* <?php
|
569 |
+
* add_action( 'um_add_error_on_form_submit_validation', 'my_add_error_on_form_submit_validation', 10, 3 );
|
570 |
+
* function my_add_error_on_form_submit_validation( $field, $key, $args ) {
|
571 |
+
* // your code here
|
572 |
+
* }
|
573 |
+
* ?>
|
574 |
+
*/
|
575 |
+
do_action( 'um_add_error_on_form_submit_validation', $array, $key, $args );
|
576 |
+
|
577 |
+
if ( ! empty( $array['required'] ) ) {
|
578 |
+
if ( ! isset( $args[ $key ] ) || $args[ $key ] == '' || $args[ $key ] == 'empty_file' ) {
|
579 |
+
if ( empty( $array['label'] ) ) {
|
580 |
+
UM()->form()->add_error( $key, __( 'This field is required', 'ultimate-member' ) );
|
581 |
+
} else {
|
582 |
+
UM()->form()->add_error( $key, sprintf( __( '%s is required', 'ultimate-member' ), $array['label'] ) );
|
583 |
+
}
|
584 |
+
}
|
585 |
+
}
|
586 |
+
|
587 |
+
if ( isset( $args[ $key ] ) ) {
|
588 |
+
|
589 |
+
if ( isset( $array['max_words'] ) && $array['max_words'] > 0 ) {
|
590 |
+
if ( str_word_count( $args[ $key ], 0, "éèàôù" ) > $array['max_words'] ) {
|
591 |
+
UM()->form()->add_error( $key, sprintf( __( 'You are only allowed to enter a maximum of %s words', 'ultimate-member' ), $array['max_words'] ) );
|
592 |
+
}
|
593 |
+
}
|
594 |
+
|
595 |
+
if ( isset( $array['min_chars'] ) && $array['min_chars'] > 0 ) {
|
596 |
+
if ( $args[ $key ] && mb_strlen( $args[ $key ] ) < $array['min_chars'] ) {
|
597 |
+
if ( empty( $array['label'] ) ) {
|
598 |
+
UM()->form()->add_error( $key, sprintf( __( 'This field must contain at least %s characters', 'ultimate-member' ), $array['min_chars'] ) );
|
599 |
+
} else {
|
600 |
+
UM()->form()->add_error( $key, sprintf( __( 'Your %s must contain at least %s characters', 'ultimate-member' ), $array['label'], $array['min_chars'] ) );
|
601 |
+
}
|
602 |
+
}
|
603 |
+
}
|
604 |
+
|
605 |
+
if ( isset( $array['max_chars'] ) && $array['max_chars'] > 0 ) {
|
606 |
+
if ( $args[ $key ] && mb_strlen( $args[ $key ] ) > $array['max_chars'] ) {
|
607 |
+
if ( empty( $array['label'] ) ) {
|
608 |
+
UM()->form()->add_error( $key, sprintf( __( 'This field must contain less than %s characters', 'ultimate-member' ), $array['max_chars'] ) );
|
609 |
+
} else {
|
610 |
+
UM()->form()->add_error( $key, sprintf( __( 'Your %s must contain less than %s characters', 'ultimate-member' ), $array['label'], $array['max_chars'] ) );
|
611 |
+
}
|
612 |
+
}
|
613 |
+
}
|
614 |
+
|
615 |
+
if ( isset( $array['type'] ) && $array['type'] == 'textarea' && UM()->profile()->get_show_bio_key( $args ) !== $key ) {
|
616 |
+
if ( ! isset( $array['html'] ) || $array['html'] == 0 ) {
|
617 |
+
if ( wp_strip_all_tags( $args[ $key ] ) != trim( $args[ $key ] ) ) {
|
618 |
+
UM()->form()->add_error( $key, __( 'You can not use HTML tags here', 'ultimate-member' ) );
|
619 |
+
}
|
620 |
+
}
|
621 |
+
}
|
622 |
+
|
623 |
+
if ( isset( $array['force_good_pass'] ) && $array['force_good_pass'] == 1 ) {
|
624 |
+
if ( ! UM()->validation()->strong_pass( $args[ $key ] ) ) {
|
625 |
+
UM()->form()->add_error( $key, __( 'Your password must contain at least one lowercase letter, one capital letter and one number', 'ultimate-member' ) );
|
626 |
+
}
|
627 |
+
}
|
628 |
+
|
629 |
+
if ( isset( $array['force_confirm_pass'] ) && $array['force_confirm_pass'] == 1 ) {
|
630 |
+
if ( $args[ 'confirm_' . $key ] == '' && ! UM()->form()->has_error( $key ) ) {
|
631 |
+
UM()->form()->add_error( 'confirm_' . $key , __( 'Please confirm your password', 'ultimate-member' ) );
|
632 |
+
}
|
633 |
+
if ( $args[ 'confirm_' . $key ] != $args[$key] && !UM()->form()->has_error( $key ) ) {
|
634 |
+
UM()->form()->add_error( 'confirm_' . $key , __( 'Your passwords do not match', 'ultimate-member' ) );
|
635 |
+
}
|
636 |
+
}
|
637 |
+
|
638 |
+
if ( isset( $array['min_selections'] ) && $array['min_selections'] > 0 ) {
|
639 |
+
if ( ( ! isset( $args[ $key ] ) ) || ( isset( $args[ $key ] ) && is_array( $args[ $key ] ) && count( $args[ $key ] ) < $array['min_selections'] ) ) {
|
640 |
+
UM()->form()->add_error($key, sprintf( __( 'Please select at least %s choices', 'ultimate-member' ), $array['min_selections'] ) );
|
641 |
+
}
|
642 |
+
}
|
643 |
+
|
644 |
+
if ( isset( $array['max_selections'] ) && $array['max_selections'] > 0 ) {
|
645 |
+
if ( isset( $args[ $key ] ) && is_array( $args[ $key ] ) && count( $args[ $key ] ) > $array['max_selections'] ) {
|
646 |
+
UM()->form()->add_error( $key, sprintf( __( 'You can only select up to %s choices', 'ultimate-member' ), $array['max_selections'] ) );
|
647 |
+
}
|
648 |
+
}
|
649 |
+
|
650 |
+
if ( isset( $array['min'] ) && is_numeric( $args[ $key ] ) ) {
|
651 |
+
if ( isset( $args[ $key ] ) && $args[ $key ] < $array['min'] ) {
|
652 |
+
UM()->form()->add_error( $key, sprintf( __( 'Minimum number limit is %s', 'ultimate-member' ), $array['min'] ) );
|
653 |
+
}
|
654 |
+
}
|
655 |
+
|
656 |
+
if ( isset( $array['max'] ) && is_numeric( $args[ $key ] ) ) {
|
657 |
+
if ( isset( $args[ $key ] ) && $args[ $key ] > $array['max'] ) {
|
658 |
+
UM()->form()->add_error( $key, sprintf( __( 'Maximum number limit is %s', 'ultimate-member' ), $array['max'] ) );
|
659 |
+
}
|
660 |
+
}
|
661 |
+
|
662 |
+
if ( ! empty( $array['validate'] ) ) {
|
663 |
+
|
664 |
+
switch( $array['validate'] ) {
|
665 |
+
|
666 |
+
case 'custom':
|
667 |
+
$custom = $array['custom_validate'];
|
668 |
+
/**
|
669 |
+
* UM hook
|
670 |
+
*
|
671 |
+
* @type action
|
672 |
+
* @title um_custom_field_validation_{$custom}
|
673 |
+
* @description Submit form validation for custom field
|
674 |
+
* @input_vars
|
675 |
+
* [{"var":"$key","type":"string","desc":"Field Key"},
|
676 |
+
* {"var":"$field","type":"array","desc":"Field Data"},
|
677 |
+
* {"var":"$args","type":"array","desc":"Form Arguments"}]
|
678 |
+
* @change_log
|
679 |
+
* ["Since: 2.0"]
|
680 |
+
* @usage add_action( 'um_custom_field_validation_{$custom}', 'function_name', 10, 3 );
|
681 |
+
* @example
|
682 |
+
* <?php
|
683 |
+
* add_action( 'um_custom_field_validation_{$custom}', 'my_custom_field_validation', 10, 3 );
|
684 |
+
* function my_custom_field_validation( $key, $field, $args ) {
|
685 |
+
* // your code here
|
686 |
+
* }
|
687 |
+
* ?>
|
688 |
+
*/
|
689 |
+
do_action( "um_custom_field_validation_{$custom}", $key, $array, $args );
|
690 |
+
break;
|
691 |
+
|
692 |
+
case 'numeric':
|
693 |
+
if ( $args[ $key ] && ! is_numeric( $args[ $key ] ) ) {
|
694 |
+
UM()->form()->add_error( $key, __( 'Please enter numbers only in this field', 'ultimate-member' ) );
|
695 |
+
}
|
696 |
+
break;
|
697 |
+
|
698 |
+
case 'phone_number':
|
699 |
+
if ( ! UM()->validation()->is_phone_number( $args[ $key ] ) ) {
|
700 |
+
UM()->form()->add_error( $key, __( 'Please enter a valid phone number', 'ultimate-member' ) );
|
701 |
+
}
|
702 |
+
break;
|
703 |
+
|
704 |
+
case 'youtube_url':
|
705 |
+
if ( ! UM()->validation()->is_url( $args[ $key ], 'youtube.com' ) && ! UM()->validation()->is_url( $args[ $key ], 'youtu.be' ) ) {
|
706 |
+
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
707 |
+
}
|
708 |
+
break;
|
709 |
+
|
710 |
+
case 'telegram_url':
|
711 |
+
if ( ! UM()->validation()->is_url( $args[ $key ], 't.me' ) ) {
|
712 |
+
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
713 |
+
}
|
714 |
+
break;
|
715 |
+
|
716 |
+
case 'soundcloud_url':
|
717 |
+
if ( ! UM()->validation()->is_url( $args[ $key ], 'soundcloud.com' ) ) {
|
718 |
+
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL','ultimate-member'), $array['label'] ) );
|
719 |
+
}
|
720 |
+
break;
|
721 |
+
|
722 |
+
case 'facebook_url':
|
723 |
+
if ( ! UM()->validation()->is_url( $args[ $key ], 'facebook.com' ) ) {
|
724 |
+
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
725 |
+
}
|
726 |
+
break;
|
727 |
+
|
728 |
+
case 'twitter_url':
|
729 |
+
if ( ! UM()->validation()->is_url( $args[ $key ], 'twitter.com' ) ) {
|
730 |
+
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
731 |
+
}
|
732 |
+
break;
|
733 |
+
|
734 |
+
case 'instagram_url':
|
735 |
+
|
736 |
+
if ( ! UM()->validation()->is_url( $args[ $key ], 'instagram.com' ) ) {
|
737 |
+
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s profile URL', 'ultimate-member' ), $array['label'] ) );
|
738 |
+
}
|
739 |
+
break;
|
740 |
+
|
741 |
+
case 'google_url':
|
742 |
+
if ( ! UM()->validation()->is_url( $args[ $key ], 'plus.google.com' ) ) {
|
743 |
+
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
744 |
+
}
|
745 |
+
break;
|
746 |
+
|
747 |
+
case 'linkedin_url':
|
748 |
+
if ( ! UM()->validation()->is_url( $args[ $key ], 'linkedin.com' ) ) {
|
749 |
+
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
750 |
+
}
|
751 |
+
break;
|
752 |
+
|
753 |
+
case 'vk_url':
|
754 |
+
if ( ! UM()->validation()->is_url( $args[ $key ], 'vk.com' ) ) {
|
755 |
+
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
|
756 |
+
}
|
757 |
+
break;
|
758 |
+
|
759 |
+
case 'discord':
|
760 |
+
if ( ! UM()->validation()->is_discord_id( $args[ $key ] ) ) {
|
761 |
+
UM()->form()->add_error( $key, __( 'Please enter a valid Discord ID', 'ultimate-member' ) );
|
762 |
+
}
|
763 |
+
break;
|
764 |
+
|
765 |
+
case 'url':
|
766 |
+
if ( ! UM()->validation()->is_url( $args[ $key ] ) ) {
|
767 |
+
UM()->form()->add_error( $key, __( 'Please enter a valid URL', 'ultimate-member' ) );
|
768 |
+
}
|
769 |
+
break;
|
770 |
+
|
771 |
+
case 'unique_username':
|
772 |
+
|
773 |
+
if ( $args[ $key ] == '' ) {
|
774 |
+
UM()->form()->add_error( $key, __( 'You must provide a username', 'ultimate-member' ) );
|
775 |
+
} elseif ( $mode == 'register' && username_exists( sanitize_user( $args[ $key ] ) ) ) {
|
776 |
+
UM()->form()->add_error( $key, __( 'The username you entered is incorrect', 'ultimate-member' ) );
|
777 |
+
} elseif ( is_email( $args[ $key ] ) ) {
|
778 |
+
UM()->form()->add_error( $key, __( 'Username cannot be an email', 'ultimate-member' ) );
|
779 |
+
} elseif ( ! UM()->validation()->safe_username( $args[ $key ] ) ) {
|
780 |
+
UM()->form()->add_error( $key, __( 'Your username contains invalid characters', 'ultimate-member' ) );
|
781 |
+
}
|
782 |
+
|
783 |
+
break;
|
784 |
+
|
785 |
+
case 'unique_username_or_email':
|
786 |
+
|
787 |
+
if ( $args[ $key ] == '' ) {
|
788 |
+
UM()->form()->add_error( $key, __( 'You must provide a username or email', 'ultimate-member' ) );
|
789 |
+
} elseif ( $mode == 'register' && username_exists( sanitize_user( $args[ $key ] ) ) ) {
|
790 |
+
UM()->form()->add_error( $key, __( 'The username you entered is incorrect', 'ultimate-member' ) );
|
791 |
+
} elseif ( $mode == 'register' && email_exists( $args[ $key ] ) ) {
|
792 |
+
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
793 |
+
} elseif ( ! UM()->validation()->safe_username( $args[ $key ] ) ) {
|
794 |
+
UM()->form()->add_error( $key, __( 'Your username contains invalid characters', 'ultimate-member' ) );
|
795 |
+
}
|
796 |
+
|
797 |
+
break;
|
798 |
+
|
799 |
+
case 'unique_email':
|
800 |
+
|
801 |
+
$args[ $key ] = trim( $args[ $key ] );
|
802 |
+
|
803 |
+
if ( in_array( $key, array( 'user_email' ) ) ) {
|
804 |
+
|
805 |
+
if ( ! isset( $args['user_id'] ) ){
|
806 |
+
$args['user_id'] = um_get_requested_user();
|
807 |
+
}
|
808 |
+
|
809 |
+
$email_exists = email_exists( $args[ $key ] );
|
810 |
+
|
811 |
+
if ( $args[ $key ] == '' && in_array( $key, array( 'user_email' ) ) ) {
|
812 |
+
UM()->form()->add_error( $key, __( 'You must provide your email', 'ultimate-member' ) );
|
813 |
+
} elseif ( in_array( $mode, array( 'register' ) ) && $email_exists ) {
|
814 |
+
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
815 |
+
} elseif ( in_array( $mode, array( 'profile' ) ) && $email_exists && $email_exists != $args['user_id'] ) {
|
816 |
+
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
817 |
+
} elseif ( ! is_email( $args[ $key ] ) ) {
|
818 |
+
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member') );
|
819 |
+
} elseif ( ! UM()->validation()->safe_username( $args[ $key ] ) ) {
|
820 |
+
UM()->form()->add_error( $key, __( 'Your email contains invalid characters', 'ultimate-member' ) );
|
821 |
+
}
|
822 |
+
|
823 |
+
} else {
|
824 |
+
|
825 |
+
if ( $args[ $key ] != '' && ! is_email( $args[ $key ] ) ) {
|
826 |
+
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
827 |
+
} elseif ( $args[ $key ] != '' && email_exists( $args[ $key ] ) ) {
|
828 |
+
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
829 |
+
} elseif ( $args[ $key ] != '' ) {
|
830 |
+
|
831 |
+
$users = get_users( 'meta_value=' . $args[ $key ] );
|
832 |
+
|
833 |
+
foreach ( $users as $user ) {
|
834 |
+
if ( $user->ID != $args['user_id'] ) {
|
835 |
+
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
836 |
+
}
|
837 |
+
}
|
838 |
+
|
839 |
+
}
|
840 |
+
|
841 |
+
}
|
842 |
+
|
843 |
+
break;
|
844 |
+
|
845 |
+
case 'is_email':
|
846 |
+
|
847 |
+
$args[ $key ] = trim( $args[ $key ] );
|
848 |
+
|
849 |
+
if ( $args[ $key ] != '' && ! is_email( $args[ $key ] ) ) {
|
850 |
+
UM()->form()->add_error( $key, __( 'This is not a valid email', 'ultimate-member' ) );
|
851 |
+
}
|
852 |
+
|
853 |
+
break;
|
854 |
+
|
855 |
+
case 'unique_value':
|
856 |
+
|
857 |
+
if ( $args[ $key ] != '' ) {
|
858 |
+
|
859 |
+
$args_unique_meta = array(
|
860 |
+
'meta_key' => $key,
|
861 |
+
'meta_value' => $args[ $key ],
|
862 |
+
'compare' => '=',
|
863 |
+
'exclude' => array( $args['user_id'] ),
|
864 |
+
);
|
865 |
+
|
866 |
+
$meta_key_exists = get_users( $args_unique_meta );
|
867 |
+
|
868 |
+
if ( $meta_key_exists ) {
|
869 |
+
UM()->form()->add_error( $key , __( 'You must provide a unique value', 'ultimate-member' ) );
|
870 |
+
}
|
871 |
+
}
|
872 |
+
break;
|
873 |
+
|
874 |
+
case 'alphabetic':
|
875 |
+
|
876 |
+
if ( $args[ $key ] != '' ) {
|
877 |
+
|
878 |
+
if ( ! preg_match( '/^\p{L}+$/u', str_replace( ' ', '', $args[ $key ] ) ) ) {
|
879 |
+
UM()->form()->add_error( $key, __( 'You must provide alphabetic letters', 'ultimate-member' ) );
|
880 |
+
}
|
881 |
+
|
882 |
+
}
|
883 |
+
|
884 |
+
break;
|
885 |
+
|
886 |
+
case 'lowercase':
|
887 |
+
|
888 |
+
if ( $args[ $key ] != '' ) {
|
889 |
+
|
890 |
+
if ( ! ctype_lower( str_replace(' ', '', $args[ $key ] ) ) ) {
|
891 |
+
UM()->form()->add_error( $key , __( 'You must provide lowercase letters.', 'ultimate-member' ) );
|
892 |
+
}
|
893 |
+
}
|
894 |
+
|
895 |
+
break;
|
896 |
+
|
897 |
+
}
|
898 |
+
|
899 |
+
}
|
900 |
+
|
901 |
+
}
|
902 |
+
|
903 |
+
if ( isset( $args['description'] ) ) {
|
904 |
+
$max_chars = UM()->options()->get( 'profile_bio_maxchars' );
|
905 |
+
$profile_show_bio = UM()->options()->get( 'profile_show_bio' );
|
906 |
+
|
907 |
+
if ( $profile_show_bio ) {
|
908 |
+
if ( mb_strlen( str_replace( array( "\r\n", "\n", "\r\t", "\t" ), ' ', $args['description'] ) ) > $max_chars && $max_chars ) {
|
909 |
+
UM()->form()->add_error( 'description', sprintf( __( 'Your user description must contain less than %s characters', 'ultimate-member' ), $max_chars ) );
|
910 |
+
}
|
911 |
+
}
|
912 |
+
|
913 |
+
}
|
914 |
+
|
915 |
+
} // end if ( isset in args array )
|
916 |
+
}
|
917 |
+
}
|
918 |
+
add_action( 'um_submit_form_errors_hook_', 'um_submit_form_errors_hook_', 10 );
|
919 |
+
|
920 |
+
|
921 |
+
/**
|
922 |
+
* @param string $url
|
923 |
+
*
|
924 |
+
* @return string
|
925 |
+
*/
|
926 |
+
function um_invalid_nonce_redirect_url( $url ) {
|
927 |
+
$url = add_query_arg( [
|
928 |
+
'um-hash' => substr( md5( rand() ), 0, 6 ),
|
929 |
+
], remove_query_arg( 'um-hash', $url ) );
|
930 |
+
|
931 |
+
return $url;
|
932 |
+
}
|
933 |
+
add_filter( 'um_login_invalid_nonce_redirect_url', 'um_invalid_nonce_redirect_url', 10, 1 );
|
934 |
+
add_filter( 'um_register_invalid_nonce_redirect_url', 'um_invalid_nonce_redirect_url', 10, 1 );
|
includes/core/um-actions-login.php
CHANGED
@@ -1,481 +1,481 @@
|
|
1 |
-
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
2 |
-
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Error procesing hook for login
|
6 |
-
*
|
7 |
-
* @param $args
|
8 |
-
*/
|
9 |
-
function um_submit_form_errors_hook_login( $args ) {
|
10 |
-
$is_email = false;
|
11 |
-
|
12 |
-
$form_id = $args['form_id'];
|
13 |
-
$mode = $args['mode'];
|
14 |
-
$user_password = $args['user_password'];
|
15 |
-
|
16 |
-
|
17 |
-
if ( isset( $args['username'] ) && $args['username'] == '' ) {
|
18 |
-
UM()->form()->add_error( 'username', __( 'Please enter your username or email', 'ultimate-member' ) );
|
19 |
-
}
|
20 |
-
|
21 |
-
if ( isset( $args['user_login'] ) && $args['user_login'] == '' ) {
|
22 |
-
UM()->form()->add_error( 'user_login', __( 'Please enter your username', 'ultimate-member' ) );
|
23 |
-
}
|
24 |
-
|
25 |
-
if ( isset( $args['user_email'] ) && $args['user_email'] == '' ) {
|
26 |
-
UM()->form()->add_error( 'user_email', __( 'Please enter your email', 'ultimate-member' ) );
|
27 |
-
}
|
28 |
-
|
29 |
-
if ( isset( $args['username'] ) ) {
|
30 |
-
$authenticate = $args['username'];
|
31 |
-
$field = 'username';
|
32 |
-
if ( is_email( $args['username'] ) ) {
|
33 |
-
$is_email = true;
|
34 |
-
$data = get_user_by('email', $args['username'] );
|
35 |
-
$user_name = isset( $data->user_login ) ? $data->user_login : null;
|
36 |
-
} else {
|
37 |
-
$user_name = $args['username'];
|
38 |
-
}
|
39 |
-
} elseif ( isset( $args['user_email'] ) ) {
|
40 |
-
$authenticate = $args['user_email'];
|
41 |
-
$field = 'user_email';
|
42 |
-
$is_email = true;
|
43 |
-
$data = get_user_by('email', $args['user_email'] );
|
44 |
-
$user_name = isset( $data->user_login ) ? $data->user_login : null;
|
45 |
-
} else {
|
46 |
-
$field = 'user_login';
|
47 |
-
$user_name = $args['user_login'];
|
48 |
-
$authenticate = $args['user_login'];
|
49 |
-
}
|
50 |
-
|
51 |
-
if ( $args['user_password'] == '' ) {
|
52 |
-
UM()->form()->add_error( 'user_password', __( 'Please enter your password', 'ultimate-member' ) );
|
53 |
-
}
|
54 |
-
|
55 |
-
$user = get_user_by( 'login', $user_name );
|
56 |
-
if ( $user && wp_check_password( $args['user_password'], $user->data->user_pass, $user->ID ) ) {
|
57 |
-
UM()->login()->auth_id = username_exists( $user_name );
|
58 |
-
} else {
|
59 |
-
UM()->form()->add_error( 'user_password', __( 'Password is incorrect. Please try again.', 'ultimate-member' ) );
|
60 |
-
}
|
61 |
-
|
62 |
-
// @since 4.18 replacement for 'wp_login_failed' action hook
|
63 |
-
// see WP function wp_authenticate()
|
64 |
-
$ignore_codes = array( 'empty_username', 'empty_password' );
|
65 |
-
|
66 |
-
$user = apply_filters( 'authenticate', null, $authenticate, $args['user_password'] );
|
67 |
-
if ( is_wp_error( $user ) && ! in_array( $user->get_error_code(), $ignore_codes ) ) {
|
68 |
-
UM()->form()->add_error( $user->get_error_code(), __( 'Password is incorrect. Please try again.', 'ultimate-member' ) );
|
69 |
-
}
|
70 |
-
|
71 |
-
$user = apply_filters( 'wp_authenticate_user', $user, $args['user_password'] );
|
72 |
-
if ( is_wp_error( $user ) && ! in_array( $user->get_error_code(), $ignore_codes ) ) {
|
73 |
-
UM()->form()->add_error( $user->get_error_code(), __( 'Password is incorrect. Please try again.', 'ultimate-member' ) );
|
74 |
-
}
|
75 |
-
|
76 |
-
// if there is an error notify wp
|
77 |
-
if ( UM()->form()->has_error( $field ) || UM()->form()->has_error( $user_password ) || UM()->form()->count_errors() > 0 ) {
|
78 |
-
do_action( 'wp_login_failed', $user_name, UM()->form()->get_wp_error() );
|
79 |
-
}
|
80 |
-
}
|
81 |
-
add_action( 'um_submit_form_errors_hook_login', 'um_submit_form_errors_hook_login', 10 );
|
82 |
-
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Display the login errors from other plugins
|
86 |
-
*
|
87 |
-
* @param $args
|
88 |
-
*/
|
89 |
-
function um_display_login_errors( $args ) {
|
90 |
-
if ( UM()->form()->count_errors() > 0 ) {
|
91 |
-
$errors = UM()->form()->errors;
|
92 |
-
// hook for other plugins to display error
|
93 |
-
$error_keys = array_keys( $errors );
|
94 |
-
}
|
95 |
-
|
96 |
-
if ( isset( $args['custom_fields'] ) ) {
|
97 |
-
$custom_fields = $args['custom_fields'];
|
98 |
-
}
|
99 |
-
|
100 |
-
if ( ! empty( $error_keys ) && ! empty( $custom_fields ) ) {
|
101 |
-
foreach ( $error_keys as $error ) {
|
102 |
-
if ( trim( $error ) && ! isset( $custom_fields[ $error ] ) && ! empty( $errors[ $error ] ) ) {
|
103 |
-
$error_message = apply_filters( 'login_errors', $errors[ $error ], $error );
|
104 |
-
if ( empty( $error_message ) ) {
|
105 |
-
return;
|
106 |
-
}
|
107 |
-
echo '<p class="um-notice err um-error-code-' . esc_attr( $error ) . '"><i class="um-icon-ios-close-empty" onclick="jQuery(this).parent().fadeOut();"></i>' . $error_message . '</p>';
|
108 |
-
}
|
109 |
-
}
|
110 |
-
}
|
111 |
-
}
|
112 |
-
add_action( 'um_before_login_fields', 'um_display_login_errors' );
|
113 |
-
|
114 |
-
|
115 |
-
/**
|
116 |
-
* Login checks thru the frontend login
|
117 |
-
*
|
118 |
-
* @param $args
|
119 |
-
*/
|
120 |
-
function um_submit_form_errors_hook_logincheck( $args ) {
|
121 |
-
// Logout if logged in
|
122 |
-
if ( is_user_logged_in() ) {
|
123 |
-
wp_logout();
|
124 |
-
}
|
125 |
-
|
126 |
-
$user_id = ( isset( UM()->login()->auth_id ) ) ? UM()->login()->auth_id : '';
|
127 |
-
um_fetch_user( $user_id );
|
128 |
-
|
129 |
-
$status = um_user( 'account_status' ); // account status
|
130 |
-
switch ( $status ) {
|
131 |
-
|
132 |
-
// If user can't login to site...
|
133 |
-
case 'inactive':
|
134 |
-
case 'awaiting_admin_review':
|
135 |
-
case 'awaiting_email_confirmation':
|
136 |
-
case 'rejected':
|
137 |
-
um_reset_user();
|
138 |
-
exit( wp_redirect( add_query_arg( 'err', esc_attr( $status ), UM()->permalinks()->get_current_url() ) ) );
|
139 |
-
break;
|
140 |
-
|
141 |
-
}
|
142 |
-
|
143 |
-
if ( isset( $args['form_id'] ) && $args['form_id'] == UM()->shortcodes()->core_login_form() && UM()->form()->errors && ! isset( $_POST[ UM()->honeypot ] ) ) {
|
144 |
-
exit( wp_redirect( um_get_core_page( 'login' ) ) );
|
145 |
-
}
|
146 |
-
|
147 |
-
}
|
148 |
-
add_action( 'um_submit_form_errors_hook_logincheck', 'um_submit_form_errors_hook_logincheck', 9999 );
|
149 |
-
|
150 |
-
|
151 |
-
/**
|
152 |
-
* Store last login timestamp
|
153 |
-
*
|
154 |
-
* @param $user_id
|
155 |
-
*/
|
156 |
-
function um_store_lastlogin_timestamp( $user_id ) {
|
157 |
-
update_user_meta( $user_id, '_um_last_login', current_time( 'timestamp' ) );
|
158 |
-
}
|
159 |
-
add_action( 'um_on_login_before_redirect', 'um_store_lastlogin_timestamp', 10, 1 );
|
160 |
-
|
161 |
-
|
162 |
-
/**
|
163 |
-
* @param $login
|
164 |
-
*/
|
165 |
-
function um_store_lastlogin_timestamp_( $login ) {
|
166 |
-
$user = get_user_by( 'login', $login );
|
167 |
-
|
168 |
-
if ( false !== $user ) {
|
169 |
-
um_store_lastlogin_timestamp( $user->ID );
|
170 |
-
|
171 |
-
$attempts = (int) get_user_meta( $user->ID, 'password_rst_attempts', true );
|
172 |
-
if ( $attempts ) {
|
173 |
-
//don't create meta but update if it's exists only
|
174 |
-
update_user_meta( $user->ID, 'password_rst_attempts', 0 );
|
175 |
-
}
|
176 |
-
}
|
177 |
-
}
|
178 |
-
add_action( 'wp_login', 'um_store_lastlogin_timestamp_' );
|
179 |
-
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Login user process
|
183 |
-
*
|
184 |
-
* @param array $args
|
185 |
-
*/
|
186 |
-
function um_user_login( $args ) {
|
187 |
-
extract( $args );
|
188 |
-
|
189 |
-
$rememberme = ( isset( $args['rememberme'] ) && 1 == $args['rememberme'] && isset( $_REQUEST['rememberme'] ) ) ? 1 : 0;
|
190 |
-
|
191 |
-
if ( ( UM()->options()->get( 'deny_admin_frontend_login' ) && ! isset( $_GET['provider'] ) ) && strrpos( um_user('wp_roles' ), 'administrator' ) !== false ) {
|
192 |
-
wp_die( esc_html__( 'This action has been prevented for security measures.', 'ultimate-member' ) );
|
193 |
-
}
|
194 |
-
|
195 |
-
UM()->user()->auto_login( um_user( 'ID' ), $rememberme );
|
196 |
-
|
197 |
-
/**
|
198 |
-
* UM hook
|
199 |
-
*
|
200 |
-
* @type action
|
201 |
-
* @title um_on_login_before_redirect
|
202 |
-
* @description Hook that runs after successful login and before user is redirected
|
203 |
-
* @input_vars
|
204 |
-
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
205 |
-
* @change_log
|
206 |
-
* ["Since: 2.0"]
|
207 |
-
* @usage add_action( 'um_on_login_before_redirect', 'function_name', 10, 1 );
|
208 |
-
* @example
|
209 |
-
* <?php
|
210 |
-
* add_action( 'um_on_login_before_redirect', 'my_on_login_before_redirect', 10, 1 );
|
211 |
-
* function my_on_login_before_redirect( $user_id ) {
|
212 |
-
* // your code here
|
213 |
-
* }
|
214 |
-
* ?>
|
215 |
-
*/
|
216 |
-
do_action( 'um_on_login_before_redirect', um_user( 'ID' ) );
|
217 |
-
|
218 |
-
// Priority redirect
|
219 |
-
if ( ! empty( $args['redirect_to'] ) ) {
|
220 |
-
exit( wp_safe_redirect( $args['redirect_to'] ) );
|
221 |
-
}
|
222 |
-
|
223 |
-
// Role redirect
|
224 |
-
$after_login = um_user( 'after_login' );
|
225 |
-
if ( empty( $after_login ) ) {
|
226 |
-
exit( wp_redirect( um_user_profile_url() ) );
|
227 |
-
}
|
228 |
-
|
229 |
-
switch ( $after_login ) {
|
230 |
-
|
231 |
-
case 'redirect_admin':
|
232 |
-
exit( wp_redirect( admin_url() ) );
|
233 |
-
break;
|
234 |
-
|
235 |
-
case 'redirect_url':
|
236 |
-
/**
|
237 |
-
* UM hook
|
238 |
-
*
|
239 |
-
* @type filter
|
240 |
-
* @title um_login_redirect_url
|
241 |
-
* @description Change redirect URL after successful login
|
242 |
-
* @input_vars
|
243 |
-
* [{"var":"$url","type":"string","desc":"Redirect URL"},
|
244 |
-
* {"var":"$id","type":"int","desc":"User ID"}]
|
245 |
-
* @change_log
|
246 |
-
* ["Since: 2.0"]
|
247 |
-
* @usage
|
248 |
-
* <?php add_filter( 'um_login_redirect_url', 'function_name', 10, 2 ); ?>
|
249 |
-
* @example
|
250 |
-
* <?php
|
251 |
-
* add_filter( 'um_login_redirect_url', 'my_login_redirect_url', 10, 2 );
|
252 |
-
* function my_login_redirect_url( $url, $id ) {
|
253 |
-
* // your code here
|
254 |
-
* return $url;
|
255 |
-
* }
|
256 |
-
* ?>
|
257 |
-
*/
|
258 |
-
$redirect_url = apply_filters( 'um_login_redirect_url', um_user( 'login_redirect_url' ), um_user( 'ID' ) );
|
259 |
-
exit( wp_redirect( $redirect_url ) );
|
260 |
-
break;
|
261 |
-
|
262 |
-
case 'refresh':
|
263 |
-
exit( wp_redirect( UM()->permalinks()->get_current_url() ) );
|
264 |
-
break;
|
265 |
-
|
266 |
-
case 'redirect_profile':
|
267 |
-
default:
|
268 |
-
exit( wp_redirect( um_user_profile_url() ) );
|
269 |
-
break;
|
270 |
-
|
271 |
-
}
|
272 |
-
}
|
273 |
-
add_action( 'um_user_login', 'um_user_login', 10 );
|
274 |
-
|
275 |
-
|
276 |
-
/**
|
277 |
-
* Form processing
|
278 |
-
*
|
279 |
-
* @param $args
|
280 |
-
*/
|
281 |
-
function um_submit_form_login( $args ) {
|
282 |
-
|
283 |
-
if ( ! isset( UM()->form()->errors ) ) {
|
284 |
-
/**
|
285 |
-
* UM hook
|
286 |
-
*
|
287 |
-
* @type action
|
288 |
-
* @title um_user_login
|
289 |
-
* @description Hook that runs after successful submit login form
|
290 |
-
* @input_vars
|
291 |
-
* [{"var":"$args","type":"array","desc":"Form data"}]
|
292 |
-
* @change_log
|
293 |
-
* ["Since: 2.0"]
|
294 |
-
* @usage add_action( 'um_user_login', 'function_name', 10, 1 );
|
295 |
-
* @example
|
296 |
-
* <?php
|
297 |
-
* add_action( 'um_user_login', 'my_user_login', 10, 1 );
|
298 |
-
* function my_user_login( $args ) {
|
299 |
-
* // your code here
|
300 |
-
* }
|
301 |
-
* ?>
|
302 |
-
*/
|
303 |
-
do_action( 'um_user_login', $args );
|
304 |
-
}
|
305 |
-
|
306 |
-
/**
|
307 |
-
* UM hook
|
308 |
-
*
|
309 |
-
* @type action
|
310 |
-
* @title um_user_login_extra_hook
|
311 |
-
* @description Hook that runs after successful submit login form
|
312 |
-
* @input_vars
|
313 |
-
* [{"var":"$args","type":"array","desc":"Form data"}]
|
314 |
-
* @change_log
|
315 |
-
* ["Since: 2.0"]
|
316 |
-
* @usage add_action( 'um_user_login_extra_hook', 'function_name', 10, 1 );
|
317 |
-
* @example
|
318 |
-
* <?php
|
319 |
-
* add_action( 'um_user_login_extra_hook', 'my_user_login_extra', 10, 1 );
|
320 |
-
* function my_user_login_extra( $args ) {
|
321 |
-
* // your code here
|
322 |
-
* }
|
323 |
-
* ?>
|
324 |
-
*/
|
325 |
-
do_action( 'um_user_login_extra_hook', $args );
|
326 |
-
}
|
327 |
-
add_action( 'um_submit_form_login', 'um_submit_form_login', 10 );
|
328 |
-
|
329 |
-
|
330 |
-
/**
|
331 |
-
* Show the submit button
|
332 |
-
*
|
333 |
-
* @param $args
|
334 |
-
*/
|
335 |
-
function um_add_submit_button_to_login( $args ) {
|
336 |
-
/**
|
337 |
-
* UM hook
|
338 |
-
*
|
339 |
-
* @type filter
|
340 |
-
* @title um_login_form_button_one
|
341 |
-
* @description Change Login Form Primary button
|
342 |
-
* @input_vars
|
343 |
-
* [{"var":"$primary_btn_word","type":"string","desc":"Button text"},
|
344 |
-
* {"var":"$args","type":"array","desc":"Login Form arguments"}]
|
345 |
-
* @change_log
|
346 |
-
* ["Since: 2.0"]
|
347 |
-
* @usage
|
348 |
-
* <?php add_filter( 'um_login_form_button_one', 'function_name', 10, 2 ); ?>
|
349 |
-
* @example
|
350 |
-
* <?php
|
351 |
-
* add_filter( 'um_login_form_button_one', 'my_login_form_button_one', 10, 2 );
|
352 |
-
* function my_login_form_button_one( $primary_btn_word, $args ) {
|
353 |
-
* // your code here
|
354 |
-
* return $primary_btn_word;
|
355 |
-
* }
|
356 |
-
* ?>
|
357 |
-
*/
|
358 |
-
$primary_btn_word = apply_filters('um_login_form_button_one', $args['primary_btn_word'], $args );
|
359 |
-
|
360 |
-
if ( ! isset( $primary_btn_word ) || $primary_btn_word == '' ){
|
361 |
-
$primary_btn_word = UM()->options()->get( 'login_primary_btn_word' );
|
362 |
-
}
|
363 |
-
|
364 |
-
/**
|
365 |
-
* UM hook
|
366 |
-
*
|
367 |
-
* @type filter
|
368 |
-
* @title um_login_form_button_two
|
369 |
-
* @description Change Login Form Secondary button
|
370 |
-
* @input_vars
|
371 |
-
* [{"var":"$secondary_btn_word","type":"string","desc":"Button text"},
|
372 |
-
* {"var":"$args","type":"array","desc":"Login Form arguments"}]
|
373 |
-
* @change_log
|
374 |
-
* ["Since: 2.0"]
|
375 |
-
* @usage
|
376 |
-
* <?php add_filter( 'um_login_form_button_two', 'function_name', 10, 2 ); ?>
|
377 |
-
* @example
|
378 |
-
* <?php
|
379 |
-
* add_filter( 'um_login_form_button_two', 'my_login_form_button_two', 10, 2 );
|
380 |
-
* function my_login_form_button_two( $secondary_btn_word, $args ) {
|
381 |
-
* // your code here
|
382 |
-
* return $secondary_btn_word;
|
383 |
-
* }
|
384 |
-
* ?>
|
385 |
-
*/
|
386 |
-
$secondary_btn_word = apply_filters( 'um_login_form_button_two', $args['secondary_btn_word'], $args );
|
387 |
-
|
388 |
-
if ( ! isset( $secondary_btn_word ) || $secondary_btn_word == '' ){
|
389 |
-
$secondary_btn_word = UM()->options()->get( 'login_secondary_btn_word' );
|
390 |
-
}
|
391 |
-
|
392 |
-
$secondary_btn_url = ! empty( $args['secondary_btn_url'] ) ? $args['secondary_btn_url'] : um_get_core_page( 'register' );
|
393 |
-
/**
|
394 |
-
* UM hook
|
395 |
-
*
|
396 |
-
* @type filter
|
397 |
-
* @title um_login_form_button_two_url
|
398 |
-
* @description Change Login Form Secondary button URL
|
399 |
-
* @input_vars
|
400 |
-
* [{"var":"$secondary_btn_url","type":"string","desc":"Button URL"},
|
401 |
-
* {"var":"$args","type":"array","desc":"Login Form arguments"}]
|
402 |
-
* @change_log
|
403 |
-
* ["Since: 2.0"]
|
404 |
-
* @usage
|
405 |
-
* <?php add_filter( 'um_login_form_button_two_url', 'function_name', 10, 2 ); ?>
|
406 |
-
* @example
|
407 |
-
* <?php
|
408 |
-
* add_filter( 'um_login_form_button_two_url', 'my_login_form_button_two_url', 10, 2 );
|
409 |
-
* function my_login_form_button_two_url( $secondary_btn_url, $args ) {
|
410 |
-
* // your code here
|
411 |
-
* return $secondary_btn_url;
|
412 |
-
* }
|
413 |
-
* ?>
|
414 |
-
*/
|
415 |
-
$secondary_btn_url = apply_filters( 'um_login_form_button_two_url', $secondary_btn_url, $args ); ?>
|
416 |
-
|
417 |
-
<div class="um-col-alt">
|
418 |
-
|
419 |
-
<?php if ( ! empty( $args['show_rememberme'] ) ) {
|
420 |
-
UM()->fields()->checkbox( 'rememberme', __( 'Keep me signed in', 'ultimate-member' ), false ); ?>
|
421 |
-
<div class="um-clear"></div>
|
422 |
-
<?php }
|
423 |
-
|
424 |
-
if ( ! empty( $args['secondary_btn'] ) ) { ?>
|
425 |
-
|
426 |
-
<div class="um-left um-half">
|
427 |
-
<input type="submit" value="<?php esc_attr_e( wp_unslash( $primary_btn_word ), 'ultimate-member' ); ?>" class="um-button" id="um-submit-btn" />
|
428 |
-
</div>
|
429 |
-
<div class="um-right um-half">
|
430 |
-
<a href="<?php echo esc_url( $secondary_btn_url ); ?>" class="um-button um-alt">
|
431 |
-
<?php _e( wp_unslash( $secondary_btn_word ), 'ultimate-member' ); ?>
|
432 |
-
</a>
|
433 |
-
</div>
|
434 |
-
|
435 |
-
<?php } else { ?>
|
436 |
-
|
437 |
-
<div class="um-center">
|
438 |
-
<input type="submit" value="<?php esc_attr_e( wp_unslash( $primary_btn_word ), 'ultimate-member' ); ?>" class="um-button" id="um-submit-btn" />
|
439 |
-
</div>
|
440 |
-
|
441 |
-
<?php } ?>
|
442 |
-
|
443 |
-
<div class="um-clear"></div>
|
444 |
-
|
445 |
-
</div>
|
446 |
-
|
447 |
-
<?php
|
448 |
-
}
|
449 |
-
add_action( 'um_after_login_fields', 'um_add_submit_button_to_login', 1000 );
|
450 |
-
|
451 |
-
|
452 |
-
/**
|
453 |
-
* Display a forgot password link
|
454 |
-
*
|
455 |
-
* @param $args
|
456 |
-
*/
|
457 |
-
function um_after_login_submit( $args ) {
|
458 |
-
if ( empty( $args['forgot_pass_link'] ) ) {
|
459 |
-
return;
|
460 |
-
} ?>
|
461 |
-
|
462 |
-
<div class="um-col-alt-b">
|
463 |
-
<a href="<?php echo esc_url( um_get_core_page( 'password-reset' ) ); ?>" class="um-link-alt">
|
464 |
-
<?php _e( 'Forgot your password?', 'ultimate-member' ); ?>
|
465 |
-
</a>
|
466 |
-
</div>
|
467 |
-
|
468 |
-
<?php
|
469 |
-
}
|
470 |
-
add_action( 'um_after_login_fields', 'um_after_login_submit', 1001 );
|
471 |
-
|
472 |
-
|
473 |
-
/**
|
474 |
-
* Show Fields
|
475 |
-
*
|
476 |
-
* @param $args
|
477 |
-
*/
|
478 |
-
function um_add_login_fields( $args ) {
|
479 |
-
echo UM()->fields()->display( 'login', $args );
|
480 |
-
}
|
481 |
-
add_action( 'um_main_login_fields', 'um_add_login_fields', 100 );
|
1 |
+
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
2 |
+
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Error procesing hook for login
|
6 |
+
*
|
7 |
+
* @param $args
|
8 |
+
*/
|
9 |
+
function um_submit_form_errors_hook_login( $args ) {
|
10 |
+
$is_email = false;
|
11 |
+
|
12 |
+
$form_id = $args['form_id'];
|
13 |
+
$mode = $args['mode'];
|
14 |
+
$user_password = $args['user_password'];
|
15 |
+
|
16 |
+
|
17 |
+
if ( isset( $args['username'] ) && $args['username'] == '' ) {
|
18 |
+
UM()->form()->add_error( 'username', __( 'Please enter your username or email', 'ultimate-member' ) );
|
19 |
+
}
|
20 |
+
|
21 |
+
if ( isset( $args['user_login'] ) && $args['user_login'] == '' ) {
|
22 |
+
UM()->form()->add_error( 'user_login', __( 'Please enter your username', 'ultimate-member' ) );
|
23 |
+
}
|
24 |
+
|
25 |
+
if ( isset( $args['user_email'] ) && $args['user_email'] == '' ) {
|
26 |
+
UM()->form()->add_error( 'user_email', __( 'Please enter your email', 'ultimate-member' ) );
|
27 |
+
}
|
28 |
+
|
29 |
+
if ( isset( $args['username'] ) ) {
|
30 |
+
$authenticate = $args['username'];
|
31 |
+
$field = 'username';
|
32 |
+
if ( is_email( $args['username'] ) ) {
|
33 |
+
$is_email = true;
|
34 |
+
$data = get_user_by('email', $args['username'] );
|
35 |
+
$user_name = isset( $data->user_login ) ? $data->user_login : null;
|
36 |
+
} else {
|
37 |
+
$user_name = $args['username'];
|
38 |
+
}
|
39 |
+
} elseif ( isset( $args['user_email'] ) ) {
|
40 |
+
$authenticate = $args['user_email'];
|
41 |
+
$field = 'user_email';
|
42 |
+
$is_email = true;
|
43 |
+
$data = get_user_by('email', $args['user_email'] );
|
44 |
+
$user_name = isset( $data->user_login ) ? $data->user_login : null;
|
45 |
+
} else {
|
46 |
+
$field = 'user_login';
|
47 |
+
$user_name = $args['user_login'];
|
48 |
+
$authenticate = $args['user_login'];
|
49 |
+
}
|
50 |
+
|
51 |
+
if ( $args['user_password'] == '' ) {
|
52 |
+
UM()->form()->add_error( 'user_password', __( 'Please enter your password', 'ultimate-member' ) );
|
53 |
+
}
|
54 |
+
|
55 |
+
$user = get_user_by( 'login', $user_name );
|
56 |
+
if ( $user && wp_check_password( $args['user_password'], $user->data->user_pass, $user->ID ) ) {
|
57 |
+
UM()->login()->auth_id = username_exists( $user_name );
|
58 |
+
} else {
|
59 |
+
UM()->form()->add_error( 'user_password', __( 'Password is incorrect. Please try again.', 'ultimate-member' ) );
|
60 |
+
}
|
61 |
+
|
62 |
+
// @since 4.18 replacement for 'wp_login_failed' action hook
|
63 |
+
// see WP function wp_authenticate()
|
64 |
+
$ignore_codes = array( 'empty_username', 'empty_password' );
|
65 |
+
|
66 |
+
$user = apply_filters( 'authenticate', null, $authenticate, $args['user_password'] );
|
67 |
+
if ( is_wp_error( $user ) && ! in_array( $user->get_error_code(), $ignore_codes ) ) {
|
68 |
+
UM()->form()->add_error( $user->get_error_code(), __( 'Password is incorrect. Please try again.', 'ultimate-member' ) );
|
69 |
+
}
|
70 |
+
|
71 |
+
$user = apply_filters( 'wp_authenticate_user', $user, $args['user_password'] );
|
72 |
+
if ( is_wp_error( $user ) && ! in_array( $user->get_error_code(), $ignore_codes ) ) {
|
73 |
+
UM()->form()->add_error( $user->get_error_code(), __( 'Password is incorrect. Please try again.', 'ultimate-member' ) );
|
74 |
+
}
|
75 |
+
|
76 |
+
// if there is an error notify wp
|
77 |
+
if ( UM()->form()->has_error( $field ) || UM()->form()->has_error( $user_password ) || UM()->form()->count_errors() > 0 ) {
|
78 |
+
do_action( 'wp_login_failed', $user_name, UM()->form()->get_wp_error() );
|
79 |
+
}
|
80 |
+
}
|
81 |
+
add_action( 'um_submit_form_errors_hook_login', 'um_submit_form_errors_hook_login', 10 );
|
82 |
+
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Display the login errors from other plugins
|
86 |
+
*
|
87 |
+
* @param $args
|
88 |
+
*/
|
89 |
+
function um_display_login_errors( $args ) {
|
90 |
+
if ( UM()->form()->count_errors() > 0 ) {
|
91 |
+
$errors = UM()->form()->errors;
|
92 |
+
// hook for other plugins to display error
|
93 |
+
$error_keys = array_keys( $errors );
|
94 |
+
}
|
95 |
+
|
96 |
+
if ( isset( $args['custom_fields'] ) ) {
|
97 |
+
$custom_fields = $args['custom_fields'];
|
98 |
+
}
|
99 |
+
|
100 |
+
if ( ! empty( $error_keys ) && ! empty( $custom_fields ) ) {
|
101 |
+
foreach ( $error_keys as $error ) {
|
102 |
+
if ( trim( $error ) && ! isset( $custom_fields[ $error ] ) && ! empty( $errors[ $error ] ) ) {
|
103 |
+
$error_message = apply_filters( 'login_errors', $errors[ $error ], $error );
|
104 |
+
if ( empty( $error_message ) ) {
|
105 |
+
return;
|
106 |
+
}
|
107 |
+
echo '<p class="um-notice err um-error-code-' . esc_attr( $error ) . '"><i class="um-icon-ios-close-empty" onclick="jQuery(this).parent().fadeOut();"></i>' . $error_message . '</p>';
|
108 |
+
}
|
109 |
+
}
|
110 |
+
}
|
111 |
+
}
|
112 |
+
add_action( 'um_before_login_fields', 'um_display_login_errors' );
|
113 |
+
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Login checks thru the frontend login
|
117 |
+
*
|
118 |
+
* @param $args
|
119 |
+
*/
|
120 |
+
function um_submit_form_errors_hook_logincheck( $args ) {
|
121 |
+
// Logout if logged in
|
122 |
+
if ( is_user_logged_in() ) {
|
123 |
+
wp_logout();
|
124 |
+
}
|
125 |
+
|
126 |
+
$user_id = ( isset( UM()->login()->auth_id ) ) ? UM()->login()->auth_id : '';
|
127 |
+
um_fetch_user( $user_id );
|
128 |
+
|
129 |
+
$status = um_user( 'account_status' ); // account status
|
130 |
+
switch ( $status ) {
|
131 |
+
|
132 |
+
// If user can't login to site...
|
133 |
+
case 'inactive':
|
134 |
+
case 'awaiting_admin_review':
|
135 |
+
case 'awaiting_email_confirmation':
|
136 |
+
case 'rejected':
|
137 |
+
um_reset_user();
|
138 |
+
exit( wp_redirect( add_query_arg( 'err', esc_attr( $status ), UM()->permalinks()->get_current_url() ) ) );
|
139 |
+
break;
|
140 |
+
|
141 |
+
}
|
142 |
+
|
143 |
+
if ( isset( $args['form_id'] ) && $args['form_id'] == UM()->shortcodes()->core_login_form() && UM()->form()->errors && ! isset( $_POST[ UM()->honeypot ] ) ) {
|
144 |
+
exit( wp_redirect( um_get_core_page( 'login' ) ) );
|
145 |
+
}
|
146 |
+
|
147 |
+
}
|
148 |
+
add_action( 'um_submit_form_errors_hook_logincheck', 'um_submit_form_errors_hook_logincheck', 9999 );
|
149 |
+
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Store last login timestamp
|
153 |
+
*
|
154 |
+
* @param $user_id
|
155 |
+
*/
|
156 |
+
function um_store_lastlogin_timestamp( $user_id ) {
|
157 |
+
update_user_meta( $user_id, '_um_last_login', current_time( 'timestamp' ) );
|
158 |
+
}
|
159 |
+
add_action( 'um_on_login_before_redirect', 'um_store_lastlogin_timestamp', 10, 1 );
|
160 |
+
|
161 |
+
|
162 |
+
/**
|
163 |
+
* @param $login
|
164 |
+
*/
|
165 |
+
function um_store_lastlogin_timestamp_( $login ) {
|
166 |
+
$user = get_user_by( 'login', $login );
|
167 |
+
|
168 |
+
if ( false !== $user ) {
|
169 |
+
um_store_lastlogin_timestamp( $user->ID );
|
170 |
+
|
171 |
+
$attempts = (int) get_user_meta( $user->ID, 'password_rst_attempts', true );
|
172 |
+
if ( $attempts ) {
|
173 |
+
//don't create meta but update if it's exists only
|
174 |
+
update_user_meta( $user->ID, 'password_rst_attempts', 0 );
|
175 |
+
}
|
176 |
+
}
|
177 |
+
}
|
178 |
+
add_action( 'wp_login', 'um_store_lastlogin_timestamp_' );
|
179 |
+
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Login user process
|
183 |
+
*
|
184 |
+
* @param array $args
|
185 |
+
*/
|
186 |
+
function um_user_login( $args ) {
|
187 |
+
extract( $args );
|
188 |
+
|
189 |
+
$rememberme = ( isset( $args['rememberme'] ) && 1 == $args['rememberme'] && isset( $_REQUEST['rememberme'] ) ) ? 1 : 0;
|
190 |
+
|
191 |
+
if ( ( UM()->options()->get( 'deny_admin_frontend_login' ) && ! isset( $_GET['provider'] ) ) && strrpos( um_user('wp_roles' ), 'administrator' ) !== false ) {
|
192 |
+
wp_die( esc_html__( 'This action has been prevented for security measures.', 'ultimate-member' ) );
|
193 |
+
}
|
194 |
+
|
195 |
+
UM()->user()->auto_login( um_user( 'ID' ), $rememberme );
|
196 |
+
|
197 |
+
/**
|
198 |
+
* UM hook
|
199 |
+
*
|
200 |
+
* @type action
|
201 |
+
* @title um_on_login_before_redirect
|
202 |
+
* @description Hook that runs after successful login and before user is redirected
|
203 |
+
* @input_vars
|
204 |
+
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
205 |
+
* @change_log
|
206 |
+
* ["Since: 2.0"]
|
207 |
+
* @usage add_action( 'um_on_login_before_redirect', 'function_name', 10, 1 );
|
208 |
+
* @example
|
209 |
+
* <?php
|
210 |
+
* add_action( 'um_on_login_before_redirect', 'my_on_login_before_redirect', 10, 1 );
|
211 |
+
* function my_on_login_before_redirect( $user_id ) {
|
212 |
+
* // your code here
|
213 |
+
* }
|
214 |
+
* ?>
|
215 |
+
*/
|
216 |
+
do_action( 'um_on_login_before_redirect', um_user( 'ID' ) );
|
217 |
+
|
218 |
+
// Priority redirect
|
219 |
+
if ( ! empty( $args['redirect_to'] ) ) {
|
220 |
+
exit( wp_safe_redirect( $args['redirect_to'] ) );
|
221 |
+
}
|
222 |
+
|
223 |
+
// Role redirect
|
224 |
+
$after_login = um_user( 'after_login' );
|
225 |
+
if ( empty( $after_login ) ) {
|
226 |
+
exit( wp_redirect( um_user_profile_url() ) );
|
227 |
+
}
|
228 |
+
|
229 |
+
switch ( $after_login ) {
|
230 |
+
|
231 |
+
case 'redirect_admin':
|
232 |
+
exit( wp_redirect( admin_url() ) );
|
233 |
+
break;
|
234 |
+
|
235 |
+
case 'redirect_url':
|
236 |
+
/**
|
237 |
+
* UM hook
|
238 |
+
*
|
239 |
+
* @type filter
|
240 |
+
* @title um_login_redirect_url
|
241 |
+
* @description Change redirect URL after successful login
|
242 |
+
* @input_vars
|
243 |
+
* [{"var":"$url","type":"string","desc":"Redirect URL"},
|
244 |
+
* {"var":"$id","type":"int","desc":"User ID"}]
|
245 |
+
* @change_log
|
246 |
+
* ["Since: 2.0"]
|
247 |
+
* @usage
|
248 |
+
* <?php add_filter( 'um_login_redirect_url', 'function_name', 10, 2 ); ?>
|
249 |
+
* @example
|
250 |
+
* <?php
|
251 |
+
* add_filter( 'um_login_redirect_url', 'my_login_redirect_url', 10, 2 );
|
252 |
+
* function my_login_redirect_url( $url, $id ) {
|
253 |
+
* // your code here
|
254 |
+
* return $url;
|
255 |
+
* }
|
256 |
+
* ?>
|
257 |
+
*/
|
258 |
+
$redirect_url = apply_filters( 'um_login_redirect_url', um_user( 'login_redirect_url' ), um_user( 'ID' ) );
|
259 |
+
exit( wp_redirect( $redirect_url ) );
|
260 |
+
break;
|
261 |
+
|
262 |
+
case 'refresh':
|
263 |
+
exit( wp_redirect( UM()->permalinks()->get_current_url() ) );
|
264 |
+
break;
|
265 |
+
|
266 |
+
case 'redirect_profile':
|
267 |
+
default:
|
268 |
+
exit( wp_redirect( um_user_profile_url() ) );
|
269 |
+
break;
|
270 |
+
|
271 |
+
}
|
272 |
+
}
|
273 |
+
add_action( 'um_user_login', 'um_user_login', 10 );
|
274 |
+
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Form processing
|
278 |
+
*
|
279 |
+
* @param $args
|
280 |
+
*/
|
281 |
+
function um_submit_form_login( $args ) {
|
282 |
+
|
283 |
+
if ( ! isset( UM()->form()->errors ) ) {
|
284 |
+
/**
|
285 |
+
* UM hook
|
286 |
+
*
|
287 |
+
* @type action
|
288 |
+
* @title um_user_login
|
289 |
+
* @description Hook that runs after successful submit login form
|
290 |
+
* @input_vars
|
291 |
+
* [{"var":"$args","type":"array","desc":"Form data"}]
|
292 |
+
* @change_log
|
293 |
+
* ["Since: 2.0"]
|
294 |
+
* @usage add_action( 'um_user_login', 'function_name', 10, 1 );
|
295 |
+
* @example
|
296 |
+
* <?php
|
297 |
+
* add_action( 'um_user_login', 'my_user_login', 10, 1 );
|
298 |
+
* function my_user_login( $args ) {
|
299 |
+
* // your code here
|
300 |
+
* }
|
301 |
+
* ?>
|
302 |
+
*/
|
303 |
+
do_action( 'um_user_login', $args );
|
304 |
+
}
|
305 |
+
|
306 |
+
/**
|
307 |
+
* UM hook
|
308 |
+
*
|
309 |
+
* @type action
|
310 |
+
* @title um_user_login_extra_hook
|
311 |
+
* @description Hook that runs after successful submit login form
|
312 |
+
* @input_vars
|
313 |
+
* [{"var":"$args","type":"array","desc":"Form data"}]
|
314 |
+
* @change_log
|
315 |
+
* ["Since: 2.0"]
|
316 |
+
* @usage add_action( 'um_user_login_extra_hook', 'function_name', 10, 1 );
|
317 |
+
* @example
|
318 |
+
* <?php
|
319 |
+
* add_action( 'um_user_login_extra_hook', 'my_user_login_extra', 10, 1 );
|
320 |
+
* function my_user_login_extra( $args ) {
|
321 |
+
* // your code here
|
322 |
+
* }
|
323 |
+
* ?>
|
324 |
+
*/
|
325 |
+
do_action( 'um_user_login_extra_hook', $args );
|
326 |
+
}
|
327 |
+
add_action( 'um_submit_form_login', 'um_submit_form_login', 10 );
|
328 |
+
|
329 |
+
|
330 |
+
/**
|
331 |
+
* Show the submit button
|
332 |
+
*
|
333 |
+
* @param $args
|
334 |
+
*/
|
335 |
+
function um_add_submit_button_to_login( $args ) {
|
336 |
+
/**
|
337 |
+
* UM hook
|
338 |
+
*
|
339 |
+
* @type filter
|
340 |
+
* @title um_login_form_button_one
|
341 |
+
* @description Change Login Form Primary button
|
342 |
+
* @input_vars
|
343 |
+
* [{"var":"$primary_btn_word","type":"string","desc":"Button text"},
|
344 |
+
* {"var":"$args","type":"array","desc":"Login Form arguments"}]
|
345 |
+
* @change_log
|
346 |
+
* ["Since: 2.0"]
|
347 |
+
* @usage
|
348 |
+
* <?php add_filter( 'um_login_form_button_one', 'function_name', 10, 2 ); ?>
|
349 |
+
* @example
|
350 |
+
* <?php
|
351 |
+
* add_filter( 'um_login_form_button_one', 'my_login_form_button_one', 10, 2 );
|
352 |
+
* function my_login_form_button_one( $primary_btn_word, $args ) {
|
353 |
+
* // your code here
|
354 |
+
* return $primary_btn_word;
|
355 |
+
* }
|
356 |
+
* ?>
|
357 |
+
*/
|
358 |
+
$primary_btn_word = apply_filters('um_login_form_button_one', $args['primary_btn_word'], $args );
|
359 |
+
|
360 |
+
if ( ! isset( $primary_btn_word ) || $primary_btn_word == '' ){
|
361 |
+
$primary_btn_word = UM()->options()->get( 'login_primary_btn_word' );
|
362 |
+
}
|
363 |
+
|
364 |
+
/**
|
365 |
+
* UM hook
|
366 |
+
*
|
367 |
+
* @type filter
|
368 |
+
* @title um_login_form_button_two
|
369 |
+
* @description Change Login Form Secondary button
|
370 |
+
* @input_vars
|
371 |
+
* [{"var":"$secondary_btn_word","type":"string","desc":"Button text"},
|
372 |
+
* {"var":"$args","type":"array","desc":"Login Form arguments"}]
|
373 |
+
* @change_log
|
374 |
+
* ["Since: 2.0"]
|
375 |
+
* @usage
|
376 |
+
* <?php add_filter( 'um_login_form_button_two', 'function_name', 10, 2 ); ?>
|
377 |
+
* @example
|
378 |
+
* <?php
|
379 |
+
* add_filter( 'um_login_form_button_two', 'my_login_form_button_two', 10, 2 );
|
380 |
+
* function my_login_form_button_two( $secondary_btn_word, $args ) {
|
381 |
+
* // your code here
|
382 |
+
* return $secondary_btn_word;
|
383 |
+
* }
|
384 |
+
* ?>
|
385 |
+
*/
|
386 |
+
$secondary_btn_word = apply_filters( 'um_login_form_button_two', $args['secondary_btn_word'], $args );
|
387 |
+
|
388 |
+
if ( ! isset( $secondary_btn_word ) || $secondary_btn_word == '' ){
|
389 |
+
$secondary_btn_word = UM()->options()->get( 'login_secondary_btn_word' );
|
390 |
+
}
|
391 |
+
|
392 |
+
$secondary_btn_url = ! empty( $args['secondary_btn_url'] ) ? $args['secondary_btn_url'] : um_get_core_page( 'register' );
|
393 |
+
/**
|
394 |
+
* UM hook
|
395 |
+
*
|
396 |
+
* @type filter
|
397 |
+
* @title um_login_form_button_two_url
|
398 |
+
* @description Change Login Form Secondary button URL
|
399 |
+
* @input_vars
|
400 |
+
* [{"var":"$secondary_btn_url","type":"string","desc":"Button URL"},
|
401 |
+
* {"var":"$args","type":"array","desc":"Login Form arguments"}]
|
402 |
+
* @change_log
|
403 |
+
* ["Since: 2.0"]
|
404 |
+
* @usage
|
405 |
+
* <?php add_filter( 'um_login_form_button_two_url', 'function_name', 10, 2 ); ?>
|
406 |
+
* @example
|
407 |
+
* <?php
|
408 |
+
* add_filter( 'um_login_form_button_two_url', 'my_login_form_button_two_url', 10, 2 );
|
409 |
+
* function my_login_form_button_two_url( $secondary_btn_url, $args ) {
|
410 |
+
* // your code here
|
411 |
+
* return $secondary_btn_url;
|
412 |
+
* }
|
413 |
+
* ?>
|
414 |
+
*/
|
415 |
+
$secondary_btn_url = apply_filters( 'um_login_form_button_two_url', $secondary_btn_url, $args ); ?>
|
416 |
+
|
417 |
+
<div class="um-col-alt">
|
418 |
+
|
419 |
+
<?php if ( ! empty( $args['show_rememberme'] ) ) {
|
420 |
+
UM()->fields()->checkbox( 'rememberme', __( 'Keep me signed in', 'ultimate-member' ), false ); ?>
|
421 |
+
<div class="um-clear"></div>
|
422 |
+
<?php }
|
423 |
+
|
424 |
+
if ( ! empty( $args['secondary_btn'] ) ) { ?>
|
425 |
+
|
426 |
+
<div class="um-left um-half">
|
427 |
+
<input type="submit" value="<?php esc_attr_e( wp_unslash( $primary_btn_word ), 'ultimate-member' ); ?>" class="um-button" id="um-submit-btn" />
|
428 |
+
</div>
|
429 |
+
<div class="um-right um-half">
|
430 |
+
<a href="<?php echo esc_url( $secondary_btn_url ); ?>" class="um-button um-alt">
|
431 |
+
<?php _e( wp_unslash( $secondary_btn_word ), 'ultimate-member' ); ?>
|
432 |
+
</a>
|
433 |
+
</div>
|
434 |
+
|
435 |
+
<?php } else { ?>
|
436 |
+
|
437 |
+
<div class="um-center">
|
438 |
+
<input type="submit" value="<?php esc_attr_e( wp_unslash( $primary_btn_word ), 'ultimate-member' ); ?>" class="um-button" id="um-submit-btn" />
|
439 |
+
</div>
|
440 |
+
|
441 |
+
<?php } ?>
|
442 |
+
|
443 |
+
<div class="um-clear"></div>
|
444 |
+
|
445 |
+
</div>
|
446 |
+
|
447 |
+
<?php
|
448 |
+
}
|
449 |
+
add_action( 'um_after_login_fields', 'um_add_submit_button_to_login', 1000 );
|
450 |
+
|
451 |
+
|
452 |
+
/**
|
453 |
+
* Display a forgot password link
|
454 |
+
*
|
455 |
+
* @param $args
|
456 |
+
*/
|
457 |
+
function um_after_login_submit( $args ) {
|
458 |
+
if ( empty( $args['forgot_pass_link'] ) ) {
|
459 |
+
return;
|
460 |
+
} ?>
|
461 |
+
|
462 |
+
<div class="um-col-alt-b">
|
463 |
+
<a href="<?php echo esc_url( um_get_core_page( 'password-reset' ) ); ?>" class="um-link-alt">
|
464 |
+
<?php _e( 'Forgot your password?', 'ultimate-member' ); ?>
|
465 |
+
</a>
|
466 |
+
</div>
|
467 |
+
|
468 |
+
<?php
|
469 |
+
}
|
470 |
+
add_action( 'um_after_login_fields', 'um_after_login_submit', 1001 );
|
471 |
+
|
472 |
+
|
473 |
+
/**
|
474 |
+
* Show Fields
|
475 |
+
*
|
476 |
+
* @param $args
|
477 |
+
*/
|
478 |
+
function um_add_login_fields( $args ) {
|
479 |
+
echo UM()->fields()->display( 'login', $args );
|
480 |
+
}
|
481 |
+
add_action( 'um_main_login_fields', 'um_add_login_fields', 100 );
|
includes/core/um-actions-profile.php
CHANGED
@@ -294,10 +294,12 @@ function um_user_edit_profile( $args ) {
|
|
294 |
if ( isset( $array['options'] ) && in_array( $array['type'], array( 'select', 'multiselect' ) ) ) {
|
295 |
|
296 |
$options = array();
|
297 |
-
if ( ! empty( $array['custom_dropdown_options_source'] ) && function_exists( $array['custom_dropdown_options_source'] ) && ! $has_custom_source
|
298 |
-
|
299 |
-
|
300 |
-
|
|
|
|
|
301 |
}
|
302 |
}
|
303 |
|
294 |
if ( isset( $array['options'] ) && in_array( $array['type'], array( 'select', 'multiselect' ) ) ) {
|
295 |
|
296 |
$options = array();
|
297 |
+
if ( ! empty( $array['custom_dropdown_options_source'] ) && function_exists( $array['custom_dropdown_options_source'] ) && ! $has_custom_source ) {
|
298 |
+
if ( ! in_array( $array['custom_dropdown_options_source'], UM()->fields()->dropdown_options_source_blacklist(), true ) ) {
|
299 |
+
$callback_result = call_user_func( $array['custom_dropdown_options_source'], $array['options'] );
|
300 |
+
if ( is_array( $callback_result ) ) {
|
301 |
+
$options = array_keys( $callback_result );
|
302 |
+
}
|
303 |
}
|
304 |
}
|
305 |
|
includes/core/um-actions-register.php
CHANGED
@@ -178,8 +178,11 @@ function um_check_user_status( $user_id, $args ) {
|
|
178 |
do_action( "track_{$status}_user_registration" );
|
179 |
|
180 |
if ( $status == 'approved' ) {
|
181 |
-
|
182 |
-
|
|
|
|
|
|
|
183 |
UM()->user()->generate_profile_slug( $user_id );
|
184 |
|
185 |
/**
|
178 |
do_action( "track_{$status}_user_registration" );
|
179 |
|
180 |
if ( $status == 'approved' ) {
|
181 |
+
// Check if user is logged in because there can be the customized way when through 'um_registration_for_loggedin_users' hook the registration is enabled for the logged in users (e.g. Administrator).
|
182 |
+
if ( ! is_user_logged_in() ) {
|
183 |
+
// Custom way if 'um_registration_for_loggedin_users' hook after custom callbacks returns true. Then don't make auto-login because user is already logged-in.
|
184 |
+
UM()->user()->auto_login( $user_id );
|
185 |
+
}
|
186 |
UM()->user()->generate_profile_slug( $user_id );
|
187 |
|
188 |
/**
|
includes/core/um-filters-fields.php
CHANGED
@@ -694,6 +694,9 @@ add_filter( 'um_field_non_utf8_value', 'um_field_non_utf8_value' );
|
|
694 |
*/
|
695 |
function um_select_dropdown_dynamic_callback_options( $options, $data ) {
|
696 |
if ( ! empty( $data['custom_dropdown_options_source'] ) && function_exists( $data['custom_dropdown_options_source'] ) ) {
|
|
|
|
|
|
|
697 |
$options = call_user_func( $data['custom_dropdown_options_source'] );
|
698 |
}
|
699 |
|
694 |
*/
|
695 |
function um_select_dropdown_dynamic_callback_options( $options, $data ) {
|
696 |
if ( ! empty( $data['custom_dropdown_options_source'] ) && function_exists( $data['custom_dropdown_options_source'] ) ) {
|
697 |
+
if ( in_array( $data['custom_dropdown_options_source'], UM()->fields()->dropdown_options_source_blacklist(), true ) ) {
|
698 |
+
return $options;
|
699 |
+
}
|
700 |
$options = call_user_func( $data['custom_dropdown_options_source'] );
|
701 |
}
|
702 |
|
includes/core/um-filters-navmenu.php
CHANGED
@@ -20,13 +20,13 @@ if ( ! is_admin() ) {
|
|
20 |
}
|
21 |
|
22 |
foreach ( $sorted_menu_items as &$menu_item ) {
|
23 |
-
if ( $menu_item->title ) {
|
24 |
$menu_item->title = UM()->shortcodes()->convert_user_tags( $menu_item->title );
|
25 |
}
|
26 |
-
if ( $menu_item->attr_title ) {
|
27 |
$menu_item->attr_title = UM()->shortcodes()->convert_user_tags( $menu_item->attr_title );
|
28 |
}
|
29 |
-
if ( $menu_item->description ) {
|
30 |
$menu_item->description = UM()->shortcodes()->convert_user_tags( $menu_item->description );
|
31 |
}
|
32 |
}
|
@@ -56,19 +56,22 @@ if ( ! is_admin() ) {
|
|
56 |
|
57 |
um_fetch_user( get_current_user_id() );
|
58 |
|
59 |
-
$filtered_items
|
60 |
$hide_children_of = array();
|
61 |
|
62 |
//other filter
|
63 |
foreach ( $menu_items as $item ) {
|
|
|
|
|
|
|
64 |
|
65 |
-
$mode
|
66 |
$roles = get_post_meta( $item->ID, 'menu-item-um_nav_roles', true );
|
67 |
|
68 |
$visible = true;
|
69 |
|
70 |
// hide any item that is the child of a hidden item
|
71 |
-
if ( in_array( $item->menu_item_parent, $hide_children_of ) ) {
|
72 |
$visible = false;
|
73 |
$hide_children_of[] = $item->ID; // for nested menus
|
74 |
}
|
@@ -79,16 +82,16 @@ if ( ! is_admin() ) {
|
|
79 |
|
80 |
case 2:
|
81 |
if ( is_user_logged_in() && ! empty( $roles ) ) {
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
} else {
|
93 |
$visible = is_user_logged_in() ? true : false;
|
94 |
}
|
20 |
}
|
21 |
|
22 |
foreach ( $sorted_menu_items as &$menu_item ) {
|
23 |
+
if ( ! empty( $menu_item->title ) ) {
|
24 |
$menu_item->title = UM()->shortcodes()->convert_user_tags( $menu_item->title );
|
25 |
}
|
26 |
+
if ( ! empty( $menu_item->attr_title ) ) {
|
27 |
$menu_item->attr_title = UM()->shortcodes()->convert_user_tags( $menu_item->attr_title );
|
28 |
}
|
29 |
+
if ( ! empty( $menu_item->description ) ) {
|
30 |
$menu_item->description = UM()->shortcodes()->convert_user_tags( $menu_item->description );
|
31 |
}
|
32 |
}
|
56 |
|
57 |
um_fetch_user( get_current_user_id() );
|
58 |
|
59 |
+
$filtered_items = array();
|
60 |
$hide_children_of = array();
|
61 |
|
62 |
//other filter
|
63 |
foreach ( $menu_items as $item ) {
|
64 |
+
if ( empty( $item->ID ) ) {
|
65 |
+
continue;
|
66 |
+
}
|
67 |
|
68 |
+
$mode = get_post_meta( $item->ID, 'menu-item-um_nav_public', true );
|
69 |
$roles = get_post_meta( $item->ID, 'menu-item-um_nav_roles', true );
|
70 |
|
71 |
$visible = true;
|
72 |
|
73 |
// hide any item that is the child of a hidden item
|
74 |
+
if ( isset( $item->menu_item_parent ) && in_array( $item->menu_item_parent, $hide_children_of ) ) {
|
75 |
$visible = false;
|
76 |
$hide_children_of[] = $item->ID; // for nested menus
|
77 |
}
|
82 |
|
83 |
case 2:
|
84 |
if ( is_user_logged_in() && ! empty( $roles ) ) {
|
85 |
+
if ( current_user_can( 'administrator' ) ) {
|
86 |
+
$visible = true;
|
87 |
+
} else {
|
88 |
+
$current_user_roles = um_user( 'roles' );
|
89 |
+
if ( empty( $current_user_roles ) ) {
|
90 |
+
$visible = false;
|
91 |
+
} else {
|
92 |
+
$visible = ( count( array_intersect( $current_user_roles, (array)$roles ) ) > 0 ) ? true : false;
|
93 |
+
}
|
94 |
+
}
|
95 |
} else {
|
96 |
$visible = is_user_logged_in() ? true : false;
|
97 |
}
|
includes/um-short-functions.php
CHANGED
@@ -1,2808 +1,2793 @@
|
|
1 |
-
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
|
2 |
-
|
3 |
-
|
4 |
-
//Make public functions without class creation
|
5 |
-
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Trim string by char length
|
9 |
-
*
|
10 |
-
*
|
11 |
-
* @param $s
|
12 |
-
* @param int $length
|
13 |
-
*
|
14 |
-
* @return string
|
15 |
-
*/
|
16 |
-
function um_trim_string( $s, $length = 20 ) {
|
17 |
-
$s = mb_strlen( $s ) > $length ? substr( $s, 0, $length ) . "..." : $s;
|
18 |
-
|
19 |
-
return $s;
|
20 |
-
}
|
21 |
-
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Get where user should be headed after logging
|
25 |
-
*
|
26 |
-
* @param string $redirect_to
|
27 |
-
*
|
28 |
-
* @return bool|false|mixed|string|void
|
29 |
-
*/
|
30 |
-
function um_dynamic_login_page_redirect( $redirect_to = '' ) {
|
31 |
-
|
32 |
-
$uri = um_get_core_page( 'login' );
|
33 |
-
|
34 |
-
if ( ! $redirect_to ) {
|
35 |
-
$redirect_to = UM()->permalinks()->get_current_url();
|
36 |
-
}
|
37 |
-
|
38 |
-
$redirect_key = urlencode_deep( $redirect_to );
|
39 |
-
|
40 |
-
$uri = add_query_arg( 'redirect_to', $redirect_key, $uri );
|
41 |
-
|
42 |
-
return $uri;
|
43 |
-
}
|
44 |
-
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Checks if session has been started
|
48 |
-
*
|
49 |
-
* @return bool
|
50 |
-
*/
|
51 |
-
function um_is_session_started() {
|
52 |
-
|
53 |
-
if ( php_sapi_name() !== 'cli' ) {
|
54 |
-
if ( version_compare( phpversion(), '5.4.0', '>=' ) ) {
|
55 |
-
return session_status() === PHP_SESSION_ACTIVE ? true : false;
|
56 |
-
} else {
|
57 |
-
return session_id() === '' ? false : true;
|
58 |
-
}
|
59 |
-
}
|
60 |
-
|
61 |
-
return false;
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* User clean basename
|
66 |
-
*
|
67 |
-
* @param $value
|
68 |
-
*
|
69 |
-
* @return mixed|void
|
70 |
-
*/
|
71 |
-
function um_clean_user_basename( $value ) {
|
72 |
-
|
73 |
-
$raw_value = $value;
|
74 |
-
$value = str_replace( '.', ' ', $value );
|
75 |
-
$value = str_replace( '-', ' ', $value );
|
76 |
-
$value = str_replace( '+', ' ', $value );
|
77 |
-
|
78 |
-
/**
|
79 |
-
* UM hook
|
80 |
-
*
|
81 |
-
* @type filter
|
82 |
-
* @title um_clean_user_basename_filter
|
83 |
-
* @description Change clean user basename
|
84 |
-
* @input_vars
|
85 |
-
* [{"var":"$basename","type":"string","desc":"User basename"},
|
86 |
-
* {"var":"$raw_basename","type":"string","desc":"RAW user basename"}]
|
87 |
-
* @change_log
|
88 |
-
* ["Since: 2.0"]
|
89 |
-
* @usage add_filter( 'um_clean_user_basename_filter', 'function_name', 10, 2 );
|
90 |
-
* @example
|
91 |
-
* <?php
|
92 |
-
* add_filter( 'um_clean_user_basename_filter', 'my_clean_user_basename', 10, 2 );
|
93 |
-
* function my_clean_user_basename( $basename, $raw_basename ) {
|
94 |
-
* // your code here
|
95 |
-
* return $basename;
|
96 |
-
* }
|
97 |
-
* ?>
|
98 |
-
*/
|
99 |
-
$value = apply_filters( 'um_clean_user_basename_filter', $value, $raw_value );
|
100 |
-
|
101 |
-
return $value;
|
102 |
-
}
|
103 |
-
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Getting replace placeholders array
|
107 |
-
*
|
108 |
-
* @return array
|
109 |
-
*/
|
110 |
-
function um_replace_placeholders() {
|
111 |
-
|
112 |
-
$search = array(
|
113 |
-
'{display_name}',
|
114 |
-
'{first_name}',
|
115 |
-
'{last_name}',
|
116 |
-
'{gender}',
|
117 |
-
'{username}',
|
118 |
-
'{email}',
|
119 |
-
'{site_name}',
|
120 |
-
'{user_account_link}',
|
121 |
-
);
|
122 |
-
|
123 |
-
|
124 |
-
/**
|
125 |
-
* UM hook
|
126 |
-
*
|
127 |
-
* @type filter
|
128 |
-
* @title um_template_tags_patterns_hook
|
129 |
-
* @description Extend UM placeholders
|
130 |
-
* @input_vars
|
131 |
-
* [{"var":"$placeholders","type":"array","desc":"UM Placeholders"}]
|
132 |
-
* @change_log
|
133 |
-
* ["Since: 2.0"]
|
134 |
-
* @usage add_filter( 'um_template_tags_patterns_hook', 'function_name', 10, 1 );
|
135 |
-
* @example
|
136 |
-
* <?php
|
137 |
-
* add_filter( 'um_template_tags_patterns_hook', 'my_template_tags_patterns', 10, 1 );
|
138 |
-
* function my_template_tags_patterns( $placeholders ) {
|
139 |
-
* // your code here
|
140 |
-
* $placeholders[] = '{my_custom_placeholder}';
|
141 |
-
* return $placeholders;
|
142 |
-
* }
|
143 |
-
* ?>
|
144 |
-
*/
|
145 |
-
$search = apply_filters( 'um_template_tags_patterns_hook', $search );
|
146 |
-
|
147 |
-
$replace = array(
|
148 |
-
um_user( 'display_name' ),
|
149 |
-
um_user( 'first_name' ),
|
150 |
-
um_user( 'last_name' ),
|
151 |
-
um_user( 'gender' ),
|
152 |
-
um_user( 'user_login' ),
|
153 |
-
um_user( 'user_email' ),
|
154 |
-
UM()->options()->get( 'site_name' ),
|
155 |
-
um_get_core_page( 'account' ),
|
156 |
-
);
|
157 |
-
|
158 |
-
/**
|
159 |
-
* UM hook
|
160 |
-
*
|
161 |
-
* @type filter
|
162 |
-
* @title um_template_tags_replaces_hook
|
163 |
-
* @description Extend UM replace placeholders
|
164 |
-
* @input_vars
|
165 |
-
* [{"var":"$replace_placeholders","type":"array","desc":"UM Replace Placeholders"}]
|
166 |
-
* @change_log
|
167 |
-
* ["Since: 2.0"]
|
168 |
-
* @usage add_filter( 'um_template_tags_replaces_hook', 'function_name', 10, 1 );
|
169 |
-
* @example
|
170 |
-
* <?php
|
171 |
-
* add_filter( 'um_template_tags_replaces_hook', 'my_template_tags_replaces', 10, 1 );
|
172 |
-
* function my_template_tags_replaces( $replace_placeholders ) {
|
173 |
-
* // your code here
|
174 |
-
* $replace_placeholders[] = 'my_replace_value';
|
175 |
-
* return $replace_placeholders;
|
176 |
-
* }
|
177 |
-
* ?>
|
178 |
-
*/
|
179 |
-
$replace = apply_filters( 'um_template_tags_replaces_hook', $replace );
|
180 |
-
|
181 |
-
return array_combine( $search, $replace );
|
182 |
-
}
|
183 |
-
|
184 |
-
|
185 |
-
/**
|
186 |
-
* Convert template tags
|
187 |
-
*
|
188 |
-
* @param $content
|
189 |
-
* @param array $args
|
190 |
-
* @param bool $with_kses
|
191 |
-
*
|
192 |
-
* @return mixed|string
|
193 |
-
*/
|
194 |
-
function um_convert_tags( $content, $args = array(), $with_kses = true ) {
|
195 |
-
$placeholders = um_replace_placeholders();
|
196 |
-
|
197 |
-
$content = str_replace( array_keys( $placeholders ), array_values( $placeholders ), $content );
|
198 |
-
if ( $with_kses ) {
|
199 |
-
$content = wp_kses_decode_entities( $content );
|
200 |
-
}
|
201 |
-
|
202 |
-
if ( isset( $args['tags'] ) && isset( $args['tags_replace'] ) ) {
|
203 |
-
$content = str_replace( $args['tags'], $args['tags_replace'], $content );
|
204 |
-
}
|
205 |
-
|
206 |
-
$regex = '~\{(usermeta:[^}]*)\}~';
|
207 |
-
preg_match_all( $regex, $content, $matches );
|
208 |
-
|
209 |
-
// Support for all usermeta keys
|
210 |
-
if ( ! empty( $matches[1] ) && is_array( $matches[1] ) ) {
|
211 |
-
foreach ( $matches[1] as $match ) {
|
212 |
-
$key = str_replace( 'usermeta:', '', $match );
|
213 |
-
$value = um_user( $key );
|
214 |
-
if ( is_array( $value ) ) {
|
215 |
-
$value = implode( ', ', $value );
|
216 |
-
}
|
217 |
-
$content = str_replace( '{' . $match . '}', apply_filters( 'um_convert_tags', $value, $key ), $content );
|
218 |
-
}
|
219 |
-
}
|
220 |
-
return $content;
|
221 |
-
}
|
222 |
-
|
223 |
-
|
224 |
-
/**
|
225 |
-
* UM Placeholders for activation link in email
|
226 |
-
*
|
227 |
-
* @param $placeholders
|
228 |
-
*
|
229 |
-
* @return array
|
230 |
-
*/
|
231 |
-
function account_activation_link_tags_patterns( $placeholders ) {
|
232 |
-
$placeholders[] = '{account_activation_link}';
|
233 |
-
return $placeholders;
|
234 |
-
}
|
235 |
-
|
236 |
-
/**
|
237 |
-
* UM Replace Placeholders for activation link in email
|
238 |
-
*
|
239 |
-
* @param $replace_placeholders
|
240 |
-
*
|
241 |
-
* @return array
|
242 |
-
*/
|
243 |
-
function account_activation_link_tags_replaces( $replace_placeholders ) {
|
244 |
-
$replace_placeholders[] = um_user( 'account_activation_link' );
|
245 |
-
return $replace_placeholders;
|
246 |
-
}
|
247 |
-
|
248 |
-
|
249 |
-
/**
|
250 |
-
* @function um_user_ip()
|
251 |
-
*
|
252 |
-
* @description This function returns the IP address of user.
|
253 |
-
*
|
254 |
-
* @usage <?php $user_ip = um_user_ip(); ?>
|
255 |
-
*
|
256 |
-
* @return string The user's IP address.
|
257 |
-
*
|
258 |
-
* @example The example below can retrieve the user's IP address
|
259 |
-
*
|
260 |
-
* <?php
|
261 |
-
*
|
262 |
-
* $user_ip = um_user_ip();
|
263 |
-
* echo 'User IP address is: ' . $user_ip; // prints the user IP address e.g. 127.0.0.1
|
264 |
-
*
|
265 |
-
* ?>
|
266 |
-
*/
|
267 |
-
function um_user_ip() {
|
268 |
-
$ip = '127.0.0.1';
|
269 |
-
|
270 |
-
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
|
271 |
-
//check ip from share internet
|
272 |
-
$ip = $_SERVER['HTTP_CLIENT_IP'];
|
273 |
-
} else if ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
|
274 |
-
//to check ip is pass from proxy
|
275 |
-
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
276 |
-
} else if ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
|
277 |
-
$ip = $_SERVER['REMOTE_ADDR'];
|
278 |
-
}
|
279 |
-
|
280 |
-
/**
|
281 |
-
* UM hook
|
282 |
-
*
|
283 |
-
* @type filter
|
284 |
-
* @title um_user_ip
|
285 |
-
* @description Change User IP
|
286 |
-
* @input_vars
|
287 |
-
* [{"var":"$ip","type":"string","desc":"User IP"}]
|
288 |
-
* @change_log
|
289 |
-
* ["Since: 2.0"]
|
290 |
-
* @usage add_filter( 'um_user_ip', 'function_name', 10, 1 );
|
291 |
-
* @example
|
292 |
-
* <?php
|
293 |
-
* add_filter( 'um_user_ip', 'my_user_ip', 10, 1 );
|
294 |
-
* function my_user_ip( $ip ) {
|
295 |
-
* // your code here
|
296 |
-
* return $ip;
|
297 |
-
* }
|
298 |
-
* ?>
|
299 |
-
*/
|
300 |
-
return apply_filters( 'um_user_ip', $ip );
|
301 |
-
}
|
302 |
-
|
303 |
-
|
304 |
-
/**
|
305 |
-
* If conditions are met return true;
|
306 |
-
*
|
307 |
-
* @param $data
|
308 |
-
*
|
309 |
-
* @return bool
|
310 |
-
*/
|
311 |
-
function um_field_conditions_are_met( $data ) {
|
312 |
-
|
313 |
-
if ( ! isset( $data['conditions'] ) ) {
|
314 |
-
return true;
|
315 |
-
}
|
316 |
-
|
317 |
-
$state = ( isset( $data['conditional_action'] ) && $data['conditional_action'] == 'show' ) ? 1 : 0;
|
318 |
-
|
319 |
-
$first_group = 0;
|
320 |
-
$state_array = array();
|
321 |
-
$count = count( $state_array );
|
322 |
-
foreach ( $data['conditions'] as $k => $arr ) {
|
323 |
-
|
324 |
-
$val = $arr[3];
|
325 |
-
$op = $arr[2];
|
326 |
-
|
327 |
-
if ( strstr( $arr[1], 'role_' ) ) {
|
328 |
-
$arr[1] = 'role';
|
329 |
-
}
|
330 |
-
|
331 |
-
$field = um_profile( $arr[1] );
|
332 |
-
|
333 |
-
|
334 |
-
if ( ! isset( $arr[5] ) || $arr[5] != $first_group ) {
|
335 |
-
|
336 |
-
|
337 |
-
if ( $arr[0] == 'show' ) {
|
338 |
-
|
339 |
-
switch ($op) {
|
340 |
-
case 'equals to':
|
341 |
-
|
342 |
-
$field = maybe_unserialize( $field );
|
343 |
-
|
344 |
-
if (is_array( $field ))
|
345 |
-
$state = in_array( $val, $field ) ? 'show' : 'hide';
|
346 |
-
else
|
347 |
-
$state = ( $field == $val ) ? 'show' : 'hide';
|
348 |
-
|
349 |
-
break;
|
350 |
-
case 'not equals':
|
351 |
-
|
352 |
-
$field = maybe_unserialize( $field );
|
353 |
-
|
354 |
-
if (is_array( $field ))
|
355 |
-
$state = !in_array( $val, $field ) ? 'show' : 'hide';
|
356 |
-
else
|
357 |
-
$state = ( $field != $val ) ? 'show' : 'hide';
|
358 |
-
|
359 |
-
break;
|
360 |
-
case 'empty':
|
361 |
-
|
362 |
-
$state = ( !$field ) ? 'show' : 'hide';
|
363 |
-
|
364 |
-
break;
|
365 |
-
case 'not empty':
|
366 |
-
|
367 |
-
$state = ( $field ) ? 'show' : 'hide';
|
368 |
-
|
369 |
-
break;
|
370 |
-
case 'greater than':
|
371 |
-
if ($field > $val) {
|
372 |
-
$state = 'show';
|
373 |
-
} else {
|
374 |
-
$state = 'hide';
|
375 |
-
}
|
376 |
-
break;
|
377 |
-
case 'less than':
|
378 |
-
if ($field < $val) {
|
379 |
-
$state = 'show';
|
380 |
-
} else {
|
381 |
-
$state = 'hide';
|
382 |
-
}
|
383 |
-
break;
|
384 |
-
case 'contains':
|
385 |
-
if (strstr( $field, $val )) {
|
386 |
-
$state = 'show';
|
387 |
-
} else {
|
388 |
-
$state = 'hide';
|
389 |
-
}
|
390 |
-
break;
|
391 |
-
}
|
392 |
-
} elseif ( $arr[0] == 'hide' ) {
|
393 |
-
|
394 |
-
switch ( $op ) {
|
395 |
-
case 'equals to':
|
396 |
-
|
397 |
-
$field = maybe_unserialize( $field );
|
398 |
-
|
399 |
-
if ( is_array( $field ) ) {
|
400 |
-
$state = in_array( $val, $field ) ? 'hide' : 'show';
|
401 |
-
} else {
|
402 |
-
$state = ( $field == $val ) ? 'hide' : 'show';
|
403 |
-
}
|
404 |
-
|
405 |
-
break;
|
406 |
-
case 'not equals':
|
407 |
-
|
408 |
-
$field = maybe_unserialize( $field );
|
409 |
-
|
410 |
-
if ( is_array( $field ) ) {
|
411 |
-
$state = ! in_array( $val, $field ) ? 'hide' : 'show';
|
412 |
-
} else {
|
413 |
-
$state = ( $field != $val ) ? 'hide' : 'show';
|
414 |
-
}
|
415 |
-
|
416 |
-
break;
|
417 |
-
case 'empty':
|
418 |
-
|
419 |
-
$state = ( ! $field ) ? 'hide' : 'show';
|
420 |
-
|
421 |
-
break;
|
422 |
-
case 'not empty':
|
423 |
-
|
424 |
-
$state = ( $field ) ? 'hide' : 'show';
|
425 |
-
|
426 |
-
break;
|
427 |
-
case 'greater than':
|
428 |
-
if ( $field <= $val ) {
|
429 |
-
$state = 'hide';
|
430 |
-
} else {
|
431 |
-
$state = 'show';
|
432 |
-
}
|
433 |
-
break;
|
434 |
-
case 'less than':
|
435 |
-
if ( $field >= $val ) {
|
436 |
-
$state = 'hide';
|
437 |
-
} else {
|
438 |
-
$state = 'show';
|
439 |
-
}
|
440 |
-
break;
|
441 |
-
case 'contains':
|
442 |
-
if ( strstr( $field, $val ) ) {
|
443 |
-
$state = 'hide';
|
444 |
-
} else {
|
445 |
-
$state = 'show';
|
446 |
-
}
|
447 |
-
break;
|
448 |
-
}
|
449 |
-
}
|
450 |
-
$first_group++;
|
451 |
-
array_push( $state_array, $state );
|
452 |
-
} else {
|
453 |
-
|
454 |
-
if ( $arr[0] == 'show' ) {
|
455 |
-
|
456 |
-
switch ( $op ) {
|
457 |
-
case 'equals to':
|
458 |
-
$field = maybe_unserialize( $field );
|
459 |
-
|
460 |
-
if ( is_array( $field ) ) {
|
461 |
-
$state = in_array( $val, $field ) ? 'show' : 'not_show';
|
462 |
-
} else {
|
463 |
-
$state = ( $field == $val ) ? 'show' : 'not_show';
|
464 |
-
}
|
465 |
-
|
466 |
-
break;
|
467 |
-
case 'not equals':
|
468 |
-
$field = maybe_unserialize( $field );
|
469 |
-
|
470 |
-
if ( is_array( $field ) ) {
|
471 |
-
$state = ! in_array( $val, $field ) ? 'show' : 'not_show';
|
472 |
-
} else {
|
473 |
-
$state = ( $field != $val ) ? 'show' : 'not_show';
|
474 |
-
}
|
475 |
-
|
476 |
-
break;
|
477 |
-
case 'empty':
|
478 |
-
|
479 |
-
$state = ( ! $field ) ? 'show' : 'not_show';
|
480 |
-
|
481 |
-
break;
|
482 |
-
case 'not empty':
|
483 |
-
|
484 |
-
$state = ( $field ) ? 'show': 'not_show';
|
485 |
-
|
486 |
-
break;
|
487 |
-
case 'greater than':
|
488 |
-
if ( $field > $val ) {
|
489 |
-
$state = 'show';
|
490 |
-
} else {
|
491 |
-
$state = 'not_show';
|
492 |
-
}
|
493 |
-
break;
|
494 |
-
case 'less than':
|
495 |
-
if ( $field < $val ) {
|
496 |
-
$state = 'show';
|
497 |
-
} else {
|
498 |
-
$state = 'not_show';
|
499 |
-
}
|
500 |
-
break;
|
501 |
-
case 'contains':
|
502 |
-
if ( strstr( $field, $val ) ) {
|
503 |
-
$state = 'show';
|
504 |
-
} else {
|
505 |
-
$state = 'not_show';
|
506 |
-
}
|
507 |
-
break;
|
508 |
-
}
|
509 |
-
} elseif ( $arr[0] == 'hide' ) {
|
510 |
-
|
511 |
-
switch ( $op ) {
|
512 |
-
case 'equals to':
|
513 |
-
$field = maybe_unserialize( $field );
|
514 |
-
|
515 |
-
if ( is_array( $field ) ) {
|
516 |
-
$state = in_array( $val, $field ) ? 'hide' : 'not_hide';
|
517 |
-
} else {
|
518 |
-
$state = ( $field == $val ) ? 'hide' : 'not_hide';
|
519 |
-
}
|
520 |
-
|
521 |
-
break;
|
522 |
-
case 'not equals':
|
523 |
-
|
524 |
-
$field = maybe_unserialize( $field );
|
525 |
-
|
526 |
-
if ( is_array( $field ) ) {
|
527 |
-
$state = ! in_array( $val, $field ) ? 'hide' : 'not_hide';
|
528 |
-
} else {
|
529 |
-
$state = ( $field != $val ) ? 'hide' : 'not_hide';
|
530 |
-
}
|
531 |
-
|
532 |
-
break;
|
533 |
-
case 'empty':
|
534 |
-
|
535 |
-
$state = ( ! $field ) ? 'hide' : 'not_hide';
|
536 |
-
|
537 |
-
break;
|
538 |
-
case 'not empty':
|
539 |
-
|
540 |
-
$state = ( $field ) ? 'hide' : 'not_hide';
|
541 |
-
|
542 |
-
break;
|
543 |
-
case 'greater than':
|
544 |
-
if ( $field <= $val ) {
|
545 |
-
$state = 'hide';
|
546 |
-
} else {
|
547 |
-
$state = 'not_hide';
|
548 |
-
}
|
549 |
-
break;
|
550 |
-
case 'less than':
|
551 |
-
if ( $field >= $val ) {
|
552 |
-
$state = 'hide';
|
553 |
-
} else {
|
554 |
-
$state = 'not_hide';
|
555 |
-
}
|
556 |
-
break;
|
557 |
-
case 'contains':
|
558 |
-
if ( strstr( $field, $val ) ) {
|
559 |
-
$state = 'hide';
|
560 |
-
} else {
|
561 |
-
$state = 'not_hide';
|
562 |
-
}
|
563 |
-
break;
|
564 |
-
}
|
565 |
-
}
|
566 |
-
if ( isset( $state_array[ $count ] ) ) {
|
567 |
-
if ( $state_array[ $count ] == 'show' || $state_array[ $count ] == 'not_hide' ) {
|
568 |
-
if ( $state == 'show' || $state == 'not_hide' ) {
|
569 |
-
$state_array[ $count ] = 'show';
|
570 |
-
} else {
|
571 |
-
$state_array[ $count ] = 'hide';
|
572 |
-
}
|
573 |
-
} else {
|
574 |
-
if ( $state == 'hide' || $state == 'not_show' ) {
|
575 |
-
$state_array[ $count ] = 'hide';
|
576 |
-
} else {
|
577 |
-
$state_array[ $count ] = 'hide';
|
578 |
-
}
|
579 |
-
}
|
580 |
-
} else {
|
581 |
-
if ( $state == 'show' || $state == 'not_hide' ) {
|
582 |
-
$state_array[ $count ] = 'show';
|
583 |
-
} else {
|
584 |
-
$state_array[ $count ] = 'hide';
|
585 |
-
}
|
586 |
-
}
|
587 |
-
}
|
588 |
-
|
589 |
-
|
590 |
-
}
|
591 |
-
$result = array_unique( $state_array );
|
592 |
-
if ( ! in_array( 'show', $result ) ) {
|
593 |
-
return $state = false;
|
594 |
-
} else {
|
595 |
-
return $state = true;
|
596 |
-
}
|
597 |
-
}
|
598 |
-
|
599 |
-
|
600 |
-
/**
|
601 |
-
* Exit and redirect to home
|
602 |
-
*
|
603 |
-
* @param string $requested_user_id
|
604 |
-
* @param string $is_my_profile
|
605 |
-
*/
|
606 |
-
function um_redirect_home( $requested_user_id = '', $is_my_profile = '' ) {
|
607 |
-
$url = apply_filters( 'um_redirect_home_custom_url', home_url(), $requested_user_id, $is_my_profile );
|
608 |
-
exit( wp_redirect( $url ) );
|
609 |
-
}
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
/**
|
614 |
-
* @param $url
|
615 |
-
*/
|
616 |
-
function um_js_redirect( $url ) {
|
617 |
-
if ( headers_sent() || empty( $url ) ) {
|
618 |
-
//for blank redirects
|
619 |
-
if ( '' == $url ) {
|
620 |
-
$url = set_url_scheme( '//' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] );
|
621 |
-
}
|
622 |
-
|
623 |
-
register_shutdown_function( function( $url ) {
|
624 |
-
echo '<script data-cfasync="false" type="text/javascript">window.location = "' . esc_js( $url ) . '"</script>';
|
625 |
-
}, $url );
|
626 |
-
|
627 |
-
if ( 1 < ob_get_level() ) {
|
628 |
-
while ( ob_get_level() > 1 ) {
|
629 |
-
ob_end_clean();
|
630 |
-
}
|
631 |
-
} ?>
|
632 |
-
<script data-cfasync='false' type="text/javascript">
|
633 |
-
window.location = '<?php echo esc_js( $url ); ?>';
|
634 |
-
</script>
|
635 |
-
<?php exit;
|
636 |
-
} else {
|
637 |
-
wp_redirect( $url );
|
638 |
-
}
|
639 |
-
exit;
|
640 |
-
}
|
641 |
-
|
642 |
-
|
643 |
-
/**
|
644 |
-
* Get limit of words from sentence
|
645 |
-
*
|
646 |
-
* @param $str
|
647 |
-
* @param int $wordCount
|
648 |
-
*
|
649 |
-
* @return string
|
650 |
-
*/
|
651 |
-
function um_get_snippet( $str, $wordCount = 10 ) {
|
652 |
-
if (str_word_count( $str, 0, "éèàôù" ) > $wordCount) {
|
653 |
-
$str = implode(
|
654 |
-
'',
|
655 |
-
array_slice(
|
656 |
-
preg_split(
|
657 |
-
'/([\s,\.;\?\!]+)/',
|
658 |
-
$str,
|
659 |
-
$wordCount * 2 + 1,
|
660 |
-
PREG_SPLIT_DELIM_CAPTURE
|
661 |
-
),
|
662 |
-
0,
|
663 |
-
$wordCount * 2 - 1
|
664 |
-
)
|
665 |
-
);
|
666 |
-
}
|
667 |
-
|
668 |
-
return $str;
|
669 |
-
}
|
670 |
-
|
671 |
-
|
672 |
-
/**
|
673 |
-
* Format submitted data for Info preview & Email template
|
674 |
-
* @param boolean $style
|
675 |
-
* @return string
|
676 |
-
*
|
677 |
-
* @since 2.1.4
|
678 |
-
*/
|
679 |
-
function um_user_submitted_registration_formatted( $style = false ) {
|
680 |
-
$output = null;
|
681 |
-
|
682 |
-
$submitted_data = um_user( 'submitted' );
|
683 |
-
|
684 |
-
if ( $style ) {
|
685 |
-
$output .= '<div class="um-admin-infobox">';
|
686 |
-
}
|
687 |
-
|
688 |
-
// Timestamp
|
689 |
-
$output .= um_user_submited_display( 'timestamp', __( 'Date Submitted', 'ultimate-member' ) );
|
690 |
-
$output .= um_user_submited_display( 'form_id', __( 'Form', 'ultimate-member' ), $submitted_data );
|
691 |
-
|
692 |
-
if ( isset( $submitted_data['use_gdpr_agreement'] ) ) {
|
693 |
-
$output .= um_user_submited_display( 'use_gdpr_agreement', __( 'GDPR Applied', 'ultimate-member' ), $submitted_data );
|
694 |
-
}
|
695 |
-
|
696 |
-
if ( isset( $submitted_data ) && is_array( $submitted_data ) ) {
|
697 |
-
|
698 |
-
if ( isset( $submitted_data['form_id'] ) ) {
|
699 |
-
$fields = UM()->query()->get_attr( 'custom_fields', $submitted_data['form_id'] );
|
700 |
-
$fields = maybe_unserialize( $fields );
|
701 |
-
}
|
702 |
-
|
703 |
-
if ( ! empty( $fields ) ) {
|
704 |
-
|
705 |
-
$fields['form_id'] = array( 'title' => __( 'Form', 'ultimate-member' ) );
|
706 |
-
|
707 |
-
$rows = array();
|
708 |
-
|
709 |
-
UM()->fields()->get_fields = $fields;
|
710 |
-
|
711 |
-
foreach ( $fields as $key => $array ) {
|
712 |
-
if ( isset( $array['type'] ) && $array['type'] == 'row' ) {
|
713 |
-
$rows[ $key ] = $array;
|
714 |
-
unset( UM()->fields()->get_fields[ $key ] ); // not needed now
|
715 |
-
}
|
716 |
-
}
|
717 |
-
|
718 |
-
if ( empty( $rows ) ) {
|
719 |
-
$rows = array(
|
720 |
-
'_um_row_1' => array(
|
721 |
-
'type' => 'row',
|
722 |
-
'id' => '_um_row_1',
|
723 |
-
'sub_rows' => 1,
|
724 |
-
'cols' => 1,
|
725 |
-
),
|
726 |
-
);
|
727 |
-
}
|
728 |
-
|
729 |
-
foreach ( $rows as $row_id => $row_array ) {
|
730 |
-
|
731 |
-
$row_fields = UM()->fields()->get_fields_by_row( $row_id );
|
732 |
-
|
733 |
-
if ( $row_fields ) {
|
734 |
-
|
735 |
-
$output .= UM()->fields()->new_row_output( $row_id, $row_array );
|
736 |
-
|
737 |
-
$sub_rows = ( isset( $row_array['sub_rows'] ) ) ? $row_array['sub_rows'] : 1;
|
738 |
-
for ( $c = 0; $c < $sub_rows; $c++ ) {
|
739 |
-
|
740 |
-
// cols
|
741 |
-
$cols = ( isset( $row_array['cols'] ) ) ? $row_array['cols'] : 1;
|
742 |
-
if ( strstr( $cols, ':' ) ) {
|
743 |
-
$col_split = explode( ':', $cols );
|
744 |
-
} else {
|
745 |
-
$col_split = array( $cols );
|
746 |
-
}
|
747 |
-
$cols_num = $col_split[ $c ];
|
748 |
-
|
749 |
-
// sub row fields
|
750 |
-
$subrow_fields = null;
|
751 |
-
$subrow_fields = UM()->fields()->get_fields_in_subrow( $row_fields, $c );
|
752 |
-
|
753 |
-
if ( is_array( $subrow_fields ) ) {
|
754 |
-
|
755 |
-
if ( isset( $subrow_fields['form_id'] ) ) {
|
756 |
-
unset( $subrow_fields['form_id'] );
|
757 |
-
}
|
758 |
-
|
759 |
-
$subrow_fields = UM()->fields()->array_sort_by_column( $subrow_fields, 'position' );
|
760 |
-
|
761 |
-
if ( $cols_num == 1 ) {
|
762 |
-
|
763 |
-
$col1_fields = UM()->fields()->get_fields_in_column( $subrow_fields, 1 );
|
764 |
-
if ( $col1_fields ) {
|
765 |
-
foreach ( $col1_fields as $key => $data ) {
|
766 |
-
$output .= um_user_submited_display( $key, $data['title'] );
|
767 |
-
}
|
768 |
-
}
|
769 |
-
|
770 |
-
} elseif ( $cols_num == 2 ) {
|
771 |
-
|
772 |
-
$col1_fields = UM()->fields()->get_fields_in_column( $subrow_fields, 1 );
|
773 |
-
if ( $col1_fields ) {
|
774 |
-
foreach ( $col1_fields as $key => $data ) {
|
775 |
-
$output .= um_user_submited_display( $key, $data['title'] );
|
776 |
-
}
|
777 |
-
}
|
778 |
-
|
779 |
-
$col2_fields = UM()->fields()->get_fields_in_column( $subrow_fields, 2 );
|
780 |
-
if ( $col2_fields ) {
|
781 |
-
foreach ( $col2_fields as $key => $data ) {
|
782 |
-
$output .= um_user_submited_display( $key, $data['title'] );
|
783 |
-
}
|
784 |
-
}
|
785 |
-
|
786 |
-
} else {
|
787 |
-
|
788 |
-
$col1_fields = UM()->fields()->get_fields_in_column( $subrow_fields, 1 );
|
789 |
-
if ( $col1_fields ) {
|
790 |
-
foreach ( $col1_fields as $key => $data ) {
|
791 |
-
$output .= um_user_submited_display( $key, $data['title'] );
|
792 |
-
}
|
793 |
-
}
|
794 |
-
|
795 |
-
$col2_fields = UM()->fields()->get_fields_in_column( $subrow_fields, 2 );
|
796 |
-
if ( $col2_fields ) {
|
797 |
-
foreach ( $col2_fields as $key => $data ) {
|
798 |
-
$output .= um_user_submited_display( $key, $data['title'] );
|
799 |
-
}
|
800 |
-
}
|
801 |
-
|
802 |
-
$col3_fields = UM()->fields()->get_fields_in_column( $subrow_fields, 3 );
|
803 |
-
if ( $col3_fields ) {
|
804 |
-
foreach ( $col3_fields as $key => $data ) {
|
805 |
-
$output .= um_user_submited_display( $key, $data['title'] );
|
806 |
-
}
|
807 |
-
}
|
808 |
-
|
809 |
-
}
|
810 |
-
|
811 |
-
}
|
812 |
-
|
813 |
-
}
|
814 |
-
|
815 |
-
}
|
816 |
-
|
817 |
-
|
818 |
-
} // endfor
|
819 |
-
|
820 |
-
}
|
821 |
-
}
|
822 |
-
|
823 |
-
|
824 |
-
if ( $style ) {
|
825 |
-
$output .= '</div>';
|
826 |
-
}
|
827 |
-
|
828 |
-
|
829 |
-
return $output;
|
830 |
-
|
831 |
-
}
|
832 |
-
|
833 |
-
/**
|
834 |
-
* Prepare template
|
835 |
-
*
|
836 |
-
* @param string $k
|
837 |
-
* @param string $title
|
838 |
-
* @param array $data
|
839 |
-
* @param boolean $style
|
840 |
-
* @return string
|
841 |
-
*
|
842 |
-
* @since 2.1.4
|
843 |
-
*/
|
844 |
-
function um_user_submited_display( $k, $title, $data = array(), $style = true ) {
|
845 |
-
$output = '';
|
846 |
-
|
847 |
-
if ( 'form_id' == $k && isset( $data['form_id'] ) && ! empty( $data['form_id'] ) ) {
|
848 |
-
$v = sprintf( __( '%s - Form ID#: %s', 'ultimate-member' ), get_the_title( $data['form_id'] ), $data['form_id'] );
|
849 |
-
} else {
|
850 |
-
$v = um_user( $k );
|
851 |
-
}
|
852 |
-
|
853 |
-
if ( strstr( $k, 'user_pass' ) || in_array( $k, array( 'g-recaptcha-response', 'request', '_wpnonce', '_wp_http_referer' ) ) ) {
|
854 |
-
return '';
|
855 |
-
}
|
856 |
-
|
857 |
-
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
858 |
-
$type = UM()->fields()->get_field_type( $k );
|
859 |
-
if ( in_array( $type, $fields_without_metakey ) ) {
|
860 |
-
return '';
|
861 |
-
}
|
862 |
-
|
863 |
-
if ( ! $v ) {
|
864 |
-
if ( $style ) {
|
865 |
-
return "<p><label>$title: </label><span>" . __( '(empty)', 'ultimate-member' ) ."</span></p>";
|
866 |
-
} else {
|
867 |
-
return '';
|
868 |
-
}
|
869 |
-
}
|
870 |
-
|
871 |
-
if ( $type == 'image' || $type == 'file' ) {
|
872 |
-
$file = basename( $v );
|
873 |
-
|
874 |
-
$filedata = get_user_meta( um_user( 'ID' ), $k . "_metadata", true );
|
875 |
-
|
876 |
-
$baseurl = UM()->uploader()->get_upload_base_url();
|
877 |
-
if ( ! file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $file ) ) {
|
878 |
-
if ( is_multisite() ) {
|
879 |
-
//multisite fix for old customers
|
880 |
-
$baseurl = str_replace( '/sites/' . get_current_blog_id() . '/', '/', $baseurl );
|
881 |
-
}
|
882 |
-
}
|
883 |
-
|
884 |
-
if ( ! empty( $filedata['original_name'] ) ) {
|
885 |
-
$v = '<a href="' . esc_attr( $baseurl . um_user( 'ID' ) . '/' . $file ) . '">' . esc_html( $filedata['original_name'] ) . '</a>';
|
886 |
-
} else {
|
887 |
-
$v = $baseurl . um_user( 'ID' ) . '/' . $file;
|
888 |
-
}
|
889 |
-
}
|
890 |
-
|
891 |
-
if ( is_array( $v ) ) {
|
892 |
-
$v = implode( ',', $v );
|
893 |
-
}
|
894 |
-
|
895 |
-
if ( $k == 'timestamp' ) {
|
896 |
-
$v = date( "d M Y H:i", $v );
|
897 |
-
} elseif ( $k == 'use_gdpr_agreement' ) {
|
898 |
-
$v = date( "d M Y H:i", $v );
|
899 |
-
}
|
900 |
-
|
901 |
-
if ( $style ) {
|
902 |
-
if ( ! $v ) {
|
903 |
-
$v = __( '(empty)', 'ultimate-member' );
|
904 |
-
}
|
905 |
-
$output .= "<p><label>$title: </label><span>$v</span></p>";
|
906 |
-
} else {
|
907 |
-
$output .= "$title: $v" . "<br />";
|
908 |
-
}
|
909 |
-
|
910 |
-
return $output;
|
911 |
-
}
|
912 |
-
|
913 |
-
|
914 |
-
/**
|
915 |
-
* Show filtered social link
|
916 |
-
*
|
917 |
-
* @param string $key
|
918 |
-
* @param string $match
|
919 |
-
*
|
920 |
-
* @return string
|
921 |
-
*/
|
922 |
-
function um_filtered_social_link( $key, $match ) {
|
923 |
-
$value = um_profile( $key );
|
924 |
-
$submatch = str_replace( 'https://', '', $match );
|
925 |
-
$submatch = str_replace( 'http://', '', $submatch );
|
926 |
-
if ( strstr( $value, $submatch ) ) {
|
927 |
-
$value = 'https://' . $value;
|
928 |
-
} elseif ( strpos( $value, 'http' ) !== 0 ) {
|
929 |
-
$value = $match . $value;
|
930 |
-
}
|
931 |
-
$value = str_replace( 'https://https://', 'https://', $value );
|
932 |
-
$value = str_replace( 'http://https://', 'https://', $value );
|
933 |
-
$value = str_replace( 'https://http://', 'https://', $value );
|
934 |
-
|
935 |
-
return $value;
|
936 |
-
}
|
937 |
-
|
938 |
-
|
939 |
-
/**
|
940 |
-
* Get filtered meta value after applying hooks
|
941 |
-
*
|
942 |
-
* @param $key
|
943 |
-
* @param bool $data
|
944 |
-
* @return mixed|string|void
|
945 |
-
*/
|
946 |
-
function um_filtered_value( $key, $data = false ) {
|
947 |
-
$value = um_user( $key );
|
948 |
-
if ( is_array( $value ) ) {
|
949 |
-
$value = add_magic_quotes( $value );
|
950 |
-
}
|
951 |
-
|
952 |
-
if ( ! $data ) {
|
953 |
-
$data = UM()->builtin()->get_specific_field( $key );
|
954 |
-
}
|
955 |
-
|
956 |
-
$type = ( isset( $data['type'] ) ) ? $data['type'] : '';
|
957 |
-
|
958 |
-
/**
|
959 |
-
* UM hook
|
960 |
-
*
|
961 |
-
* @type filter
|
962 |
-
* @title um_profile_field_filter_hook__
|
963 |
-
* @description Change or filter field value
|
964 |
-
* @input_vars
|
965 |
-
* [{"var":"$value","type":"string","desc":"Field Value"},
|
966 |
-
* {"var":"$data","type":"array","desc":"Field Data"},
|
967 |
-
* {"var":"$type","type":"string","desc":"Field Type"}]
|
968 |
-
* @change_log
|
969 |
-
* ["Since: 2.0"]
|
970 |
-
* @usage add_filter( 'um_profile_field_filter_hook__', 'function_name', 10, 3 );
|
971 |
-
* @example
|
972 |
-
* <?php
|
973 |
-
* add_filter( 'um_profile_field_filter_hook__', 'my_profile_field', 10, 3 );
|
974 |
-
* function my_profile_field( $value, $data, $type ) {
|
975 |
-
* // your code here
|
976 |
-
* return $value;
|
977 |
-
* }
|
978 |
-
* ?>
|
979 |
-
*/
|
980 |
-
$value = apply_filters( 'um_profile_field_filter_hook__', $value, $data, $type );
|
981 |
-
|
982 |
-
/**
|
983 |
-
* UM hook
|
984 |
-
*
|
985 |
-
* @type filter
|
986 |
-
* @title um_profile_field_filter_hook__{$key}
|
987 |
-
* @description Change or filter field value by field key ($key)
|
988 |
-
* @input_vars
|
989 |
-
* [{"var":"$value","type":"string","desc":"Field Value"},
|
990 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
991 |
-
* @change_log
|
992 |
-
* ["Since: 2.0"]
|
993 |
-
* @usage add_filter( 'um_profile_field_filter_hook__{$key}', 'function_name', 10, 2 );
|
994 |
-
* @example
|
995 |
-
* <?php
|
996 |
-
* add_filter( 'um_profile_field_filter_hook__{$key}', 'my_profile_field', 10, 2 );
|
997 |
-
* function my_profile_field( $value, $data ) {
|
998 |
-
* // your code here
|
999 |
-
* return $value;
|
1000 |
-
* }
|
1001 |
-
* ?>
|
1002 |
-
*/
|
1003 |
-
$value = apply_filters( "um_profile_field_filter_hook__{$key}", $value, $data );
|
1004 |
-
|
1005 |
-
/**
|
1006 |
-
* UM hook
|
1007 |
-
*
|
1008 |
-
* @type filter
|
1009 |
-
* @title um_profile_field_filter_hook__{$type}
|
1010 |
-
* @description Change or filter field value by field type ($type)
|
1011 |
-
* @input_vars
|
1012 |
-
* [{"var":"$value","type":"string","desc":"Field Value"},
|
1013 |
-
* {"var":"$data","type":"array","desc":"Field Data"}]
|
1014 |
-
* @change_log
|
1015 |
-
* ["Since: 2.0"]
|
1016 |
-
* @usage add_filter( 'um_profile_field_filter_hook__{$type}', 'function_name', 10, 2 );
|
1017 |
-
* @example
|
1018 |
-
* <?php
|
1019 |
-
* add_filter( 'um_profile_field_filter_hook__{$type}', 'my_profile_field', 10, 2 );
|
1020 |
-
* function my_profile_field( $value, $data ) {
|
1021 |
-
* // your code here
|
1022 |
-
* return $value;
|
1023 |
-
* }
|
1024 |
-
* ?>
|
1025 |
-
*/
|
1026 |
-
$value = apply_filters( "um_profile_field_filter_hook__{$type}", $value, $data );
|
1027 |
-
$value = UM()->shortcodes()->emotize( $value );
|
1028 |
-
return $value;
|
1029 |
-
}
|
1030 |
-
|
1031 |
-
|
1032 |
-
/**
|
1033 |
-
* Returns requested User ID or current User ID
|
1034 |
-
*
|
1035 |
-
* @return int
|
1036 |
-
*/
|
1037 |
-
function um_profile_id() {
|
1038 |
-
$requested_user = um_get_requested_user();
|
1039 |
-
|
1040 |
-
if ( $requested_user ) {
|
1041 |
-
return um_get_requested_user();
|
1042 |
-
} elseif ( is_user_logged_in() && get_current_user_id() ) {
|
1043 |
-
return get_current_user_id();
|
1044 |
-
}
|
1045 |
-
|
1046 |
-
return 0;
|
1047 |
-
}
|
1048 |
-
|
1049 |
-
|
1050 |
-
/**
|
1051 |
-
* Check that temp upload is valid
|
1052 |
-
*
|
1053 |
-
* @param string $url
|
1054 |
-
*
|
1055 |
-
* @return bool|string
|
1056 |
-
*/
|
1057 |
-
function um_is_temp_upload( $url ) {
|
1058 |
-
if ( is_string( $url ) ) {
|
1059 |
-
$url = trim( $url );
|
1060 |
-
}
|
1061 |
-
|
1062 |
-
if ( filter_var( $url, FILTER_VALIDATE_URL ) === false ) {
|
1063 |
-
$url = realpath( $url );
|
1064 |
-
}
|
1065 |
-
|
1066 |
-
if ( ! $url ) {
|
1067 |
-
return false;
|
1068 |
-
}
|
1069 |
-
|
1070 |
-
$url = explode( '/ultimatemember/temp/', $url );
|
1071 |
-
if ( isset( $url[1] ) ) {
|
1072 |
-
|
1073 |
-
if ( strstr( $url[1], '../' ) || strstr( $url[1], '%' ) ) {
|
1074 |
-
return false;
|
1075 |
-
}
|
1076 |
-
|
1077 |
-
$src = UM()->files()->upload_temp . $url[1];
|
1078 |
-
if ( ! file_exists( $src ) ) {
|
1079 |
-
return false;
|
1080 |
-
}
|
1081 |
-
|
1082 |
-
return $src;
|
1083 |
-
}
|
1084 |
-
|
1085 |
-
return false;
|
1086 |
-
}
|
1087 |
-
|
1088 |
-
|
1089 |
-
/**
|
1090 |
-
* Check that temp image is valid
|
1091 |
-
*
|
1092 |
-
* @param $url
|
1093 |
-
*
|
1094 |
-
* @return bool|string
|
1095 |
-
*/
|
1096 |
-
function um_is_temp_image( $url ) {
|
1097 |
-
$url = explode( '/ultimatemember/temp/', $url );
|
1098 |
-
if (isset( $url[1] )) {
|
1099 |
-
$src = UM()->files()->upload_temp . $url[1];
|
1100 |
-
if (!file_exists( $src ))
|
1101 |
-
return false;
|
1102 |
-
list( $width, $height, $type, $attr ) = @getimagesize( $src );
|
1103 |
-
if (isset( $width ) && isset( $height ))
|
1104 |
-
return $src;
|
1105 |
-
}
|
1106 |
-
|
1107 |
-
return false;
|
1108 |
-
}
|
1109 |
-
|
1110 |
-
|
1111 |
-
/**
|
1112 |
-
* Check user's file ownership
|
1113 |
-
* @param string $url
|
1114 |
-
* @param int|null $user_id
|
1115 |
-
* @param string|bool $image_path
|
1116 |
-
* @return bool
|
1117 |
-
*/
|
1118 |
-
function um_is_file_owner( $url, $user_id = null, $image_path = false ) {
|
1119 |
-
|
1120 |
-
if ( strpos( $url, UM()->uploader()->get_upload_base_url() . $user_id . '/' ) !== false && is_user_logged_in() ) {
|
1121 |
-
$user_basedir = UM()->uploader()->get_upload_user_base_dir( $user_id );
|
1122 |
-
} else {
|
1123 |
-
$user_basedir = UM()->uploader()->get_upload_user_base_dir( 'temp' );
|
1124 |
-
}
|
1125 |
-
|
1126 |
-
$filename = wp_basename( parse_url( $url, PHP_URL_PATH ) );
|
1127 |
-
|
1128 |
-
$file = $user_basedir . DIRECTORY_SEPARATOR . $filename;
|
1129 |
-
if ( file_exists( $file ) ) {
|
1130 |
-
if ( $image_path ) {
|
1131 |
-
return $file;
|
1132 |
-
}
|
1133 |
-
|
1134 |
-
return true;
|
1135 |
-
}
|
1136 |
-
|
1137 |
-
return false;
|
1138 |
-
}
|
1139 |
-
|
1140 |
-
|
1141 |
-
/**
|
1142 |
-
* Check if file is temporary
|
1143 |
-
* @param string $filename
|
1144 |
-
* @return bool
|
1145 |
-
*/
|
1146 |
-
function um_is_temp_file( $filename ) {
|
1147 |
-
$user_basedir = UM()->uploader()->get_upload_user_base_dir( 'temp' );
|
1148 |
-
|
1149 |
-
$file = $user_basedir . '/' . $filename;
|
1150 |
-
|
1151 |
-
if ( file_exists( $file ) ) {
|
1152 |
-
return true;
|
1153 |
-
}
|
1154 |
-
return false;
|
1155 |
-
}
|
1156 |
-
|
1157 |
-
|
1158 |
-
/**
|
1159 |
-
* Get user's last login timestamp
|
1160 |
-
*
|
1161 |
-
* @param $user_id
|
1162 |
-
*
|
1163 |
-
* @return mixed|string
|
1164 |
-
*/
|
1165 |
-
function um_user_last_login_timestamp( $user_id ) {
|
1166 |
-
$value = get_user_meta( $user_id, '_um_last_login', true );
|
1167 |
-
if ( $value ) {
|
1168 |
-
return $value;
|
1169 |
-
}
|
1170 |
-
|
1171 |
-
return '';
|
1172 |
-
}
|
1173 |
-
|
1174 |
-
|
1175 |
-
/**
|
1176 |
-
* Get user's last login (time diff)
|
1177 |
-
*
|
1178 |
-
* @param int $user_id
|
1179 |
-
*
|
1180 |
-
* @return string
|
1181 |
-
*/
|
1182 |
-
function um_user_last_login( $user_id ) {
|
1183 |
-
$value = get_user_meta( $user_id, '_um_last_login', true );
|
1184 |
-
return ! empty( $value ) ? UM()->datetime()->time_diff( $value, current_time( 'timestamp' ) ) : '';
|
1185 |
-
}
|
1186 |
-
|
1187 |
-
|
1188 |
-
/**
|
1189 |
-
* Get core page url
|
1190 |
-
*
|
1191 |
-
* @param $slug
|
1192 |
-
* @param bool $updated
|
1193 |
-
*
|
1194 |
-
* @return bool|false|mixed|string|void
|
1195 |
-
*/
|
1196 |
-
function um_get_core_page( $slug, $updated = false ) {
|
1197 |
-
$url = '';
|
1198 |
-
|
1199 |
-
if ( isset( UM()->config()->permalinks[ $slug ] ) ) {
|
1200 |
-
$url = get_permalink( UM()->config()->permalinks[ $slug ] );
|
1201 |
-
if ( $updated ) {
|
1202 |
-
$url = add_query_arg( 'updated', esc_attr( $updated ), $url );
|
1203 |
-
}
|
1204 |
-
}
|
1205 |
-
|
1206 |
-
/**
|
1207 |
-
* UM hook
|
1208 |
-
*
|
1209 |
-
* @type filter
|
1210 |
-
* @title um_get_core_page_filter
|
1211 |
-
* @description Change UM core page URL
|
1212 |
-
* @input_vars
|
1213 |
-
* [{"var":"$url","type":"string","desc":"UM Page URL"},
|
1214 |
-
* {"var":"$slug","type":"string","desc":"UM Page slug"},
|
1215 |
-
* {"var":"$updated","type":"bool","desc":"Additional parameter"}]
|
1216 |
-
* @change_log
|
1217 |
-
* ["Since: 2.0"]
|
1218 |
-
* @usage add_filter( 'um_get_core_page_filter', 'function_name', 10, 3 );
|
1219 |
-
* @example
|
1220 |
-
* <?php
|
1221 |
-
* add_filter( 'um_get_core_page_filter', 'my_core_page_url', 10, 3 );
|
1222 |
-
* function my_core_page_url( $url, $slug, $updated ) {
|
1223 |
-
* // your code here
|
1224 |
-
* return $url;
|
1225 |
-
* }
|
1226 |
-
* ?>
|
1227 |
-
*/
|
1228 |
-
return apply_filters( 'um_get_core_page_filter', $url, $slug, $updated );
|
1229 |
-
}
|
1230 |
-
|
1231 |
-
|
1232 |
-
/**
|
1233 |
-
* Check if we are on a UM Core Page or not
|
1234 |
-
*
|
1235 |
-
* Default um core pages slugs
|
1236 |
-
* 'user', 'login', 'register', 'members', 'logout', 'account', 'password-reset'
|
1237 |
-
*
|
1238 |
-
* @param string $page UM core page slug
|
1239 |
-
*
|
1240 |
-
* @return bool
|
1241 |
-
*/
|
1242 |
-
function um_is_core_page( $page ) {
|
1243 |
-
global $post;
|
1244 |
-
|
1245 |
-
if ( empty( $post ) ) {
|
1246 |
-
return false;
|
1247 |
-
}
|
1248 |
-
|
1249 |
-
if ( isset( $post->ID ) && isset( UM()->config()->permalinks[ $page ] ) && $post->ID == UM()->config()->permalinks[ $page ] ) {
|
1250 |
-
return true;
|
1251 |
-
}
|
1252 |
-
|
1253 |
-
if ( isset( $post->ID ) && get_post_meta( $post->ID, '_um_wpml_' . $page, true ) == 1 ) {
|
1254 |
-
return true;
|
1255 |
-
}
|
1256 |
-
|
1257 |
-
if ( UM()->external_integrations()->is_wpml_active() ) {
|
1258 |
-
global $sitepress;
|
1259 |
-
if ( isset( UM()->config()->permalinks[ $page ] ) && UM()->config()->permalinks[ $page ] == wpml_object_id_filter( $post->ID, 'page', true, $sitepress->get_default_language() ) ) {
|
1260 |
-
return true;
|
1261 |
-
}
|
1262 |
-
}
|
1263 |
-
|
1264 |
-
if ( isset( $post->ID ) ) {
|
1265 |
-
$_icl_lang_duplicate_of = get_post_meta( $post->ID, '_icl_lang_duplicate_of', true );
|
1266 |
-
|
1267 |
-
if ( isset( UM()->config()->permalinks[ $page ] ) && ( ( $_icl_lang_duplicate_of == UM()->config()->permalinks[ $page ] && !empty( $_icl_lang_duplicate_of ) ) || UM()->config()->permalinks[ $page ] == $post->ID ) ) {
|
1268 |
-
return true;
|
1269 |
-
}
|
1270 |
-
}
|
1271 |
-
|
1272 |
-
return false;
|
1273 |
-
}
|
1274 |
-
|
1275 |
-
|
1276 |
-
/**
|
1277 |
-
* @param $post
|
1278 |
-
* @param $core_page
|
1279 |
-
*
|
1280 |
-
* @return bool
|
1281 |
-
*/
|
1282 |
-
function um_is_core_post( $post, $core_page ) {
|
1283 |
-
if ( isset( $post->ID ) && isset( UM()->config()->permalinks[ $core_page ] ) && $post->ID == UM()->config()->permalinks[ $core_page ] ) {
|
1284 |
-
return true;
|
1285 |
-
}
|
1286 |
-
if ( isset( $post->ID ) && get_post_meta( $post->ID, '_um_wpml_' . $core_page, true ) == 1 ) {
|
1287 |
-
return true;
|
1288 |
-
}
|
1289 |
-
|
1290 |
-
if ( isset( $post->ID ) ) {
|
1291 |
-
$_icl_lang_duplicate_of = get_post_meta( $post->ID, '_icl_lang_duplicate_of', true );
|
1292 |
-
|
1293 |
-
if ( isset( UM()->config()->permalinks[ $core_page ] ) && ( ( $_icl_lang_duplicate_of == UM()->config()->permalinks[ $core_page ] && ! empty( $_icl_lang_duplicate_of ) ) || UM()->config()->permalinks[ $core_page ] == $post->ID ) ) {
|
1294 |
-
return true;
|
1295 |
-
}
|
1296 |
-
}
|
1297 |
-
|
1298 |
-
return false;
|
1299 |
-
}
|
1300 |
-
|
1301 |
-
|
1302 |
-
/**
|
1303 |
-
* Get styling defaults
|
1304 |
-
*
|
1305 |
-
* @param $mode
|
1306 |
-
*
|
1307 |
-
* @return array
|
1308 |
-
*/
|
1309 |
-
function um_styling_defaults( $mode ) {
|
1310 |
-
|
1311 |
-
$new_arr = array();
|
1312 |
-
$core_form_meta_all = UM()->config()->core_form_meta_all;
|
1313 |
-
$core_global_meta_all = UM()->config()->core_global_meta_all;
|
1314 |
-
|
1315 |
-
foreach ( $core_form_meta_all as $k => $v ) {
|
1316 |
-
$s = str_replace( $mode . '_', '', $k );
|
1317 |
-
if (strstr( $k, '_um_' . $mode . '_' ) && !in_array( $s, $core_global_meta_all )) {
|
1318 |
-
$a = str_replace( '_um_' . $mode . '_', '', $k );
|
1319 |
-
$b = str_replace( '_um_', '', $k );
|
1320 |
-
$new_arr[$a] = UM()->options()->get( $b );
|
1321 |
-
} else if (in_array( $k, $core_global_meta_all )) {
|
1322 |
-
$a = str_replace( '_um_', '', $k );
|
1323 |
-
$new_arr[$a] = UM()->options()->get( $a );
|
1324 |
-
}
|
1325 |
-
}
|
1326 |
-
|
1327 |
-
return $new_arr;
|
1328 |
-
}
|
1329 |
-
|
1330 |
-
|
1331 |
-
/**
|
1332 |
-
* Get meta option default
|
1333 |
-
*
|
1334 |
-
* @param $id
|
1335 |
-
*
|
1336 |
-
* @return string
|
1337 |
-
*/
|
1338 |
-
function um_get_metadefault( $id ) {
|
1339 |
-
$core_form_meta_all = UM()->config()->core_form_meta_all;
|
1340 |
-
|
1341 |
-
return isset( $core_form_meta_all[ '_um_' . $id ] ) ? $core_form_meta_all[ '_um_' . $id ] : '';
|
1342 |
-
}
|
1343 |
-
|
1344 |
-
|
1345 |
-
/**
|
1346 |
-
* boolean for account page editing
|
1347 |
-
*
|
1348 |
-
* @return bool
|
1349 |
-
*/
|
1350 |
-
function um_submitting_account_page() {
|
1351 |
-
if ( isset( $_POST['_um_account'] ) && $_POST['_um_account'] == 1 && is_user_logged_in() ) {
|
1352 |
-
return true;
|
1353 |
-
}
|
1354 |
-
|
1355 |
-
return false;
|
1356 |
-
}
|
1357 |
-
|
1358 |
-
|
1359 |
-
/**
|
1360 |
-
* Get a user's display name
|
1361 |
-
*
|
1362 |
-
* @param $user_id
|
1363 |
-
*
|
1364 |
-
* @return string
|
1365 |
-
*/
|
1366 |
-
function um_get_display_name( $user_id ) {
|
1367 |
-
um_fetch_user( $user_id );
|
1368 |
-
$name = um_user( 'display_name' );
|
1369 |
-
um_reset_user();
|
1370 |
-
|
1371 |
-
return $name;
|
1372 |
-
}
|
1373 |
-
|
1374 |
-
|
1375 |
-
/**
|
1376 |
-
* Clears the user data. You need to fetch a user manually after using this function.
|
1377 |
-
*
|
1378 |
-
* @function um_reset_user_clean()
|
1379 |
-
*
|
1380 |
-
* @description This function is similar to um_reset_user() with a difference that it will not use the logged-in
|
1381 |
-
* user data after resetting. It is a hard-reset function for all user data.
|
1382 |
-
*
|
1383 |
-
* @usage <?php um_reset_user_clean(); ?>
|
1384 |
-
*
|
1385 |
-
* @example You can reset user data by using the following line in your code
|
1386 |
-
*
|
1387 |
-
* <?php um_reset_user_clean(); ?>
|
1388 |
-
*/
|
1389 |
-
function um_reset_user_clean() {
|
1390 |
-
UM()->user()->reset( true );
|
1391 |
-
}
|
1392 |
-
|
1393 |
-
|
1394 |
-
/**
|
1395 |
-
* Clears the user data. If a user is logged in, the user data will be reset to that user's data
|
1396 |
-
*
|
1397 |
-
* @function um_reset_user()
|
1398 |
-
*
|
1399 |
-
* @description This function resets the current user. You can use it to reset user data after
|
1400 |
-
* retrieving the details of a specific user.
|
1401 |
-
*
|
1402 |
-
* @usage <?php um_reset_user(); ?>
|
1403 |
-
*
|
1404 |
-
* @example You can reset user data by using the following line in your code
|
1405 |
-
*
|
1406 |
-
* <?php um_reset_user(); ?>
|
1407 |
-
*/
|
1408 |
-
function um_reset_user() {
|
1409 |
-
UM()->user()->reset();
|
1410 |
-
}
|
1411 |
-
|
1412 |
-
|
1413 |
-
/**
|
1414 |
-
* Gets the queried user
|
1415 |
-
*
|
1416 |
-
* @return mixed
|
1417 |
-
*/
|
1418 |
-
function um_queried_user() {
|
1419 |
-
return get_query_var( 'um_user' );
|
1420 |
-
}
|
1421 |
-
|
1422 |
-
|
1423 |
-
/**
|
1424 |
-
* Sets the requested user
|
1425 |
-
*
|
1426 |
-
* @param $user_id
|
1427 |
-
*/
|
1428 |
-
function um_set_requested_user( $user_id ) {
|
1429 |
-
UM()->user()->target_id = $user_id;
|
1430 |
-
}
|
1431 |
-
|
1432 |
-
|
1433 |
-
/**
|
1434 |
-
* Gets the requested user
|
1435 |
-
*
|
1436 |
-
* @return bool|null
|
1437 |
-
*/
|
1438 |
-
function um_get_requested_user() {
|
1439 |
-
if ( ! empty( UM()->user()->target_id ) ) {
|
1440 |
-
return UM()->user()->target_id;
|
1441 |
-
}
|
1442 |
-
|
1443 |
-
return false;
|
1444 |
-
}
|
1445 |
-
|
1446 |
-
|
1447 |
-
/**
|
1448 |
-
* Remove edit profile args from url
|
1449 |
-
*
|
1450 |
-
* @param string $url
|
1451 |
-
*
|
1452 |
-
* @return mixed|string|void
|
1453 |
-
*/
|
1454 |
-
function um_edit_my_profile_cancel_uri( $url = '' ) {
|
1455 |
-
|
1456 |
-
if ( empty( $url ) ) {
|
1457 |
-
$url = remove_query_arg( 'um_action' );
|
1458 |
-
$url = remove_query_arg( 'profiletab', $url );
|
1459 |
-
$url = add_query_arg( 'profiletab', 'main', $url );
|
1460 |
-
}
|
1461 |
-
|
1462 |
-
/**
|
1463 |
-
* UM hook
|
1464 |
-
*
|
1465 |
-
* @type filter
|
1466 |
-
* @title um_edit_profile_cancel_uri
|
1467 |
-
* @description Change Edit Profile Cancel URL
|
1468 |
-
* @input_vars
|
1469 |
-
* [{"var":"$url","type":"string","desc":"Cancel URL"}]
|
1470 |
-
* @change_log
|
1471 |
-
* ["Since: 2.0"]
|
1472 |
-
* @usage add_filter( 'um_edit_profile_cancel_uri', 'function_name', 10, 1 );
|
1473 |
-
* @example
|
1474 |
-
* <?php
|
1475 |
-
* add_filter( 'um_edit_profile_cancel_uri', 'my_edit_profile_cancel_uri', 10, 1 );
|
1476 |
-
* function my_edit_profile_cancel_uri( $url ) {
|
1477 |
-
* // your code here
|
1478 |
-
* return $url;
|
1479 |
-
* }
|
1480 |
-
* ?>
|
1481 |
-
*/
|
1482 |
-
$url = apply_filters( 'um_edit_profile_cancel_uri', $url );
|
1483 |
-
|
1484 |
-
return $url;
|
1485 |
-
}
|
1486 |
-
|
1487 |
-
|
1488 |
-
/**
|
1489 |
-
* boolean for profile edit page
|
1490 |
-
*
|
1491 |
-
* @return bool
|
1492 |
-
*/
|
1493 |
-
function um_is_on_edit_profile() {
|
1494 |
-
if ( isset( $_REQUEST['um_action'] ) && sanitize_key( $_REQUEST['um_action'] ) == 'edit' ) {
|
1495 |
-
return true;
|
1496 |
-
}
|
1497 |
-
|
1498 |
-
return false;
|
1499 |
-
}
|
1500 |
-
|
1501 |
-
|
1502 |
-
/**
|
1503 |
-
* Can view field
|
1504 |
-
*
|
1505 |
-
* @param $data
|
1506 |
-
*
|
1507 |
-
* @return bool
|
1508 |
-
*/
|
1509 |
-
function um_can_view_field( $data ) {
|
1510 |
-
$can_view = true;
|
1511 |
-
|
1512 |
-
if ( ! isset( UM()->fields()->set_mode ) ) {
|
1513 |
-
UM()->fields()->set_mode = '';
|
1514 |
-
}
|
1515 |
-
|
1516 |
-
if ( isset( $data['public'] ) && UM()->fields()->set_mode != 'register' ) {
|
1517 |
-
|
1518 |
-
$can_edit = false;
|
1519 |
-
$current_user_roles = [];
|
1520 |
-
if ( is_user_logged_in() ) {
|
1521 |
-
|
1522 |
-
$can_edit = UM()->roles()->um_current_user_can( 'edit', um_user( 'ID' ) );
|
1523 |
-
|
1524 |
-
$previous_user = um_user( 'ID' );
|
1525 |
-
um_fetch_user( get_current_user_id() );
|
1526 |
-
|
1527 |
-
$current_user_roles = um_user( 'roles' );
|
1528 |
-
um_fetch_user( $previous_user );
|
1529 |
-
}
|
1530 |
-
|
1531 |
-
switch ( $data['public'] ) {
|
1532 |
-
case '1': // Everyone
|
1533 |
-
break;
|
1534 |
-
case '2': // Members
|
1535 |
-
if ( ! is_user_logged_in() ) {
|
1536 |
-
$can_view = false;
|
1537 |
-
}
|
1538 |
-
break;
|
1539 |
-
case '-1': // Only visible to profile owner and users who can edit other member accounts
|
1540 |
-
if ( ! is_user_logged_in() ) {
|
1541 |
-
$can_view = false;
|
1542 |
-
} elseif ( ! um_is_user_himself() && ! $can_edit ) {
|
1543 |
-
$can_view = false;
|
1544 |
-
}
|
1545 |
-
break;
|
1546 |
-
case '-2': // Only specific member roles
|
1547 |
-
if ( ! is_user_logged_in() ) {
|
1548 |
-
$can_view = false;
|
1549 |
-
} elseif ( ! empty( $data['roles'] ) && count( array_intersect( $current_user_roles, $data['roles'] ) ) <= 0 ) {
|
1550 |
-
$can_view = false;
|
1551 |
-
}
|
1552 |
-
break;
|
1553 |
-
case '-3': // Only visible to profile owner and specific roles
|
1554 |
-
if ( ! is_user_logged_in() ) {
|
1555 |
-
$can_view = false;
|
1556 |
-
} elseif ( ! um_is_user_himself() && ! empty( $data['roles'] ) && count( array_intersect( $current_user_roles, $data['roles'] ) ) <= 0 ) {
|
1557 |
-
$can_view = false;
|
1558 |
-
}
|
1559 |
-
break;
|
1560 |
-
default:
|
1561 |
-
$can_view = apply_filters( 'um_can_view_field_custom', $can_view, $data );
|
1562 |
-
break;
|
1563 |
-
}
|
1564 |
-
|
1565 |
-
}
|
1566 |
-
|
1567 |
-
return apply_filters( 'um_can_view_field', $can_view, $data );
|
1568 |
-
}
|
1569 |
-
|
1570 |
-
|
1571 |
-
/**
|
1572 |
-
* Checks if user can view profile
|
1573 |
-
*
|
1574 |
-
* @param $user_id
|
1575 |
-
*
|
1576 |
-
* @return bool
|
1577 |
-
*/
|
1578 |
-
function um_can_view_profile( $user_id ) {
|
1579 |
-
if ( ! is_user_logged_in() ) {
|
1580 |
-
return ! UM()->user()->is_private_profile( $user_id );
|
1581 |
-
}
|
1582 |
-
|
1583 |
-
$temp_id = um_user('ID');
|
1584 |
-
um_fetch_user( get_current_user_id() );
|
1585 |
-
|
1586 |
-
if ( ! um_user( 'can_view_all' ) && $user_id != get_current_user_id() && is_user_logged_in() ) {
|
1587 |
-
um_fetch_user( $temp_id );
|
1588 |
-
return false;
|
1589 |
-
}
|
1590 |
-
|
1591 |
-
if ( ! um_user( 'can_access_private_profile' ) && UM()->user()->is_private_profile( $user_id ) ) {
|
1592 |
-
um_fetch_user( $temp_id );
|
1593 |
-
return false;
|
1594 |
-
}
|
1595 |
-
|
1596 |
-
if ( um_user( 'can_view_roles' ) && $user_id != get_current_user_id() ) {
|
1597 |
-
$can_view_roles = um_user( 'can_view_roles' );
|
1598 |
-
|
1599 |
-
if ( ! is_array( $can_view_roles ) ) {
|
1600 |
-
$can_view_roles = array();
|
1601 |
-
}
|
1602 |
-
|
1603 |
-
if ( count( $can_view_roles ) && count( array_intersect( UM()->roles()->get_all_user_roles( $user_id ), $can_view_roles ) ) <= 0 ) {
|
1604 |
-
um_fetch_user( $temp_id );
|
1605 |
-
return false;
|
1606 |
-
}
|
1607 |
-
}
|
1608 |
-
|
1609 |
-
um_fetch_user( $temp_id );
|
1610 |
-
return true;
|
1611 |
-
}
|
1612 |
-
|
1613 |
-
|
1614 |
-
/**
|
1615 |
-
* boolean check for not same user
|
1616 |
-
*
|
1617 |
-
* @return bool
|
1618 |
-
*/
|
1619 |
-
function um_is_user_himself() {
|
1620 |
-
if (um_get_requested_user() && um_get_requested_user() != get_current_user_id())
|
1621 |
-
return false;
|
1622 |
-
|
1623 |
-
return true;
|
1624 |
-
}
|
1625 |
-
|
1626 |
-
/**
|
1627 |
-
* Can edit field
|
1628 |
-
*
|
1629 |
-
* @param $data
|
1630 |
-
*
|
1631 |
-
* @return bool
|
1632 |
-
*/
|
1633 |
-
function um_can_edit_field( $data ) {
|
1634 |
-
$can_edit = true;
|
1635 |
-
|
1636 |
-
if ( ! empty( UM()->fields()->editing ) && isset( UM()->fields()->set_mode ) && UM()->fields()->set_mode == 'profile' ) {
|
1637 |
-
if ( ! is_user_logged_in() ) {
|
1638 |
-
$can_edit = false;
|
1639 |
-
} else {
|
1640 |
-
if ( ! UM()->roles()->um_user_can( 'can_edit_everyone' ) ) {
|
1641 |
-
if ( isset( $data['editable'] ) && $data['editable'] == 0 ) {
|
1642 |
-
$can_edit = false;
|
1643 |
-
} else {
|
1644 |
-
if ( ! um_is_user_himself() ) {
|
1645 |
-
$can_edit = false;
|
1646 |
-
}
|
1647 |
-
}
|
1648 |
-
}
|
1649 |
-
}
|
1650 |
-
}
|
1651 |
-
|
1652 |
-
return apply_filters( 'um_can_edit_field', $can_edit, $data );
|
1653 |
-
}
|
1654 |
-
|
1655 |
-
|
1656 |
-
/**
|
1657 |
-
* Check if user is in his profile
|
1658 |
-
*
|
1659 |
-
* @return bool
|
1660 |
-
*/
|
1661 |
-
function um_is_myprofile() {
|
1662 |
-
if (get_current_user_id() && get_current_user_id() == um_get_requested_user()) return true;
|
1663 |
-
if (!um_get_requested_user() && um_is_core_page( 'user' ) && get_current_user_id()) return true;
|
1664 |
-
|
1665 |
-
return false;
|
1666 |
-
}
|
1667 |
-
|
1668 |
-
|
1669 |
-
/**
|
1670 |
-
* Returns the edit profile link
|
1671 |
-
*
|
1672 |
-
* @param int $user_id
|
1673 |
-
*
|
1674 |
-
* @return string
|
1675 |
-
*/
|
1676 |
-
function um_edit_profile_url( $user_id = null ) {
|
1677 |
-
if ( um_is_core_page( 'user' ) ) {
|
1678 |
-
$url = UM()->permalinks()->get_current_url();
|
1679 |
-
} else {
|
1680 |
-
$url = isset( $user_id ) ? um_user_profile_url( $user_id ) : um_user_profile_url();
|
1681 |
-
}
|
1682 |
-
|
1683 |
-
$url = remove_query_arg( 'profiletab', $url );
|
1684 |
-
$url = remove_query_arg( 'subnav', $url );
|
1685 |
-
$url = add_query_arg( 'um_action', 'edit', $url );
|
1686 |
-
|
1687 |
-
return $url;
|
1688 |
-
}
|
1689 |
-
|
1690 |
-
|
1691 |
-
/**
|
1692 |
-
* Checks if user can edit his profile
|
1693 |
-
*
|
1694 |
-
* @return bool
|
1695 |
-
*/
|
1696 |
-
function um_can_edit_my_profile() {
|
1697 |
-
if ( ! is_user_logged_in() || ! um_user( 'can_edit_profile' ) ) {
|
1698 |
-
return false;
|
1699 |
-
}
|
1700 |
-
|
1701 |
-
return true;
|
1702 |
-
}
|
1703 |
-
|
1704 |
-
|
1705 |
-
/**
|
1706 |
-
* Short for admin e-mail
|
1707 |
-
*
|
1708 |
-
* @return mixed|string|void
|
1709 |
-
*/
|
1710 |
-
function um_admin_email() {
|
1711 |
-
return UM()->options()->get( 'admin_email' );
|
1712 |
-
}
|
1713 |
-
|
1714 |
-
|
1715 |
-
/**
|
1716 |
-
* Get admin e-mails
|
1717 |
-
*
|
1718 |
-
* @return array
|
1719 |
-
*/
|
1720 |
-
function um_multi_admin_email() {
|
1721 |
-
$emails = UM()->options()->get( 'admin_email' );
|
1722 |
-
|
1723 |
-
$emails_array = explode( ',', $emails );
|
1724 |
-
if ( ! empty( $emails_array ) ) {
|
1725 |
-
$emails_array = array_map( 'trim', $emails_array );
|
1726 |
-
}
|
1727 |
-
|
1728 |
-
$emails_array = array_unique( $emails_array );
|
1729 |
-
return $emails_array;
|
1730 |
-
}
|
1731 |
-
|
1732 |
-
|
1733 |
-
/**
|
1734 |
-
* Display a link to profile page
|
1735 |
-
*
|
1736 |
-
* @param int|bool $user_id
|
1737 |
-
*
|
1738 |
-
* @return bool|string
|
1739 |
-
*/
|
1740 |
-
function um_user_profile_url( $user_id = false ) {
|
1741 |
-
if ( ! $user_id ) {
|
1742 |
-
$user_id = um_user( 'ID' );
|
1743 |
-
}
|
1744 |
-
|
1745 |
-
$url = UM()->user()->get_profile_link( $user_id );
|
1746 |
-
if ( empty( $url ) ) {
|
1747 |
-
//if empty profile slug - generate it and re-get profile URL
|
1748 |
-
UM()->user()->generate_profile_slug( $user_id );
|
1749 |
-
$url = UM()->user()->get_profile_link( $user_id );
|
1750 |
-
}
|
1751 |
-
|
1752 |
-
return $url;
|
1753 |
-
}
|
1754 |
-
|
1755 |
-
|
1756 |
-
/**
|
1757 |
-
* Get all UM roles in array
|
1758 |
-
*
|
1759 |
-
* @return array
|
1760 |
-
*/
|
1761 |
-
function um_get_roles() {
|
1762 |
-
return UM()->roles()->get_roles();
|
1763 |
-
}
|
1764 |
-
|
1765 |
-
|
1766 |
-
/**
|
1767 |
-
* Sets a specific user and prepares profile data and user permissions and makes them accessible.
|
1768 |
-
*
|
1769 |
-
* @function um_fetch_user()
|
1770 |
-
*
|
1771 |
-
* @description This function sets a user and allow you to retrieve any information for the retrieved user
|
1772 |
-
*
|
1773 |
-
* @usage <?php um_fetch_user( $user_id ); ?>
|
1774 |
-
*
|
1775 |
-
* @param $user_id (numeric) (required) A user ID is required. This is the user's ID that you wish to set/retrieve
|
1776 |
-
*
|
1777 |
-
*
|
1778 |
-
* @example The example below will set user ID 5 prior to retrieving his profile information.
|
1779 |
-
*
|
1780 |
-
* <?php
|
1781 |
-
*
|
1782 |
-
* um_fetch_user(5);
|
1783 |
-
* echo um_user('display_name'); // returns the display name of user ID 5
|
1784 |
-
*
|
1785 |
-
* ?>
|
1786 |
-
*
|
1787 |
-
* @example In the following example you can fetch the profile of a logged-in user dynamically.
|
1788 |
-
*
|
1789 |
-
* <?php
|
1790 |
-
*
|
1791 |
-
* um_fetch_user( get_current_user_id() );
|
1792 |
-
* echo um_user('display_name'); // returns the display name of logged-in user
|
1793 |
-
*
|
1794 |
-
* ?>
|
1795 |
-
*
|
1796 |
-
*/
|
1797 |
-
function um_fetch_user( $user_id ) {
|
1798 |
-
UM()->user()->set( $user_id );
|
1799 |
-
}
|
1800 |
-
|
1801 |
-
|
1802 |
-
/**
|
1803 |
-
* Load profile key
|
1804 |
-
*
|
1805 |
-
* @param $key
|
1806 |
-
*
|
1807 |
-
* @return bool|string
|
1808 |
-
*/
|
1809 |
-
function um_profile( $key ) {
|
1810 |
-
if ( ! empty( UM()->user()->profile[ $key ] ) ) {
|
1811 |
-
/**
|
1812 |
-
* UM hook
|
1813 |
-
*
|
1814 |
-
* @type filter
|
1815 |
-
* @title um_profile_{$key}__filter
|
1816 |
-
* @description Change not empty profile field value
|
1817 |
-
* @input_vars
|
1818 |
-
* [{"var":"$value","type":"mixed","desc":"Profile Value"}]
|
1819 |
-
* @change_log
|
1820 |
-
* ["Since: 2.0"]
|
1821 |
-
* @usage add_filter( 'um_profile_{$key}__filter', 'function_name', 10, 1 );
|
1822 |
-
* @example
|
1823 |
-
* <?php
|
1824 |
-
* add_filter( 'um_profile_{$key}__filter', 'my_profile_value', 10, 1 );
|
1825 |
-
* function my_profile_value( $value ) {
|
1826 |
-
* // your code here
|
1827 |
-
* return $value;
|
1828 |
-
* }
|
1829 |
-
* ?>
|
1830 |
-
*/
|
1831 |
-
$value = apply_filters( "um_profile_{$key}__filter", UM()->user()->profile[ $key ] );
|
1832 |
-
} else {
|
1833 |
-
/**
|
1834 |
-
* UM hook
|
1835 |
-
*
|
1836 |
-
* @type filter
|
1837 |
-
* @title um_profile_{$key}_empty__filter
|
1838 |
-
* @description Change Profile field value if it's empty
|
1839 |
-
* @input_vars
|
1840 |
-
* [{"var":"$value","type":"mixed","desc":"Profile Value"}]
|
1841 |
-
* @change_log
|
1842 |
-
* ["Since: 2.0"]
|
1843 |
-
* @usage add_filter( 'um_profile_{$key}_empty__filter', 'function_name', 10, 1 );
|
1844 |
-
* @example
|
1845 |
-
* <?php
|
1846 |
-
* add_filter( 'um_profile_{$key}_empty__filter', 'my_profile_value', 10, 1 );
|
1847 |
-
* function my_profile_value( $value ) {
|
1848 |
-
* // your code here
|
1849 |
-
* return $value;
|
1850 |
-
* }
|
1851 |
-
* ?>
|
1852 |
-
*/
|
1853 |
-
$value = apply_filters( "um_profile_{$key}_empty__filter", false );
|
1854 |
-
}
|
1855 |
-
|
1856 |
-
return $value;
|
1857 |
-
}
|
1858 |
-
|
1859 |
-
|
1860 |
-
/**
|
1861 |
-
* Get youtube video ID from url
|
1862 |
-
*
|
1863 |
-
* @param $url
|
1864 |
-
*
|
1865 |
-
* @return bool
|
1866 |
-
*/
|
1867 |
-
function um_youtube_id_from_url( $url ) {
|
1868 |
-
$pattern =
|
1869 |
-
'%^# Match any youtube URL
|
1870 |
-
(?:https?://)? # Optional scheme. Either http or https
|
1871 |
-
(?:www\.)? # Optional www subdomain
|
1872 |
-
(?: # Group host alternatives
|
1873 |
-
youtu\.be/ # Either youtu.be,
|
1874 |
-
| youtube\.com # or youtube.com
|
1875 |
-
(?: # Group path alternatives
|
1876 |
-
/embed/ # Either /embed/
|
1877 |
-
| /v/ # or /v/
|
1878 |
-
| /watch\?v= # or /watch\?v=
|
1879 |
-
) # End path alternatives.
|
1880 |
-
) # End host alternatives.
|
1881 |
-
([\w-]{10,12}) # Allow 10-12 for 11 char youtube id.
|
1882 |
-
$%x';
|
1883 |
-
$result = preg_match( $pattern, $url, $matches );
|
1884 |
-
if ( false !== $result && isset( $matches[1] ) ) {
|
1885 |
-
return $matches[1];
|
1886 |
-
}
|
1887 |
-
|
1888 |
-
return false;
|
1889 |
-
}
|
1890 |
-
|
1891 |
-
|
1892 |
-
/**
|
1893 |
-
* Find closest number in an array
|
1894 |
-
*
|
1895 |
-
* @param $array
|
1896 |
-
* @param $number
|
1897 |
-
*
|
1898 |
-
* @return mixed
|
1899 |
-
*/
|
1900 |
-
function um_closest_num( $array, $number ) {
|
1901 |
-
sort( $array );
|
1902 |
-
foreach ( $array as $a ) {
|
1903 |
-
if ( $a >= $number ) return $a;
|
1904 |
-
}
|
1905 |
-
|
1906 |
-
return end( $array );
|
1907 |
-
}
|
1908 |
-
|
1909 |
-
|
1910 |
-
/**
|
1911 |
-
* get cover uri
|
1912 |
-
*
|
1913 |
-
* @param $image
|
1914 |
-
* @param $attrs
|
1915 |
-
*
|
1916 |
-
* @return bool|string
|
1917 |
-
*/
|
1918 |
-
function um_get_cover_uri( $image, $attrs ) {
|
1919 |
-
$uri = false;
|
1920 |
-
$uri_common = false;
|
1921 |
-
$ext = '.' . pathinfo( $image, PATHINFO_EXTENSION );
|
1922 |
-
|
1923 |
-
$ratio = str_replace(':1','',UM()->options()->get( 'profile_cover_ratio' ) );
|
1924 |
-
$height = round( $attrs / $ratio );
|
1925 |
-
|
1926 |
-
if ( is_multisite() ) {
|
1927 |
-
//multisite fix for old customers
|
1928 |
-
$multisite_fix_dir = UM()->uploader()->get_upload_base_dir();
|
1929 |
-
$multisite_fix_url = UM()->uploader()->get_upload_base_url();
|
1930 |
-
$multisite_fix_dir = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $multisite_fix_dir );
|
1931 |
-
$multisite_fix_url = str_replace( '/sites/' . get_current_blog_id() . '/', '/', $multisite_fix_url );
|
1932 |
-
|
1933 |
-
if ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo{$ext}" ) ) {
|
1934 |
-
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/cover_photo{$ext}?" . current_time( 'timestamp' );
|
1935 |
-
}
|
1936 |
-
|
1937 |
-
if ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}{$ext}" ) ) {
|
1938 |
-
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/cover_photo-{$attrs}{$ext}?" . current_time( 'timestamp' );
|
1939 |
-
}elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}x{$height}{$ext}" ) ) {
|
1940 |
-
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/cover_photo-{$attrs}x{$height}{$ext}?". current_time( 'timestamp' );
|
1941 |
-
}
|
1942 |
-
}
|
1943 |
-
|
1944 |
-
if ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo{$ext}" ) ) {
|
1945 |
-
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/cover_photo{$ext}?" . current_time( 'timestamp' );
|
1946 |
-
}
|
1947 |
-
|
1948 |
-
if ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}{$ext}" ) ) {
|
1949 |
-
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/cover_photo-{$attrs}{$ext}?" . current_time( 'timestamp' );
|
1950 |
-
}elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}x{$height}{$ext}" ) ) {
|
1951 |
-
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/cover_photo-{$attrs}x{$height}{$ext}?". current_time( 'timestamp' );
|
1952 |
-
}
|
1953 |
-
|
1954 |
-
if ( ! empty( $uri_common ) && empty( $uri ) ) {
|
1955 |
-
$uri = $uri_common;
|
1956 |
-
}
|
1957 |
-
|
1958 |
-
return $uri;
|
1959 |
-
}
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
/**
|
1964 |
-
* get avatar URL instead of image
|
1965 |
-
*
|
1966 |
-
* @param $get_avatar
|
1967 |
-
*
|
1968 |
-
* @return mixed
|
1969 |
-
*/
|
1970 |
-
function um_get_avatar_url( $get_avatar ) {
|
1971 |
-
preg_match( '/src="(.*?)"/i', $get_avatar, $matches );
|
1972 |
-
|
1973 |
-
return isset( $matches[1] ) ? $matches[1] : '';
|
1974 |
-
}
|
1975 |
-
|
1976 |
-
|
1977 |
-
/**
|
1978 |
-
* get avatar uri
|
1979 |
-
*
|
1980 |
-
* @param $image
|
1981 |
-
* @param string|array $attrs
|
1982 |
-
*
|
1983 |
-
* @return bool|string
|
1984 |
-
*/
|
1985 |
-
function um_get_avatar_uri( $image, $attrs ) {
|
1986 |
-
$uri = false;
|
1987 |
-
$uri_common = false;
|
1988 |
-
$find = false;
|
1989 |
-
$ext = '.' . pathinfo( $image, PATHINFO_EXTENSION );
|
1990 |
-
|
1991 |
-
if ( is_multisite() ) {
|
1992 |
-
//multisite fix for old customers
|
1993 |
-
$multisite_fix_dir = UM()->uploader()->get_upload_base_dir();
|
1994 |
-
$multisite_fix_url = UM()->uploader()->get_upload_base_url();
|
1995 |
-
$multisite_fix_dir = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $multisite_fix_dir );
|
1996 |
-
$multisite_fix_url = str_replace( '/sites/' . get_current_blog_id() . '/', '/', $multisite_fix_url );
|
1997 |
-
|
1998 |
-
if ( $attrs == 'original' && file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo{$ext}" ) ) {
|
1999 |
-
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo{$ext}";
|
2000 |
-
} elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$attrs}x{$attrs}{$ext}" ) ) {
|
2001 |
-
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo-{$attrs}x{$attrs}{$ext}";
|
2002 |
-
} elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$attrs}{$ext}" ) ) {
|
2003 |
-
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo-{$attrs}{$ext}";
|
2004 |
-
} else {
|
2005 |
-
$sizes = UM()->options()->get( 'photo_thumb_sizes' );
|
2006 |
-
if ( is_array( $sizes ) ) {
|
2007 |
-
$find = um_closest_num( $sizes, $attrs );
|
2008 |
-
}
|
2009 |
-
|
2010 |
-
if ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$find}x{$find}{$ext}" ) ) {
|
2011 |
-
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo-{$find}x{$find}{$ext}";
|
2012 |
-
} elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$find}{$ext}" ) ) {
|
2013 |
-
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo-{$find}{$ext}";
|
2014 |
-
} elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo{$ext}" ) ) {
|
2015 |
-
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo{$ext}";
|
2016 |
-
}
|
2017 |
-
}
|
2018 |
-
}
|
2019 |
-
|
2020 |
-
if ( $attrs == 'original' && file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo{$ext}" ) ) {
|
2021 |
-
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo{$ext}";
|
2022 |
-
} elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$attrs}x{$attrs}{$ext}" ) ) {
|
2023 |
-
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo-{$attrs}x{$attrs}{$ext}";
|
2024 |
-
} elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$attrs}{$ext}" ) ) {
|
2025 |
-
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo-{$attrs}{$ext}";
|
2026 |
-
} else {
|
2027 |
-
$sizes = UM()->options()->get( 'photo_thumb_sizes' );
|
2028 |
-
if ( is_array( $sizes ) ) {
|
2029 |
-
$find = um_closest_num( $sizes, $attrs );
|
2030 |
-
}
|
2031 |
-
|
2032 |
-
if ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$find}x{$find}{$ext}" ) ) {
|
2033 |
-
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo-{$find}x{$find}{$ext}";
|
2034 |
-
} elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$find}{$ext}" ) ) {
|
2035 |
-
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo-{$find}{$ext}";
|
2036 |
-
} elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo{$ext}" ) ) {
|
2037 |
-
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo{$ext}";
|
2038 |
-
}
|
2039 |
-
}
|
2040 |
-
|
2041 |
-
if ( ! empty( $uri_common ) && empty( $uri ) ) {
|
2042 |
-
$uri = $uri_common;
|
2043 |
-
}
|
2044 |
-
|
2045 |
-
/**
|
2046 |
-
* UM hook
|
2047 |
-
*
|
2048 |
-
* @type filter
|
2049 |
-
* @title um_filter_avatar_cache_time
|
2050 |
-
* @description Change Profile field value if it's empty
|
2051 |
-
* @input_vars
|
2052 |
-
* [{"var":"$timestamp","type":"timestamp","desc":"Avatar cache time"},
|
2053 |
-
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
2054 |
-
* @change_log
|
2055 |
-
* ["Since: 2.0"]
|
2056 |
-
* @usage add_filter( 'um_filter_avatar_cache_time', 'function_name', 10, 2 );
|
2057 |
-
* @example
|
2058 |
-
* <?php
|
2059 |
-
* add_filter( 'um_filter_avatar_cache_time', 'my_avatar_cache_time', 10, 2 );
|
2060 |
-
* function my_avatar_cache_time( $timestamp, $user_id ) {
|
2061 |
-
* // your code here
|
2062 |
-
* return $timestamp;
|
2063 |
-
* }
|
2064 |
-
* ?>
|
2065 |
-
*/
|
2066 |
-
$cache_time = apply_filters( 'um_filter_avatar_cache_time', current_time( 'timestamp' ), um_user( 'ID' ) );
|
2067 |
-
if ( ! empty( $cache_time ) ) {
|
2068 |
-
$uri .= "?{$cache_time}";
|
2069 |
-
}
|
2070 |
-
|
2071 |
-
return $uri;
|
2072 |
-
}
|
2073 |
-
|
2074 |
-
|
2075 |
-
/**
|
2076 |
-
* Default avatar URL
|
2077 |
-
*
|
2078 |
-
* @return string
|
2079 |
-
*/
|
2080 |
-
function um_get_default_avatar_uri() {
|
2081 |
-
$uri = UM()->options()->get( 'default_avatar' );
|
2082 |
-
$uri = !empty( $uri['url'] ) ? $uri['url'] : '';
|
2083 |
-
if ( ! $uri ) {
|
2084 |
-
$uri = um_url . 'assets/img/default_avatar.jpg';
|
2085 |
-
}
|
2086 |
-
|
2087 |
-
return set_url_scheme( $uri );
|
2088 |
-
}
|
2089 |
-
|
2090 |
-
|
2091 |
-
/**
|
2092 |
-
* get user avatar url
|
2093 |
-
*
|
2094 |
-
* @param $user_id
|
2095 |
-
* @param $size
|
2096 |
-
*
|
2097 |
-
* @return bool|string
|
2098 |
-
*/
|
2099 |
-
function um_get_user_avatar_data( $user_id = '', $size = '96' ) {
|
2100 |
-
if( empty( $user_id ) ) {
|
2101 |
-
$user_id = um_user( 'ID' );
|
2102 |
-
} else {
|
2103 |
-
um_fetch_user( $user_id );
|
2104 |
-
}
|
2105 |
-
|
2106 |
-
$data = array(
|
2107 |
-
'user_id' => $user_id,
|
2108 |
-
'default' => um_get_default_avatar_uri(),
|
2109 |
-
'class' => 'gravatar avatar avatar-' . $size . ' um-avatar',
|
2110 |
-
'size' => $size
|
2111 |
-
);
|
2112 |
-
|
2113 |
-
if ( $profile_photo = um_profile( 'profile_photo' ) ) {
|
2114 |
-
$data['url'] = um_get_avatar_uri( $profile_photo, $size );
|
2115 |
-
$data['type'] = 'upload';
|
2116 |
-
$data['class'] .= ' um-avatar-uploaded';
|
2117 |
-
} elseif ( $synced_profile_photo = um_user( 'synced_profile_photo' ) ) {
|
2118 |
-
$data['url'] = $synced_profile_photo;
|
2119 |
-
$data['type'] = 'sync';
|
2120 |
-
$data['class'] .= ' um-avatar-default';
|
2121 |
-
} elseif ( UM()->options()->get( 'use_gravatars' ) ) {
|
2122 |
-
$avatar_hash_id = md5( um_user( 'user_email' ) );
|
2123 |
-
$data['url'] = set_url_scheme( '//gravatar.com/avatar/' . $avatar_hash_id );
|
2124 |
-
$data['url'] = add_query_arg( 's', 400, $data['url'] );
|
2125 |
-
$rating = get_option( 'avatar_rating' );
|
2126 |
-
if ( ! empty( $rating ) ) {
|
2127 |
-
$data['url'] = add_query_arg( 'r', $rating, $data['url'] );
|
2128 |
-
}
|
2129 |
-
|
2130 |
-
$gravatar_type = UM()->options()->get( 'use_um_gravatar_default_builtin_image' );
|
2131 |
-
if ( $gravatar_type == 'default' ) {
|
2132 |
-
if ( UM()->options()->get( 'use_um_gravatar_default_image' ) ) {
|
2133 |
-
$data['url'] = add_query_arg( 'd', $data['default'], $data['url'] );
|
2134 |
-
} else {
|
2135 |
-
$default = get_option( 'avatar_default', 'mystery' );
|
2136 |
-
if ( $default == 'gravatar_default' ) {
|
2137 |
-
$default = '';
|
2138 |
-
}
|
2139 |
-
$data['url'] = add_query_arg( 'd', $default, $data['url'] );
|
2140 |
-
}
|
2141 |
-
} else {
|
2142 |
-
$data['url'] = add_query_arg( 'd', $gravatar_type, $data['url'] );
|
2143 |
-
}
|
2144 |
-
|
2145 |
-
$data['type'] = 'gravatar';
|
2146 |
-
$data['class'] .= ' um-avatar-gravatar';
|
2147 |
-
} else {
|
2148 |
-
$data['url'] = $data['default'];
|
2149 |
-
$data['type'] = 'default';
|
2150 |
-
$data['class'] .= ' um-avatar-default';
|
2151 |
-
}
|
2152 |
-
|
2153 |
-
|
2154 |
-
/**
|
2155 |
-
* UM hook
|
2156 |
-
*
|
2157 |
-
* @type filter
|
2158 |
-
* @title um_user_avatar_url_filter
|
2159 |
-
* @description Change user avatar URL
|
2160 |
-
* @input_vars
|
2161 |
-
* [{"var":"$avatar_uri","type":"string","desc":"Avatar URL"},
|
2162 |
-
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
2163 |
-
* @change_log
|
2164 |
-
* ["Since: 2.0"]
|
2165 |
-
* @usage add_filter( 'um_user_avatar_url_filter', 'function_name', 10, 2 );
|
2166 |
-
* @example
|
2167 |
-
* <?php
|
2168 |
-
* add_filter( 'um_user_avatar_url_filter', 'my_user_avatar_url', 10, 2 );
|
2169 |
-
* function my_user_avatar_url( $avatar_uri ) {
|
2170 |
-
* // your code here
|
2171 |
-
* return $avatar_uri;
|
2172 |
-
* }
|
2173 |
-
* ?>
|
2174 |
-
*/
|
2175 |
-
$data['url'] = apply_filters( 'um_user_avatar_url_filter', $data['url'], $user_id, $data );
|
2176 |
-
/**
|
2177 |
-
* UM hook
|
2178 |
-
*
|
2179 |
-
* @type filter
|
2180 |
-
* @title um_avatar_image_alternate_text
|
2181 |
-
* @description Change user display name on um_user function profile photo
|
2182 |
-
* @input_vars
|
2183 |
-
* [{"var":"$display_name","type":"string","desc":"User Display Name"}]
|
2184 |
-
* @change_log
|
2185 |
-
* ["Since: 2.0"]
|
2186 |
-
* @usage add_filter( 'um_avatar_image_alternate_text', 'function_name', 10, 1 );
|
2187 |
-
* @example
|
2188 |
-
* <?php
|
2189 |
-
* add_filter( 'um_avatar_image_alternate_text', 'my_avatar_image_alternate_text', 10, 1 );
|
2190 |
-
* function my_avatar_image_alternate_text( $display_name ) {
|
2191 |
-
* // your code here
|
2192 |
-
* return $display_name;
|
2193 |
-
* }
|
2194 |
-
* ?>
|
2195 |
-
*/
|
2196 |
-
$data['alt'] = apply_filters( "um_avatar_image_alternate_text", um_user( "display_name" ), $data );
|
2197 |
-
|
2198 |
-
return $data;
|
2199 |
-
}
|
2200 |
-
|
2201 |
-
|
2202 |
-
/**
|
2203 |
-
* get user avatar url
|
2204 |
-
*
|
2205 |
-
* @param $user_id
|
2206 |
-
* @param $size
|
2207 |
-
*
|
2208 |
-
* @return bool|string
|
2209 |
-
*/
|
2210 |
-
function um_get_user_avatar_url( $user_id = '', $size = '96' ) {
|
2211 |
-
$data = um_get_user_avatar_data( $user_id, $size );
|
2212 |
-
return $data['url'];
|
2213 |
-
}
|
2214 |
-
|
2215 |
-
|
2216 |
-
/**
|
2217 |
-
* default cover
|
2218 |
-
*
|
2219 |
-
* @return mixed|string|void
|
2220 |
-
*/
|
2221 |
-
function um_get_default_cover_uri() {
|
2222 |
-
$uri = UM()->options()->get( 'default_cover' );
|
2223 |
-
$uri = ! empty( $uri['url'] ) ? $uri['url'] : '';
|
2224 |
-
if ( $uri ) {
|
2225 |
-
|
2226 |
-
/**
|
2227 |
-
* UM hook
|
2228 |
-
*
|
2229 |
-
* @type filter
|
2230 |
-
* @title um_get_default_cover_uri_filter
|
2231 |
-
* @description Change Default Cover URL
|
2232 |
-
* @input_vars
|
2233 |
-
* [{"var":"$uri","type":"string","desc":"Default Cover URL"}]
|
2234 |
-
* @change_log
|
2235 |
-
* ["Since: 2.0"]
|
2236 |
-
* @usage add_filter( 'um_get_default_cover_uri_filter', 'function_name', 10, 1 );
|
2237 |
-
* @example
|
2238 |
-
* <?php
|
2239 |
-
* add_filter( 'um_get_default_cover_uri_filter', 'my_default_cover_uri', 10, 1 );
|
2240 |
-
* function my_default_cover_uri( $uri ) {
|
2241 |
-
* // your code here
|
2242 |
-
* return $uri;
|
2243 |
-
* }
|
2244 |
-
* ?>
|
2245 |
-
*/
|
2246 |
-
return apply_filters( 'um_get_default_cover_uri_filter', $uri );
|
2247 |
-
}
|
2248 |
-
|
2249 |
-
return '';
|
2250 |
-
}
|
2251 |
-
|
2252 |
-
|
2253 |
-
/**
|
2254 |
-
* @param $data
|
2255 |
-
* @param null $attrs
|
2256 |
-
*
|
2257 |
-
* @return string|array
|
2258 |
-
*/
|
2259 |
-
function um_user( $data, $attrs = null ) {
|
2260 |
-
|
2261 |
-
switch ($data) {
|
2262 |
-
|
2263 |
-
default:
|
2264 |
-
|
2265 |
-
$value = um_profile( $data );
|
2266 |
-
|
2267 |
-
$value = maybe_unserialize( $value );
|
2268 |
-
|
2269 |
-
if ( in_array( $data, array( 'role', 'gender' ) ) ) {
|
2270 |
-
if ( is_array( $value ) ) {
|
2271 |
-
$value = implode( ",", $value );
|
2272 |
-
}
|
2273 |
-
|
2274 |
-
return $value;
|
2275 |
-
}
|
2276 |
-
|
2277 |
-
return $value;
|
2278 |
-
break;
|
2279 |
-
|
2280 |
-
case 'user_email':
|
2281 |
-
|
2282 |
-
$user_email_in_meta = get_user_meta( um_user( 'ID' ), 'user_email', true );
|
2283 |
-
if ( $user_email_in_meta ) {
|
2284 |
-
delete_user_meta( um_user( 'ID' ), 'user_email' );
|
2285 |
-
}
|
2286 |
-
|
2287 |
-
$value = um_profile( $data );
|
2288 |
-
|
2289 |
-
return $value;
|
2290 |
-
break;
|
2291 |
-
|
2292 |
-
case 'user_login':
|
2293 |
-
|
2294 |
-
$user_login_in_meta = get_user_meta( um_user( 'ID' ), 'user_login', true );
|
2295 |
-
if ( $user_login_in_meta ) {
|
2296 |
-
delete_user_meta( um_user( 'ID' ), 'user_login' );
|
2297 |
-
}
|
2298 |
-
|
2299 |
-
$value = um_profile( $data );
|
2300 |
-
|
2301 |
-
return $value;
|
2302 |
-
break;
|
2303 |
-
|
2304 |
-
case 'first_name':
|
2305 |
-
case 'last_name':
|
2306 |
-
|
2307 |
-
$name = um_profile( $data );
|
2308 |
-
|
2309 |
-
|
2310 |
-
|
2311 |
-
|
2312 |
-
|
2313 |
-
|
2314 |
-
*
|
2315 |
-
*
|
2316 |
-
*
|
2317 |
-
* @
|
2318 |
-
*
|
2319 |
-
* @
|
2320 |
-
*
|
2321 |
-
*
|
2322 |
-
*
|
2323 |
-
*
|
2324 |
-
*
|
2325 |
-
*
|
2326 |
-
*
|
2327 |
-
*
|
2328 |
-
|
2329 |
-
|
2330 |
-
|
2331 |
-
|
2332 |
-
|
2333 |
-
|
2334 |
-
|
2335 |
-
|
2336 |
-
|
2337 |
-
|
2338 |
-
|
2339 |
-
|
2340 |
-
|
2341 |
-
|
2342 |
-
|
2343 |
-
|
2344 |
-
|
2345 |
-
|
2346 |
-
|
2347 |
-
|
2348 |
-
|
2349 |
-
|
2350 |
-
|
2351 |
-
|
2352 |
-
|
2353 |
-
|
2354 |
-
|
2355 |
-
|
2356 |
-
|
2357 |
-
|
2358 |
-
|
2359 |
-
|
2360 |
-
|
2361 |
-
|
2362 |
-
|
2363 |
-
|
2364 |
-
|
2365 |
-
|
2366 |
-
|
2367 |
-
|
2368 |
-
|
2369 |
-
|
2370 |
-
|
2371 |
-
|
2372 |
-
|
2373 |
-
|
2374 |
-
|
2375 |
-
|
2376 |
-
|
2377 |
-
|
2378 |
-
|
2379 |
-
|
2380 |
-
|
2381 |
-
|
2382 |
-
|
2383 |
-
|
2384 |
-
|
2385 |
-
|
2386 |
-
|
2387 |
-
|
2388 |
-
|
2389 |
-
|
2390 |
-
|
2391 |
-
|
2392 |
-
|
2393 |
-
}
|
2394 |
-
|
2395 |
-
if ( $op == '
|
2396 |
-
if ( um_user( 'first_name' ) && um_user( 'last_name' ) ) {
|
2397 |
-
$name = um_user( '
|
2398 |
-
} else {
|
2399 |
-
$name = um_profile( $data );
|
2400 |
-
}
|
2401 |
-
|
2402 |
-
|
2403 |
-
|
2404 |
-
|
2405 |
-
|
2406 |
-
|
2407 |
-
|
2408 |
-
|
2409 |
-
|
2410 |
-
|
2411 |
-
|
2412 |
-
|
2413 |
-
|
2414 |
-
|
2415 |
-
|
2416 |
-
|
2417 |
-
|
2418 |
-
$name =
|
2419 |
-
}
|
2420 |
-
|
2421 |
-
|
2422 |
-
|
2423 |
-
|
2424 |
-
|
2425 |
-
|
2426 |
-
|
2427 |
-
|
2428 |
-
|
2429 |
-
$name =
|
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 |
-
case '
|
2494 |
-
|
2495 |
-
|
2496 |
-
|
2497 |
-
|
2498 |
-
|
2499 |
-
|
2500 |
-
|
2501 |
-
|
2502 |
-
|
2503 |
-
|
2504 |
-
|
2505 |
-
|
2506 |
-
|
2507 |
-
|
2508 |
-
|
2509 |
-
|
2510 |
-
|
2511 |
-
|
2512 |
-
|
2513 |
-
|
2514 |
-
|
2515 |
-
|
2516 |
-
|
2517 |
-
$
|
2518 |
-
|
2519 |
-
|
2520 |
-
|
2521 |
-
|
2522 |
-
|
2523 |
-
|
2524 |
-
|
2525 |
-
|
2526 |
-
|
2527 |
-
|
2528 |
-
|
2529 |
-
|
2530 |
-
|
2531 |
-
|
2532 |
-
|
2533 |
-
|
2534 |
-
|
2535 |
-
|
2536 |
-
|
2537 |
-
|
2538 |
-
|
2539 |
-
|
2540 |
-
|
2541 |
-
|
2542 |
-
|
2543 |
-
|
2544 |
-
*
|
2545 |
-
*
|
2546 |
-
*
|
2547 |
-
*
|
2548 |
-
*
|
2549 |
-
|
2550 |
-
|
2551 |
-
|
2552 |
-
|
2553 |
-
|
2554 |
-
|
2555 |
-
|
2556 |
-
|
2557 |
-
|
2558 |
-
|
2559 |
-
|
2560 |
-
|
2561 |
-
|
2562 |
-
|
2563 |
-
|
2564 |
-
|
2565 |
-
|
2566 |
-
|
2567 |
-
|
2568 |
-
|
2569 |
-
|
2570 |
-
|
2571 |
-
|
2572 |
-
|
2573 |
-
|
2574 |
-
|
2575 |
-
|
2576 |
-
|
2577 |
-
|
2578 |
-
|
2579 |
-
|
2580 |
-
|
2581 |
-
|
2582 |
-
|
2583 |
-
|
2584 |
-
|
2585 |
-
|
2586 |
-
|
2587 |
-
|
2588 |
-
|
2589 |
-
|
2590 |
-
|
2591 |
-
|
2592 |
-
|
2593 |
-
*
|
2594 |
-
|
2595 |
-
|
2596 |
-
|
2597 |
-
|
2598 |
-
|
2599 |
-
|
2600 |
-
|
2601 |
-
|
2602 |
-
|
2603 |
-
|
2604 |
-
|
2605 |
-
|
2606 |
-
|
2607 |
-
|
2608 |
-
|
2609 |
-
|
2610 |
-
*
|
2611 |
-
*
|
2612 |
-
* @
|
2613 |
-
|
2614 |
-
|
2615 |
-
|
2616 |
-
|
2617 |
-
|
2618 |
-
|
2619 |
-
|
2620 |
-
|
2621 |
-
|
2622 |
-
|
2623 |
-
|
2624 |
-
|
2625 |
-
|
2626 |
-
|
2627 |
-
|
2628 |
-
|
2629 |
-
|
2630 |
-
|
2631 |
-
|
2632 |
-
|
2633 |
-
|
2634 |
-
$
|
2635 |
-
|
2636 |
-
|
2637 |
-
|
2638 |
-
|
2639 |
-
|
2640 |
-
|
2641 |
-
|
2642 |
-
|
2643 |
-
|
2644 |
-
|
2645 |
-
|
2646 |
-
|
2647 |
-
|
2648 |
-
|
2649 |
-
|
2650 |
-
|
2651 |
-
|
2652 |
-
|
2653 |
-
|
2654 |
-
|
2655 |
-
|
2656 |
-
|
2657 |
-
|
2658 |
-
|
2659 |
-
|
2660 |
-
|
2661 |
-
|
2662 |
-
|
2663 |
-
|
2664 |
-
|
2665 |
-
|
2666 |
-
|
2667 |
-
|
2668 |
-
|
2669 |
-
|
2670 |
-
|
2671 |
-
|
2672 |
-
|
2673 |
-
|
2674 |
-
|
2675 |
-
|
2676 |
-
|
2677 |
-
|
2678 |
-
|
2679 |
-
|
2680 |
-
$host = '
|
2681 |
-
}
|
2682 |
-
|
2683 |
-
|
2684 |
-
|
2685 |
-
|
2686 |
-
|
2687 |
-
|
2688 |
-
|
2689 |
-
|
2690 |
-
|
2691 |
-
|
2692 |
-
|
2693 |
-
|
2694 |
-
|
2695 |
-
|
2696 |
-
|
2697 |
-
|
2698 |
-
|
2699 |
-
|
2700 |
-
|
2701 |
-
|
2702 |
-
|
2703 |
-
|
2704 |
-
|
2705 |
-
|
2706 |
-
|
2707 |
-
|
2708 |
-
|
2709 |
-
|
2710 |
-
|
2711 |
-
|
2712 |
-
|
2713 |
-
|
2714 |
-
|
2715 |
-
|
2716 |
-
|
2717 |
-
|
2718 |
-
|
2719 |
-
|
2720 |
-
|
2721 |
-
|
2722 |
-
|
2723 |
-
|
2724 |
-
|
2725 |
-
|
2726 |
-
|
2727 |
-
|
2728 |
-
|
2729 |
-
|
2730 |
-
return
|
2731 |
-
}
|
2732 |
-
|
2733 |
-
|
2734 |
-
/**
|
2735 |
-
*
|
2736 |
-
|
2737 |
-
|
2738 |
-
|
2739 |
-
|
2740 |
-
|
2741 |
-
|
2742 |
-
|
2743 |
-
|
2744 |
-
|
2745 |
-
|
2746 |
-
|
2747 |
-
|
2748 |
-
|
2749 |
-
|
2750 |
-
|
2751 |
-
|
2752 |
-
function
|
2753 |
-
|
2754 |
-
|
2755 |
-
|
2756 |
-
|
2757 |
-
|
2758 |
-
|
2759 |
-
|
2760 |
-
|
2761 |
-
|
2762 |
-
|
2763 |
-
|
2764 |
-
|
2765 |
-
|
2766 |
-
|
2767 |
-
|
2768 |
-
|
2769 |
-
|
2770 |
-
|
2771 |
-
|
2772 |
-
|
2773 |
-
|
2774 |
-
|
2775 |
-
|
2776 |
-
|
2777 |
-
|
2778 |
-
|
2779 |
-
|
2780 |
-
|
2781 |
-
|
2782 |
-
|
2783 |
-
|
2784 |
-
|
2785 |
-
|
2786 |
-
|
2787 |
-
|
2788 |
-
|
2789 |
-
|
2790 |
-
|
2791 |
-
|
2792 |
-
|
2793 |
-
|
2794 |
-
function um_is_amp( $check_theme_support = true ) {
|
2795 |
-
|
2796 |
-
$is_amp = false;
|
2797 |
-
|
2798 |
-
if ( ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) ||
|
2799 |
-
( function_exists( 'is_better_amp' ) && is_better_amp() ) ) {
|
2800 |
-
$is_amp = true;
|
2801 |
-
}
|
2802 |
-
|
2803 |
-
if ( $is_amp && $check_theme_support ) {
|
2804 |
-
$is_amp = current_theme_supports( 'amp' );
|
2805 |
-
}
|
2806 |
-
|
2807 |
-
return apply_filters( 'um_is_amp', $is_amp );
|
2808 |
-
}
|
1 |
+
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
|
2 |
+
|
3 |
+
|
4 |
+
//Make public functions without class creation
|
5 |
+
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Trim string by char length
|
9 |
+
*
|
10 |
+
*
|
11 |
+
* @param $s
|
12 |
+
* @param int $length
|
13 |
+
*
|
14 |
+
* @return string
|
15 |
+
*/
|
16 |
+
function um_trim_string( $s, $length = 20 ) {
|
17 |
+
$s = mb_strlen( $s ) > $length ? substr( $s, 0, $length ) . "..." : $s;
|
18 |
+
|
19 |
+
return $s;
|
20 |
+
}
|
21 |
+
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Get where user should be headed after logging
|
25 |
+
*
|
26 |
+
* @param string $redirect_to
|
27 |
+
*
|
28 |
+
* @return bool|false|mixed|string|void
|
29 |
+
*/
|
30 |
+
function um_dynamic_login_page_redirect( $redirect_to = '' ) {
|
31 |
+
|
32 |
+
$uri = um_get_core_page( 'login' );
|
33 |
+
|
34 |
+
if ( ! $redirect_to ) {
|
35 |
+
$redirect_to = UM()->permalinks()->get_current_url();
|
36 |
+
}
|
37 |
+
|
38 |
+
$redirect_key = urlencode_deep( $redirect_to );
|
39 |
+
|
40 |
+
$uri = add_query_arg( 'redirect_to', $redirect_key, $uri );
|
41 |
+
|
42 |
+
return $uri;
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Checks if session has been started
|
48 |
+
*
|
49 |
+
* @return bool
|
50 |
+
*/
|
51 |
+
function um_is_session_started() {
|
52 |
+
|
53 |
+
if ( php_sapi_name() !== 'cli' ) {
|
54 |
+
if ( version_compare( phpversion(), '5.4.0', '>=' ) ) {
|
55 |
+
return session_status() === PHP_SESSION_ACTIVE ? true : false;
|
56 |
+
} else {
|
57 |
+
return session_id() === '' ? false : true;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
return false;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* User clean basename
|
66 |
+
*
|
67 |
+
* @param $value
|
68 |
+
*
|
69 |
+
* @return mixed|void
|
70 |
+
*/
|
71 |
+
function um_clean_user_basename( $value ) {
|
72 |
+
|
73 |
+
$raw_value = $value;
|
74 |
+
$value = str_replace( '.', ' ', $value );
|
75 |
+
$value = str_replace( '-', ' ', $value );
|
76 |
+
$value = str_replace( '+', ' ', $value );
|
77 |
+
|
78 |
+
/**
|
79 |
+
* UM hook
|
80 |
+
*
|
81 |
+
* @type filter
|
82 |
+
* @title um_clean_user_basename_filter
|
83 |
+
* @description Change clean user basename
|
84 |
+
* @input_vars
|
85 |
+
* [{"var":"$basename","type":"string","desc":"User basename"},
|
86 |
+
* {"var":"$raw_basename","type":"string","desc":"RAW user basename"}]
|
87 |
+
* @change_log
|
88 |
+
* ["Since: 2.0"]
|
89 |
+
* @usage add_filter( 'um_clean_user_basename_filter', 'function_name', 10, 2 );
|
90 |
+
* @example
|
91 |
+
* <?php
|
92 |
+
* add_filter( 'um_clean_user_basename_filter', 'my_clean_user_basename', 10, 2 );
|
93 |
+
* function my_clean_user_basename( $basename, $raw_basename ) {
|
94 |
+
* // your code here
|
95 |
+
* return $basename;
|
96 |
+
* }
|
97 |
+
* ?>
|
98 |
+
*/
|
99 |
+
$value = apply_filters( 'um_clean_user_basename_filter', $value, $raw_value );
|
100 |
+
|
101 |
+
return $value;
|
102 |
+
}
|
103 |
+
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Getting replace placeholders array
|
107 |
+
*
|
108 |
+
* @return array
|
109 |
+
*/
|
110 |
+
function um_replace_placeholders() {
|
111 |
+
|
112 |
+
$search = array(
|
113 |
+
'{display_name}',
|
114 |
+
'{first_name}',
|
115 |
+
'{last_name}',
|
116 |
+
'{gender}',
|
117 |
+
'{username}',
|
118 |
+
'{email}',
|
119 |
+
'{site_name}',
|
120 |
+
'{user_account_link}',
|
121 |
+
);
|
122 |
+
|
123 |
+
|
124 |
+
/**
|
125 |
+
* UM hook
|
126 |
+
*
|
127 |
+
* @type filter
|
128 |
+
* @title um_template_tags_patterns_hook
|
129 |
+
* @description Extend UM placeholders
|
130 |
+
* @input_vars
|
131 |
+
* [{"var":"$placeholders","type":"array","desc":"UM Placeholders"}]
|
132 |
+
* @change_log
|
133 |
+
* ["Since: 2.0"]
|
134 |
+
* @usage add_filter( 'um_template_tags_patterns_hook', 'function_name', 10, 1 );
|
135 |
+
* @example
|
136 |
+
* <?php
|
137 |
+
* add_filter( 'um_template_tags_patterns_hook', 'my_template_tags_patterns', 10, 1 );
|
138 |
+
* function my_template_tags_patterns( $placeholders ) {
|
139 |
+
* // your code here
|
140 |
+
* $placeholders[] = '{my_custom_placeholder}';
|
141 |
+
* return $placeholders;
|
142 |
+
* }
|
143 |
+
* ?>
|
144 |
+
*/
|
145 |
+
$search = apply_filters( 'um_template_tags_patterns_hook', $search );
|
146 |
+
|
147 |
+
$replace = array(
|
148 |
+
um_user( 'display_name' ),
|
149 |
+
um_user( 'first_name' ),
|
150 |
+
um_user( 'last_name' ),
|
151 |
+
um_user( 'gender' ),
|
152 |
+
um_user( 'user_login' ),
|
153 |
+
um_user( 'user_email' ),
|
154 |
+
UM()->options()->get( 'site_name' ),
|
155 |
+
um_get_core_page( 'account' ),
|
156 |
+
);
|
157 |
+
|
158 |
+
/**
|
159 |
+
* UM hook
|
160 |
+
*
|
161 |
+
* @type filter
|
162 |
+
* @title um_template_tags_replaces_hook
|
163 |
+
* @description Extend UM replace placeholders
|
164 |
+
* @input_vars
|
165 |
+
* [{"var":"$replace_placeholders","type":"array","desc":"UM Replace Placeholders"}]
|
166 |
+
* @change_log
|
167 |
+
* ["Since: 2.0"]
|
168 |
+
* @usage add_filter( 'um_template_tags_replaces_hook', 'function_name', 10, 1 );
|
169 |
+
* @example
|
170 |
+
* <?php
|
171 |
+
* add_filter( 'um_template_tags_replaces_hook', 'my_template_tags_replaces', 10, 1 );
|
172 |
+
* function my_template_tags_replaces( $replace_placeholders ) {
|
173 |
+
* // your code here
|
174 |
+
* $replace_placeholders[] = 'my_replace_value';
|
175 |
+
* return $replace_placeholders;
|
176 |
+
* }
|
177 |
+
* ?>
|
178 |
+
*/
|
179 |
+
$replace = apply_filters( 'um_template_tags_replaces_hook', $replace );
|
180 |
+
|
181 |
+
return array_combine( $search, $replace );
|
182 |
+
}
|
183 |
+
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Convert template tags
|
187 |
+
*
|
188 |
+
* @param $content
|
189 |
+
* @param array $args
|
190 |
+
* @param bool $with_kses
|
191 |
+
*
|
192 |
+
* @return mixed|string
|
193 |
+
*/
|
194 |
+
function um_convert_tags( $content, $args = array(), $with_kses = true ) {
|
195 |
+
$placeholders = um_replace_placeholders();
|
196 |
+
|
197 |
+
$content = str_replace( array_keys( $placeholders ), array_values( $placeholders ), $content );
|
198 |
+
if ( $with_kses ) {
|
199 |
+
$content = wp_kses_decode_entities( $content );
|
200 |
+
}
|
201 |
+
|
202 |
+
if ( isset( $args['tags'] ) && isset( $args['tags_replace'] ) ) {
|
203 |
+
$content = str_replace( $args['tags'], $args['tags_replace'], $content );
|
204 |
+
}
|
205 |
+
|
206 |
+
$regex = '~\{(usermeta:[^}]*)\}~';
|
207 |
+
preg_match_all( $regex, $content, $matches );
|
208 |
+
|
209 |
+
// Support for all usermeta keys
|
210 |
+
if ( ! empty( $matches[1] ) && is_array( $matches[1] ) ) {
|
211 |
+
foreach ( $matches[1] as $match ) {
|
212 |
+
$key = str_replace( 'usermeta:', '', $match );
|
213 |
+
$value = um_user( $key );
|
214 |
+
if ( is_array( $value ) ) {
|
215 |
+
$value = implode( ', ', $value );
|
216 |
+
}
|
217 |
+
$content = str_replace( '{' . $match . '}', apply_filters( 'um_convert_tags', $value, $key ), $content );
|
218 |
+
}
|
219 |
+
}
|
220 |
+
return $content;
|
221 |
+
}
|
222 |
+
|
223 |
+
|
224 |
+
/**
|
225 |
+
* UM Placeholders for activation link in email
|
226 |
+
*
|
227 |
+
* @param $placeholders
|
228 |
+
*
|
229 |
+
* @return array
|
230 |
+
*/
|
231 |
+
function account_activation_link_tags_patterns( $placeholders ) {
|
232 |
+
$placeholders[] = '{account_activation_link}';
|
233 |
+
return $placeholders;
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* UM Replace Placeholders for activation link in email
|
238 |
+
*
|
239 |
+
* @param $replace_placeholders
|
240 |
+
*
|
241 |
+
* @return array
|
242 |
+
*/
|
243 |
+
function account_activation_link_tags_replaces( $replace_placeholders ) {
|
244 |
+
$replace_placeholders[] = um_user( 'account_activation_link' );
|
245 |
+
return $replace_placeholders;
|
246 |
+
}
|
247 |
+
|
248 |
+
|
249 |
+
/**
|
250 |
+
* @function um_user_ip()
|
251 |
+
*
|
252 |
+
* @description This function returns the IP address of user.
|
253 |
+
*
|
254 |
+
* @usage <?php $user_ip = um_user_ip(); ?>
|
255 |
+
*
|
256 |
+
* @return string The user's IP address.
|
257 |
+
*
|
258 |
+
* @example The example below can retrieve the user's IP address
|
259 |
+
*
|
260 |
+
* <?php
|
261 |
+
*
|
262 |
+
* $user_ip = um_user_ip();
|
263 |
+
* echo 'User IP address is: ' . $user_ip; // prints the user IP address e.g. 127.0.0.1
|
264 |
+
*
|
265 |
+
* ?>
|
266 |
+
*/
|
267 |
+
function um_user_ip() {
|
268 |
+
$ip = '127.0.0.1';
|
269 |
+
|
270 |
+
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
|
271 |
+
//check ip from share internet
|
272 |
+
$ip = $_SERVER['HTTP_CLIENT_IP'];
|
273 |
+
} else if ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
|
274 |
+
//to check ip is pass from proxy
|
275 |
+
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
276 |
+
} else if ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
|
277 |
+
$ip = $_SERVER['REMOTE_ADDR'];
|
278 |
+
}
|
279 |
+
|
280 |
+
/**
|
281 |
+
* UM hook
|
282 |
+
*
|
283 |
+
* @type filter
|
284 |
+
* @title um_user_ip
|
285 |
+
* @description Change User IP
|
286 |
+
* @input_vars
|
287 |
+
* [{"var":"$ip","type":"string","desc":"User IP"}]
|
288 |
+
* @change_log
|
289 |
+
* ["Since: 2.0"]
|
290 |
+
* @usage add_filter( 'um_user_ip', 'function_name', 10, 1 );
|
291 |
+
* @example
|
292 |
+
* <?php
|
293 |
+
* add_filter( 'um_user_ip', 'my_user_ip', 10, 1 );
|
294 |
+
* function my_user_ip( $ip ) {
|
295 |
+
* // your code here
|
296 |
+
* return $ip;
|
297 |
+
* }
|
298 |
+
* ?>
|
299 |
+
*/
|
300 |
+
return apply_filters( 'um_user_ip', $ip );
|
301 |
+
}
|
302 |
+
|
303 |
+
|
304 |
+
/**
|
305 |
+
* If conditions are met return true;
|
306 |
+
*
|
307 |
+
* @param $data
|
308 |
+
*
|
309 |
+
* @return bool
|
310 |
+
*/
|
311 |
+
function um_field_conditions_are_met( $data ) {
|
312 |
+
|
313 |
+
if ( ! isset( $data['conditions'] ) ) {
|
314 |
+
return true;
|
315 |
+
}
|
316 |
+
|
317 |
+
$state = ( isset( $data['conditional_action'] ) && $data['conditional_action'] == 'show' ) ? 1 : 0;
|
318 |
+
|
319 |
+
$first_group = 0;
|
320 |
+
$state_array = array();
|
321 |
+
$count = count( $state_array );
|
322 |
+
foreach ( $data['conditions'] as $k => $arr ) {
|
323 |
+
|
324 |
+
$val = $arr[3];
|
325 |
+
$op = $arr[2];
|
326 |
+
|
327 |
+
if ( strstr( $arr[1], 'role_' ) ) {
|
328 |
+
$arr[1] = 'role';
|
329 |
+
}
|
330 |
+
|
331 |
+
$field = um_profile( $arr[1] );
|
332 |
+
|
333 |
+
|
334 |
+
if ( ! isset( $arr[5] ) || $arr[5] != $first_group ) {
|
335 |
+
|
336 |
+
|
337 |
+
if ( $arr[0] == 'show' ) {
|
338 |
+
|
339 |
+
switch ($op) {
|
340 |
+
case 'equals to':
|
341 |
+
|
342 |
+
$field = maybe_unserialize( $field );
|
343 |
+
|
344 |
+
if (is_array( $field ))
|
345 |
+
$state = in_array( $val, $field ) ? 'show' : 'hide';
|
346 |
+
else
|
347 |
+
$state = ( $field == $val ) ? 'show' : 'hide';
|
348 |
+
|
349 |
+
break;
|
350 |
+
case 'not equals':
|
351 |
+
|
352 |
+
$field = maybe_unserialize( $field );
|
353 |
+
|
354 |
+
if (is_array( $field ))
|
355 |
+
$state = !in_array( $val, $field ) ? 'show' : 'hide';
|
356 |
+
else
|
357 |
+
$state = ( $field != $val ) ? 'show' : 'hide';
|
358 |
+
|
359 |
+
break;
|
360 |
+
case 'empty':
|
361 |
+
|
362 |
+
$state = ( !$field ) ? 'show' : 'hide';
|
363 |
+
|
364 |
+
break;
|
365 |
+
case 'not empty':
|
366 |
+
|
367 |
+
$state = ( $field ) ? 'show' : 'hide';
|
368 |
+
|
369 |
+
break;
|
370 |
+
case 'greater than':
|
371 |
+
if ($field > $val) {
|
372 |
+
$state = 'show';
|
373 |
+
} else {
|
374 |
+
$state = 'hide';
|
375 |
+
}
|
376 |
+
break;
|
377 |
+
case 'less than':
|
378 |
+
if ($field < $val) {
|
379 |
+
$state = 'show';
|
380 |
+
} else {
|
381 |
+
$state = 'hide';
|
382 |
+
}
|
383 |
+
break;
|
384 |
+
case 'contains':
|
385 |
+
if (strstr( $field, $val )) {
|
386 |
+
$state = 'show';
|
387 |
+
} else {
|
388 |
+
$state = 'hide';
|
389 |
+
}
|
390 |
+
break;
|
391 |
+
}
|
392 |
+
} elseif ( $arr[0] == 'hide' ) {
|
393 |
+
|
394 |
+
switch ( $op ) {
|
395 |
+
case 'equals to':
|
396 |
+
|
397 |
+
$field = maybe_unserialize( $field );
|
398 |
+
|
399 |
+
if ( is_array( $field ) ) {
|
400 |
+
$state = in_array( $val, $field ) ? 'hide' : 'show';
|
401 |
+
} else {
|
402 |
+
$state = ( $field == $val ) ? 'hide' : 'show';
|
403 |
+
}
|
404 |
+
|
405 |
+
break;
|
406 |
+
case 'not equals':
|
407 |
+
|
408 |
+
$field = maybe_unserialize( $field );
|
409 |
+
|
410 |
+
if ( is_array( $field ) ) {
|
411 |
+
$state = ! in_array( $val, $field ) ? 'hide' : 'show';
|
412 |
+
} else {
|
413 |
+
$state = ( $field != $val ) ? 'hide' : 'show';
|
414 |
+
}
|
415 |
+
|
416 |
+
break;
|
417 |
+
case 'empty':
|
418 |
+
|
419 |
+
$state = ( ! $field ) ? 'hide' : 'show';
|
420 |
+
|
421 |
+
break;
|
422 |
+
case 'not empty':
|
423 |
+
|
424 |
+
$state = ( $field ) ? 'hide' : 'show';
|
425 |
+
|
426 |
+
break;
|
427 |
+
case 'greater than':
|
428 |
+
if ( $field <= $val ) {
|
429 |
+
$state = 'hide';
|
430 |
+
} else {
|
431 |
+
$state = 'show';
|
432 |
+
}
|
433 |
+
break;
|
434 |
+
case 'less than':
|
435 |
+
if ( $field >= $val ) {
|
436 |
+
$state = 'hide';
|
437 |
+
} else {
|
438 |
+
$state = 'show';
|
439 |
+
}
|
440 |
+
break;
|
441 |
+
case 'contains':
|
442 |
+
if ( strstr( $field, $val ) ) {
|
443 |
+
$state = 'hide';
|
444 |
+
} else {
|
445 |
+
$state = 'show';
|
446 |
+
}
|
447 |
+
break;
|
448 |
+
}
|
449 |
+
}
|
450 |
+
$first_group++;
|
451 |
+
array_push( $state_array, $state );
|
452 |
+
} else {
|
453 |
+
|
454 |
+
if ( $arr[0] == 'show' ) {
|
455 |
+
|
456 |
+
switch ( $op ) {
|
457 |
+
case 'equals to':
|
458 |
+
$field = maybe_unserialize( $field );
|
459 |
+
|
460 |
+
if ( is_array( $field ) ) {
|
461 |
+
$state = in_array( $val, $field ) ? 'show' : 'not_show';
|
462 |
+
} else {
|
463 |
+
$state = ( $field == $val ) ? 'show' : 'not_show';
|
464 |
+
}
|
465 |
+
|
466 |
+
break;
|
467 |
+
case 'not equals':
|
468 |
+
$field = maybe_unserialize( $field );
|
469 |
+
|
470 |
+
if ( is_array( $field ) ) {
|
471 |
+
$state = ! in_array( $val, $field ) ? 'show' : 'not_show';
|
472 |
+
} else {
|
473 |
+
$state = ( $field != $val ) ? 'show' : 'not_show';
|
474 |
+
}
|
475 |
+
|
476 |
+
break;
|
477 |
+
case 'empty':
|
478 |
+
|
479 |
+
$state = ( ! $field ) ? 'show' : 'not_show';
|
480 |
+
|
481 |
+
break;
|
482 |
+
case 'not empty':
|
483 |
+
|
484 |
+
$state = ( $field ) ? 'show': 'not_show';
|
485 |
+
|
486 |
+
break;
|
487 |
+
case 'greater than':
|
488 |
+
if ( $field > $val ) {
|
489 |
+
$state = 'show';
|
490 |
+
} else {
|
491 |
+
$state = 'not_show';
|
492 |
+
}
|
493 |
+
break;
|
494 |
+
case 'less than':
|
495 |
+
if ( $field < $val ) {
|
496 |
+
$state = 'show';
|
497 |
+
} else {
|
498 |
+
$state = 'not_show';
|
499 |
+
}
|
500 |
+
break;
|
501 |
+
case 'contains':
|
502 |
+
if ( strstr( $field, $val ) ) {
|
503 |
+
$state = 'show';
|
504 |
+
} else {
|
505 |
+
$state = 'not_show';
|
506 |
+
}
|
507 |
+
break;
|
508 |
+
}
|
509 |
+
} elseif ( $arr[0] == 'hide' ) {
|
510 |
+
|
511 |
+
switch ( $op ) {
|
512 |
+
case 'equals to':
|
513 |
+
$field = maybe_unserialize( $field );
|
514 |
+
|
515 |
+
if ( is_array( $field ) ) {
|
516 |
+
$state = in_array( $val, $field ) ? 'hide' : 'not_hide';
|
517 |
+
} else {
|
518 |
+
$state = ( $field == $val ) ? 'hide' : 'not_hide';
|
519 |
+
}
|
520 |
+
|
521 |
+
break;
|
522 |
+
case 'not equals':
|
523 |
+
|
524 |
+
$field = maybe_unserialize( $field );
|
525 |
+
|
526 |
+
if ( is_array( $field ) ) {
|
527 |
+
$state = ! in_array( $val, $field ) ? 'hide' : 'not_hide';
|
528 |
+
} else {
|
529 |
+
$state = ( $field != $val ) ? 'hide' : 'not_hide';
|
530 |
+
}
|
531 |
+
|
532 |
+
break;
|
533 |
+
case 'empty':
|
534 |
+
|
535 |
+
$state = ( ! $field ) ? 'hide' : 'not_hide';
|
536 |
+
|
537 |
+
break;
|
538 |
+
case 'not empty':
|
539 |
+
|
540 |
+
$state = ( $field ) ? 'hide' : 'not_hide';
|
541 |
+
|
542 |
+
break;
|
543 |
+
case 'greater than':
|
544 |
+
if ( $field <= $val ) {
|
545 |
+
$state = 'hide';
|
546 |
+
} else {
|
547 |
+
$state = 'not_hide';
|
548 |
+
}
|
549 |
+
break;
|
550 |
+
case 'less than':
|
551 |
+
if ( $field >= $val ) {
|
552 |
+
$state = 'hide';
|
553 |
+
} else {
|
554 |
+
$state = 'not_hide';
|
555 |
+
}
|
556 |
+
break;
|
557 |
+
case 'contains':
|
558 |
+
if ( strstr( $field, $val ) ) {
|
559 |
+
$state = 'hide';
|
560 |
+
} else {
|
561 |
+
$state = 'not_hide';
|
562 |
+
}
|
563 |
+
break;
|
564 |
+
}
|
565 |
+
}
|
566 |
+
if ( isset( $state_array[ $count ] ) ) {
|
567 |
+
if ( $state_array[ $count ] == 'show' || $state_array[ $count ] == 'not_hide' ) {
|
568 |
+
if ( $state == 'show' || $state == 'not_hide' ) {
|
569 |
+
$state_array[ $count ] = 'show';
|
570 |
+
} else {
|
571 |
+
$state_array[ $count ] = 'hide';
|
572 |
+
}
|
573 |
+
} else {
|
574 |
+
if ( $state == 'hide' || $state == 'not_show' ) {
|
575 |
+
$state_array[ $count ] = 'hide';
|
576 |
+
} else {
|
577 |
+
$state_array[ $count ] = 'hide';
|
578 |
+
}
|
579 |
+
}
|
580 |
+
} else {
|
581 |
+
if ( $state == 'show' || $state == 'not_hide' ) {
|
582 |
+
$state_array[ $count ] = 'show';
|
583 |
+
} else {
|
584 |
+
$state_array[ $count ] = 'hide';
|
585 |
+
}
|
586 |
+
}
|
587 |
+
}
|
588 |
+
|
589 |
+
|
590 |
+
}
|
591 |
+
$result = array_unique( $state_array );
|
592 |
+
if ( ! in_array( 'show', $result ) ) {
|
593 |
+
return $state = false;
|
594 |
+
} else {
|
595 |
+
return $state = true;
|
596 |
+
}
|
597 |
+
}
|
598 |
+
|
599 |
+
|
600 |
+
/**
|
601 |
+
* Exit and redirect to home
|
602 |
+
*
|
603 |
+
* @param string $requested_user_id
|
604 |
+
* @param string $is_my_profile
|
605 |
+
*/
|
606 |
+
function um_redirect_home( $requested_user_id = '', $is_my_profile = '' ) {
|
607 |
+
$url = apply_filters( 'um_redirect_home_custom_url', home_url(), $requested_user_id, $is_my_profile );
|
608 |
+
exit( wp_redirect( $url ) );
|
609 |
+
}
|
610 |
+
|
611 |
+
|
612 |
+
|
613 |
+
/**
|
614 |
+
* @param $url
|
615 |
+
*/
|
616 |
+
function um_js_redirect( $url ) {
|
617 |
+
if ( headers_sent() || empty( $url ) ) {
|
618 |
+
//for blank redirects
|
619 |
+
if ( '' == $url ) {
|
620 |
+
$url = set_url_scheme( '//' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] );
|
621 |
+
}
|
622 |
+
|
623 |
+
register_shutdown_function( function( $url ) {
|
624 |
+
echo '<script data-cfasync="false" type="text/javascript">window.location = "' . esc_js( $url ) . '"</script>';
|
625 |
+
}, $url );
|
626 |
+
|
627 |
+
if ( 1 < ob_get_level() ) {
|
628 |
+
while ( ob_get_level() > 1 ) {
|
629 |
+
ob_end_clean();
|
630 |
+
}
|
631 |
+
} ?>
|
632 |
+
<script data-cfasync='false' type="text/javascript">
|
633 |
+
window.location = '<?php echo esc_js( $url ); ?>';
|
634 |
+
</script>
|
635 |
+
<?php exit;
|
636 |
+
} else {
|
637 |
+
wp_redirect( $url );
|
638 |
+
}
|
639 |
+
exit;
|
640 |
+
}
|
641 |
+
|
642 |
+
|
643 |
+
/**
|
644 |
+
* Get limit of words from sentence
|
645 |
+
*
|
646 |
+
* @param $str
|
647 |
+
* @param int $wordCount
|
648 |
+
*
|
649 |
+
* @return string
|
650 |
+
*/
|
651 |
+
function um_get_snippet( $str, $wordCount = 10 ) {
|
652 |
+
if (str_word_count( $str, 0, "éèàôù" ) > $wordCount) {
|
653 |
+
$str = implode(
|
654 |
+
'',
|
655 |
+
array_slice(
|
656 |
+
preg_split(
|
657 |
+
'/([\s,\.;\?\!]+)/',
|
658 |
+
$str,
|
659 |
+
$wordCount * 2 + 1,
|
660 |
+
PREG_SPLIT_DELIM_CAPTURE
|
661 |
+
),
|
662 |
+
0,
|
663 |
+
$wordCount * 2 - 1
|
664 |
+
)
|
665 |
+
);
|
666 |
+
}
|
667 |
+
|
668 |
+
return $str;
|
669 |
+
}
|
670 |
+
|
671 |
+
|
672 |
+
/**
|
673 |
+
* Format submitted data for Info preview & Email template
|
674 |
+
* @param boolean $style
|
675 |
+
* @return string
|
676 |
+
*
|
677 |
+
* @since 2.1.4
|
678 |
+
*/
|
679 |
+
function um_user_submitted_registration_formatted( $style = false ) {
|
680 |
+
$output = null;
|
681 |
+
|
682 |
+
$submitted_data = um_user( 'submitted' );
|
683 |
+
|
684 |
+
if ( $style ) {
|
685 |
+
$output .= '<div class="um-admin-infobox">';
|
686 |
+
}
|
687 |
+
|
688 |
+
// Timestamp
|
689 |
+
$output .= um_user_submited_display( 'timestamp', __( 'Date Submitted', 'ultimate-member' ) );
|
690 |
+
$output .= um_user_submited_display( 'form_id', __( 'Form', 'ultimate-member' ), $submitted_data );
|
691 |
+
|
692 |
+
if ( isset( $submitted_data['use_gdpr_agreement'] ) ) {
|
693 |
+
$output .= um_user_submited_display( 'use_gdpr_agreement', __( 'GDPR Applied', 'ultimate-member' ), $submitted_data );
|
694 |
+
}
|
695 |
+
|
696 |
+
if ( isset( $submitted_data ) && is_array( $submitted_data ) ) {
|
697 |
+
|
698 |
+
if ( isset( $submitted_data['form_id'] ) ) {
|
699 |
+
$fields = UM()->query()->get_attr( 'custom_fields', $submitted_data['form_id'] );
|
700 |
+
$fields = maybe_unserialize( $fields );
|
701 |
+
}
|
702 |
+
|
703 |
+
if ( ! empty( $fields ) ) {
|
704 |
+
|
705 |
+
$fields['form_id'] = array( 'title' => __( 'Form', 'ultimate-member' ) );
|
706 |
+
|
707 |
+
$rows = array();
|
708 |
+
|
709 |
+
UM()->fields()->get_fields = $fields;
|
710 |
+
|
711 |
+
foreach ( $fields as $key => $array ) {
|
712 |
+
if ( isset( $array['type'] ) && $array['type'] == 'row' ) {
|
713 |
+
$rows[ $key ] = $array;
|
714 |
+
unset( UM()->fields()->get_fields[ $key ] ); // not needed now
|
715 |
+
}
|
716 |
+
}
|
717 |
+
|
718 |
+
if ( empty( $rows ) ) {
|
719 |
+
$rows = array(
|
720 |
+
'_um_row_1' => array(
|
721 |
+
'type' => 'row',
|
722 |
+
'id' => '_um_row_1',
|
723 |
+
'sub_rows' => 1,
|
724 |
+
'cols' => 1,
|
725 |
+
),
|
726 |
+
);
|
727 |
+
}
|
728 |
+
|
729 |
+
foreach ( $rows as $row_id => $row_array ) {
|
730 |
+
|
731 |
+
$row_fields = UM()->fields()->get_fields_by_row( $row_id );
|
732 |
+
|
733 |
+
if ( $row_fields ) {
|
734 |
+
|
735 |
+
$output .= UM()->fields()->new_row_output( $row_id, $row_array );
|
736 |
+
|
737 |
+
$sub_rows = ( isset( $row_array['sub_rows'] ) ) ? $row_array['sub_rows'] : 1;
|
738 |
+
for ( $c = 0; $c < $sub_rows; $c++ ) {
|
739 |
+
|
740 |
+
// cols
|
741 |
+
$cols = ( isset( $row_array['cols'] ) ) ? $row_array['cols'] : 1;
|
742 |
+
if ( strstr( $cols, ':' ) ) {
|
743 |
+
$col_split = explode( ':', $cols );
|
744 |
+
} else {
|
745 |
+
$col_split = array( $cols );
|
746 |
+
}
|
747 |
+
$cols_num = $col_split[ $c ];
|
748 |
+
|
749 |
+
// sub row fields
|
750 |
+
$subrow_fields = null;
|
751 |
+
$subrow_fields = UM()->fields()->get_fields_in_subrow( $row_fields, $c );
|
752 |
+
|
753 |
+
if ( is_array( $subrow_fields ) ) {
|
754 |
+
|
755 |
+
if ( isset( $subrow_fields['form_id'] ) ) {
|
756 |
+
unset( $subrow_fields['form_id'] );
|
757 |
+
}
|
758 |
+
|
759 |
+
$subrow_fields = UM()->fields()->array_sort_by_column( $subrow_fields, 'position' );
|
760 |
+
|
761 |
+
if ( $cols_num == 1 ) {
|
762 |
+
|
763 |
+
$col1_fields = UM()->fields()->get_fields_in_column( $subrow_fields, 1 );
|
764 |
+
if ( $col1_fields ) {
|
765 |
+
foreach ( $col1_fields as $key => $data ) {
|
766 |
+
$output .= um_user_submited_display( $key, $data['title'] );
|
767 |
+
}
|
768 |
+
}
|
769 |
+
|
770 |
+
} elseif ( $cols_num == 2 ) {
|
771 |
+
|
772 |
+
$col1_fields = UM()->fields()->get_fields_in_column( $subrow_fields, 1 );
|
773 |
+
if ( $col1_fields ) {
|
774 |
+
foreach ( $col1_fields as $key => $data ) {
|
775 |
+
$output .= um_user_submited_display( $key, $data['title'] );
|
776 |
+
}
|
777 |
+
}
|
778 |
+
|
779 |
+
$col2_fields = UM()->fields()->get_fields_in_column( $subrow_fields, 2 );
|
780 |
+
if ( $col2_fields ) {
|
781 |
+
foreach ( $col2_fields as $key => $data ) {
|
782 |
+
$output .= um_user_submited_display( $key, $data['title'] );
|
783 |
+
}
|
784 |
+
}
|
785 |
+
|
786 |
+
} else {
|
787 |
+
|
788 |
+
$col1_fields = UM()->fields()->get_fields_in_column( $subrow_fields, 1 );
|
789 |
+
if ( $col1_fields ) {
|
790 |
+
foreach ( $col1_fields as $key => $data ) {
|
791 |
+
$output .= um_user_submited_display( $key, $data['title'] );
|
792 |
+
}
|
793 |
+
}
|
794 |
+
|
795 |
+
$col2_fields = UM()->fields()->get_fields_in_column( $subrow_fields, 2 );
|
796 |
+
if ( $col2_fields ) {
|
797 |
+
foreach ( $col2_fields as $key => $data ) {
|
798 |
+
$output .= um_user_submited_display( $key, $data['title'] );
|
799 |
+
}
|
800 |
+
}
|
801 |
+
|
802 |
+
$col3_fields = UM()->fields()->get_fields_in_column( $subrow_fields, 3 );
|
803 |
+
if ( $col3_fields ) {
|
804 |
+
foreach ( $col3_fields as $key => $data ) {
|
805 |
+
$output .= um_user_submited_display( $key, $data['title'] );
|
806 |
+
}
|
807 |
+
}
|
808 |
+
|
809 |
+
}
|
810 |
+
|
811 |
+
}
|
812 |
+
|
813 |
+
}
|
814 |
+
|
815 |
+
}
|
816 |
+
|
817 |
+
|
818 |
+
} // endfor
|
819 |
+
|
820 |
+
}
|
821 |
+
}
|
822 |
+
|
823 |
+
|
824 |
+
if ( $style ) {
|
825 |
+
$output .= '</div>';
|
826 |
+
}
|
827 |
+
|
828 |
+
|
829 |
+
return $output;
|
830 |
+
|
831 |
+
}
|
832 |
+
|
833 |
+
/**
|
834 |
+
* Prepare template
|
835 |
+
*
|
836 |
+
* @param string $k
|
837 |
+
* @param string $title
|
838 |
+
* @param array $data
|
839 |
+
* @param boolean $style
|
840 |
+
* @return string
|
841 |
+
*
|
842 |
+
* @since 2.1.4
|
843 |
+
*/
|
844 |
+
function um_user_submited_display( $k, $title, $data = array(), $style = true ) {
|
845 |
+
$output = '';
|
846 |
+
|
847 |
+
if ( 'form_id' == $k && isset( $data['form_id'] ) && ! empty( $data['form_id'] ) ) {
|
848 |
+
$v = sprintf( __( '%s - Form ID#: %s', 'ultimate-member' ), get_the_title( $data['form_id'] ), $data['form_id'] );
|
849 |
+
} else {
|
850 |
+
$v = um_user( $k );
|
851 |
+
}
|
852 |
+
|
853 |
+
if ( strstr( $k, 'user_pass' ) || in_array( $k, array( 'g-recaptcha-response', 'request', '_wpnonce', '_wp_http_referer' ) ) ) {
|
854 |
+
return '';
|
855 |
+
}
|
856 |
+
|
857 |
+
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
858 |
+
$type = UM()->fields()->get_field_type( $k );
|
859 |
+
if ( in_array( $type, $fields_without_metakey ) ) {
|
860 |
+
return '';
|
861 |
+
}
|
862 |
+
|
863 |
+
if ( ! $v ) {
|
864 |
+
if ( $style ) {
|
865 |
+
return "<p><label>$title: </label><span>" . __( '(empty)', 'ultimate-member' ) ."</span></p>";
|
866 |
+
} else {
|
867 |
+
return '';
|
868 |
+
}
|
869 |
+
}
|
870 |
+
|
871 |
+
if ( $type == 'image' || $type == 'file' ) {
|
872 |
+
$file = basename( $v );
|
873 |
+
|
874 |
+
$filedata = get_user_meta( um_user( 'ID' ), $k . "_metadata", true );
|
875 |
+
|
876 |
+
$baseurl = UM()->uploader()->get_upload_base_url();
|
877 |
+
if ( ! file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $file ) ) {
|
878 |
+
if ( is_multisite() ) {
|
879 |
+
//multisite fix for old customers
|
880 |
+
$baseurl = str_replace( '/sites/' . get_current_blog_id() . '/', '/', $baseurl );
|
881 |
+
}
|
882 |
+
}
|
883 |
+
|
884 |
+
if ( ! empty( $filedata['original_name'] ) ) {
|
885 |
+
$v = '<a href="' . esc_attr( $baseurl . um_user( 'ID' ) . '/' . $file ) . '">' . esc_html( $filedata['original_name'] ) . '</a>';
|
886 |
+
} else {
|
887 |
+
$v = $baseurl . um_user( 'ID' ) . '/' . $file;
|
888 |
+
}
|
889 |
+
}
|
890 |
+
|
891 |
+
if ( is_array( $v ) ) {
|
892 |
+
$v = implode( ',', $v );
|
893 |
+
}
|
894 |
+
|
895 |
+
if ( $k == 'timestamp' ) {
|
896 |
+
$v = date( "d M Y H:i", $v );
|
897 |
+
} elseif ( $k == 'use_gdpr_agreement' ) {
|
898 |
+
$v = date( "d M Y H:i", $v );
|
899 |
+
}
|
900 |
+
|
901 |
+
if ( $style ) {
|
902 |
+
if ( ! $v ) {
|
903 |
+
$v = __( '(empty)', 'ultimate-member' );
|
904 |
+
}
|
905 |
+
$output .= "<p><label>$title: </label><span>$v</span></p>";
|
906 |
+
} else {
|
907 |
+
$output .= "$title: $v" . "<br />";
|
908 |
+
}
|
909 |
+
|
910 |
+
return $output;
|
911 |
+
}
|
912 |
+
|
913 |
+
|
914 |
+
/**
|
915 |
+
* Show filtered social link
|
916 |
+
*
|
917 |
+
* @param string $key
|
918 |
+
* @param string $match
|
919 |
+
*
|
920 |
+
* @return string
|
921 |
+
*/
|
922 |
+
function um_filtered_social_link( $key, $match ) {
|
923 |
+
$value = um_profile( $key );
|
924 |
+
$submatch = str_replace( 'https://', '', $match );
|
925 |
+
$submatch = str_replace( 'http://', '', $submatch );
|
926 |
+
if ( strstr( $value, $submatch ) ) {
|
927 |
+
$value = 'https://' . $value;
|
928 |
+
} elseif ( strpos( $value, 'http' ) !== 0 ) {
|
929 |
+
$value = $match . $value;
|
930 |
+
}
|
931 |
+
$value = str_replace( 'https://https://', 'https://', $value );
|
932 |
+
$value = str_replace( 'http://https://', 'https://', $value );
|
933 |
+
$value = str_replace( 'https://http://', 'https://', $value );
|
934 |
+
|
935 |
+
return $value;
|
936 |
+
}
|
937 |
+
|
938 |
+
|
939 |
+
/**
|
940 |
+
* Get filtered meta value after applying hooks
|
941 |
+
*
|
942 |
+
* @param $key
|
943 |
+
* @param bool $data
|
944 |
+
* @return mixed|string|void
|
945 |
+
*/
|
946 |
+
function um_filtered_value( $key, $data = false ) {
|
947 |
+
$value = um_user( $key );
|
948 |
+
if ( is_array( $value ) ) {
|
949 |
+
$value = add_magic_quotes( $value );
|
950 |
+
}
|
951 |
+
|
952 |
+
if ( ! $data ) {
|
953 |
+
$data = UM()->builtin()->get_specific_field( $key );
|
954 |
+
}
|
955 |
+
|
956 |
+
$type = ( isset( $data['type'] ) ) ? $data['type'] : '';
|
957 |
+
|
958 |
+
/**
|
959 |
+
* UM hook
|
960 |
+
*
|
961 |
+
* @type filter
|
962 |
+
* @title um_profile_field_filter_hook__
|
963 |
+
* @description Change or filter field value
|
964 |
+
* @input_vars
|
965 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
966 |
+
* {"var":"$data","type":"array","desc":"Field Data"},
|
967 |
+
* {"var":"$type","type":"string","desc":"Field Type"}]
|
968 |
+
* @change_log
|
969 |
+
* ["Since: 2.0"]
|
970 |
+
* @usage add_filter( 'um_profile_field_filter_hook__', 'function_name', 10, 3 );
|
971 |
+
* @example
|
972 |
+
* <?php
|
973 |
+
* add_filter( 'um_profile_field_filter_hook__', 'my_profile_field', 10, 3 );
|
974 |
+
* function my_profile_field( $value, $data, $type ) {
|
975 |
+
* // your code here
|
976 |
+
* return $value;
|
977 |
+
* }
|
978 |
+
* ?>
|
979 |
+
*/
|
980 |
+
$value = apply_filters( 'um_profile_field_filter_hook__', $value, $data, $type );
|
981 |
+
|
982 |
+
/**
|
983 |
+
* UM hook
|
984 |
+
*
|
985 |
+
* @type filter
|
986 |
+
* @title um_profile_field_filter_hook__{$key}
|
987 |
+
* @description Change or filter field value by field key ($key)
|
988 |
+
* @input_vars
|
989 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
990 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
991 |
+
* @change_log
|
992 |
+
* ["Since: 2.0"]
|
993 |
+
* @usage add_filter( 'um_profile_field_filter_hook__{$key}', 'function_name', 10, 2 );
|
994 |
+
* @example
|
995 |
+
* <?php
|
996 |
+
* add_filter( 'um_profile_field_filter_hook__{$key}', 'my_profile_field', 10, 2 );
|
997 |
+
* function my_profile_field( $value, $data ) {
|
998 |
+
* // your code here
|
999 |
+
* return $value;
|
1000 |
+
* }
|
1001 |
+
* ?>
|
1002 |
+
*/
|
1003 |
+
$value = apply_filters( "um_profile_field_filter_hook__{$key}", $value, $data );
|
1004 |
+
|
1005 |
+
/**
|
1006 |
+
* UM hook
|
1007 |
+
*
|
1008 |
+
* @type filter
|
1009 |
+
* @title um_profile_field_filter_hook__{$type}
|
1010 |
+
* @description Change or filter field value by field type ($type)
|
1011 |
+
* @input_vars
|
1012 |
+
* [{"var":"$value","type":"string","desc":"Field Value"},
|
1013 |
+
* {"var":"$data","type":"array","desc":"Field Data"}]
|
1014 |
+
* @change_log
|
1015 |
+
* ["Since: 2.0"]
|
1016 |
+
* @usage add_filter( 'um_profile_field_filter_hook__{$type}', 'function_name', 10, 2 );
|
1017 |
+
* @example
|
1018 |
+
* <?php
|
1019 |
+
* add_filter( 'um_profile_field_filter_hook__{$type}', 'my_profile_field', 10, 2 );
|
1020 |
+
* function my_profile_field( $value, $data ) {
|
1021 |
+
* // your code here
|
1022 |
+
* return $value;
|
1023 |
+
* }
|
1024 |
+
* ?>
|
1025 |
+
*/
|
1026 |
+
$value = apply_filters( "um_profile_field_filter_hook__{$type}", $value, $data );
|
1027 |
+
$value = UM()->shortcodes()->emotize( $value );
|
1028 |
+
return $value;
|
1029 |
+
}
|
1030 |
+
|
1031 |
+
|
1032 |
+
/**
|
1033 |
+
* Returns requested User ID or current User ID
|
1034 |
+
*
|
1035 |
+
* @return int
|
1036 |
+
*/
|
1037 |
+
function um_profile_id() {
|
1038 |
+
$requested_user = um_get_requested_user();
|
1039 |
+
|
1040 |
+
if ( $requested_user ) {
|
1041 |
+
return um_get_requested_user();
|
1042 |
+
} elseif ( is_user_logged_in() && get_current_user_id() ) {
|
1043 |
+
return get_current_user_id();
|
1044 |
+
}
|
1045 |
+
|
1046 |
+
return 0;
|
1047 |
+
}
|
1048 |
+
|
1049 |
+
|
1050 |
+
/**
|
1051 |
+
* Check that temp upload is valid
|
1052 |
+
*
|
1053 |
+
* @param string $url
|
1054 |
+
*
|
1055 |
+
* @return bool|string
|
1056 |
+
*/
|
1057 |
+
function um_is_temp_upload( $url ) {
|
1058 |
+
if ( is_string( $url ) ) {
|
1059 |
+
$url = trim( $url );
|
1060 |
+
}
|
1061 |
+
|
1062 |
+
if ( filter_var( $url, FILTER_VALIDATE_URL ) === false ) {
|
1063 |
+
$url = realpath( $url );
|
1064 |
+
}
|
1065 |
+
|
1066 |
+
if ( ! $url ) {
|
1067 |
+
return false;
|
1068 |
+
}
|
1069 |
+
|
1070 |
+
$url = explode( '/ultimatemember/temp/', $url );
|
1071 |
+
if ( isset( $url[1] ) ) {
|
1072 |
+
|
1073 |
+
if ( strstr( $url[1], '../' ) || strstr( $url[1], '%' ) ) {
|
1074 |
+
return false;
|
1075 |
+
}
|
1076 |
+
|
1077 |
+
$src = UM()->files()->upload_temp . $url[1];
|
1078 |
+
if ( ! file_exists( $src ) ) {
|
1079 |
+
return false;
|
1080 |
+
}
|
1081 |
+
|
1082 |
+
return $src;
|
1083 |
+
}
|
1084 |
+
|
1085 |
+
return false;
|
1086 |
+
}
|
1087 |
+
|
1088 |
+
|
1089 |
+
/**
|
1090 |
+
* Check that temp image is valid
|
1091 |
+
*
|
1092 |
+
* @param $url
|
1093 |
+
*
|
1094 |
+
* @return bool|string
|
1095 |
+
*/
|
1096 |
+
function um_is_temp_image( $url ) {
|
1097 |
+
$url = explode( '/ultimatemember/temp/', $url );
|
1098 |
+
if (isset( $url[1] )) {
|
1099 |
+
$src = UM()->files()->upload_temp . $url[1];
|
1100 |
+
if (!file_exists( $src ))
|
1101 |
+
return false;
|
1102 |
+
list( $width, $height, $type, $attr ) = @getimagesize( $src );
|
1103 |
+
if (isset( $width ) && isset( $height ))
|
1104 |
+
return $src;
|
1105 |
+
}
|
1106 |
+
|
1107 |
+
return false;
|
1108 |
+
}
|
1109 |
+
|
1110 |
+
|
1111 |
+
/**
|
1112 |
+
* Check user's file ownership
|
1113 |
+
* @param string $url
|
1114 |
+
* @param int|null $user_id
|
1115 |
+
* @param string|bool $image_path
|
1116 |
+
* @return bool
|
1117 |
+
*/
|
1118 |
+
function um_is_file_owner( $url, $user_id = null, $image_path = false ) {
|
1119 |
+
|
1120 |
+
if ( strpos( $url, UM()->uploader()->get_upload_base_url() . $user_id . '/' ) !== false && is_user_logged_in() ) {
|
1121 |
+
$user_basedir = UM()->uploader()->get_upload_user_base_dir( $user_id );
|
1122 |
+
} else {
|
1123 |
+
$user_basedir = UM()->uploader()->get_upload_user_base_dir( 'temp' );
|
1124 |
+
}
|
1125 |
+
|
1126 |
+
$filename = wp_basename( parse_url( $url, PHP_URL_PATH ) );
|
1127 |
+
|
1128 |
+
$file = $user_basedir . DIRECTORY_SEPARATOR . $filename;
|
1129 |
+
if ( file_exists( $file ) ) {
|
1130 |
+
if ( $image_path ) {
|
1131 |
+
return $file;
|
1132 |
+
}
|
1133 |
+
|
1134 |
+
return true;
|
1135 |
+
}
|
1136 |
+
|
1137 |
+
return false;
|
1138 |
+
}
|
1139 |
+
|
1140 |
+
|
1141 |
+
/**
|
1142 |
+
* Check if file is temporary
|
1143 |
+
* @param string $filename
|
1144 |
+
* @return bool
|
1145 |
+
*/
|
1146 |
+
function um_is_temp_file( $filename ) {
|
1147 |
+
$user_basedir = UM()->uploader()->get_upload_user_base_dir( 'temp' );
|
1148 |
+
|
1149 |
+
$file = $user_basedir . '/' . $filename;
|
1150 |
+
|
1151 |
+
if ( file_exists( $file ) ) {
|
1152 |
+
return true;
|
1153 |
+
}
|
1154 |
+
return false;
|
1155 |
+
}
|
1156 |
+
|
1157 |
+
|
1158 |
+
/**
|
1159 |
+
* Get user's last login timestamp
|
1160 |
+
*
|
1161 |
+
* @param $user_id
|
1162 |
+
*
|
1163 |
+
* @return mixed|string
|
1164 |
+
*/
|
1165 |
+
function um_user_last_login_timestamp( $user_id ) {
|
1166 |
+
$value = get_user_meta( $user_id, '_um_last_login', true );
|
1167 |
+
if ( $value ) {
|
1168 |
+
return $value;
|
1169 |
+
}
|
1170 |
+
|
1171 |
+
return '';
|
1172 |
+
}
|
1173 |
+
|
1174 |
+
|
1175 |
+
/**
|
1176 |
+
* Get user's last login (time diff)
|
1177 |
+
*
|
1178 |
+
* @param int $user_id
|
1179 |
+
*
|
1180 |
+
* @return string
|
1181 |
+
*/
|
1182 |
+
function um_user_last_login( $user_id ) {
|
1183 |
+
$value = get_user_meta( $user_id, '_um_last_login', true );
|
1184 |
+
return ! empty( $value ) ? UM()->datetime()->time_diff( $value, current_time( 'timestamp' ) ) : '';
|
1185 |
+
}
|
1186 |
+
|
1187 |
+
|
1188 |
+
/**
|
1189 |
+
* Get core page url
|
1190 |
+
*
|
1191 |
+
* @param $slug
|
1192 |
+
* @param bool $updated
|
1193 |
+
*
|
1194 |
+
* @return bool|false|mixed|string|void
|
1195 |
+
*/
|
1196 |
+
function um_get_core_page( $slug, $updated = false ) {
|
1197 |
+
$url = '';
|
1198 |
+
|
1199 |
+
if ( isset( UM()->config()->permalinks[ $slug ] ) ) {
|
1200 |
+
$url = get_permalink( UM()->config()->permalinks[ $slug ] );
|
1201 |
+
if ( $updated ) {
|
1202 |
+
$url = add_query_arg( 'updated', esc_attr( $updated ), $url );
|
1203 |
+
}
|
1204 |
+
}
|
1205 |
+
|
1206 |
+
/**
|
1207 |
+
* UM hook
|
1208 |
+
*
|
1209 |
+
* @type filter
|
1210 |
+
* @title um_get_core_page_filter
|
1211 |
+
* @description Change UM core page URL
|
1212 |
+
* @input_vars
|
1213 |
+
* [{"var":"$url","type":"string","desc":"UM Page URL"},
|
1214 |
+
* {"var":"$slug","type":"string","desc":"UM Page slug"},
|
1215 |
+
* {"var":"$updated","type":"bool","desc":"Additional parameter"}]
|
1216 |
+
* @change_log
|
1217 |
+
* ["Since: 2.0"]
|
1218 |
+
* @usage add_filter( 'um_get_core_page_filter', 'function_name', 10, 3 );
|
1219 |
+
* @example
|
1220 |
+
* <?php
|
1221 |
+
* add_filter( 'um_get_core_page_filter', 'my_core_page_url', 10, 3 );
|
1222 |
+
* function my_core_page_url( $url, $slug, $updated ) {
|
1223 |
+
* // your code here
|
1224 |
+
* return $url;
|
1225 |
+
* }
|
1226 |
+
* ?>
|
1227 |
+
*/
|
1228 |
+
return apply_filters( 'um_get_core_page_filter', $url, $slug, $updated );
|
1229 |
+
}
|
1230 |
+
|
1231 |
+
|
1232 |
+
/**
|
1233 |
+
* Check if we are on a UM Core Page or not
|
1234 |
+
*
|
1235 |
+
* Default um core pages slugs
|
1236 |
+
* 'user', 'login', 'register', 'members', 'logout', 'account', 'password-reset'
|
1237 |
+
*
|
1238 |
+
* @param string $page UM core page slug
|
1239 |
+
*
|
1240 |
+
* @return bool
|
1241 |
+
*/
|
1242 |
+
function um_is_core_page( $page ) {
|
1243 |
+
global $post;
|
1244 |
+
|
1245 |
+
if ( empty( $post ) ) {
|
1246 |
+
return false;
|
1247 |
+
}
|
1248 |
+
|
1249 |
+
if ( isset( $post->ID ) && isset( UM()->config()->permalinks[ $page ] ) && $post->ID == UM()->config()->permalinks[ $page ] ) {
|
1250 |
+
return true;
|
1251 |
+
}
|
1252 |
+
|
1253 |
+
if ( isset( $post->ID ) && get_post_meta( $post->ID, '_um_wpml_' . $page, true ) == 1 ) {
|
1254 |
+
return true;
|
1255 |
+
}
|
1256 |
+
|
1257 |
+
if ( UM()->external_integrations()->is_wpml_active() ) {
|
1258 |
+
global $sitepress;
|
1259 |
+
if ( isset( UM()->config()->permalinks[ $page ] ) && UM()->config()->permalinks[ $page ] == wpml_object_id_filter( $post->ID, 'page', true, $sitepress->get_default_language() ) ) {
|
1260 |
+
return true;
|
1261 |
+
}
|
1262 |
+
}
|
1263 |
+
|
1264 |
+
if ( isset( $post->ID ) ) {
|
1265 |
+
$_icl_lang_duplicate_of = get_post_meta( $post->ID, '_icl_lang_duplicate_of', true );
|
1266 |
+
|
1267 |
+
if ( isset( UM()->config()->permalinks[ $page ] ) && ( ( $_icl_lang_duplicate_of == UM()->config()->permalinks[ $page ] && !empty( $_icl_lang_duplicate_of ) ) || UM()->config()->permalinks[ $page ] == $post->ID ) ) {
|
1268 |
+
return true;
|
1269 |
+
}
|
1270 |
+
}
|
1271 |
+
|
1272 |
+
return false;
|
1273 |
+
}
|
1274 |
+
|
1275 |
+
|
1276 |
+
/**
|
1277 |
+
* @param $post
|
1278 |
+
* @param $core_page
|
1279 |
+
*
|
1280 |
+
* @return bool
|
1281 |
+
*/
|
1282 |
+
function um_is_core_post( $post, $core_page ) {
|
1283 |
+
if ( isset( $post->ID ) && isset( UM()->config()->permalinks[ $core_page ] ) && $post->ID == UM()->config()->permalinks[ $core_page ] ) {
|
1284 |
+
return true;
|
1285 |
+
}
|
1286 |
+
if ( isset( $post->ID ) && get_post_meta( $post->ID, '_um_wpml_' . $core_page, true ) == 1 ) {
|
1287 |
+
return true;
|
1288 |
+
}
|
1289 |
+
|
1290 |
+
if ( isset( $post->ID ) ) {
|
1291 |
+
$_icl_lang_duplicate_of = get_post_meta( $post->ID, '_icl_lang_duplicate_of', true );
|
1292 |
+
|
1293 |
+
if ( isset( UM()->config()->permalinks[ $core_page ] ) && ( ( $_icl_lang_duplicate_of == UM()->config()->permalinks[ $core_page ] && ! empty( $_icl_lang_duplicate_of ) ) || UM()->config()->permalinks[ $core_page ] == $post->ID ) ) {
|
1294 |
+
return true;
|
1295 |
+
}
|
1296 |
+
}
|
1297 |
+
|
1298 |
+
return false;
|
1299 |
+
}
|
1300 |
+
|
1301 |
+
|
1302 |
+
/**
|
1303 |
+
* Get styling defaults
|
1304 |
+
*
|
1305 |
+
* @param $mode
|
1306 |
+
*
|
1307 |
+
* @return array
|
1308 |
+
*/
|
1309 |
+
function um_styling_defaults( $mode ) {
|
1310 |
+
|
1311 |
+
$new_arr = array();
|
1312 |
+
$core_form_meta_all = UM()->config()->core_form_meta_all;
|
1313 |
+
$core_global_meta_all = UM()->config()->core_global_meta_all;
|
1314 |
+
|
1315 |
+
foreach ( $core_form_meta_all as $k => $v ) {
|
1316 |
+
$s = str_replace( $mode . '_', '', $k );
|
1317 |
+
if (strstr( $k, '_um_' . $mode . '_' ) && !in_array( $s, $core_global_meta_all )) {
|
1318 |
+
$a = str_replace( '_um_' . $mode . '_', '', $k );
|
1319 |
+
$b = str_replace( '_um_', '', $k );
|
1320 |
+
$new_arr[$a] = UM()->options()->get( $b );
|
1321 |
+
} else if (in_array( $k, $core_global_meta_all )) {
|
1322 |
+
$a = str_replace( '_um_', '', $k );
|
1323 |
+
$new_arr[$a] = UM()->options()->get( $a );
|
1324 |
+
}
|
1325 |
+
}
|
1326 |
+
|
1327 |
+
return $new_arr;
|
1328 |
+
}
|
1329 |
+
|
1330 |
+
|
1331 |
+
/**
|
1332 |
+
* Get meta option default
|
1333 |
+
*
|
1334 |
+
* @param $id
|
1335 |
+
*
|
1336 |
+
* @return string
|
1337 |
+
*/
|
1338 |
+
function um_get_metadefault( $id ) {
|
1339 |
+
$core_form_meta_all = UM()->config()->core_form_meta_all;
|
1340 |
+
|
1341 |
+
return isset( $core_form_meta_all[ '_um_' . $id ] ) ? $core_form_meta_all[ '_um_' . $id ] : '';
|
1342 |
+
}
|
1343 |
+
|
1344 |
+
|
1345 |
+
/**
|
1346 |
+
* boolean for account page editing
|
1347 |
+
*
|
1348 |
+
* @return bool
|
1349 |
+
*/
|
1350 |
+
function um_submitting_account_page() {
|
1351 |
+
if ( isset( $_POST['_um_account'] ) && $_POST['_um_account'] == 1 && is_user_logged_in() ) {
|
1352 |
+
return true;
|
1353 |
+
}
|
1354 |
+
|
1355 |
+
return false;
|
1356 |
+
}
|
1357 |
+
|
1358 |
+
|
1359 |
+
/**
|
1360 |
+
* Get a user's display name
|
1361 |
+
*
|
1362 |
+
* @param $user_id
|
1363 |
+
*
|
1364 |
+
* @return string
|
1365 |
+
*/
|
1366 |
+
function um_get_display_name( $user_id ) {
|
1367 |
+
um_fetch_user( $user_id );
|
1368 |
+
$name = um_user( 'display_name' );
|
1369 |
+
um_reset_user();
|
1370 |
+
|
1371 |
+
return $name;
|
1372 |
+
}
|
1373 |
+
|
1374 |
+
|
1375 |
+
/**
|
1376 |
+
* Clears the user data. You need to fetch a user manually after using this function.
|
1377 |
+
*
|
1378 |
+
* @function um_reset_user_clean()
|
1379 |
+
*
|
1380 |
+
* @description This function is similar to um_reset_user() with a difference that it will not use the logged-in
|
1381 |
+
* user data after resetting. It is a hard-reset function for all user data.
|
1382 |
+
*
|
1383 |
+
* @usage <?php um_reset_user_clean(); ?>
|
1384 |
+
*
|
1385 |
+
* @example You can reset user data by using the following line in your code
|
1386 |
+
*
|
1387 |
+
* <?php um_reset_user_clean(); ?>
|
1388 |
+
*/
|
1389 |
+
function um_reset_user_clean() {
|
1390 |
+
UM()->user()->reset( true );
|
1391 |
+
}
|
1392 |
+
|
1393 |
+
|
1394 |
+
/**
|
1395 |
+
* Clears the user data. If a user is logged in, the user data will be reset to that user's data
|
1396 |
+
*
|
1397 |
+
* @function um_reset_user()
|
1398 |
+
*
|
1399 |
+
* @description This function resets the current user. You can use it to reset user data after
|
1400 |
+
* retrieving the details of a specific user.
|
1401 |
+
*
|
1402 |
+
* @usage <?php um_reset_user(); ?>
|
1403 |
+
*
|
1404 |
+
* @example You can reset user data by using the following line in your code
|
1405 |
+
*
|
1406 |
+
* <?php um_reset_user(); ?>
|
1407 |
+
*/
|
1408 |
+
function um_reset_user() {
|
1409 |
+
UM()->user()->reset();
|
1410 |
+
}
|
1411 |
+
|
1412 |
+
|
1413 |
+
/**
|
1414 |
+
* Gets the queried user
|
1415 |
+
*
|
1416 |
+
* @return mixed
|
1417 |
+
*/
|
1418 |
+
function um_queried_user() {
|
1419 |
+
return get_query_var( 'um_user' );
|
1420 |
+
}
|
1421 |
+
|
1422 |
+
|
1423 |
+
/**
|
1424 |
+
* Sets the requested user
|
1425 |
+
*
|
1426 |
+
* @param $user_id
|
1427 |
+
*/
|
1428 |
+
function um_set_requested_user( $user_id ) {
|
1429 |
+
UM()->user()->target_id = $user_id;
|
1430 |
+
}
|
1431 |
+
|
1432 |
+
|
1433 |
+
/**
|
1434 |
+
* Gets the requested user
|
1435 |
+
*
|
1436 |
+
* @return bool|null
|
1437 |
+
*/
|
1438 |
+
function um_get_requested_user() {
|
1439 |
+
if ( ! empty( UM()->user()->target_id ) ) {
|
1440 |
+
return UM()->user()->target_id;
|
1441 |
+
}
|
1442 |
+
|
1443 |
+
return false;
|
1444 |
+
}
|
1445 |
+
|
1446 |
+
|
1447 |
+
/**
|
1448 |
+
* Remove edit profile args from url
|
1449 |
+
*
|
1450 |
+
* @param string $url
|
1451 |
+
*
|
1452 |
+
* @return mixed|string|void
|
1453 |
+
*/
|
1454 |
+
function um_edit_my_profile_cancel_uri( $url = '' ) {
|
1455 |
+
|
1456 |
+
if ( empty( $url ) ) {
|
1457 |
+
$url = remove_query_arg( 'um_action' );
|
1458 |
+
$url = remove_query_arg( 'profiletab', $url );
|
1459 |
+
$url = add_query_arg( 'profiletab', 'main', $url );
|
1460 |
+
}
|
1461 |
+
|
1462 |
+
/**
|
1463 |
+
* UM hook
|
1464 |
+
*
|
1465 |
+
* @type filter
|
1466 |
+
* @title um_edit_profile_cancel_uri
|
1467 |
+
* @description Change Edit Profile Cancel URL
|
1468 |
+
* @input_vars
|
1469 |
+
* [{"var":"$url","type":"string","desc":"Cancel URL"}]
|
1470 |
+
* @change_log
|
1471 |
+
* ["Since: 2.0"]
|
1472 |
+
* @usage add_filter( 'um_edit_profile_cancel_uri', 'function_name', 10, 1 );
|
1473 |
+
* @example
|
1474 |
+
* <?php
|
1475 |
+
* add_filter( 'um_edit_profile_cancel_uri', 'my_edit_profile_cancel_uri', 10, 1 );
|
1476 |
+
* function my_edit_profile_cancel_uri( $url ) {
|
1477 |
+
* // your code here
|
1478 |
+
* return $url;
|
1479 |
+
* }
|
1480 |
+
* ?>
|
1481 |
+
*/
|
1482 |
+
$url = apply_filters( 'um_edit_profile_cancel_uri', $url );
|
1483 |
+
|
1484 |
+
return $url;
|
1485 |
+
}
|
1486 |
+
|
1487 |
+
|
1488 |
+
/**
|
1489 |
+
* boolean for profile edit page
|
1490 |
+
*
|
1491 |
+
* @return bool
|
1492 |
+
*/
|
1493 |
+
function um_is_on_edit_profile() {
|
1494 |
+
if ( isset( $_REQUEST['um_action'] ) && sanitize_key( $_REQUEST['um_action'] ) == 'edit' ) {
|
1495 |
+
return true;
|
1496 |
+
}
|
1497 |
+
|
1498 |
+
return false;
|
1499 |
+
}
|
1500 |
+
|
1501 |
+
|
1502 |
+
/**
|
1503 |
+
* Can view field
|
1504 |
+
*
|
1505 |
+
* @param $data
|
1506 |
+
*
|
1507 |
+
* @return bool
|
1508 |
+
*/
|
1509 |
+
function um_can_view_field( $data ) {
|
1510 |
+
$can_view = true;
|
1511 |
+
|
1512 |
+
if ( ! isset( UM()->fields()->set_mode ) ) {
|
1513 |
+
UM()->fields()->set_mode = '';
|
1514 |
+
}
|
1515 |
+
|
1516 |
+
if ( isset( $data['public'] ) && UM()->fields()->set_mode != 'register' ) {
|
1517 |
+
|
1518 |
+
$can_edit = false;
|
1519 |
+
$current_user_roles = [];
|
1520 |
+
if ( is_user_logged_in() ) {
|
1521 |
+
|
1522 |
+
$can_edit = UM()->roles()->um_current_user_can( 'edit', um_user( 'ID' ) );
|
1523 |
+
|
1524 |
+
$previous_user = um_user( 'ID' );
|
1525 |
+
um_fetch_user( get_current_user_id() );
|
1526 |
+
|
1527 |
+
$current_user_roles = um_user( 'roles' );
|
1528 |
+
um_fetch_user( $previous_user );
|
1529 |
+
}
|
1530 |
+
|
1531 |
+
switch ( $data['public'] ) {
|
1532 |
+
case '1': // Everyone
|
1533 |
+
break;
|
1534 |
+
case '2': // Members
|
1535 |
+
if ( ! is_user_logged_in() ) {
|
1536 |
+
$can_view = false;
|
1537 |
+
}
|
1538 |
+
break;
|
1539 |
+
case '-1': // Only visible to profile owner and users who can edit other member accounts
|
1540 |
+
if ( ! is_user_logged_in() ) {
|
1541 |
+
$can_view = false;
|
1542 |
+
} elseif ( ! um_is_user_himself() && ! $can_edit ) {
|
1543 |
+
$can_view = false;
|
1544 |
+
}
|
1545 |
+
break;
|
1546 |
+
case '-2': // Only specific member roles
|
1547 |
+
if ( ! is_user_logged_in() ) {
|
1548 |
+
$can_view = false;
|
1549 |
+
} elseif ( ! empty( $data['roles'] ) && count( array_intersect( $current_user_roles, $data['roles'] ) ) <= 0 ) {
|
1550 |
+
$can_view = false;
|
1551 |
+
}
|
1552 |
+
break;
|
1553 |
+
case '-3': // Only visible to profile owner and specific roles
|
1554 |
+
if ( ! is_user_logged_in() ) {
|
1555 |
+
$can_view = false;
|
1556 |
+
} elseif ( ! um_is_user_himself() && ! empty( $data['roles'] ) && count( array_intersect( $current_user_roles, $data['roles'] ) ) <= 0 ) {
|
1557 |
+
$can_view = false;
|
1558 |
+
}
|
1559 |
+
break;
|
1560 |
+
default:
|
1561 |
+
$can_view = apply_filters( 'um_can_view_field_custom', $can_view, $data );
|
1562 |
+
break;
|
1563 |
+
}
|
1564 |
+
|
1565 |
+
}
|
1566 |
+
|
1567 |
+
return apply_filters( 'um_can_view_field', $can_view, $data );
|
1568 |
+
}
|
1569 |
+
|
1570 |
+
|
1571 |
+
/**
|
1572 |
+
* Checks if user can view profile
|
1573 |
+
*
|
1574 |
+
* @param $user_id
|
1575 |
+
*
|
1576 |
+
* @return bool
|
1577 |
+
*/
|
1578 |
+
function um_can_view_profile( $user_id ) {
|
1579 |
+
if ( ! is_user_logged_in() ) {
|
1580 |
+
return ! UM()->user()->is_private_profile( $user_id );
|
1581 |
+
}
|
1582 |
+
|
1583 |
+
$temp_id = um_user('ID');
|
1584 |
+
um_fetch_user( get_current_user_id() );
|
1585 |
+
|
1586 |
+
if ( ! um_user( 'can_view_all' ) && $user_id != get_current_user_id() && is_user_logged_in() ) {
|
1587 |
+
um_fetch_user( $temp_id );
|
1588 |
+
return false;
|
1589 |
+
}
|
1590 |
+
|
1591 |
+
if ( ! um_user( 'can_access_private_profile' ) && UM()->user()->is_private_profile( $user_id ) ) {
|
1592 |
+
um_fetch_user( $temp_id );
|
1593 |
+
return false;
|
1594 |
+
}
|
1595 |
+
|
1596 |
+
if ( um_user( 'can_view_roles' ) && $user_id != get_current_user_id() ) {
|
1597 |
+
$can_view_roles = um_user( 'can_view_roles' );
|
1598 |
+
|
1599 |
+
if ( ! is_array( $can_view_roles ) ) {
|
1600 |
+
$can_view_roles = array();
|
1601 |
+
}
|
1602 |
+
|
1603 |
+
if ( count( $can_view_roles ) && count( array_intersect( UM()->roles()->get_all_user_roles( $user_id ), $can_view_roles ) ) <= 0 ) {
|
1604 |
+
um_fetch_user( $temp_id );
|
1605 |
+
return false;
|
1606 |
+
}
|
1607 |
+
}
|
1608 |
+
|
1609 |
+
um_fetch_user( $temp_id );
|
1610 |
+
return true;
|
1611 |
+
}
|
1612 |
+
|
1613 |
+
|
1614 |
+
/**
|
1615 |
+
* boolean check for not same user
|
1616 |
+
*
|
1617 |
+
* @return bool
|
1618 |
+
*/
|
1619 |
+
function um_is_user_himself() {
|
1620 |
+
if (um_get_requested_user() && um_get_requested_user() != get_current_user_id())
|
1621 |
+
return false;
|
1622 |
+
|
1623 |
+
return true;
|
1624 |
+
}
|
1625 |
+
|
1626 |
+
/**
|
1627 |
+
* Can edit field
|
1628 |
+
*
|
1629 |
+
* @param $data
|
1630 |
+
*
|
1631 |
+
* @return bool
|
1632 |
+
*/
|
1633 |
+
function um_can_edit_field( $data ) {
|
1634 |
+
$can_edit = true;
|
1635 |
+
|
1636 |
+
if ( ! empty( UM()->fields()->editing ) && isset( UM()->fields()->set_mode ) && UM()->fields()->set_mode == 'profile' ) {
|
1637 |
+
if ( ! is_user_logged_in() ) {
|
1638 |
+
$can_edit = false;
|
1639 |
+
} else {
|
1640 |
+
if ( ! UM()->roles()->um_user_can( 'can_edit_everyone' ) ) {
|
1641 |
+
if ( isset( $data['editable'] ) && $data['editable'] == 0 ) {
|
1642 |
+
$can_edit = false;
|
1643 |
+
} else {
|
1644 |
+
if ( ! um_is_user_himself() ) {
|
1645 |
+
$can_edit = false;
|
1646 |
+
}
|
1647 |
+
}
|
1648 |
+
}
|
1649 |
+
}
|
1650 |
+
}
|
1651 |
+
|
1652 |
+
return apply_filters( 'um_can_edit_field', $can_edit, $data );
|
1653 |
+
}
|
1654 |
+
|
1655 |
+
|
1656 |
+
/**
|
1657 |
+
* Check if user is in his profile
|
1658 |
+
*
|
1659 |
+
* @return bool
|
1660 |
+
*/
|
1661 |
+
function um_is_myprofile() {
|
1662 |
+
if (get_current_user_id() && get_current_user_id() == um_get_requested_user()) return true;
|
1663 |
+
if (!um_get_requested_user() && um_is_core_page( 'user' ) && get_current_user_id()) return true;
|
1664 |
+
|
1665 |
+
return false;
|
1666 |
+
}
|
1667 |
+
|
1668 |
+
|
1669 |
+
/**
|
1670 |
+
* Returns the edit profile link
|
1671 |
+
*
|
1672 |
+
* @param int $user_id
|
1673 |
+
*
|
1674 |
+
* @return string
|
1675 |
+
*/
|
1676 |
+
function um_edit_profile_url( $user_id = null ) {
|
1677 |
+
if ( um_is_core_page( 'user' ) ) {
|
1678 |
+
$url = UM()->permalinks()->get_current_url();
|
1679 |
+
} else {
|
1680 |
+
$url = isset( $user_id ) ? um_user_profile_url( $user_id ) : um_user_profile_url();
|
1681 |
+
}
|
1682 |
+
|
1683 |
+
$url = remove_query_arg( 'profiletab', $url );
|
1684 |
+
$url = remove_query_arg( 'subnav', $url );
|
1685 |
+
$url = add_query_arg( 'um_action', 'edit', $url );
|
1686 |
+
|
1687 |
+
return $url;
|
1688 |
+
}
|
1689 |
+
|
1690 |
+
|
1691 |
+
/**
|
1692 |
+
* Checks if user can edit his profile
|
1693 |
+
*
|
1694 |
+
* @return bool
|
1695 |
+
*/
|
1696 |
+
function um_can_edit_my_profile() {
|
1697 |
+
if ( ! is_user_logged_in() || ! um_user( 'can_edit_profile' ) ) {
|
1698 |
+
return false;
|
1699 |
+
}
|
1700 |
+
|
1701 |
+
return true;
|
1702 |
+
}
|
1703 |
+
|
1704 |
+
|
1705 |
+
/**
|
1706 |
+
* Short for admin e-mail
|
1707 |
+
*
|
1708 |
+
* @return mixed|string|void
|
1709 |
+
*/
|
1710 |
+
function um_admin_email() {
|
1711 |
+
return UM()->options()->get( 'admin_email' );
|
1712 |
+
}
|
1713 |
+
|
1714 |
+
|
1715 |
+
/**
|
1716 |
+
* Get admin e-mails
|
1717 |
+
*
|
1718 |
+
* @return array
|
1719 |
+
*/
|
1720 |
+
function um_multi_admin_email() {
|
1721 |
+
$emails = UM()->options()->get( 'admin_email' );
|
1722 |
+
|
1723 |
+
$emails_array = explode( ',', $emails );
|
1724 |
+
if ( ! empty( $emails_array ) ) {
|
1725 |
+
$emails_array = array_map( 'trim', $emails_array );
|
1726 |
+
}
|
1727 |
+
|
1728 |
+
$emails_array = array_unique( $emails_array );
|
1729 |
+
return $emails_array;
|
1730 |
+
}
|
1731 |
+
|
1732 |
+
|
1733 |
+
/**
|
1734 |
+
* Display a link to profile page
|
1735 |
+
*
|
1736 |
+
* @param int|bool $user_id
|
1737 |
+
*
|
1738 |
+
* @return bool|string
|
1739 |
+
*/
|
1740 |
+
function um_user_profile_url( $user_id = false ) {
|
1741 |
+
if ( ! $user_id ) {
|
1742 |
+
$user_id = um_user( 'ID' );
|
1743 |
+
}
|
1744 |
+
|
1745 |
+
$url = UM()->user()->get_profile_link( $user_id );
|
1746 |
+
if ( empty( $url ) ) {
|
1747 |
+
//if empty profile slug - generate it and re-get profile URL
|
1748 |
+
UM()->user()->generate_profile_slug( $user_id );
|
1749 |
+
$url = UM()->user()->get_profile_link( $user_id );
|
1750 |
+
}
|
1751 |
+
|
1752 |
+
return $url;
|
1753 |
+
}
|
1754 |
+
|
1755 |
+
|
1756 |
+
/**
|
1757 |
+
* Get all UM roles in array
|
1758 |
+
*
|
1759 |
+
* @return array
|
1760 |
+
*/
|
1761 |
+
function um_get_roles() {
|
1762 |
+
return UM()->roles()->get_roles();
|
1763 |
+
}
|
1764 |
+
|
1765 |
+
|
1766 |
+
/**
|
1767 |
+
* Sets a specific user and prepares profile data and user permissions and makes them accessible.
|
1768 |
+
*
|
1769 |
+
* @function um_fetch_user()
|
1770 |
+
*
|
1771 |
+
* @description This function sets a user and allow you to retrieve any information for the retrieved user
|
1772 |
+
*
|
1773 |
+
* @usage <?php um_fetch_user( $user_id ); ?>
|
1774 |
+
*
|
1775 |
+
* @param $user_id (numeric) (required) A user ID is required. This is the user's ID that you wish to set/retrieve
|
1776 |
+
*
|
1777 |
+
*
|
1778 |
+
* @example The example below will set user ID 5 prior to retrieving his profile information.
|
1779 |
+
*
|
1780 |
+
* <?php
|
1781 |
+
*
|
1782 |
+
* um_fetch_user(5);
|
1783 |
+
* echo um_user('display_name'); // returns the display name of user ID 5
|
1784 |
+
*
|
1785 |
+
* ?>
|
1786 |
+
*
|
1787 |
+
* @example In the following example you can fetch the profile of a logged-in user dynamically.
|
1788 |
+
*
|
1789 |
+
* <?php
|
1790 |
+
*
|
1791 |
+
* um_fetch_user( get_current_user_id() );
|
1792 |
+
* echo um_user('display_name'); // returns the display name of logged-in user
|
1793 |
+
*
|
1794 |
+
* ?>
|
1795 |
+
*
|
1796 |
+
*/
|
1797 |
+
function um_fetch_user( $user_id ) {
|
1798 |
+
UM()->user()->set( $user_id );
|
1799 |
+
}
|
1800 |
+
|
1801 |
+
|
1802 |
+
/**
|
1803 |
+
* Load profile key
|
1804 |
+
*
|
1805 |
+
* @param $key
|
1806 |
+
*
|
1807 |
+
* @return bool|string
|
1808 |
+
*/
|
1809 |
+
function um_profile( $key ) {
|
1810 |
+
if ( ! empty( UM()->user()->profile[ $key ] ) ) {
|
1811 |
+
/**
|
1812 |
+
* UM hook
|
1813 |
+
*
|
1814 |
+
* @type filter
|
1815 |
+
* @title um_profile_{$key}__filter
|
1816 |
+
* @description Change not empty profile field value
|
1817 |
+
* @input_vars
|
1818 |
+
* [{"var":"$value","type":"mixed","desc":"Profile Value"}]
|
1819 |
+
* @change_log
|
1820 |
+
* ["Since: 2.0"]
|
1821 |
+
* @usage add_filter( 'um_profile_{$key}__filter', 'function_name', 10, 1 );
|
1822 |
+
* @example
|
1823 |
+
* <?php
|
1824 |
+
* add_filter( 'um_profile_{$key}__filter', 'my_profile_value', 10, 1 );
|
1825 |
+
* function my_profile_value( $value ) {
|
1826 |
+
* // your code here
|
1827 |
+
* return $value;
|
1828 |
+
* }
|
1829 |
+
* ?>
|
1830 |
+
*/
|
1831 |
+
$value = apply_filters( "um_profile_{$key}__filter", UM()->user()->profile[ $key ] );
|
1832 |
+
} else {
|
1833 |
+
/**
|
1834 |
+
* UM hook
|
1835 |
+
*
|
1836 |
+
* @type filter
|
1837 |
+
* @title um_profile_{$key}_empty__filter
|
1838 |
+
* @description Change Profile field value if it's empty
|
1839 |
+
* @input_vars
|
1840 |
+
* [{"var":"$value","type":"mixed","desc":"Profile Value"}]
|
1841 |
+
* @change_log
|
1842 |
+
* ["Since: 2.0"]
|
1843 |
+
* @usage add_filter( 'um_profile_{$key}_empty__filter', 'function_name', 10, 1 );
|
1844 |
+
* @example
|
1845 |
+
* <?php
|
1846 |
+
* add_filter( 'um_profile_{$key}_empty__filter', 'my_profile_value', 10, 1 );
|
1847 |
+
* function my_profile_value( $value ) {
|
1848 |
+
* // your code here
|
1849 |
+
* return $value;
|
1850 |
+
* }
|
1851 |
+
* ?>
|
1852 |
+
*/
|
1853 |
+
$value = apply_filters( "um_profile_{$key}_empty__filter", false );
|
1854 |
+
}
|
1855 |
+
|
1856 |
+
return $value;
|
1857 |
+
}
|
1858 |
+
|
1859 |
+
|
1860 |
+
/**
|
1861 |
+
* Get youtube video ID from url
|
1862 |
+
*
|
1863 |
+
* @param $url
|
1864 |
+
*
|
1865 |
+
* @return bool
|
1866 |
+
*/
|
1867 |
+
function um_youtube_id_from_url( $url ) {
|
1868 |
+
$pattern =
|
1869 |
+
'%^# Match any youtube URL
|
1870 |
+
(?:https?://)? # Optional scheme. Either http or https
|
1871 |
+
(?:www\.)? # Optional www subdomain
|
1872 |
+
(?: # Group host alternatives
|
1873 |
+
youtu\.be/ # Either youtu.be,
|
1874 |
+
| youtube\.com # or youtube.com
|
1875 |
+
(?: # Group path alternatives
|
1876 |
+
/embed/ # Either /embed/
|
1877 |
+
| /v/ # or /v/
|
1878 |
+
| /watch\?v= # or /watch\?v=
|
1879 |
+
) # End path alternatives.
|
1880 |
+
) # End host alternatives.
|
1881 |
+
([\w-]{10,12}) # Allow 10-12 for 11 char youtube id.
|
1882 |
+
$%x';
|
1883 |
+
$result = preg_match( $pattern, $url, $matches );
|
1884 |
+
if ( false !== $result && isset( $matches[1] ) ) {
|
1885 |
+
return $matches[1];
|
1886 |
+
}
|
1887 |
+
|
1888 |
+
return false;
|
1889 |
+
}
|
1890 |
+
|
1891 |
+
|
1892 |
+
/**
|
1893 |
+
* Find closest number in an array
|
1894 |
+
*
|
1895 |
+
* @param $array
|
1896 |
+
* @param $number
|
1897 |
+
*
|
1898 |
+
* @return mixed
|
1899 |
+
*/
|
1900 |
+
function um_closest_num( $array, $number ) {
|
1901 |
+
sort( $array );
|
1902 |
+
foreach ( $array as $a ) {
|
1903 |
+
if ( $a >= $number ) return $a;
|
1904 |
+
}
|
1905 |
+
|
1906 |
+
return end( $array );
|
1907 |
+
}
|
1908 |
+
|
1909 |
+
|
1910 |
+
/**
|
1911 |
+
* get cover uri
|
1912 |
+
*
|
1913 |
+
* @param $image
|
1914 |
+
* @param $attrs
|
1915 |
+
*
|
1916 |
+
* @return bool|string
|
1917 |
+
*/
|
1918 |
+
function um_get_cover_uri( $image, $attrs ) {
|
1919 |
+
$uri = false;
|
1920 |
+
$uri_common = false;
|
1921 |
+
$ext = '.' . pathinfo( $image, PATHINFO_EXTENSION );
|
1922 |
+
|
1923 |
+
$ratio = str_replace(':1','',UM()->options()->get( 'profile_cover_ratio' ) );
|
1924 |
+
$height = round( $attrs / $ratio );
|
1925 |
+
|
1926 |
+
if ( is_multisite() ) {
|
1927 |
+
//multisite fix for old customers
|
1928 |
+
$multisite_fix_dir = UM()->uploader()->get_upload_base_dir();
|
1929 |
+
$multisite_fix_url = UM()->uploader()->get_upload_base_url();
|
1930 |
+
$multisite_fix_dir = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $multisite_fix_dir );
|
1931 |
+
$multisite_fix_url = str_replace( '/sites/' . get_current_blog_id() . '/', '/', $multisite_fix_url );
|
1932 |
+
|
1933 |
+
if ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo{$ext}" ) ) {
|
1934 |
+
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/cover_photo{$ext}?" . current_time( 'timestamp' );
|
1935 |
+
}
|
1936 |
+
|
1937 |
+
if ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}{$ext}" ) ) {
|
1938 |
+
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/cover_photo-{$attrs}{$ext}?" . current_time( 'timestamp' );
|
1939 |
+
}elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}x{$height}{$ext}" ) ) {
|
1940 |
+
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/cover_photo-{$attrs}x{$height}{$ext}?". current_time( 'timestamp' );
|
1941 |
+
}
|
1942 |
+
}
|
1943 |
+
|
1944 |
+
if ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo{$ext}" ) ) {
|
1945 |
+
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/cover_photo{$ext}?" . current_time( 'timestamp' );
|
1946 |
+
}
|
1947 |
+
|
1948 |
+
if ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}{$ext}" ) ) {
|
1949 |
+
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/cover_photo-{$attrs}{$ext}?" . current_time( 'timestamp' );
|
1950 |
+
}elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}x{$height}{$ext}" ) ) {
|
1951 |
+
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/cover_photo-{$attrs}x{$height}{$ext}?". current_time( 'timestamp' );
|
1952 |
+
}
|
1953 |
+
|
1954 |
+
if ( ! empty( $uri_common ) && empty( $uri ) ) {
|
1955 |
+
$uri = $uri_common;
|
1956 |
+
}
|
1957 |
+
|
1958 |
+
return $uri;
|
1959 |
+
}
|
1960 |
+
|
1961 |
+
|
1962 |
+
|
1963 |
+
/**
|
1964 |
+
* get avatar URL instead of image
|
1965 |
+
*
|
1966 |
+
* @param $get_avatar
|
1967 |
+
*
|
1968 |
+
* @return mixed
|
1969 |
+
*/
|
1970 |
+
function um_get_avatar_url( $get_avatar ) {
|
1971 |
+
preg_match( '/src="(.*?)"/i', $get_avatar, $matches );
|
1972 |
+
|
1973 |
+
return isset( $matches[1] ) ? $matches[1] : '';
|
1974 |
+
}
|
1975 |
+
|
1976 |
+
|
1977 |
+
/**
|
1978 |
+
* get avatar uri
|
1979 |
+
*
|
1980 |
+
* @param $image
|
1981 |
+
* @param string|array $attrs
|
1982 |
+
*
|
1983 |
+
* @return bool|string
|
1984 |
+
*/
|
1985 |
+
function um_get_avatar_uri( $image, $attrs ) {
|
1986 |
+
$uri = false;
|
1987 |
+
$uri_common = false;
|
1988 |
+
$find = false;
|
1989 |
+
$ext = '.' . pathinfo( $image, PATHINFO_EXTENSION );
|
1990 |
+
|
1991 |
+
if ( is_multisite() ) {
|
1992 |
+
//multisite fix for old customers
|
1993 |
+
$multisite_fix_dir = UM()->uploader()->get_upload_base_dir();
|
1994 |
+
$multisite_fix_url = UM()->uploader()->get_upload_base_url();
|
1995 |
+
$multisite_fix_dir = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $multisite_fix_dir );
|
1996 |
+
$multisite_fix_url = str_replace( '/sites/' . get_current_blog_id() . '/', '/', $multisite_fix_url );
|
1997 |
+
|
1998 |
+
if ( $attrs == 'original' && file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo{$ext}" ) ) {
|
1999 |
+
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo{$ext}";
|
2000 |
+
} elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$attrs}x{$attrs}{$ext}" ) ) {
|
2001 |
+
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo-{$attrs}x{$attrs}{$ext}";
|
2002 |
+
} elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$attrs}{$ext}" ) ) {
|
2003 |
+
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo-{$attrs}{$ext}";
|
2004 |
+
} else {
|
2005 |
+
$sizes = UM()->options()->get( 'photo_thumb_sizes' );
|
2006 |
+
if ( is_array( $sizes ) ) {
|
2007 |
+
$find = um_closest_num( $sizes, $attrs );
|
2008 |
+
}
|
2009 |
+
|
2010 |
+
if ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$find}x{$find}{$ext}" ) ) {
|
2011 |
+
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo-{$find}x{$find}{$ext}";
|
2012 |
+
} elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$find}{$ext}" ) ) {
|
2013 |
+
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo-{$find}{$ext}";
|
2014 |
+
} elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo{$ext}" ) ) {
|
2015 |
+
$uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo{$ext}";
|
2016 |
+
}
|
2017 |
+
}
|
2018 |
+
}
|
2019 |
+
|
2020 |
+
if ( $attrs == 'original' && file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo{$ext}" ) ) {
|
2021 |
+
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo{$ext}";
|
2022 |
+
} elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$attrs}x{$attrs}{$ext}" ) ) {
|
2023 |
+
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo-{$attrs}x{$attrs}{$ext}";
|
2024 |
+
} elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$attrs}{$ext}" ) ) {
|
2025 |
+
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo-{$attrs}{$ext}";
|
2026 |
+
} else {
|
2027 |
+
$sizes = UM()->options()->get( 'photo_thumb_sizes' );
|
2028 |
+
if ( is_array( $sizes ) ) {
|
2029 |
+
$find = um_closest_num( $sizes, $attrs );
|
2030 |
+
}
|
2031 |
+
|
2032 |
+
if ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$find}x{$find}{$ext}" ) ) {
|
2033 |
+
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo-{$find}x{$find}{$ext}";
|
2034 |
+
} elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$find}{$ext}" ) ) {
|
2035 |
+
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo-{$find}{$ext}";
|
2036 |
+
} elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo{$ext}" ) ) {
|
2037 |
+
$uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo{$ext}";
|
2038 |
+
}
|
2039 |
+
}
|
2040 |
+
|
2041 |
+
if ( ! empty( $uri_common ) && empty( $uri ) ) {
|
2042 |
+
$uri = $uri_common;
|
2043 |
+
}
|
2044 |
+
|
2045 |
+
/**
|
2046 |
+
* UM hook
|
2047 |
+
*
|
2048 |
+
* @type filter
|
2049 |
+
* @title um_filter_avatar_cache_time
|
2050 |
+
* @description Change Profile field value if it's empty
|
2051 |
+
* @input_vars
|
2052 |
+
* [{"var":"$timestamp","type":"timestamp","desc":"Avatar cache time"},
|
2053 |
+
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
2054 |
+
* @change_log
|
2055 |
+
* ["Since: 2.0"]
|
2056 |
+
* @usage add_filter( 'um_filter_avatar_cache_time', 'function_name', 10, 2 );
|
2057 |
+
* @example
|
2058 |
+
* <?php
|
2059 |
+
* add_filter( 'um_filter_avatar_cache_time', 'my_avatar_cache_time', 10, 2 );
|
2060 |
+
* function my_avatar_cache_time( $timestamp, $user_id ) {
|
2061 |
+
* // your code here
|
2062 |
+
* return $timestamp;
|
2063 |
+
* }
|
2064 |
+
* ?>
|
2065 |
+
*/
|
2066 |
+
$cache_time = apply_filters( 'um_filter_avatar_cache_time', current_time( 'timestamp' ), um_user( 'ID' ) );
|
2067 |
+
if ( ! empty( $cache_time ) ) {
|
2068 |
+
$uri .= "?{$cache_time}";
|
2069 |
+
}
|
2070 |
+
|
2071 |
+
return $uri;
|
2072 |
+
}
|
2073 |
+
|
2074 |
+
|
2075 |
+
/**
|
2076 |
+
* Default avatar URL
|
2077 |
+
*
|
2078 |
+
* @return string
|
2079 |
+
*/
|
2080 |
+
function um_get_default_avatar_uri() {
|
2081 |
+
$uri = UM()->options()->get( 'default_avatar' );
|
2082 |
+
$uri = !empty( $uri['url'] ) ? $uri['url'] : '';
|
2083 |
+
if ( ! $uri ) {
|
2084 |
+
$uri = um_url . 'assets/img/default_avatar.jpg';
|
2085 |
+
}
|
2086 |
+
|
2087 |
+
return set_url_scheme( $uri );
|
2088 |
+
}
|
2089 |
+
|
2090 |
+
|
2091 |
+
/**
|
2092 |
+
* get user avatar url
|
2093 |
+
*
|
2094 |
+
* @param $user_id
|
2095 |
+
* @param $size
|
2096 |
+
*
|
2097 |
+
* @return bool|string
|
2098 |
+
*/
|
2099 |
+
function um_get_user_avatar_data( $user_id = '', $size = '96' ) {
|
2100 |
+
if( empty( $user_id ) ) {
|
2101 |
+
$user_id = um_user( 'ID' );
|
2102 |
+
} else {
|
2103 |
+
um_fetch_user( $user_id );
|
2104 |
+
}
|
2105 |
+
|
2106 |
+
$data = array(
|
2107 |
+
'user_id' => $user_id,
|
2108 |
+
'default' => um_get_default_avatar_uri(),
|
2109 |
+
'class' => 'gravatar avatar avatar-' . $size . ' um-avatar',
|
2110 |
+
'size' => $size
|
2111 |
+
);
|
2112 |
+
|
2113 |
+
if ( $profile_photo = um_profile( 'profile_photo' ) ) {
|
2114 |
+
$data['url'] = um_get_avatar_uri( $profile_photo, $size );
|
2115 |
+
$data['type'] = 'upload';
|
2116 |
+
$data['class'] .= ' um-avatar-uploaded';
|
2117 |
+
} elseif ( $synced_profile_photo = um_user( 'synced_profile_photo' ) ) {
|
2118 |
+
$data['url'] = $synced_profile_photo;
|
2119 |
+
$data['type'] = 'sync';
|
2120 |
+
$data['class'] .= ' um-avatar-default';
|
2121 |
+
} elseif ( UM()->options()->get( 'use_gravatars' ) ) {
|
2122 |
+
$avatar_hash_id = md5( um_user( 'user_email' ) );
|
2123 |
+
$data['url'] = set_url_scheme( '//gravatar.com/avatar/' . $avatar_hash_id );
|
2124 |
+
$data['url'] = add_query_arg( 's', 400, $data['url'] );
|
2125 |
+
$rating = get_option( 'avatar_rating' );
|
2126 |
+
if ( ! empty( $rating ) ) {
|
2127 |
+
$data['url'] = add_query_arg( 'r', $rating, $data['url'] );
|
2128 |
+
}
|
2129 |
+
|
2130 |
+
$gravatar_type = UM()->options()->get( 'use_um_gravatar_default_builtin_image' );
|
2131 |
+
if ( $gravatar_type == 'default' ) {
|
2132 |
+
if ( UM()->options()->get( 'use_um_gravatar_default_image' ) ) {
|
2133 |
+
$data['url'] = add_query_arg( 'd', $data['default'], $data['url'] );
|
2134 |
+
} else {
|
2135 |
+
$default = get_option( 'avatar_default', 'mystery' );
|
2136 |
+
if ( $default == 'gravatar_default' ) {
|
2137 |
+
$default = '';
|
2138 |
+
}
|
2139 |
+
$data['url'] = add_query_arg( 'd', $default, $data['url'] );
|
2140 |
+
}
|
2141 |
+
} else {
|
2142 |
+
$data['url'] = add_query_arg( 'd', $gravatar_type, $data['url'] );
|
2143 |
+
}
|
2144 |
+
|
2145 |
+
$data['type'] = 'gravatar';
|
2146 |
+
$data['class'] .= ' um-avatar-gravatar';
|
2147 |
+
} else {
|
2148 |
+
$data['url'] = $data['default'];
|
2149 |
+
$data['type'] = 'default';
|
2150 |
+
$data['class'] .= ' um-avatar-default';
|
2151 |
+
}
|
2152 |
+
|
2153 |
+
|
2154 |
+
/**
|
2155 |
+
* UM hook
|
2156 |
+
*
|
2157 |
+
* @type filter
|
2158 |
+
* @title um_user_avatar_url_filter
|
2159 |
+
* @description Change user avatar URL
|
2160 |
+
* @input_vars
|
2161 |
+
* [{"var":"$avatar_uri","type":"string","desc":"Avatar URL"},
|
2162 |
+
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
2163 |
+
* @change_log
|
2164 |
+
* ["Since: 2.0"]
|
2165 |
+
* @usage add_filter( 'um_user_avatar_url_filter', 'function_name', 10, 2 );
|
2166 |
+
* @example
|
2167 |
+
* <?php
|
2168 |
+
* add_filter( 'um_user_avatar_url_filter', 'my_user_avatar_url', 10, 2 );
|
2169 |
+
* function my_user_avatar_url( $avatar_uri ) {
|
2170 |
+
* // your code here
|
2171 |
+
* return $avatar_uri;
|
2172 |
+
* }
|
2173 |
+
* ?>
|
2174 |
+
*/
|
2175 |
+
$data['url'] = apply_filters( 'um_user_avatar_url_filter', $data['url'], $user_id, $data );
|
2176 |
+
/**
|
2177 |
+
* UM hook
|
2178 |
+
*
|
2179 |
+
* @type filter
|
2180 |
+
* @title um_avatar_image_alternate_text
|
2181 |
+
* @description Change user display name on um_user function profile photo
|
2182 |
+
* @input_vars
|
2183 |
+
* [{"var":"$display_name","type":"string","desc":"User Display Name"}]
|
2184 |
+
* @change_log
|
2185 |
+
* ["Since: 2.0"]
|
2186 |
+
* @usage add_filter( 'um_avatar_image_alternate_text', 'function_name', 10, 1 );
|
2187 |
+
* @example
|
2188 |
+
* <?php
|
2189 |
+
* add_filter( 'um_avatar_image_alternate_text', 'my_avatar_image_alternate_text', 10, 1 );
|
2190 |
+
* function my_avatar_image_alternate_text( $display_name ) {
|
2191 |
+
* // your code here
|
2192 |
+
* return $display_name;
|
2193 |
+
* }
|
2194 |
+
* ?>
|
2195 |
+
*/
|
2196 |
+
$data['alt'] = apply_filters( "um_avatar_image_alternate_text", um_user( "display_name" ), $data );
|
2197 |
+
|
2198 |
+
return $data;
|
2199 |
+
}
|
2200 |
+
|
2201 |
+
|
2202 |
+
/**
|
2203 |
+
* get user avatar url
|
2204 |
+
*
|
2205 |
+
* @param $user_id
|
2206 |
+
* @param $size
|
2207 |
+
*
|
2208 |
+
* @return bool|string
|
2209 |
+
*/
|
2210 |
+
function um_get_user_avatar_url( $user_id = '', $size = '96' ) {
|
2211 |
+
$data = um_get_user_avatar_data( $user_id, $size );
|
2212 |
+
return $data['url'];
|
2213 |
+
}
|
2214 |
+
|
2215 |
+
|
2216 |
+
/**
|
2217 |
+
* default cover
|
2218 |
+
*
|
2219 |
+
* @return mixed|string|void
|
2220 |
+
*/
|
2221 |
+
function um_get_default_cover_uri() {
|
2222 |
+
$uri = UM()->options()->get( 'default_cover' );
|
2223 |
+
$uri = ! empty( $uri['url'] ) ? $uri['url'] : '';
|
2224 |
+
if ( $uri ) {
|
2225 |
+
|
2226 |
+
/**
|
2227 |
+
* UM hook
|
2228 |
+
*
|
2229 |
+
* @type filter
|
2230 |
+
* @title um_get_default_cover_uri_filter
|
2231 |
+
* @description Change Default Cover URL
|
2232 |
+
* @input_vars
|
2233 |
+
* [{"var":"$uri","type":"string","desc":"Default Cover URL"}]
|
2234 |
+
* @change_log
|
2235 |
+
* ["Since: 2.0"]
|
2236 |
+
* @usage add_filter( 'um_get_default_cover_uri_filter', 'function_name', 10, 1 );
|
2237 |
+
* @example
|
2238 |
+
* <?php
|
2239 |
+
* add_filter( 'um_get_default_cover_uri_filter', 'my_default_cover_uri', 10, 1 );
|
2240 |
+
* function my_default_cover_uri( $uri ) {
|
2241 |
+
* // your code here
|
2242 |
+
* return $uri;
|
2243 |
+
* }
|
2244 |
+
* ?>
|
2245 |
+
*/
|
2246 |
+
return apply_filters( 'um_get_default_cover_uri_filter', $uri );
|
2247 |
+
}
|
2248 |
+
|
2249 |
+
return '';
|
2250 |
+
}
|
2251 |
+
|
2252 |
+
|
2253 |
+
/**
|
2254 |
+
* @param $data
|
2255 |
+
* @param null $attrs
|
2256 |
+
*
|
2257 |
+
* @return string|array
|
2258 |
+
*/
|
2259 |
+
function um_user( $data, $attrs = null ) {
|
2260 |
+
|
2261 |
+
switch ($data) {
|
2262 |
+
|
2263 |
+
default:
|
2264 |
+
|
2265 |
+
$value = um_profile( $data );
|
2266 |
+
|
2267 |
+
$value = maybe_unserialize( $value );
|
2268 |
+
|
2269 |
+
if ( in_array( $data, array( 'role', 'gender' ) ) ) {
|
2270 |
+
if ( is_array( $value ) ) {
|
2271 |
+
$value = implode( ",", $value );
|
2272 |
+
}
|
2273 |
+
|
2274 |
+
return $value;
|
2275 |
+
}
|
2276 |
+
|
2277 |
+
return $value;
|
2278 |
+
break;
|
2279 |
+
|
2280 |
+
case 'user_email':
|
2281 |
+
|
2282 |
+
$user_email_in_meta = get_user_meta( um_user( 'ID' ), 'user_email', true );
|
2283 |
+
if ( $user_email_in_meta ) {
|
2284 |
+
delete_user_meta( um_user( 'ID' ), 'user_email' );
|
2285 |
+
}
|
2286 |
+
|
2287 |
+
$value = um_profile( $data );
|
2288 |
+
|
2289 |
+
return $value;
|
2290 |
+
break;
|
2291 |
+
|
2292 |
+
case 'user_login':
|
2293 |
+
|
2294 |
+
$user_login_in_meta = get_user_meta( um_user( 'ID' ), 'user_login', true );
|
2295 |
+
if ( $user_login_in_meta ) {
|
2296 |
+
delete_user_meta( um_user( 'ID' ), 'user_login' );
|
2297 |
+
}
|
2298 |
+
|
2299 |
+
$value = um_profile( $data );
|
2300 |
+
|
2301 |
+
return $value;
|
2302 |
+
break;
|
2303 |
+
|
2304 |
+
case 'first_name':
|
2305 |
+
case 'last_name':
|
2306 |
+
|
2307 |
+
$name = um_profile( $data );
|
2308 |
+
|
2309 |
+
/**
|
2310 |
+
* UM hook
|
2311 |
+
*
|
2312 |
+
* @type filter
|
2313 |
+
* @title um_user_{$data}_case
|
2314 |
+
* @description Change user name on um_user function
|
2315 |
+
* @input_vars
|
2316 |
+
* [{"var":"$name","type":"string","desc":"User Name"}]
|
2317 |
+
* @change_log
|
2318 |
+
* ["Since: 2.0"]
|
2319 |
+
* @usage add_filter( 'um_user_{$data}_case', 'function_name', 10, 1 );
|
2320 |
+
* @example
|
2321 |
+
* <?php
|
2322 |
+
* add_filter( 'um_user_{$data}_case', 'my_user_case', 10, 1 );
|
2323 |
+
* function my_user_case( $name ) {
|
2324 |
+
* // your code here
|
2325 |
+
* return $name;
|
2326 |
+
* }
|
2327 |
+
* ?>
|
2328 |
+
*/
|
2329 |
+
$name = apply_filters( "um_user_{$data}_case", $name );
|
2330 |
+
|
2331 |
+
return $name;
|
2332 |
+
|
2333 |
+
break;
|
2334 |
+
|
2335 |
+
case 'full_name':
|
2336 |
+
|
2337 |
+
if ( um_user( 'first_name' ) && um_user( 'last_name' ) ) {
|
2338 |
+
$full_name = um_user( 'first_name' ) . ' ' . um_user( 'last_name' );
|
2339 |
+
} else {
|
2340 |
+
$full_name = um_user( 'display_name' );
|
2341 |
+
}
|
2342 |
+
|
2343 |
+
$full_name = UM()->validation()->safe_name_in_url( $full_name );
|
2344 |
+
|
2345 |
+
// update full_name changed
|
2346 |
+
if ( um_profile( $data ) !== $full_name ) {
|
2347 |
+
update_user_meta( um_user( 'ID' ), 'full_name', $full_name );
|
2348 |
+
}
|
2349 |
+
|
2350 |
+
return $full_name;
|
2351 |
+
|
2352 |
+
break;
|
2353 |
+
|
2354 |
+
case 'first_and_last_name_initial':
|
2355 |
+
|
2356 |
+
$f_and_l_initial = '';
|
2357 |
+
|
2358 |
+
if ( um_user( 'first_name' ) && um_user( 'last_name' ) ) {
|
2359 |
+
$initial = um_user( 'last_name' );
|
2360 |
+
$f_and_l_initial = um_user( 'first_name' ) . ' ' . $initial[0];
|
2361 |
+
} else {
|
2362 |
+
$f_and_l_initial = um_profile( $data );
|
2363 |
+
}
|
2364 |
+
|
2365 |
+
$name = UM()->validation()->safe_name_in_url( $f_and_l_initial );
|
2366 |
+
return $name;
|
2367 |
+
|
2368 |
+
break;
|
2369 |
+
|
2370 |
+
case 'display_name':
|
2371 |
+
|
2372 |
+
$op = UM()->options()->get( 'display_name' );
|
2373 |
+
|
2374 |
+
$name = '';
|
2375 |
+
|
2376 |
+
if ( $op == 'default' ) {
|
2377 |
+
$name = um_profile( 'display_name' );
|
2378 |
+
}
|
2379 |
+
|
2380 |
+
if ( $op == 'nickname' ) {
|
2381 |
+
$name = um_profile( 'nickname' );
|
2382 |
+
}
|
2383 |
+
|
2384 |
+
if ( $op == 'full_name' ) {
|
2385 |
+
if ( um_user( 'first_name' ) && um_user( 'last_name' ) ) {
|
2386 |
+
$name = um_user( 'first_name' ) . ' ' . um_user( 'last_name' );
|
2387 |
+
} else {
|
2388 |
+
$name = um_profile( $data );
|
2389 |
+
}
|
2390 |
+
if ( ! $name ) {
|
2391 |
+
$name = um_user( 'user_login' );
|
2392 |
+
}
|
2393 |
+
}
|
2394 |
+
|
2395 |
+
if ( $op == 'sur_name' ) {
|
2396 |
+
if ( um_user( 'first_name' ) && um_user( 'last_name' ) ) {
|
2397 |
+
$name = um_user( 'last_name' ) . ' ' . um_user( 'first_name' );
|
2398 |
+
} else {
|
2399 |
+
$name = um_profile( $data );
|
2400 |
+
}
|
2401 |
+
}
|
2402 |
+
|
2403 |
+
if ( $op == 'first_name' ) {
|
2404 |
+
if ( um_user( 'first_name' ) ) {
|
2405 |
+
$name = um_user( 'first_name' );
|
2406 |
+
} else {
|
2407 |
+
$name = um_profile( $data );
|
2408 |
+
}
|
2409 |
+
}
|
2410 |
+
|
2411 |
+
if ( $op == 'username' ) {
|
2412 |
+
$name = um_user( 'user_login' );
|
2413 |
+
}
|
2414 |
+
|
2415 |
+
if ( $op == 'initial_name' ) {
|
2416 |
+
if (um_user( 'first_name' ) && um_user( 'last_name' )) {
|
2417 |
+
$initial = um_user( 'last_name' );
|
2418 |
+
$name = um_user( 'first_name' ) . ' ' . $initial[0];
|
2419 |
+
} else {
|
2420 |
+
$name = um_profile( $data );
|
2421 |
+
}
|
2422 |
+
}
|
2423 |
+
|
2424 |
+
if ( $op == 'initial_name_f' ) {
|
2425 |
+
if ( um_user( 'first_name' ) && um_user( 'last_name' ) ) {
|
2426 |
+
$initial = um_user( 'first_name' );
|
2427 |
+
$name = $initial[0] . ' ' . um_user( 'last_name' );
|
2428 |
+
} else {
|
2429 |
+
$name = um_profile( $data );
|
2430 |
+
}
|
2431 |
+
}
|
2432 |
+
|
2433 |
+
|
2434 |
+
if ( $op == 'field' && UM()->options()->get( 'display_name_field' ) != '' ) {
|
2435 |
+
$fields = array_filter( preg_split( '/[,\s]+/', UM()->options()->get( 'display_name_field' ) ) );
|
2436 |
+
$name = '';
|
2437 |
+
|
2438 |
+
foreach ( $fields as $field ) {
|
2439 |
+
if ( um_profile( $field ) ) {
|
2440 |
+
|
2441 |
+
$field_value = maybe_unserialize( um_profile( $field ) );
|
2442 |
+
$field_value = is_array( $field_value ) ? implode( ',', $field_value ) : $field_value;
|
2443 |
+
|
2444 |
+
$name .= $field_value . ' ';
|
2445 |
+
} elseif ( um_user( $field ) && $field != 'display_name' && $field != 'full_name' ) {
|
2446 |
+
$name .= um_user( $field ) . ' ';
|
2447 |
+
}
|
2448 |
+
}
|
2449 |
+
}
|
2450 |
+
|
2451 |
+
/**
|
2452 |
+
* UM hook
|
2453 |
+
*
|
2454 |
+
* @type filter
|
2455 |
+
* @title um_user_display_name_filter
|
2456 |
+
* @description Change user display name on um_user function
|
2457 |
+
* @input_vars
|
2458 |
+
* [{"var":"$name","type":"string","desc":"User Name"},
|
2459 |
+
* {"var":"$user_id","type":"int","desc":"User ID"},
|
2460 |
+
* {"var":"$html","type":"bool","desc":"Is HTML"}]
|
2461 |
+
* @change_log
|
2462 |
+
* ["Since: 2.0"]
|
2463 |
+
* @usage add_filter( 'um_user_display_name_filter', 'function_name', 10, 3 );
|
2464 |
+
* @example
|
2465 |
+
* <?php
|
2466 |
+
* add_filter( 'um_user_display_name_filter', 'my_user_display_name', 10, 3 );
|
2467 |
+
* function my_user_display_name( $name, $user_id, $html ) {
|
2468 |
+
* // your code here
|
2469 |
+
* return $name;
|
2470 |
+
* }
|
2471 |
+
* ?>
|
2472 |
+
*/
|
2473 |
+
return apply_filters( 'um_user_display_name_filter', $name, um_user( 'ID' ), ( $attrs == 'html' ) ? 1 : 0 );
|
2474 |
+
|
2475 |
+
break;
|
2476 |
+
|
2477 |
+
case 'role_select':
|
2478 |
+
case 'role_radio':
|
2479 |
+
|
2480 |
+
return UM()->roles()->get_role_name( UM()->roles()->get_editable_priority_user_role( um_user( 'ID' ) ) );
|
2481 |
+
break;
|
2482 |
+
|
2483 |
+
case 'submitted':
|
2484 |
+
$array = um_profile( $data );
|
2485 |
+
if ( empty( $array ) ) {
|
2486 |
+
return '';
|
2487 |
+
}
|
2488 |
+
$array = maybe_unserialize( $array );
|
2489 |
+
|
2490 |
+
return $array;
|
2491 |
+
break;
|
2492 |
+
|
2493 |
+
case 'password_reset_link':
|
2494 |
+
return UM()->password()->reset_url();
|
2495 |
+
break;
|
2496 |
+
|
2497 |
+
case 'account_activation_link':
|
2498 |
+
return UM()->permalinks()->activate_url();
|
2499 |
+
break;
|
2500 |
+
|
2501 |
+
case 'profile_photo':
|
2502 |
+
$data = um_get_user_avatar_data( um_user( 'ID' ), $attrs );
|
2503 |
+
|
2504 |
+
return sprintf( '<img src="%s" class="%s" width="%s" height="%s" alt="%s" data-default="%s" onerror="%s" />',
|
2505 |
+
esc_attr( $data['url'] ),
|
2506 |
+
esc_attr( $data['class'] ),
|
2507 |
+
esc_attr( $data['size'] ),
|
2508 |
+
esc_attr( $data['size'] ),
|
2509 |
+
esc_attr( $data['alt'] ),
|
2510 |
+
esc_attr( $data['default'] ),
|
2511 |
+
'if ( ! this.getAttribute(\'data-load-error\') ){ this.setAttribute(\'data-load-error\', \'1\');this.setAttribute(\'src\', this.getAttribute(\'data-default\'));}'
|
2512 |
+
);
|
2513 |
+
break;
|
2514 |
+
|
2515 |
+
case 'cover_photo':
|
2516 |
+
|
2517 |
+
$is_default = false;
|
2518 |
+
|
2519 |
+
if ( um_profile( 'cover_photo' ) ) {
|
2520 |
+
$cover_uri = um_get_cover_uri( um_profile( 'cover_photo' ), $attrs );
|
2521 |
+
} elseif ( um_profile( 'synced_cover_photo' ) ) {
|
2522 |
+
$cover_uri = um_profile( 'synced_cover_photo' );
|
2523 |
+
} else {
|
2524 |
+
$cover_uri = um_get_default_cover_uri();
|
2525 |
+
$is_default = true;
|
2526 |
+
}
|
2527 |
+
|
2528 |
+
/**
|
2529 |
+
* UM hook
|
2530 |
+
*
|
2531 |
+
* @type filter
|
2532 |
+
* @title um_user_cover_photo_uri__filter
|
2533 |
+
* @description Change user avatar URL
|
2534 |
+
* @input_vars
|
2535 |
+
* [{"var":"$cover_uri","type":"string","desc":"Cover URL"},
|
2536 |
+
* {"var":"$is_default","type":"bool","desc":"Default or not"},
|
2537 |
+
* {"var":"$attrs","type":"array","desc":"Attributes"}]
|
2538 |
+
* @change_log
|
2539 |
+
* ["Since: 2.0"]
|
2540 |
+
* @usage add_filter( 'um_user_cover_photo_uri__filter', 'function_name', 10, 3 );
|
2541 |
+
* @example
|
2542 |
+
* <?php
|
2543 |
+
* add_filter( 'um_user_cover_photo_uri__filter', 'my_user_cover_photo_uri', 10, 3 );
|
2544 |
+
* function my_user_cover_photo_uri( $cover_uri, $is_default, $attrs ) {
|
2545 |
+
* // your code here
|
2546 |
+
* return $cover_uri;
|
2547 |
+
* }
|
2548 |
+
* ?>
|
2549 |
+
*/
|
2550 |
+
$cover_uri = apply_filters( 'um_user_cover_photo_uri__filter', $cover_uri, $is_default, $attrs );
|
2551 |
+
|
2552 |
+
$alt = um_profile( 'nickname' );
|
2553 |
+
|
2554 |
+
$cover_html = $cover_uri ? '<img src="' . esc_attr( $cover_uri ) . '" alt="' . esc_attr( $alt ) . '" />' : '';
|
2555 |
+
|
2556 |
+
$cover_html = apply_filters( 'um_user_cover_photo_html__filter', $cover_html, $cover_uri, $alt, $is_default, $attrs );
|
2557 |
+
return $cover_html;
|
2558 |
+
|
2559 |
+
break;
|
2560 |
+
|
2561 |
+
case 'user_url':
|
2562 |
+
|
2563 |
+
$value = um_profile( $data );
|
2564 |
+
|
2565 |
+
return $value;
|
2566 |
+
|
2567 |
+
break;
|
2568 |
+
|
2569 |
+
|
2570 |
+
}
|
2571 |
+
|
2572 |
+
}
|
2573 |
+
|
2574 |
+
|
2575 |
+
/**
|
2576 |
+
* Get server protocol
|
2577 |
+
*
|
2578 |
+
* @return string
|
2579 |
+
*/
|
2580 |
+
function um_get_domain_protocol() {
|
2581 |
+
|
2582 |
+
if (is_ssl()) {
|
2583 |
+
$protocol = 'https://';
|
2584 |
+
} else {
|
2585 |
+
$protocol = 'http://';
|
2586 |
+
}
|
2587 |
+
|
2588 |
+
return $protocol;
|
2589 |
+
}
|
2590 |
+
|
2591 |
+
|
2592 |
+
/**
|
2593 |
+
* Set SSL to media URI
|
2594 |
+
*
|
2595 |
+
* @param string $url
|
2596 |
+
*
|
2597 |
+
* @return string
|
2598 |
+
*/
|
2599 |
+
function um_secure_media_uri( $url ) {
|
2600 |
+
|
2601 |
+
if (is_ssl()) {
|
2602 |
+
$url = str_replace( 'http:', 'https:', $url );
|
2603 |
+
}
|
2604 |
+
|
2605 |
+
return $url;
|
2606 |
+
}
|
2607 |
+
|
2608 |
+
|
2609 |
+
/**
|
2610 |
+
* Force strings to UTF-8 encoded
|
2611 |
+
*
|
2612 |
+
* @param mixed $value
|
2613 |
+
*
|
2614 |
+
* @return mixed
|
2615 |
+
*/
|
2616 |
+
function um_force_utf8_string( $value ) {
|
2617 |
+
|
2618 |
+
if ( is_array( $value ) ) {
|
2619 |
+
$arr_value = array();
|
2620 |
+
foreach ( $value as $key => $v ) {
|
2621 |
+
$utf8_decoded_value = utf8_decode( $v );
|
2622 |
+
|
2623 |
+
if ( mb_check_encoding( $utf8_decoded_value, 'UTF-8' ) ) {
|
2624 |
+
array_push( $arr_value, $utf8_decoded_value );
|
2625 |
+
} else {
|
2626 |
+
array_push( $arr_value, $v );
|
2627 |
+
}
|
2628 |
+
|
2629 |
+
}
|
2630 |
+
|
2631 |
+
return $arr_value;
|
2632 |
+
} else {
|
2633 |
+
|
2634 |
+
$utf8_decoded_value = utf8_decode( $value );
|
2635 |
+
|
2636 |
+
if (mb_check_encoding( $utf8_decoded_value, 'UTF-8' )) {
|
2637 |
+
return $utf8_decoded_value;
|
2638 |
+
}
|
2639 |
+
}
|
2640 |
+
|
2641 |
+
return $value;
|
2642 |
+
}
|
2643 |
+
|
2644 |
+
|
2645 |
+
/**
|
2646 |
+
* Get user host
|
2647 |
+
*
|
2648 |
+
* Returns the webhost this site is using if possible
|
2649 |
+
*
|
2650 |
+
* @since 1.3.68
|
2651 |
+
* @return mixed string $host if detected, false otherwise
|
2652 |
+
*/
|
2653 |
+
function um_get_host() {
|
2654 |
+
$host = false;
|
2655 |
+
|
2656 |
+
if (defined( 'WPE_APIKEY' )) {
|
2657 |
+
$host = 'WP Engine';
|
2658 |
+
} else if (defined( 'PAGELYBIN' )) {
|
2659 |
+
$host = 'Pagely';
|
2660 |
+
} else if (DB_HOST == 'localhost:/tmp/mysql5.sock') {
|
2661 |
+
$host = 'ICDSoft';
|
2662 |
+
} else if (DB_HOST == 'mysqlv5') {
|
2663 |
+
$host = 'NetworkSolutions';
|
2664 |
+
} else if (strpos( DB_HOST, 'ipagemysql.com' ) !== false) {
|
2665 |
+
$host = 'iPage';
|
2666 |
+
} else if (strpos( DB_HOST, 'ipowermysql.com' ) !== false) {
|
2667 |
+
$host = 'IPower';
|
2668 |
+
} else if (strpos( DB_HOST, '.gridserver.com' ) !== false) {
|
2669 |
+
$host = 'MediaTemple Grid';
|
2670 |
+
} else if (strpos( DB_HOST, '.pair.com' ) !== false) {
|
2671 |
+
$host = 'pair Networks';
|
2672 |
+
} else if (strpos( DB_HOST, '.stabletransit.com' ) !== false) {
|
2673 |
+
$host = 'Rackspace Cloud';
|
2674 |
+
} else if (strpos( DB_HOST, '.sysfix.eu' ) !== false) {
|
2675 |
+
$host = 'SysFix.eu Power Hosting';
|
2676 |
+
} else if (strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false) {
|
2677 |
+
$host = 'Flywheel';
|
2678 |
+
} else {
|
2679 |
+
// Adding a general fallback for data gathering
|
2680 |
+
$host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
|
2681 |
+
}
|
2682 |
+
|
2683 |
+
return $host;
|
2684 |
+
}
|
2685 |
+
|
2686 |
+
|
2687 |
+
/**
|
2688 |
+
* Let To Num
|
2689 |
+
*
|
2690 |
+
* Does Size Conversions
|
2691 |
+
*
|
2692 |
+
* @since 1.3.68
|
2693 |
+
* @author Chris Christoff
|
2694 |
+
*
|
2695 |
+
* @param string $v
|
2696 |
+
*
|
2697 |
+
* @return int|string
|
2698 |
+
*/
|
2699 |
+
function um_let_to_num( $v ) {
|
2700 |
+
$l = substr( $v, -1 );
|
2701 |
+
$ret = substr( $v, 0, -1 );
|
2702 |
+
|
2703 |
+
switch (strtoupper( $l )) {
|
2704 |
+
case 'P': // fall-through
|
2705 |
+
case 'T': // fall-through
|
2706 |
+
case 'G': // fall-through
|
2707 |
+
case 'M': // fall-through
|
2708 |
+
case 'K': // fall-through
|
2709 |
+
$ret *= 1024;
|
2710 |
+
break;
|
2711 |
+
default:
|
2712 |
+
break;
|
2713 |
+
}
|
2714 |
+
|
2715 |
+
return $ret;
|
2716 |
+
}
|
2717 |
+
|
2718 |
+
|
2719 |
+
/**
|
2720 |
+
* Check if we are on UM page
|
2721 |
+
*
|
2722 |
+
* @return bool
|
2723 |
+
*/
|
2724 |
+
function is_ultimatemember() {
|
2725 |
+
global $post;
|
2726 |
+
|
2727 |
+
if ( isset( $post->ID ) && in_array( $post->ID, UM()->config()->permalinks ) )
|
2728 |
+
return true;
|
2729 |
+
|
2730 |
+
return false;
|
2731 |
+
}
|
2732 |
+
|
2733 |
+
|
2734 |
+
/**
|
2735 |
+
* Maybe set empty time limit
|
2736 |
+
*/
|
2737 |
+
function um_maybe_unset_time_limit() {
|
2738 |
+
@set_time_limit( 0 );
|
2739 |
+
}
|
2740 |
+
|
2741 |
+
|
2742 |
+
/*
|
2743 |
+
* Check if current user is owner of requested profile
|
2744 |
+
* @Returns Boolean
|
2745 |
+
*/
|
2746 |
+
if ( ! function_exists( 'um_is_profile_owner' ) ) {
|
2747 |
+
/**
|
2748 |
+
* @param $user_id
|
2749 |
+
*
|
2750 |
+
* @return bool
|
2751 |
+
*/
|
2752 |
+
function um_is_profile_owner( $user_id = false ) {
|
2753 |
+
if ( ! is_user_logged_in() ) {
|
2754 |
+
return false;
|
2755 |
+
}
|
2756 |
+
|
2757 |
+
if ( empty( $user_id ) ) {
|
2758 |
+
$user_id = get_current_user_id();
|
2759 |
+
}
|
2760 |
+
|
2761 |
+
return ( $user_id == um_profile_id() );
|
2762 |
+
}
|
2763 |
+
}
|
2764 |
+
|
2765 |
+
|
2766 |
+
/**
|
2767 |
+
* Check whether the current page is in AMP mode or not.
|
2768 |
+
* We need to check for specific functions, as there is no special AMP header.
|
2769 |
+
*
|
2770 |
+
* @since 2.1.11
|
2771 |
+
*
|
2772 |
+
* @param bool $check_theme_support Whether theme support should be checked. Defaults to true.
|
2773 |
+
*
|
2774 |
+
* @uses is_amp_endpoint() AMP by Automattic
|
2775 |
+
* @uses is_better_amp() Better AMP
|
2776 |
+
*
|
2777 |
+
* @return bool
|
2778 |
+
*/
|
2779 |
+
function um_is_amp( $check_theme_support = true ) {
|
2780 |
+
|
2781 |
+
$is_amp = false;
|
2782 |
+
|
2783 |
+
if ( ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) ||
|
2784 |
+
( function_exists( 'is_better_amp' ) && is_better_amp() ) ) {
|
2785 |
+
$is_amp = true;
|
2786 |
+
}
|
2787 |
+
|
2788 |
+
if ( $is_amp && $check_theme_support ) {
|
2789 |
+
$is_amp = current_theme_supports( 'amp' );
|
2790 |
+
}
|
2791 |
+
|
2792 |
+
return apply_filters( 'um_is_amp', $is_amp );
|
2793 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/ultimate-member.pot
CHANGED
@@ -2,16 +2,16 @@
|
|
2 |
# This file is distributed under the same license as the Ultimate Member plugin.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Ultimate Member 2.5.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/ultimate-member\n"
|
7 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"POT-Creation-Date: 2022-
|
13 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
-
"X-Generator: WP-CLI 2.
|
15 |
"X-Domain: ultimate-member\n"
|
16 |
|
17 |
#. Plugin Name of the plugin
|
@@ -121,7 +121,7 @@ msgstr ""
|
|
121 |
#: includes/admin/core/class-admin-builder.php:776
|
122 |
#: includes/admin/core/class-admin-dragdrop.php:33
|
123 |
#: includes/admin/core/class-admin-menu.php:106
|
124 |
-
#: includes/core/class-fields.php:
|
125 |
msgid "Please login as administrator"
|
126 |
msgstr ""
|
127 |
|
@@ -182,7 +182,7 @@ msgid "Predefined Fields"
|
|
182 |
msgstr ""
|
183 |
|
184 |
#: includes/admin/core/class-admin-builder.php:903
|
185 |
-
#: includes/core/class-builtin.php:
|
186 |
msgid "None"
|
187 |
msgstr ""
|
188 |
|
@@ -208,13 +208,18 @@ msgstr ""
|
|
208 |
#: includes/admin/core/class-admin-builder.php:1207
|
209 |
#: includes/core/class-form.php:138
|
210 |
#: includes/core/class-form.php:146
|
211 |
-
#: includes/core/class-form.php:
|
212 |
-
#: includes/core/class-form.php:
|
|
|
213 |
#: includes/core/class-password.php:525
|
214 |
-
#: includes/core/um-actions-profile.php:
|
215 |
msgid "This is not possible for security reasons."
|
216 |
msgstr ""
|
217 |
|
|
|
|
|
|
|
|
|
218 |
#: includes/admin/core/class-admin-columns.php:50
|
219 |
msgid "Status"
|
220 |
msgstr ""
|
@@ -262,10 +267,10 @@ msgstr ""
|
|
262 |
#: includes/admin/templates/form/register_customize.php:89
|
263 |
#: includes/admin/templates/form/register_gdpr.php:31
|
264 |
#: includes/admin/templates/role/profile.php:53
|
265 |
-
#: includes/core/class-builtin.php:
|
266 |
-
#: includes/core/class-builtin.php:
|
267 |
-
#: includes/core/class-builtin.php:1279
|
268 |
#: includes/core/class-builtin.php:1282
|
|
|
269 |
#: includes/core/um-actions-account.php:332
|
270 |
msgid "No"
|
271 |
msgstr ""
|
@@ -294,9 +299,9 @@ msgstr ""
|
|
294 |
#: includes/admin/templates/form/register_customize.php:90
|
295 |
#: includes/admin/templates/form/register_gdpr.php:32
|
296 |
#: includes/admin/templates/role/profile.php:54
|
297 |
-
#: includes/core/class-builtin.php:
|
298 |
-
#: includes/core/class-builtin.php:
|
299 |
-
#: includes/core/class-builtin.php:
|
300 |
#: includes/core/class-user.php:430
|
301 |
#: includes/core/class-user.php:431
|
302 |
#: includes/core/um-actions-account.php:327
|
@@ -314,8 +319,8 @@ msgstr ""
|
|
314 |
#: includes/admin/core/class-admin-enqueue.php:501
|
315 |
#: includes/core/class-builtin.php:748
|
316 |
#: includes/core/class-builtin.php:751
|
317 |
-
#: includes/core/class-builtin.php:1288
|
318 |
#: includes/core/class-builtin.php:1291
|
|
|
319 |
#: includes/core/um-actions-account.php:623
|
320 |
#: includes/core/um-actions-account.php:695
|
321 |
msgid "Password"
|
@@ -373,7 +378,7 @@ msgstr ""
|
|
373 |
#: includes/admin/core/class-admin-forms.php:1617
|
374 |
#: includes/admin/core/class-admin-forms.php:1639
|
375 |
#: includes/admin/core/class-admin-notices.php:427
|
376 |
-
#: includes/core/um-actions-profile.php:
|
377 |
#: includes/admin/assets/js/um-admin-forms.js:250
|
378 |
#: includes/admin/assets/js/um-admin-forms.js:315
|
379 |
#: includes/admin/assets/js/um-admin-forms.js:592
|
@@ -1317,10 +1322,10 @@ msgid "The text that appears on the button. e.g. Upload"
|
|
1317 |
msgstr ""
|
1318 |
|
1319 |
#: includes/admin/core/class-admin-metabox.php:2017
|
1320 |
-
#: includes/core/class-fields.php:
|
1321 |
-
#: includes/core/class-fields.php:
|
1322 |
-
#: includes/core/class-fields.php:
|
1323 |
-
#: includes/core/class-fields.php:
|
1324 |
msgid "Upload"
|
1325 |
msgstr ""
|
1326 |
|
@@ -2483,7 +2488,7 @@ msgid "Appearance"
|
|
2483 |
msgstr ""
|
2484 |
|
2485 |
#: includes/admin/core/class-admin-settings.php:1349
|
2486 |
-
#: includes/core/class-form.php:
|
2487 |
msgid "Profile"
|
2488 |
msgstr ""
|
2489 |
|
@@ -3101,7 +3106,7 @@ msgid "UM Action"
|
|
3101 |
msgstr ""
|
3102 |
|
3103 |
#: includes/admin/core/class-admin-users.php:193
|
3104 |
-
#: includes/core/class-fields.php:
|
3105 |
msgid "Apply"
|
3106 |
msgstr ""
|
3107 |
|
@@ -4288,14 +4293,14 @@ msgstr ""
|
|
4288 |
#: includes/admin/templates/modal/forms/fonticons.php:14
|
4289 |
#: includes/admin/templates/role/publish.php:30
|
4290 |
#: includes/class-config.php:254
|
4291 |
-
#: includes/core/class-fields.php:
|
4292 |
-
#: includes/core/class-fields.php:
|
4293 |
-
#: includes/core/um-actions-profile.php:
|
4294 |
-
#: includes/core/um-actions-profile.php:
|
4295 |
-
#: includes/core/um-actions-profile.php:
|
4296 |
-
#: includes/core/um-actions-profile.php:
|
4297 |
-
#: includes/core/um-actions-profile.php:
|
4298 |
-
#: includes/core/um-actions-profile.php:
|
4299 |
msgid "Cancel"
|
4300 |
msgstr ""
|
4301 |
|
@@ -4631,7 +4636,7 @@ msgstr ""
|
|
4631 |
#: includes/class-config.php:264
|
4632 |
#: includes/class-config.php:272
|
4633 |
#: includes/class-config.php:800
|
4634 |
-
#: includes/core/class-form.php:
|
4635 |
msgid "Login"
|
4636 |
msgstr ""
|
4637 |
|
@@ -4639,14 +4644,14 @@ msgstr ""
|
|
4639 |
#: includes/class-config.php:262
|
4640 |
#: includes/class-config.php:276
|
4641 |
#: includes/class-config.php:801
|
4642 |
-
#: includes/core/class-form.php:
|
4643 |
msgid "Register"
|
4644 |
msgstr ""
|
4645 |
|
4646 |
#: includes/class-config.php:135
|
4647 |
#: includes/class-config.php:803
|
4648 |
#: includes/core/class-member-directory.php:2300
|
4649 |
-
#: includes/core/um-actions-profile.php:
|
4650 |
#: includes/core/um-actions-user.php:19
|
4651 |
msgid "Logout"
|
4652 |
msgstr ""
|
@@ -4828,8 +4833,8 @@ msgstr ""
|
|
4828 |
#. translators: %s: Restricted post message.
|
4829 |
#. translators: %s: The message after registration process based on a role data and user status after registration
|
4830 |
#. translators: %s: Restricted taxonomy message.
|
4831 |
-
#: includes/core/class-access.php:
|
4832 |
-
#: includes/core/class-fields.php:
|
4833 |
#: includes/core/um-actions-account.php:495
|
4834 |
#: templates/message.php:8
|
4835 |
#: templates/restricted-taxonomy.php:47
|
@@ -4858,8 +4863,8 @@ msgstr ""
|
|
4858 |
|
4859 |
#: includes/core/class-account.php:124
|
4860 |
#: includes/core/class-account.php:125
|
4861 |
-
#: includes/core/class-builtin.php:1271
|
4862 |
#: includes/core/class-builtin.php:1274
|
|
|
4863 |
msgid "Delete Account"
|
4864 |
msgstr ""
|
4865 |
|
@@ -4958,13 +4963,13 @@ msgid "You must add a shortcode to the content area"
|
|
4958 |
msgstr ""
|
4959 |
|
4960 |
#: includes/core/class-builtin.php:713
|
4961 |
-
#: includes/core/class-user.php:
|
4962 |
msgid "Only me"
|
4963 |
msgstr ""
|
4964 |
|
4965 |
#: includes/core/class-builtin.php:737
|
4966 |
#: includes/core/class-builtin.php:740
|
4967 |
-
#: includes/core/class-builtin.php:
|
4968 |
msgid "Username or E-mail"
|
4969 |
msgstr ""
|
4970 |
|
@@ -4986,7 +4991,7 @@ msgstr ""
|
|
4986 |
|
4987 |
#: includes/core/class-builtin.php:793
|
4988 |
#: includes/core/class-builtin.php:796
|
4989 |
-
#: includes/core/class-builtin.php:
|
4990 |
msgid "Website URL"
|
4991 |
msgstr ""
|
4992 |
|
@@ -5078,7 +5083,7 @@ msgstr ""
|
|
5078 |
|
5079 |
#: includes/core/class-builtin.php:989
|
5080 |
#: includes/core/class-builtin.php:992
|
5081 |
-
#: includes/core/class-builtin.php:
|
5082 |
msgid "Skype ID"
|
5083 |
msgstr ""
|
5084 |
|
@@ -5106,1919 +5111,1920 @@ msgid "Discord"
|
|
5106 |
msgstr ""
|
5107 |
|
5108 |
#: includes/core/class-builtin.php:1051
|
5109 |
-
#: includes/core/class-builtin.php:
|
5110 |
msgid "Discord ID"
|
5111 |
msgstr ""
|
5112 |
|
5113 |
#: includes/core/class-builtin.php:1061
|
5114 |
#: includes/core/class-builtin.php:1064
|
|
|
5115 |
msgid "YouTube"
|
5116 |
msgstr ""
|
5117 |
|
5118 |
-
#: includes/core/class-builtin.php:1079
|
5119 |
#: includes/core/class-builtin.php:1082
|
|
|
5120 |
msgid "SoundCloud"
|
5121 |
msgstr ""
|
5122 |
|
5123 |
-
#: includes/core/class-builtin.php:1097
|
5124 |
#: includes/core/class-builtin.php:1100
|
|
|
5125 |
msgid "VKontakte"
|
5126 |
msgstr ""
|
5127 |
|
5128 |
-
#: includes/core/class-builtin.php:
|
5129 |
msgid "Roles (Dropdown)"
|
5130 |
msgstr ""
|
5131 |
|
5132 |
-
#: includes/core/class-builtin.php:
|
5133 |
-
#: includes/core/class-builtin.php:
|
5134 |
msgid "Account Type"
|
5135 |
msgstr ""
|
5136 |
|
5137 |
-
#: includes/core/class-builtin.php:
|
5138 |
msgid "Roles (Radio)"
|
5139 |
msgstr ""
|
5140 |
|
5141 |
-
#: includes/core/class-builtin.php:
|
5142 |
#: includes/core/class-member-directory.php:346
|
5143 |
msgid "Languages"
|
5144 |
msgstr ""
|
5145 |
|
5146 |
-
#: includes/core/class-builtin.php:
|
5147 |
msgid "Languages Spoken"
|
5148 |
msgstr ""
|
5149 |
|
5150 |
-
#: includes/core/class-builtin.php:
|
5151 |
msgid "Select languages"
|
5152 |
msgstr ""
|
5153 |
|
5154 |
-
#: includes/core/class-builtin.php:1150
|
5155 |
#: includes/core/class-builtin.php:1153
|
5156 |
-
#: includes/core/class-builtin.php:
|
|
|
5157 |
#: includes/core/class-member-directory.php:356
|
5158 |
msgid "Phone Number"
|
5159 |
msgstr ""
|
5160 |
|
5161 |
-
#: includes/core/class-builtin.php:1162
|
5162 |
#: includes/core/class-builtin.php:1165
|
|
|
5163 |
#: includes/core/class-member-directory.php:357
|
5164 |
msgid "Mobile Number"
|
5165 |
msgstr ""
|
5166 |
|
5167 |
-
#: includes/core/class-builtin.php:
|
5168 |
msgid "Profile Photo"
|
5169 |
msgstr ""
|
5170 |
|
5171 |
-
#: includes/core/class-builtin.php:
|
5172 |
msgid "Change your profile photo"
|
5173 |
msgstr ""
|
5174 |
|
5175 |
-
#: includes/core/class-builtin.php:
|
5176 |
msgid "Upload your photo here"
|
5177 |
msgstr ""
|
5178 |
|
5179 |
-
#: includes/core/class-builtin.php:
|
5180 |
msgid "Cover Photo"
|
5181 |
msgstr ""
|
5182 |
|
5183 |
-
#: includes/core/class-builtin.php:
|
5184 |
-
#: includes/core/um-actions-profile.php:
|
5185 |
msgid "Change your cover photo"
|
5186 |
msgstr ""
|
5187 |
|
5188 |
-
#: includes/core/class-builtin.php:
|
5189 |
msgid "Upload profile cover here"
|
5190 |
msgstr ""
|
5191 |
|
5192 |
-
#: includes/core/class-builtin.php:
|
5193 |
msgid "Enter your username or email"
|
5194 |
msgstr ""
|
5195 |
|
5196 |
-
#: includes/core/class-builtin.php:1218
|
5197 |
#: includes/core/class-builtin.php:1221
|
|
|
5198 |
msgid "Profile Privacy"
|
5199 |
msgstr ""
|
5200 |
|
5201 |
-
#: includes/core/class-builtin.php:
|
5202 |
msgid "Who can see your public profile?"
|
5203 |
msgstr ""
|
5204 |
|
5205 |
-
#: includes/core/class-builtin.php:1234
|
5206 |
#: includes/core/class-builtin.php:1237
|
|
|
5207 |
msgid "Avoid indexing my profile by search engines"
|
5208 |
msgstr ""
|
5209 |
|
5210 |
-
#: includes/core/class-builtin.php:
|
5211 |
msgid "Hide my profile for robots?"
|
5212 |
msgstr ""
|
5213 |
|
5214 |
-
#: includes/core/class-builtin.php:1253
|
5215 |
#: includes/core/class-builtin.php:1256
|
|
|
5216 |
msgid "Hide my profile from directory"
|
5217 |
msgstr ""
|
5218 |
|
5219 |
-
#: includes/core/class-builtin.php:
|
5220 |
msgid "Here you can hide yourself from appearing in public directory"
|
5221 |
msgstr ""
|
5222 |
|
5223 |
-
#: includes/core/class-builtin.php:
|
5224 |
msgid "If you confirm, everything related to your profile will be deleted permanently from the site"
|
5225 |
msgstr ""
|
5226 |
|
5227 |
-
#: includes/core/class-builtin.php:
|
5228 |
msgid "Alphabetic value only"
|
5229 |
msgstr ""
|
5230 |
|
5231 |
-
#: includes/core/class-builtin.php:
|
5232 |
msgid "Alpha-numeric value"
|
5233 |
msgstr ""
|
5234 |
|
5235 |
-
#: includes/core/class-builtin.php:
|
5236 |
msgid "English letters only"
|
5237 |
msgstr ""
|
5238 |
|
5239 |
-
#: includes/core/class-builtin.php:
|
5240 |
msgid "Facebook URL"
|
5241 |
msgstr ""
|
5242 |
|
5243 |
-
#: includes/core/class-builtin.php:
|
5244 |
msgid "Google+ URL"
|
5245 |
msgstr ""
|
5246 |
|
5247 |
-
#: includes/core/class-builtin.php:
|
5248 |
msgid "Instagram URL"
|
5249 |
msgstr ""
|
5250 |
|
5251 |
-
#: includes/core/class-builtin.php:
|
5252 |
msgid "LinkedIn URL"
|
5253 |
msgstr ""
|
5254 |
|
5255 |
-
#: includes/core/class-builtin.php:
|
5256 |
msgid "VKontakte URL"
|
5257 |
msgstr ""
|
5258 |
|
5259 |
-
#: includes/core/class-builtin.php:
|
5260 |
msgid "Lowercase only"
|
5261 |
msgstr ""
|
5262 |
|
5263 |
-
#: includes/core/class-builtin.php:
|
5264 |
msgid "Numeric value only"
|
5265 |
msgstr ""
|
5266 |
|
5267 |
-
#: includes/core/class-builtin.php:
|
5268 |
msgid "SoundCloud Profile"
|
5269 |
msgstr ""
|
5270 |
|
5271 |
-
#: includes/core/class-builtin.php:
|
5272 |
msgid "Twitter URL"
|
5273 |
msgstr ""
|
5274 |
|
5275 |
-
#: includes/core/class-builtin.php:
|
5276 |
msgid "E-mail( Not Unique )"
|
5277 |
msgstr ""
|
5278 |
|
5279 |
-
#: includes/core/class-builtin.php:
|
5280 |
msgid "Unique E-mail"
|
5281 |
msgstr ""
|
5282 |
|
5283 |
-
#: includes/core/class-builtin.php:
|
5284 |
msgid "Unique Metakey value"
|
5285 |
msgstr ""
|
5286 |
|
5287 |
-
#: includes/core/class-builtin.php:
|
5288 |
msgid "Unique Username"
|
5289 |
msgstr ""
|
5290 |
|
5291 |
-
#: includes/core/class-builtin.php:
|
5292 |
msgid "Unique Username/E-mail"
|
5293 |
msgstr ""
|
5294 |
|
5295 |
-
#: includes/core/class-builtin.php:
|
5296 |
msgid "YouTube Profile"
|
5297 |
msgstr ""
|
5298 |
|
5299 |
-
#: includes/core/class-builtin.php:
|
5300 |
msgid "Telegram URL"
|
5301 |
msgstr ""
|
5302 |
|
5303 |
-
#: includes/core/class-builtin.php:
|
5304 |
msgid "Custom Validation"
|
5305 |
msgstr ""
|
5306 |
|
5307 |
-
#: includes/core/class-builtin.php:
|
5308 |
msgid "Afar"
|
5309 |
msgstr ""
|
5310 |
|
5311 |
-
#: includes/core/class-builtin.php:
|
5312 |
msgid "Abkhazian"
|
5313 |
msgstr ""
|
5314 |
|
5315 |
-
#: includes/core/class-builtin.php:
|
5316 |
msgid "Avestan"
|
5317 |
msgstr ""
|
5318 |
|
5319 |
-
#: includes/core/class-builtin.php:
|
5320 |
msgid "Afrikaans"
|
5321 |
msgstr ""
|
5322 |
|
5323 |
-
#: includes/core/class-builtin.php:
|
5324 |
msgid "Akan"
|
5325 |
msgstr ""
|
5326 |
|
5327 |
-
#: includes/core/class-builtin.php:
|
5328 |
msgid "Amharic"
|
5329 |
msgstr ""
|
5330 |
|
5331 |
-
#: includes/core/class-builtin.php:
|
5332 |
msgid "Aragonese"
|
5333 |
msgstr ""
|
5334 |
|
5335 |
-
#: includes/core/class-builtin.php:
|
5336 |
msgid "Arabic"
|
5337 |
msgstr ""
|
5338 |
|
5339 |
-
#: includes/core/class-builtin.php:
|
5340 |
msgid "Assamese"
|
5341 |
msgstr ""
|
5342 |
|
5343 |
-
#: includes/core/class-builtin.php:
|
5344 |
msgid "Avaric"
|
5345 |
msgstr ""
|
5346 |
|
5347 |
-
#: includes/core/class-builtin.php:
|
5348 |
msgid "Aymara"
|
5349 |
msgstr ""
|
5350 |
|
5351 |
-
#: includes/core/class-builtin.php:
|
5352 |
msgid "Azerbaijani"
|
5353 |
msgstr ""
|
5354 |
|
5355 |
-
#: includes/core/class-builtin.php:
|
5356 |
msgid "Bashkir"
|
5357 |
msgstr ""
|
5358 |
|
5359 |
-
#: includes/core/class-builtin.php:
|
5360 |
msgid "Belarusian"
|
5361 |
msgstr ""
|
5362 |
|
5363 |
-
#: includes/core/class-builtin.php:
|
5364 |
msgid "Bulgarian"
|
5365 |
msgstr ""
|
5366 |
|
5367 |
-
#: includes/core/class-builtin.php:
|
5368 |
msgid "Bihari"
|
5369 |
msgstr ""
|
5370 |
|
5371 |
-
#: includes/core/class-builtin.php:
|
5372 |
msgid "Bislama"
|
5373 |
msgstr ""
|
5374 |
|
5375 |
-
#: includes/core/class-builtin.php:
|
5376 |
msgid "Bambara"
|
5377 |
msgstr ""
|
5378 |
|
5379 |
-
#: includes/core/class-builtin.php:
|
5380 |
msgid "Bengali"
|
5381 |
msgstr ""
|
5382 |
|
5383 |
-
#: includes/core/class-builtin.php:
|
5384 |
msgid "Tibetan"
|
5385 |
msgstr ""
|
5386 |
|
5387 |
-
#: includes/core/class-builtin.php:
|
5388 |
msgid "Breton"
|
5389 |
msgstr ""
|
5390 |
|
5391 |
-
#: includes/core/class-builtin.php:
|
5392 |
msgid "Bosnian"
|
5393 |
msgstr ""
|
5394 |
|
5395 |
-
#: includes/core/class-builtin.php:
|
5396 |
msgid "Catalan"
|
5397 |
msgstr ""
|
5398 |
|
5399 |
-
#: includes/core/class-builtin.php:
|
5400 |
msgid "Chechen"
|
5401 |
msgstr ""
|
5402 |
|
5403 |
-
#: includes/core/class-builtin.php:
|
5404 |
msgid "Chamorro"
|
5405 |
msgstr ""
|
5406 |
|
5407 |
-
#: includes/core/class-builtin.php:
|
5408 |
msgid "Corsican"
|
5409 |
msgstr ""
|
5410 |
|
5411 |
-
#: includes/core/class-builtin.php:
|
5412 |
msgid "Cree"
|
5413 |
msgstr ""
|
5414 |
|
5415 |
-
#: includes/core/class-builtin.php:
|
5416 |
msgid "Czech"
|
5417 |
msgstr ""
|
5418 |
|
5419 |
-
#: includes/core/class-builtin.php:
|
5420 |
msgid "Church Slavic"
|
5421 |
msgstr ""
|
5422 |
|
5423 |
-
#: includes/core/class-builtin.php:
|
5424 |
msgid "Chuvash"
|
5425 |
msgstr ""
|
5426 |
|
5427 |
-
#: includes/core/class-builtin.php:
|
5428 |
msgid "Welsh"
|
5429 |
msgstr ""
|
5430 |
|
5431 |
-
#: includes/core/class-builtin.php:
|
5432 |
msgid "Danish"
|
5433 |
msgstr ""
|
5434 |
|
5435 |
-
#: includes/core/class-builtin.php:
|
5436 |
msgid "German"
|
5437 |
msgstr ""
|
5438 |
|
5439 |
-
#: includes/core/class-builtin.php:
|
5440 |
msgid "Divehi"
|
5441 |
msgstr ""
|
5442 |
|
5443 |
-
#: includes/core/class-builtin.php:
|
5444 |
msgid "Dzongkha"
|
5445 |
msgstr ""
|
5446 |
|
5447 |
-
#: includes/core/class-builtin.php:
|
5448 |
msgid "Ewe"
|
5449 |
msgstr ""
|
5450 |
|
5451 |
-
#: includes/core/class-builtin.php:
|
5452 |
msgid "Greek"
|
5453 |
msgstr ""
|
5454 |
|
5455 |
-
#: includes/core/class-builtin.php:
|
5456 |
msgid "English"
|
5457 |
msgstr ""
|
5458 |
|
5459 |
-
#: includes/core/class-builtin.php:
|
5460 |
msgid "Esperanto"
|
5461 |
msgstr ""
|
5462 |
|
5463 |
-
#: includes/core/class-builtin.php:
|
5464 |
msgid "Spanish"
|
5465 |
msgstr ""
|
5466 |
|
5467 |
-
#: includes/core/class-builtin.php:
|
5468 |
msgid "Estonian"
|
5469 |
msgstr ""
|
5470 |
|
5471 |
-
#: includes/core/class-builtin.php:
|
5472 |
msgid "Basque"
|
5473 |
msgstr ""
|
5474 |
|
5475 |
-
#: includes/core/class-builtin.php:
|
5476 |
msgid "Persian"
|
5477 |
msgstr ""
|
5478 |
|
5479 |
-
#: includes/core/class-builtin.php:
|
5480 |
msgid "Fulah"
|
5481 |
msgstr ""
|
5482 |
|
5483 |
-
#: includes/core/class-builtin.php:
|
5484 |
msgid "Finnish"
|
5485 |
msgstr ""
|
5486 |
|
5487 |
-
#: includes/core/class-builtin.php:
|
5488 |
msgid "Fijian"
|
5489 |
msgstr ""
|
5490 |
|
5491 |
-
#: includes/core/class-builtin.php:
|
5492 |
msgid "Faroese"
|
5493 |
msgstr ""
|
5494 |
|
5495 |
-
#: includes/core/class-builtin.php:
|
5496 |
msgid "French"
|
5497 |
msgstr ""
|
5498 |
|
5499 |
-
#: includes/core/class-builtin.php:
|
5500 |
msgid "Western Frisian"
|
5501 |
msgstr ""
|
5502 |
|
5503 |
-
#: includes/core/class-builtin.php:
|
5504 |
msgid "Irish"
|
5505 |
msgstr ""
|
5506 |
|
5507 |
-
#: includes/core/class-builtin.php:
|
5508 |
msgid "Scottish Gaelic"
|
5509 |
msgstr ""
|
5510 |
|
5511 |
-
#: includes/core/class-builtin.php:
|
5512 |
msgid "Galician"
|
5513 |
msgstr ""
|
5514 |
|
5515 |
-
#: includes/core/class-builtin.php:
|
5516 |
msgid "Guarani"
|
5517 |
msgstr ""
|
5518 |
|
5519 |
-
#: includes/core/class-builtin.php:
|
5520 |
msgid "Gujarati"
|
5521 |
msgstr ""
|
5522 |
|
5523 |
-
#: includes/core/class-builtin.php:
|
5524 |
msgid "Manx"
|
5525 |
msgstr ""
|
5526 |
|
5527 |
-
#: includes/core/class-builtin.php:
|
5528 |
msgid "Hausa"
|
5529 |
msgstr ""
|
5530 |
|
5531 |
-
#: includes/core/class-builtin.php:
|
5532 |
msgid "Hebrew"
|
5533 |
msgstr ""
|
5534 |
|
5535 |
-
#: includes/core/class-builtin.php:
|
5536 |
msgid "Hindi"
|
5537 |
msgstr ""
|
5538 |
|
5539 |
-
#: includes/core/class-builtin.php:
|
5540 |
msgid "Hiri Motu"
|
5541 |
msgstr ""
|
5542 |
|
5543 |
-
#: includes/core/class-builtin.php:
|
5544 |
msgid "Croatian"
|
5545 |
msgstr ""
|
5546 |
|
5547 |
-
#: includes/core/class-builtin.php:
|
5548 |
msgid "Haitian"
|
5549 |
msgstr ""
|
5550 |
|
5551 |
-
#: includes/core/class-builtin.php:
|
5552 |
msgid "Hungarian"
|
5553 |
msgstr ""
|
5554 |
|
5555 |
-
#: includes/core/class-builtin.php:
|
5556 |
msgid "Armenian"
|
5557 |
msgstr ""
|
5558 |
|
5559 |
-
#: includes/core/class-builtin.php:
|
5560 |
msgid "Herero"
|
5561 |
msgstr ""
|
5562 |
|
5563 |
-
#: includes/core/class-builtin.php:
|
5564 |
msgid "Interlingua (International Auxiliary Language Association)"
|
5565 |
msgstr ""
|
5566 |
|
5567 |
-
#: includes/core/class-builtin.php:
|
5568 |
msgid "Indonesian"
|
5569 |
msgstr ""
|
5570 |
|
5571 |
-
#: includes/core/class-builtin.php:
|
5572 |
msgid "Interlingue"
|
5573 |
msgstr ""
|
5574 |
|
5575 |
-
#: includes/core/class-builtin.php:
|
5576 |
msgid "Igbo"
|
5577 |
msgstr ""
|
5578 |
|
5579 |
-
#: includes/core/class-builtin.php:
|
5580 |
msgid "Sichuan Yi"
|
5581 |
msgstr ""
|
5582 |
|
5583 |
-
#: includes/core/class-builtin.php:
|
5584 |
msgid "Inupiaq"
|
5585 |
msgstr ""
|
5586 |
|
5587 |
-
#: includes/core/class-builtin.php:
|
5588 |
msgid "Ido"
|
5589 |
msgstr ""
|
5590 |
|
5591 |
-
#: includes/core/class-builtin.php:
|
5592 |
msgid "Icelandic"
|
5593 |
msgstr ""
|
5594 |
|
5595 |
-
#: includes/core/class-builtin.php:
|
5596 |
msgid "Italian"
|
5597 |
msgstr ""
|
5598 |
|
5599 |
-
#: includes/core/class-builtin.php:
|
5600 |
msgid "Inuktitut"
|
5601 |
msgstr ""
|
5602 |
|
5603 |
-
#: includes/core/class-builtin.php:
|
5604 |
msgid "Japanese"
|
5605 |
msgstr ""
|
5606 |
|
5607 |
-
#: includes/core/class-builtin.php:
|
5608 |
msgid "Javanese"
|
5609 |
msgstr ""
|
5610 |
|
5611 |
-
#: includes/core/class-builtin.php:
|
5612 |
msgid "Kartuli"
|
5613 |
msgstr ""
|
5614 |
|
5615 |
-
#: includes/core/class-builtin.php:
|
5616 |
msgid "Kongo"
|
5617 |
msgstr ""
|
5618 |
|
5619 |
-
#: includes/core/class-builtin.php:
|
5620 |
msgid "Kikuyu"
|
5621 |
msgstr ""
|
5622 |
|
5623 |
-
#: includes/core/class-builtin.php:
|
5624 |
msgid "Kwanyama"
|
5625 |
msgstr ""
|
5626 |
|
5627 |
-
#: includes/core/class-builtin.php:
|
5628 |
msgid "Kazakh"
|
5629 |
msgstr ""
|
5630 |
|
5631 |
-
#: includes/core/class-builtin.php:
|
5632 |
msgid "Kalaallisut"
|
5633 |
msgstr ""
|
5634 |
|
5635 |
-
#: includes/core/class-builtin.php:
|
5636 |
msgid "Khmer"
|
5637 |
msgstr ""
|
5638 |
|
5639 |
-
#: includes/core/class-builtin.php:
|
5640 |
msgid "Kannada"
|
5641 |
msgstr ""
|
5642 |
|
5643 |
-
#: includes/core/class-builtin.php:
|
5644 |
msgid "Korean"
|
5645 |
msgstr ""
|
5646 |
|
5647 |
-
#: includes/core/class-builtin.php:
|
5648 |
msgid "Kanuri"
|
5649 |
msgstr ""
|
5650 |
|
5651 |
-
#: includes/core/class-builtin.php:
|
5652 |
msgid "Kashmiri"
|
5653 |
msgstr ""
|
5654 |
|
5655 |
-
#: includes/core/class-builtin.php:
|
5656 |
msgid "Kurdish"
|
5657 |
msgstr ""
|
5658 |
|
5659 |
-
#: includes/core/class-builtin.php:
|
5660 |
msgid "Komi"
|
5661 |
msgstr ""
|
5662 |
|
5663 |
-
#: includes/core/class-builtin.php:
|
5664 |
msgid "Cornish"
|
5665 |
msgstr ""
|
5666 |
|
5667 |
-
#: includes/core/class-builtin.php:
|
5668 |
msgid "Kirghiz"
|
5669 |
msgstr ""
|
5670 |
|
5671 |
-
#: includes/core/class-builtin.php:
|
5672 |
msgid "Latin"
|
5673 |
msgstr ""
|
5674 |
|
5675 |
-
#: includes/core/class-builtin.php:
|
5676 |
msgid "Luxembourgish"
|
5677 |
msgstr ""
|
5678 |
|
5679 |
-
#: includes/core/class-builtin.php:
|
5680 |
msgid "Ganda"
|
5681 |
msgstr ""
|
5682 |
|
5683 |
-
#: includes/core/class-builtin.php:
|
5684 |
msgid "Limburgish"
|
5685 |
msgstr ""
|
5686 |
|
5687 |
-
#: includes/core/class-builtin.php:
|
5688 |
msgid "Lingala"
|
5689 |
msgstr ""
|
5690 |
|
5691 |
-
#: includes/core/class-builtin.php:
|
5692 |
msgid "Lao"
|
5693 |
msgstr ""
|
5694 |
|
5695 |
-
#: includes/core/class-builtin.php:
|
5696 |
msgid "Lithuanian"
|
5697 |
msgstr ""
|
5698 |
|
5699 |
-
#: includes/core/class-builtin.php:
|
5700 |
msgid "Luba-Katanga"
|
5701 |
msgstr ""
|
5702 |
|
5703 |
-
#: includes/core/class-builtin.php:
|
5704 |
msgid "Latvian"
|
5705 |
msgstr ""
|
5706 |
|
5707 |
-
#: includes/core/class-builtin.php:
|
5708 |
msgid "Malagasy"
|
5709 |
msgstr ""
|
5710 |
|
5711 |
-
#: includes/core/class-builtin.php:
|
5712 |
msgid "Marshallese"
|
5713 |
msgstr ""
|
5714 |
|
5715 |
-
#: includes/core/class-builtin.php:
|
5716 |
msgid "Maori"
|
5717 |
msgstr ""
|
5718 |
|
5719 |
-
#: includes/core/class-builtin.php:
|
5720 |
msgid "Macedonian"
|
5721 |
msgstr ""
|
5722 |
|
5723 |
-
#: includes/core/class-builtin.php:
|
5724 |
msgid "Malayalam"
|
5725 |
msgstr ""
|
5726 |
|
5727 |
-
#: includes/core/class-builtin.php:
|
5728 |
msgid "Mongolian"
|
5729 |
msgstr ""
|
5730 |
|
5731 |
-
#: includes/core/class-builtin.php:
|
5732 |
msgid "Marathi"
|
5733 |
msgstr ""
|
5734 |
|
5735 |
-
#: includes/core/class-builtin.php:
|
5736 |
msgid "Malay"
|
5737 |
msgstr ""
|
5738 |
|
5739 |
-
#: includes/core/class-builtin.php:
|
5740 |
msgid "Maltese"
|
5741 |
msgstr ""
|
5742 |
|
5743 |
-
#: includes/core/class-builtin.php:
|
5744 |
msgid "Burmese"
|
5745 |
msgstr ""
|
5746 |
|
5747 |
-
#: includes/core/class-builtin.php:
|
5748 |
-
#: includes/core/class-builtin.php:
|
5749 |
msgid "Nauru"
|
5750 |
msgstr ""
|
5751 |
|
5752 |
-
#: includes/core/class-builtin.php:
|
5753 |
msgid "Norwegian Bokmal"
|
5754 |
msgstr ""
|
5755 |
|
5756 |
-
#: includes/core/class-builtin.php:
|
5757 |
msgid "North Ndebele"
|
5758 |
msgstr ""
|
5759 |
|
5760 |
-
#: includes/core/class-builtin.php:
|
5761 |
msgid "Nepali"
|
5762 |
msgstr ""
|
5763 |
|
5764 |
-
#: includes/core/class-builtin.php:
|
5765 |
msgid "Ndonga"
|
5766 |
msgstr ""
|
5767 |
|
5768 |
-
#: includes/core/class-builtin.php:
|
5769 |
msgid "Dutch"
|
5770 |
msgstr ""
|
5771 |
|
5772 |
-
#: includes/core/class-builtin.php:
|
5773 |
msgid "Norwegian Nynorsk"
|
5774 |
msgstr ""
|
5775 |
|
5776 |
-
#: includes/core/class-builtin.php:
|
5777 |
msgid "Norwegian"
|
5778 |
msgstr ""
|
5779 |
|
5780 |
-
#: includes/core/class-builtin.php:
|
5781 |
msgid "South Ndebele"
|
5782 |
msgstr ""
|
5783 |
|
5784 |
-
#: includes/core/class-builtin.php:
|
5785 |
msgid "Navajo"
|
5786 |
msgstr ""
|
5787 |
|
5788 |
-
#: includes/core/class-builtin.php:
|
5789 |
msgid "Chichewa"
|
5790 |
msgstr ""
|
5791 |
|
5792 |
-
#: includes/core/class-builtin.php:
|
5793 |
msgid "Occitan"
|
5794 |
msgstr ""
|
5795 |
|
5796 |
-
#: includes/core/class-builtin.php:
|
5797 |
msgid "Ojibwa"
|
5798 |
msgstr ""
|
5799 |
|
5800 |
-
#: includes/core/class-builtin.php:
|
5801 |
msgid "Oromo"
|
5802 |
msgstr ""
|
5803 |
|
5804 |
-
#: includes/core/class-builtin.php:
|
5805 |
msgid "Oriya"
|
5806 |
msgstr ""
|
5807 |
|
5808 |
-
#: includes/core/class-builtin.php:
|
5809 |
msgid "Ossetian"
|
5810 |
msgstr ""
|
5811 |
|
5812 |
-
#: includes/core/class-builtin.php:
|
5813 |
msgid "Panjabi"
|
5814 |
msgstr ""
|
5815 |
|
5816 |
-
#: includes/core/class-builtin.php:
|
5817 |
msgid "Pali"
|
5818 |
msgstr ""
|
5819 |
|
5820 |
-
#: includes/core/class-builtin.php:
|
5821 |
msgid "Polish"
|
5822 |
msgstr ""
|
5823 |
|
5824 |
-
#: includes/core/class-builtin.php:
|
5825 |
msgid "Pashto"
|
5826 |
msgstr ""
|
5827 |
|
5828 |
-
#: includes/core/class-builtin.php:
|
5829 |
msgid "Portuguese"
|
5830 |
msgstr ""
|
5831 |
|
5832 |
-
#: includes/core/class-builtin.php:
|
5833 |
msgid "Quechua"
|
5834 |
msgstr ""
|
5835 |
|
5836 |
-
#: includes/core/class-builtin.php:
|
5837 |
msgid "Raeto-Romance"
|
5838 |
msgstr ""
|
5839 |
|
5840 |
-
#: includes/core/class-builtin.php:
|
5841 |
msgid "Kirundi"
|
5842 |
msgstr ""
|
5843 |
|
5844 |
-
#: includes/core/class-builtin.php:
|
5845 |
msgid "Romanian"
|
5846 |
msgstr ""
|
5847 |
|
5848 |
-
#: includes/core/class-builtin.php:
|
5849 |
msgid "Russian"
|
5850 |
msgstr ""
|
5851 |
|
5852 |
-
#: includes/core/class-builtin.php:
|
5853 |
msgid "Kinyarwanda"
|
5854 |
msgstr ""
|
5855 |
|
5856 |
-
#: includes/core/class-builtin.php:
|
5857 |
msgid "Sanskrit"
|
5858 |
msgstr ""
|
5859 |
|
5860 |
-
#: includes/core/class-builtin.php:
|
5861 |
msgid "Sardinian"
|
5862 |
msgstr ""
|
5863 |
|
5864 |
-
#: includes/core/class-builtin.php:
|
5865 |
msgid "Sindhi"
|
5866 |
msgstr ""
|
5867 |
|
5868 |
-
#: includes/core/class-builtin.php:
|
5869 |
msgid "Northern Sami"
|
5870 |
msgstr ""
|
5871 |
|
5872 |
-
#: includes/core/class-builtin.php:
|
5873 |
msgid "Sango"
|
5874 |
msgstr ""
|
5875 |
|
5876 |
-
#: includes/core/class-builtin.php:
|
5877 |
msgid "Sinhala"
|
5878 |
msgstr ""
|
5879 |
|
5880 |
-
#: includes/core/class-builtin.php:
|
5881 |
msgid "Slovak"
|
5882 |
msgstr ""
|
5883 |
|
5884 |
-
#: includes/core/class-builtin.php:
|
5885 |
msgid "Slovenian"
|
5886 |
msgstr ""
|
5887 |
|
5888 |
-
#: includes/core/class-builtin.php:
|
5889 |
msgid "Samoan"
|
5890 |
msgstr ""
|
5891 |
|
5892 |
-
#: includes/core/class-builtin.php:
|
5893 |
msgid "Shona"
|
5894 |
msgstr ""
|
5895 |
|
5896 |
-
#: includes/core/class-builtin.php:
|
5897 |
msgid "Somali"
|
5898 |
msgstr ""
|
5899 |
|
5900 |
-
#: includes/core/class-builtin.php:
|
5901 |
msgid "Albanian"
|
5902 |
msgstr ""
|
5903 |
|
5904 |
-
#: includes/core/class-builtin.php:
|
5905 |
msgid "Serbian"
|
5906 |
msgstr ""
|
5907 |
|
5908 |
-
#: includes/core/class-builtin.php:
|
5909 |
msgid "Swati"
|
5910 |
msgstr ""
|
5911 |
|
5912 |
-
#: includes/core/class-builtin.php:
|
5913 |
msgid "Southern Sotho"
|
5914 |
msgstr ""
|
5915 |
|
5916 |
-
#: includes/core/class-builtin.php:
|
5917 |
msgid "Sundanese"
|
5918 |
msgstr ""
|
5919 |
|
5920 |
-
#: includes/core/class-builtin.php:
|
5921 |
msgid "Swedish"
|
5922 |
msgstr ""
|
5923 |
|
5924 |
-
#: includes/core/class-builtin.php:
|
5925 |
msgid "Swahili"
|
5926 |
msgstr ""
|
5927 |
|
5928 |
-
#: includes/core/class-builtin.php:
|
5929 |
msgid "Tamil"
|
5930 |
msgstr ""
|
5931 |
|
5932 |
-
#: includes/core/class-builtin.php:
|
5933 |
msgid "Telugu"
|
5934 |
msgstr ""
|
5935 |
|
5936 |
-
#: includes/core/class-builtin.php:
|
5937 |
msgid "Tajik"
|
5938 |
msgstr ""
|
5939 |
|
5940 |
-
#: includes/core/class-builtin.php:
|
5941 |
msgid "Thai"
|
5942 |
msgstr ""
|
5943 |
|
5944 |
-
#: includes/core/class-builtin.php:
|
5945 |
msgid "Tigrinya"
|
5946 |
msgstr ""
|
5947 |
|
5948 |
-
#: includes/core/class-builtin.php:
|
5949 |
msgid "Turkmen"
|
5950 |
msgstr ""
|
5951 |
|
5952 |
-
#: includes/core/class-builtin.php:
|
5953 |
msgid "Tagalog"
|
5954 |
msgstr ""
|
5955 |
|
5956 |
-
#: includes/core/class-builtin.php:
|
5957 |
msgid "Tswana"
|
5958 |
msgstr ""
|
5959 |
|
5960 |
-
#: includes/core/class-builtin.php:
|
5961 |
-
#: includes/core/class-builtin.php:
|
5962 |
msgid "Tonga"
|
5963 |
msgstr ""
|
5964 |
|
5965 |
-
#: includes/core/class-builtin.php:
|
5966 |
msgid "Turkish"
|
5967 |
msgstr ""
|
5968 |
|
5969 |
-
#: includes/core/class-builtin.php:
|
5970 |
msgid "Tsonga"
|
5971 |
msgstr ""
|
5972 |
|
5973 |
-
#: includes/core/class-builtin.php:
|
5974 |
msgid "Tatar"
|
5975 |
msgstr ""
|
5976 |
|
5977 |
-
#: includes/core/class-builtin.php:
|
5978 |
msgid "Twi"
|
5979 |
msgstr ""
|
5980 |
|
5981 |
-
#: includes/core/class-builtin.php:
|
5982 |
msgid "Tahitian"
|
5983 |
msgstr ""
|
5984 |
|
5985 |
-
#: includes/core/class-builtin.php:
|
5986 |
msgid "Uighur"
|
5987 |
msgstr ""
|
5988 |
|
5989 |
-
#: includes/core/class-builtin.php:
|
5990 |
msgid "Ukrainian"
|
5991 |
msgstr ""
|
5992 |
|
5993 |
-
#: includes/core/class-builtin.php:
|
5994 |
msgid "Urdu"
|
5995 |
msgstr ""
|
5996 |
|
5997 |
-
#: includes/core/class-builtin.php:
|
5998 |
msgid "Uzbek"
|
5999 |
msgstr ""
|
6000 |
|
6001 |
-
#: includes/core/class-builtin.php:
|
6002 |
msgid "Venda"
|
6003 |
msgstr ""
|
6004 |
|
6005 |
-
#: includes/core/class-builtin.php:
|
6006 |
msgid "Vietnamese"
|
6007 |
msgstr ""
|
6008 |
|
6009 |
-
#: includes/core/class-builtin.php:
|
6010 |
msgid "Volapuk"
|
6011 |
msgstr ""
|
6012 |
|
6013 |
-
#: includes/core/class-builtin.php:
|
6014 |
msgid "Walloon"
|
6015 |
msgstr ""
|
6016 |
|
6017 |
-
#: includes/core/class-builtin.php:
|
6018 |
msgid "Wolof"
|
6019 |
msgstr ""
|
6020 |
|
6021 |
-
#: includes/core/class-builtin.php:
|
6022 |
msgid "Xhosa"
|
6023 |
msgstr ""
|
6024 |
|
6025 |
-
#: includes/core/class-builtin.php:
|
6026 |
msgid "Yiddish"
|
6027 |
msgstr ""
|
6028 |
|
6029 |
-
#: includes/core/class-builtin.php:
|
6030 |
msgid "Yoruba"
|
6031 |
msgstr ""
|
6032 |
|
6033 |
-
#: includes/core/class-builtin.php:
|
6034 |
msgid "Zhuang"
|
6035 |
msgstr ""
|
6036 |
|
6037 |
-
#: includes/core/class-builtin.php:
|
6038 |
msgid "Chinese"
|
6039 |
msgstr ""
|
6040 |
|
6041 |
-
#: includes/core/class-builtin.php:
|
6042 |
msgid "Zulu"
|
6043 |
msgstr ""
|
6044 |
|
6045 |
-
#: includes/core/class-builtin.php:
|
6046 |
msgid "Afghanistan"
|
6047 |
msgstr ""
|
6048 |
|
6049 |
-
#: includes/core/class-builtin.php:
|
6050 |
msgid "Åland Islands"
|
6051 |
msgstr ""
|
6052 |
|
6053 |
-
#: includes/core/class-builtin.php:
|
6054 |
msgid "Albania"
|
6055 |
msgstr ""
|
6056 |
|
6057 |
-
#: includes/core/class-builtin.php:
|
6058 |
msgid "Algeria"
|
6059 |
msgstr ""
|
6060 |
|
6061 |
-
#: includes/core/class-builtin.php:
|
6062 |
msgid "American Samoa"
|
6063 |
msgstr ""
|
6064 |
|
6065 |
-
#: includes/core/class-builtin.php:
|
6066 |
msgid "Andorra"
|
6067 |
msgstr ""
|
6068 |
|
6069 |
-
#: includes/core/class-builtin.php:
|
6070 |
msgid "Angola"
|
6071 |
msgstr ""
|
6072 |
|
6073 |
-
#: includes/core/class-builtin.php:
|
6074 |
msgid "Anguilla"
|
6075 |
msgstr ""
|
6076 |
|
6077 |
-
#: includes/core/class-builtin.php:
|
6078 |
msgid "Antarctica"
|
6079 |
msgstr ""
|
6080 |
|
6081 |
-
#: includes/core/class-builtin.php:
|
6082 |
msgid "Antigua and Barbuda"
|
6083 |
msgstr ""
|
6084 |
|
6085 |
-
#: includes/core/class-builtin.php:
|
6086 |
msgid "Argentina"
|
6087 |
msgstr ""
|
6088 |
|
6089 |
-
#: includes/core/class-builtin.php:
|
6090 |
msgid "Armenia"
|
6091 |
msgstr ""
|
6092 |
|
6093 |
-
#: includes/core/class-builtin.php:
|
6094 |
msgid "Aruba"
|
6095 |
msgstr ""
|
6096 |
|
6097 |
-
#: includes/core/class-builtin.php:
|
6098 |
msgid "Australia"
|
6099 |
msgstr ""
|
6100 |
|
6101 |
-
#: includes/core/class-builtin.php:
|
6102 |
msgid "Austria"
|
6103 |
msgstr ""
|
6104 |
|
6105 |
-
#: includes/core/class-builtin.php:
|
6106 |
msgid "Azerbaijan"
|
6107 |
msgstr ""
|
6108 |
|
6109 |
-
#: includes/core/class-builtin.php:
|
6110 |
msgid "Bahamas"
|
6111 |
msgstr ""
|
6112 |
|
6113 |
-
#: includes/core/class-builtin.php:
|
6114 |
msgid "Bahrain"
|
6115 |
msgstr ""
|
6116 |
|
6117 |
-
#: includes/core/class-builtin.php:
|
6118 |
msgid "Bangladesh"
|
6119 |
msgstr ""
|
6120 |
|
6121 |
-
#: includes/core/class-builtin.php:
|
6122 |
msgid "Barbados"
|
6123 |
msgstr ""
|
6124 |
|
6125 |
-
#: includes/core/class-builtin.php:
|
6126 |
msgid "Belarus"
|
6127 |
msgstr ""
|
6128 |
|
6129 |
-
#: includes/core/class-builtin.php:
|
6130 |
msgid "Belgium"
|
6131 |
msgstr ""
|
6132 |
|
6133 |
-
#: includes/core/class-builtin.php:
|
6134 |
msgid "Belize"
|
6135 |
msgstr ""
|
6136 |
|
6137 |
-
#: includes/core/class-builtin.php:
|
6138 |
msgid "Benin"
|
6139 |
msgstr ""
|
6140 |
|
6141 |
-
#: includes/core/class-builtin.php:
|
6142 |
msgid "Bermuda"
|
6143 |
msgstr ""
|
6144 |
|
6145 |
-
#: includes/core/class-builtin.php:
|
6146 |
msgid "Bhutan"
|
6147 |
msgstr ""
|
6148 |
|
6149 |
-
#: includes/core/class-builtin.php:
|
6150 |
msgid "Bolivia, Plurinational State of"
|
6151 |
msgstr ""
|
6152 |
|
6153 |
-
#: includes/core/class-builtin.php:
|
6154 |
msgid "Bosnia and Herzegovina"
|
6155 |
msgstr ""
|
6156 |
|
6157 |
-
#: includes/core/class-builtin.php:
|
6158 |
msgid "Botswana"
|
6159 |
msgstr ""
|
6160 |
|
6161 |
-
#: includes/core/class-builtin.php:
|
6162 |
msgid "Bouvet Island"
|
6163 |
msgstr ""
|
6164 |
|
6165 |
-
#: includes/core/class-builtin.php:
|
6166 |
msgid "Brazil"
|
6167 |
msgstr ""
|
6168 |
|
6169 |
-
#: includes/core/class-builtin.php:
|
6170 |
msgid "British Indian Ocean Territory"
|
6171 |
msgstr ""
|
6172 |
|
6173 |
-
#: includes/core/class-builtin.php:
|
6174 |
msgid "Brunei Darussalam"
|
6175 |
msgstr ""
|
6176 |
|
6177 |
-
#: includes/core/class-builtin.php:
|
6178 |
msgid "Bulgaria"
|
6179 |
msgstr ""
|
6180 |
|
6181 |
-
#: includes/core/class-builtin.php:
|
6182 |
msgid "Burkina Faso"
|
6183 |
msgstr ""
|
6184 |
|
6185 |
-
#: includes/core/class-builtin.php:
|
6186 |
msgid "Burundi"
|
6187 |
msgstr ""
|
6188 |
|
6189 |
-
#: includes/core/class-builtin.php:
|
6190 |
msgid "Cambodia"
|
6191 |
msgstr ""
|
6192 |
|
6193 |
-
#: includes/core/class-builtin.php:
|
6194 |
msgid "Cameroon"
|
6195 |
msgstr ""
|
6196 |
|
6197 |
-
#: includes/core/class-builtin.php:
|
6198 |
msgid "Canada"
|
6199 |
msgstr ""
|
6200 |
|
6201 |
-
#: includes/core/class-builtin.php:
|
6202 |
msgid "Cape Verde"
|
6203 |
msgstr ""
|
6204 |
|
6205 |
-
#: includes/core/class-builtin.php:
|
6206 |
msgid "Cayman Islands"
|
6207 |
msgstr ""
|
6208 |
|
6209 |
-
#: includes/core/class-builtin.php:
|
6210 |
msgid "Central African Republic"
|
6211 |
msgstr ""
|
6212 |
|
6213 |
-
#: includes/core/class-builtin.php:
|
6214 |
msgid "Chad"
|
6215 |
msgstr ""
|
6216 |
|
6217 |
-
#: includes/core/class-builtin.php:
|
6218 |
msgid "Chile"
|
6219 |
msgstr ""
|
6220 |
|
6221 |
-
#: includes/core/class-builtin.php:
|
6222 |
msgid "China"
|
6223 |
msgstr ""
|
6224 |
|
6225 |
-
#: includes/core/class-builtin.php:
|
6226 |
msgid "Christmas Island"
|
6227 |
msgstr ""
|
6228 |
|
6229 |
-
#: includes/core/class-builtin.php:
|
6230 |
msgid "Cocos (Keeling) Islands"
|
6231 |
msgstr ""
|
6232 |
|
6233 |
-
#: includes/core/class-builtin.php:
|
6234 |
msgid "Colombia"
|
6235 |
msgstr ""
|
6236 |
|
6237 |
-
#: includes/core/class-builtin.php:
|
6238 |
msgid "Comoros"
|
6239 |
msgstr ""
|
6240 |
|
6241 |
-
#: includes/core/class-builtin.php:
|
6242 |
msgid "Congo"
|
6243 |
msgstr ""
|
6244 |
|
6245 |
-
#: includes/core/class-builtin.php:
|
6246 |
msgid "Congo, the Democratic Republic of the"
|
6247 |
msgstr ""
|
6248 |
|
6249 |
-
#: includes/core/class-builtin.php:
|
6250 |
msgid "Cook Islands"
|
6251 |
msgstr ""
|
6252 |
|
6253 |
-
#: includes/core/class-builtin.php:
|
6254 |
msgid "Costa Rica"
|
6255 |
msgstr ""
|
6256 |
|
6257 |
-
#: includes/core/class-builtin.php:
|
6258 |
msgid "Côte d'Ivoire"
|
6259 |
msgstr ""
|
6260 |
|
6261 |
-
#: includes/core/class-builtin.php:
|
6262 |
msgid "Croatia"
|
6263 |
msgstr ""
|
6264 |
|
6265 |
-
#: includes/core/class-builtin.php:
|
6266 |
msgid "Cuba"
|
6267 |
msgstr ""
|
6268 |
|
6269 |
-
#: includes/core/class-builtin.php:
|
6270 |
msgid "Cyprus"
|
6271 |
msgstr ""
|
6272 |
|
6273 |
-
#: includes/core/class-builtin.php:
|
6274 |
msgid "Czech Republic"
|
6275 |
msgstr ""
|
6276 |
|
6277 |
-
#: includes/core/class-builtin.php:
|
6278 |
msgid "Denmark"
|
6279 |
msgstr ""
|
6280 |
|
6281 |
-
#: includes/core/class-builtin.php:
|
6282 |
msgid "Djibouti"
|
6283 |
msgstr ""
|
6284 |
|
6285 |
-
#: includes/core/class-builtin.php:
|
6286 |
msgid "Dominica"
|
6287 |
msgstr ""
|
6288 |
|
6289 |
-
#: includes/core/class-builtin.php:
|
6290 |
msgid "Dominican Republic"
|
6291 |
msgstr ""
|
6292 |
|
6293 |
-
#: includes/core/class-builtin.php:
|
6294 |
msgid "Ecuador"
|
6295 |
msgstr ""
|
6296 |
|
6297 |
-
#: includes/core/class-builtin.php:
|
6298 |
msgid "Egypt"
|
6299 |
msgstr ""
|
6300 |
|
6301 |
-
#: includes/core/class-builtin.php:
|
6302 |
msgid "El Salvador"
|
6303 |
msgstr ""
|
6304 |
|
6305 |
-
#: includes/core/class-builtin.php:
|
6306 |
msgid "Equatorial Guinea"
|
6307 |
msgstr ""
|
6308 |
|
6309 |
-
#: includes/core/class-builtin.php:
|
6310 |
msgid "Eritrea"
|
6311 |
msgstr ""
|
6312 |
|
6313 |
-
#: includes/core/class-builtin.php:
|
6314 |
msgid "Estonia"
|
6315 |
msgstr ""
|
6316 |
|
6317 |
-
#: includes/core/class-builtin.php:
|
6318 |
msgid "Ethiopia"
|
6319 |
msgstr ""
|
6320 |
|
6321 |
-
#: includes/core/class-builtin.php:
|
6322 |
msgid "Falkland Islands (Malvinas)"
|
6323 |
msgstr ""
|
6324 |
|
6325 |
-
#: includes/core/class-builtin.php:
|
6326 |
msgid "Faroe Islands"
|
6327 |
msgstr ""
|
6328 |
|
6329 |
-
#: includes/core/class-builtin.php:
|
6330 |
msgid "Fiji"
|
6331 |
msgstr ""
|
6332 |
|
6333 |
-
#: includes/core/class-builtin.php:
|
6334 |
msgid "Finland"
|
6335 |
msgstr ""
|
6336 |
|
6337 |
-
#: includes/core/class-builtin.php:
|
6338 |
msgid "France"
|
6339 |
msgstr ""
|
6340 |
|
6341 |
-
#: includes/core/class-builtin.php:
|
6342 |
msgid "French Guiana"
|
6343 |
msgstr ""
|
6344 |
|
6345 |
-
#: includes/core/class-builtin.php:
|
6346 |
msgid "French Polynesia"
|
6347 |
msgstr ""
|
6348 |
|
6349 |
-
#: includes/core/class-builtin.php:
|
6350 |
msgid "French Southern Territories"
|
6351 |
msgstr ""
|
6352 |
|
6353 |
-
#: includes/core/class-builtin.php:
|
6354 |
msgid "Gabon"
|
6355 |
msgstr ""
|
6356 |
|
6357 |
-
#: includes/core/class-builtin.php:
|
6358 |
msgid "Gambia"
|
6359 |
msgstr ""
|
6360 |
|
6361 |
-
#: includes/core/class-builtin.php:
|
6362 |
msgid "Sakartvelo"
|
6363 |
msgstr ""
|
6364 |
|
6365 |
-
#: includes/core/class-builtin.php:
|
6366 |
msgid "Germany"
|
6367 |
msgstr ""
|
6368 |
|
6369 |
-
#: includes/core/class-builtin.php:
|
6370 |
msgid "Ghana"
|
6371 |
msgstr ""
|
6372 |
|
6373 |
-
#: includes/core/class-builtin.php:
|
6374 |
msgid "Gibraltar"
|
6375 |
msgstr ""
|
6376 |
|
6377 |
-
#: includes/core/class-builtin.php:
|
6378 |
msgid "Greece"
|
6379 |
msgstr ""
|
6380 |
|
6381 |
-
#: includes/core/class-builtin.php:
|
6382 |
msgid "Greenland"
|
6383 |
msgstr ""
|
6384 |
|
6385 |
-
#: includes/core/class-builtin.php:
|
6386 |
msgid "Grenada"
|
6387 |
msgstr ""
|
6388 |
|
6389 |
-
#: includes/core/class-builtin.php:
|
6390 |
msgid "Guadeloupe"
|
6391 |
msgstr ""
|
6392 |
|
6393 |
-
#: includes/core/class-builtin.php:
|
6394 |
msgid "Guam"
|
6395 |
msgstr ""
|
6396 |
|
6397 |
-
#: includes/core/class-builtin.php:
|
6398 |
msgid "Guatemala"
|
6399 |
msgstr ""
|
6400 |
|
6401 |
-
#: includes/core/class-builtin.php:
|
6402 |
msgid "Guernsey"
|
6403 |
msgstr ""
|
6404 |
|
6405 |
-
#: includes/core/class-builtin.php:
|
6406 |
msgid "Guinea"
|
6407 |
msgstr ""
|
6408 |
|
6409 |
-
#: includes/core/class-builtin.php:
|
6410 |
msgid "Guinea-Bissau"
|
6411 |
msgstr ""
|
6412 |
|
6413 |
-
#: includes/core/class-builtin.php:
|
6414 |
msgid "Guyana"
|
6415 |
msgstr ""
|
6416 |
|
6417 |
-
#: includes/core/class-builtin.php:
|
6418 |
msgid "Haiti"
|
6419 |
msgstr ""
|
6420 |
|
6421 |
-
#: includes/core/class-builtin.php:
|
6422 |
msgid "Heard Island and McDonald Islands"
|
6423 |
msgstr ""
|
6424 |
|
6425 |
-
#: includes/core/class-builtin.php:
|
6426 |
msgid "Holy See (Vatican City State)"
|
6427 |
msgstr ""
|
6428 |
|
6429 |
-
#: includes/core/class-builtin.php:
|
6430 |
msgid "Honduras"
|
6431 |
msgstr ""
|
6432 |
|
6433 |
-
#: includes/core/class-builtin.php:
|
6434 |
msgid "Hong Kong"
|
6435 |
msgstr ""
|
6436 |
|
6437 |
-
#: includes/core/class-builtin.php:
|
6438 |
msgid "Hungary"
|
6439 |
msgstr ""
|
6440 |
|
6441 |
-
#: includes/core/class-builtin.php:
|
6442 |
msgid "Iceland"
|
6443 |
msgstr ""
|
6444 |
|
6445 |
-
#: includes/core/class-builtin.php:
|
6446 |
msgid "India"
|
6447 |
msgstr ""
|
6448 |
|
6449 |
-
#: includes/core/class-builtin.php:
|
6450 |
msgid "Indonesia"
|
6451 |
msgstr ""
|
6452 |
|
6453 |
-
#: includes/core/class-builtin.php:
|
6454 |
msgid "Iran, Islamic Republic of"
|
6455 |
msgstr ""
|
6456 |
|
6457 |
-
#: includes/core/class-builtin.php:
|
6458 |
msgid "Iraq"
|
6459 |
msgstr ""
|
6460 |
|
6461 |
-
#: includes/core/class-builtin.php:
|
6462 |
msgid "Ireland"
|
6463 |
msgstr ""
|
6464 |
|
6465 |
-
#: includes/core/class-builtin.php:
|
6466 |
msgid "Isle of Man"
|
6467 |
msgstr ""
|
6468 |
|
6469 |
-
#: includes/core/class-builtin.php:
|
6470 |
msgid "Israel"
|
6471 |
msgstr ""
|
6472 |
|
6473 |
-
#: includes/core/class-builtin.php:
|
6474 |
msgid "Italy"
|
6475 |
msgstr ""
|
6476 |
|
6477 |
-
#: includes/core/class-builtin.php:
|
6478 |
msgid "Jamaica"
|
6479 |
msgstr ""
|
6480 |
|
6481 |
-
#: includes/core/class-builtin.php:
|
6482 |
msgid "Japan"
|
6483 |
msgstr ""
|
6484 |
|
6485 |
-
#: includes/core/class-builtin.php:
|
6486 |
msgid "Jersey"
|
6487 |
msgstr ""
|
6488 |
|
6489 |
-
#: includes/core/class-builtin.php:
|
6490 |
msgid "Jordan"
|
6491 |
msgstr ""
|
6492 |
|
6493 |
-
#: includes/core/class-builtin.php:
|
6494 |
msgid "Kazakhstan"
|
6495 |
msgstr ""
|
6496 |
|
6497 |
-
#: includes/core/class-builtin.php:
|
6498 |
msgid "Kenya"
|
6499 |
msgstr ""
|
6500 |
|
6501 |
-
#: includes/core/class-builtin.php:
|
6502 |
msgid "Kiribati"
|
6503 |
msgstr ""
|
6504 |
|
6505 |
-
#: includes/core/class-builtin.php:
|
6506 |
msgid "Korea, Democratic People's Republic of"
|
6507 |
msgstr ""
|
6508 |
|
6509 |
-
#: includes/core/class-builtin.php:
|
6510 |
msgid "Korea, Republic of"
|
6511 |
msgstr ""
|
6512 |
|
6513 |
-
#: includes/core/class-builtin.php:
|
6514 |
msgid "Kuwait"
|
6515 |
msgstr ""
|
6516 |
|
6517 |
-
#: includes/core/class-builtin.php:
|
6518 |
msgid "Kyrgyzstan"
|
6519 |
msgstr ""
|
6520 |
|
6521 |
-
#: includes/core/class-builtin.php:
|
6522 |
msgid "Lao People's Democratic Republic"
|
6523 |
msgstr ""
|
6524 |
|
6525 |
-
#: includes/core/class-builtin.php:
|
6526 |
msgid "Latvia"
|
6527 |
msgstr ""
|
6528 |
|
6529 |
-
#: includes/core/class-builtin.php:
|
6530 |
msgid "Lebanon"
|
6531 |
msgstr ""
|
6532 |
|
6533 |
-
#: includes/core/class-builtin.php:
|
6534 |
msgid "Lesotho"
|
6535 |
msgstr ""
|
6536 |
|
6537 |
-
#: includes/core/class-builtin.php:
|
6538 |
msgid "Liberia"
|
6539 |
msgstr ""
|
6540 |
|
6541 |
-
#: includes/core/class-builtin.php:
|
6542 |
msgid "Libyan Arab Jamahiriya"
|
6543 |
msgstr ""
|
6544 |
|
6545 |
-
#: includes/core/class-builtin.php:
|
6546 |
msgid "Liechtenstein"
|
6547 |
msgstr ""
|
6548 |
|
6549 |
-
#: includes/core/class-builtin.php:
|
6550 |
msgid "Lithuania"
|
6551 |
msgstr ""
|
6552 |
|
6553 |
-
#: includes/core/class-builtin.php:
|
6554 |
msgid "Luxembourg"
|
6555 |
msgstr ""
|
6556 |
|
6557 |
-
#: includes/core/class-builtin.php:
|
6558 |
msgid "Macao"
|
6559 |
msgstr ""
|
6560 |
|
6561 |
-
#: includes/core/class-builtin.php:
|
6562 |
msgid "Macedonia, the former Yugoslav Republic of"
|
6563 |
msgstr ""
|
6564 |
|
6565 |
-
#: includes/core/class-builtin.php:
|
6566 |
msgid "Madagascar"
|
6567 |
msgstr ""
|
6568 |
|
6569 |
-
#: includes/core/class-builtin.php:
|
6570 |
msgid "Malawi"
|
6571 |
msgstr ""
|
6572 |
|
6573 |
-
#: includes/core/class-builtin.php:
|
6574 |
msgid "Malaysia"
|
6575 |
msgstr ""
|
6576 |
|
6577 |
-
#: includes/core/class-builtin.php:
|
6578 |
msgid "Maldives"
|
6579 |
msgstr ""
|
6580 |
|
6581 |
-
#: includes/core/class-builtin.php:
|
6582 |
msgid "Mali"
|
6583 |
msgstr ""
|
6584 |
|
6585 |
-
#: includes/core/class-builtin.php:
|
6586 |
msgid "Malta"
|
6587 |
msgstr ""
|
6588 |
|
6589 |
-
#: includes/core/class-builtin.php:
|
6590 |
msgid "Marshall Islands"
|
6591 |
msgstr ""
|
6592 |
|
6593 |
-
#: includes/core/class-builtin.php:
|
6594 |
msgid "Martinique"
|
6595 |
msgstr ""
|
6596 |
|
6597 |
-
#: includes/core/class-builtin.php:
|
6598 |
msgid "Mauritania"
|
6599 |
msgstr ""
|
6600 |
|
6601 |
-
#: includes/core/class-builtin.php:
|
6602 |
msgid "Mauritius"
|
6603 |
msgstr ""
|
6604 |
|
6605 |
-
#: includes/core/class-builtin.php:
|
6606 |
msgid "Mayotte"
|
6607 |
msgstr ""
|
6608 |
|
6609 |
-
#: includes/core/class-builtin.php:
|
6610 |
msgid "Mexico"
|
6611 |
msgstr ""
|
6612 |
|
6613 |
-
#: includes/core/class-builtin.php:
|
6614 |
msgid "Micronesia, Federated States of"
|
6615 |
msgstr ""
|
6616 |
|
6617 |
-
#: includes/core/class-builtin.php:
|
6618 |
msgid "Moldova, Republic of"
|
6619 |
msgstr ""
|
6620 |
|
6621 |
-
#: includes/core/class-builtin.php:
|
6622 |
msgid "Monaco"
|
6623 |
msgstr ""
|
6624 |
|
6625 |
-
#: includes/core/class-builtin.php:
|
6626 |
msgid "Mongolia"
|
6627 |
msgstr ""
|
6628 |
|
6629 |
-
#: includes/core/class-builtin.php:
|
6630 |
msgid "Montenegro"
|
6631 |
msgstr ""
|
6632 |
|
6633 |
-
#: includes/core/class-builtin.php:
|
6634 |
msgid "Montserrat"
|
6635 |
msgstr ""
|
6636 |
|
6637 |
-
#: includes/core/class-builtin.php:
|
6638 |
msgid "Morocco"
|
6639 |
msgstr ""
|
6640 |
|
6641 |
-
#: includes/core/class-builtin.php:
|
6642 |
msgid "Mozambique"
|
6643 |
msgstr ""
|
6644 |
|
6645 |
-
#: includes/core/class-builtin.php:
|
6646 |
msgid "Myanmar"
|
6647 |
msgstr ""
|
6648 |
|
6649 |
-
#: includes/core/class-builtin.php:
|
6650 |
msgid "Namibia"
|
6651 |
msgstr ""
|
6652 |
|
6653 |
-
#: includes/core/class-builtin.php:
|
6654 |
msgid "Nepal"
|
6655 |
msgstr ""
|
6656 |
|
6657 |
-
#: includes/core/class-builtin.php:
|
6658 |
msgid "Netherlands"
|
6659 |
msgstr ""
|
6660 |
|
6661 |
-
#: includes/core/class-builtin.php:
|
6662 |
msgid "Netherlands Antilles"
|
6663 |
msgstr ""
|
6664 |
|
6665 |
-
#: includes/core/class-builtin.php:
|
6666 |
msgid "New Caledonia"
|
6667 |
msgstr ""
|
6668 |
|
6669 |
-
#: includes/core/class-builtin.php:
|
6670 |
msgid "New Zealand"
|
6671 |
msgstr ""
|
6672 |
|
6673 |
-
#: includes/core/class-builtin.php:
|
6674 |
msgid "Nicaragua"
|
6675 |
msgstr ""
|
6676 |
|
6677 |
-
#: includes/core/class-builtin.php:
|
6678 |
msgid "Niger"
|
6679 |
msgstr ""
|
6680 |
|
6681 |
-
#: includes/core/class-builtin.php:
|
6682 |
msgid "Nigeria"
|
6683 |
msgstr ""
|
6684 |
|
6685 |
-
#: includes/core/class-builtin.php:
|
6686 |
msgid "Niue"
|
6687 |
msgstr ""
|
6688 |
|
6689 |
-
#: includes/core/class-builtin.php:
|
6690 |
msgid "Norfolk Island"
|
6691 |
msgstr ""
|
6692 |
|
6693 |
-
#: includes/core/class-builtin.php:
|
6694 |
msgid "Northern Mariana Islands"
|
6695 |
msgstr ""
|
6696 |
|
6697 |
-
#: includes/core/class-builtin.php:
|
6698 |
msgid "Norway"
|
6699 |
msgstr ""
|
6700 |
|
6701 |
-
#: includes/core/class-builtin.php:
|
6702 |
msgid "Oman"
|
6703 |
msgstr ""
|
6704 |
|
6705 |
-
#: includes/core/class-builtin.php:
|
6706 |
msgid "Pakistan"
|
6707 |
msgstr ""
|
6708 |
|
6709 |
-
#: includes/core/class-builtin.php:
|
6710 |
msgid "Palau"
|
6711 |
msgstr ""
|
6712 |
|
6713 |
-
#: includes/core/class-builtin.php:
|
6714 |
msgid "Palestine"
|
6715 |
msgstr ""
|
6716 |
|
6717 |
-
#: includes/core/class-builtin.php:
|
6718 |
msgid "Panama"
|
6719 |
msgstr ""
|
6720 |
|
6721 |
-
#: includes/core/class-builtin.php:
|
6722 |
msgid "Papua New Guinea"
|
6723 |
msgstr ""
|
6724 |
|
6725 |
-
#: includes/core/class-builtin.php:
|
6726 |
msgid "Paraguay"
|
6727 |
msgstr ""
|
6728 |
|
6729 |
-
#: includes/core/class-builtin.php:
|
6730 |
msgid "Peru"
|
6731 |
msgstr ""
|
6732 |
|
6733 |
-
#: includes/core/class-builtin.php:
|
6734 |
msgid "Philippines"
|
6735 |
msgstr ""
|
6736 |
|
6737 |
-
#: includes/core/class-builtin.php:
|
6738 |
msgid "Pitcairn"
|
6739 |
msgstr ""
|
6740 |
|
6741 |
-
#: includes/core/class-builtin.php:
|
6742 |
msgid "Poland"
|
6743 |
msgstr ""
|
6744 |
|
6745 |
-
#: includes/core/class-builtin.php:
|
6746 |
msgid "Portugal"
|
6747 |
msgstr ""
|
6748 |
|
6749 |
-
#: includes/core/class-builtin.php:
|
6750 |
msgid "Puerto Rico"
|
6751 |
msgstr ""
|
6752 |
|
6753 |
-
#: includes/core/class-builtin.php:
|
6754 |
msgid "Qatar"
|
6755 |
msgstr ""
|
6756 |
|
6757 |
-
#: includes/core/class-builtin.php:
|
6758 |
msgid "Réunion"
|
6759 |
msgstr ""
|
6760 |
|
6761 |
-
#: includes/core/class-builtin.php:
|
6762 |
msgid "Romania"
|
6763 |
msgstr ""
|
6764 |
|
6765 |
-
#: includes/core/class-builtin.php:
|
6766 |
msgid "Russian Federation"
|
6767 |
msgstr ""
|
6768 |
|
6769 |
-
#: includes/core/class-builtin.php:
|
6770 |
msgid "Rwanda"
|
6771 |
msgstr ""
|
6772 |
|
6773 |
-
#: includes/core/class-builtin.php:
|
6774 |
msgid "Saint Barthélemy"
|
6775 |
msgstr ""
|
6776 |
|
6777 |
-
#: includes/core/class-builtin.php:
|
6778 |
msgid "Saint Helena"
|
6779 |
msgstr ""
|
6780 |
|
6781 |
-
#: includes/core/class-builtin.php:
|
6782 |
msgid "Saint Kitts and Nevis"
|
6783 |
msgstr ""
|
6784 |
|
6785 |
-
#: includes/core/class-builtin.php:
|
6786 |
msgid "Saint Lucia"
|
6787 |
msgstr ""
|
6788 |
|
6789 |
-
#: includes/core/class-builtin.php:
|
6790 |
msgid "Saint Martin (French part)"
|
6791 |
msgstr ""
|
6792 |
|
6793 |
-
#: includes/core/class-builtin.php:
|
6794 |
msgid "Saint Pierre and Miquelon"
|
6795 |
msgstr ""
|
6796 |
|
6797 |
-
#: includes/core/class-builtin.php:
|
6798 |
msgid "Saint Vincent and the Grenadines"
|
6799 |
msgstr ""
|
6800 |
|
6801 |
-
#: includes/core/class-builtin.php:
|
6802 |
msgid "Samoa"
|
6803 |
msgstr ""
|
6804 |
|
6805 |
-
#: includes/core/class-builtin.php:
|
6806 |
msgid "San Marino"
|
6807 |
msgstr ""
|
6808 |
|
6809 |
-
#: includes/core/class-builtin.php:
|
6810 |
msgid "Sao Tome and Principe"
|
6811 |
msgstr ""
|
6812 |
|
6813 |
-
#: includes/core/class-builtin.php:
|
6814 |
msgid "Saudi Arabia"
|
6815 |
msgstr ""
|
6816 |
|
6817 |
-
#: includes/core/class-builtin.php:
|
6818 |
msgid "Senegal"
|
6819 |
msgstr ""
|
6820 |
|
6821 |
-
#: includes/core/class-builtin.php:
|
6822 |
msgid "Serbia"
|
6823 |
msgstr ""
|
6824 |
|
6825 |
-
#: includes/core/class-builtin.php:
|
6826 |
msgid "Seychelles"
|
6827 |
msgstr ""
|
6828 |
|
6829 |
-
#: includes/core/class-builtin.php:
|
6830 |
msgid "Sierra Leone"
|
6831 |
msgstr ""
|
6832 |
|
6833 |
-
#: includes/core/class-builtin.php:
|
6834 |
msgid "Singapore"
|
6835 |
msgstr ""
|
6836 |
|
6837 |
-
#: includes/core/class-builtin.php:
|
6838 |
msgid "Slovakia"
|
6839 |
msgstr ""
|
6840 |
|
6841 |
-
#: includes/core/class-builtin.php:
|
6842 |
msgid "Slovenia"
|
6843 |
msgstr ""
|
6844 |
|
6845 |
-
#: includes/core/class-builtin.php:
|
6846 |
msgid "Solomon Islands"
|
6847 |
msgstr ""
|
6848 |
|
6849 |
-
#: includes/core/class-builtin.php:
|
6850 |
msgid "Somalia"
|
6851 |
msgstr ""
|
6852 |
|
6853 |
-
#: includes/core/class-builtin.php:
|
6854 |
msgid "South Africa"
|
6855 |
msgstr ""
|
6856 |
|
6857 |
-
#: includes/core/class-builtin.php:
|
6858 |
msgid "South Georgia and the South Sandwich Islands"
|
6859 |
msgstr ""
|
6860 |
|
6861 |
-
#: includes/core/class-builtin.php:
|
6862 |
msgid "South Sudan"
|
6863 |
msgstr ""
|
6864 |
|
6865 |
-
#: includes/core/class-builtin.php:
|
6866 |
msgid "Spain"
|
6867 |
msgstr ""
|
6868 |
|
6869 |
-
#: includes/core/class-builtin.php:
|
6870 |
msgid "Sri Lanka"
|
6871 |
msgstr ""
|
6872 |
|
6873 |
-
#: includes/core/class-builtin.php:
|
6874 |
msgid "Sudan"
|
6875 |
msgstr ""
|
6876 |
|
6877 |
-
#: includes/core/class-builtin.php:
|
6878 |
msgid "Suriname"
|
6879 |
msgstr ""
|
6880 |
|
6881 |
-
#: includes/core/class-builtin.php:
|
6882 |
msgid "Svalbard and Jan Mayen"
|
6883 |
msgstr ""
|
6884 |
|
6885 |
-
#: includes/core/class-builtin.php:
|
6886 |
msgid "Swaziland"
|
6887 |
msgstr ""
|
6888 |
|
6889 |
-
#: includes/core/class-builtin.php:
|
6890 |
msgid "Sweden"
|
6891 |
msgstr ""
|
6892 |
|
6893 |
-
#: includes/core/class-builtin.php:
|
6894 |
msgid "Switzerland"
|
6895 |
msgstr ""
|
6896 |
|
6897 |
-
#: includes/core/class-builtin.php:
|
6898 |
msgid "Syrian Arab Republic"
|
6899 |
msgstr ""
|
6900 |
|
6901 |
-
#: includes/core/class-builtin.php:
|
6902 |
msgid "Taiwan, Province of China"
|
6903 |
msgstr ""
|
6904 |
|
6905 |
-
#: includes/core/class-builtin.php:
|
6906 |
msgid "Tajikistan"
|
6907 |
msgstr ""
|
6908 |
|
6909 |
-
#: includes/core/class-builtin.php:
|
6910 |
msgid "Tanzania, United Republic of"
|
6911 |
msgstr ""
|
6912 |
|
6913 |
-
#: includes/core/class-builtin.php:
|
6914 |
msgid "Thailand"
|
6915 |
msgstr ""
|
6916 |
|
6917 |
-
#: includes/core/class-builtin.php:
|
6918 |
msgid "Timor-Leste"
|
6919 |
msgstr ""
|
6920 |
|
6921 |
-
#: includes/core/class-builtin.php:
|
6922 |
msgid "Togo"
|
6923 |
msgstr ""
|
6924 |
|
6925 |
-
#: includes/core/class-builtin.php:
|
6926 |
msgid "Tokelau"
|
6927 |
msgstr ""
|
6928 |
|
6929 |
-
#: includes/core/class-builtin.php:
|
6930 |
msgid "Trinidad and Tobago"
|
6931 |
msgstr ""
|
6932 |
|
6933 |
-
#: includes/core/class-builtin.php:
|
6934 |
msgid "Tunisia"
|
6935 |
msgstr ""
|
6936 |
|
6937 |
-
#: includes/core/class-builtin.php:
|
6938 |
msgid "Turkey"
|
6939 |
msgstr ""
|
6940 |
|
6941 |
-
#: includes/core/class-builtin.php:
|
6942 |
msgid "Turkmenistan"
|
6943 |
msgstr ""
|
6944 |
|
6945 |
-
#: includes/core/class-builtin.php:
|
6946 |
msgid "Turks and Caicos Islands"
|
6947 |
msgstr ""
|
6948 |
|
6949 |
-
#: includes/core/class-builtin.php:
|
6950 |
msgid "Tuvalu"
|
6951 |
msgstr ""
|
6952 |
|
6953 |
-
#: includes/core/class-builtin.php:
|
6954 |
msgid "Uganda"
|
6955 |
msgstr ""
|
6956 |
|
6957 |
-
#: includes/core/class-builtin.php:
|
6958 |
msgid "Ukraine"
|
6959 |
msgstr ""
|
6960 |
|
6961 |
-
#: includes/core/class-builtin.php:
|
6962 |
msgid "United Arab Emirates"
|
6963 |
msgstr ""
|
6964 |
|
6965 |
-
#: includes/core/class-builtin.php:
|
6966 |
msgid "United Kingdom"
|
6967 |
msgstr ""
|
6968 |
|
6969 |
-
#: includes/core/class-builtin.php:
|
6970 |
msgid "United States"
|
6971 |
msgstr ""
|
6972 |
|
6973 |
-
#: includes/core/class-builtin.php:
|
6974 |
msgid "United States Minor Outlying Islands"
|
6975 |
msgstr ""
|
6976 |
|
6977 |
-
#: includes/core/class-builtin.php:
|
6978 |
msgid "Uruguay"
|
6979 |
msgstr ""
|
6980 |
|
6981 |
-
#: includes/core/class-builtin.php:
|
6982 |
msgid "Uzbekistan"
|
6983 |
msgstr ""
|
6984 |
|
6985 |
-
#: includes/core/class-builtin.php:
|
6986 |
msgid "Vanuatu"
|
6987 |
msgstr ""
|
6988 |
|
6989 |
-
#: includes/core/class-builtin.php:
|
6990 |
msgid "Venezuela, Bolivarian Republic of"
|
6991 |
msgstr ""
|
6992 |
|
6993 |
-
#: includes/core/class-builtin.php:
|
6994 |
msgid "Viet Nam"
|
6995 |
msgstr ""
|
6996 |
|
6997 |
-
#: includes/core/class-builtin.php:
|
6998 |
msgid "Virgin Islands, British"
|
6999 |
msgstr ""
|
7000 |
|
7001 |
-
#: includes/core/class-builtin.php:
|
7002 |
msgid "Virgin Islands, U.S."
|
7003 |
msgstr ""
|
7004 |
|
7005 |
-
#: includes/core/class-builtin.php:
|
7006 |
msgid "Wallis and Futuna"
|
7007 |
msgstr ""
|
7008 |
|
7009 |
-
#: includes/core/class-builtin.php:
|
7010 |
msgid "Western Sahara"
|
7011 |
msgstr ""
|
7012 |
|
7013 |
-
#: includes/core/class-builtin.php:
|
7014 |
msgid "Yemen"
|
7015 |
msgstr ""
|
7016 |
|
7017 |
-
#: includes/core/class-builtin.php:
|
7018 |
msgid "Zambia"
|
7019 |
msgstr ""
|
7020 |
|
7021 |
-
#: includes/core/class-builtin.php:
|
7022 |
msgid "Zimbabwe"
|
7023 |
msgstr ""
|
7024 |
|
@@ -7114,97 +7120,97 @@ msgstr ""
|
|
7114 |
msgid "Less than 1 year old"
|
7115 |
msgstr ""
|
7116 |
|
7117 |
-
#: includes/core/class-fields.php:
|
7118 |
msgid "Custom Field"
|
7119 |
msgstr ""
|
7120 |
|
7121 |
-
#: includes/core/class-fields.php:
|
7122 |
msgid "Please upload a valid image!"
|
7123 |
msgstr ""
|
7124 |
|
7125 |
-
#: includes/core/class-fields.php:
|
7126 |
msgid "Sorry this is not a valid image."
|
7127 |
msgstr ""
|
7128 |
|
7129 |
-
#: includes/core/class-fields.php:
|
7130 |
msgid "This image is too large!"
|
7131 |
msgstr ""
|
7132 |
|
7133 |
-
#: includes/core/class-fields.php:
|
7134 |
msgid "This image is too small!"
|
7135 |
msgstr ""
|
7136 |
|
7137 |
-
#: includes/core/class-fields.php:
|
7138 |
msgid "You can only upload one image"
|
7139 |
msgstr ""
|
7140 |
|
7141 |
-
#: includes/core/class-fields.php:
|
7142 |
msgid "Sorry this is not a valid file."
|
7143 |
msgstr ""
|
7144 |
|
7145 |
-
#: includes/core/class-fields.php:
|
7146 |
msgid "This file is too large!"
|
7147 |
msgstr ""
|
7148 |
|
7149 |
-
#: includes/core/class-fields.php:
|
7150 |
msgid "This file is too small!"
|
7151 |
msgstr ""
|
7152 |
|
7153 |
-
#: includes/core/class-fields.php:
|
7154 |
msgid "You can only upload one file"
|
7155 |
msgstr ""
|
7156 |
|
7157 |
-
#: includes/core/class-fields.php:
|
7158 |
msgid "Current Password"
|
7159 |
msgstr ""
|
7160 |
|
7161 |
-
#: includes/core/class-fields.php:
|
7162 |
msgid "New Password"
|
7163 |
msgstr ""
|
7164 |
|
7165 |
-
#: includes/core/class-fields.php:
|
7166 |
-
#: includes/core/class-fields.php:
|
7167 |
-
#: includes/core/class-fields.php:
|
7168 |
msgid "Confirm %s"
|
7169 |
msgstr ""
|
7170 |
|
7171 |
-
#: includes/core/class-fields.php:
|
7172 |
msgid "Upload Photo"
|
7173 |
msgstr ""
|
7174 |
|
7175 |
-
#: includes/core/class-fields.php:
|
7176 |
-
#: includes/core/class-fields.php:
|
7177 |
-
#: includes/core/um-actions-profile.php:
|
7178 |
msgid "Change photo"
|
7179 |
msgstr ""
|
7180 |
|
7181 |
-
#: includes/core/class-fields.php:
|
7182 |
-
#: includes/core/class-fields.php:
|
7183 |
msgid "Processing..."
|
7184 |
msgstr ""
|
7185 |
|
7186 |
-
#: includes/core/class-fields.php:
|
7187 |
msgid "Upload File"
|
7188 |
msgstr ""
|
7189 |
|
7190 |
-
#: includes/core/class-fields.php:
|
7191 |
#: includes/core/um-filters-fields.php:330
|
7192 |
msgid "This file has been removed."
|
7193 |
msgstr ""
|
7194 |
|
7195 |
-
#: includes/core/class-fields.php:
|
7196 |
msgid "Change file"
|
7197 |
msgstr ""
|
7198 |
|
7199 |
-
#: includes/core/class-fields.php:
|
7200 |
msgid "Save"
|
7201 |
msgstr ""
|
7202 |
|
7203 |
-
#: includes/core/class-fields.php:
|
7204 |
msgid "Your profile is looking a little empty. Why not <a href=\"%s\">add</a> some information!"
|
7205 |
msgstr ""
|
7206 |
|
7207 |
-
#: includes/core/class-fields.php:
|
7208 |
msgid "This user has not added any information to their profile yet."
|
7209 |
msgstr ""
|
7210 |
|
@@ -7262,7 +7268,7 @@ msgstr ""
|
|
7262 |
msgid "Wrong callback."
|
7263 |
msgstr ""
|
7264 |
|
7265 |
-
#: includes/core/class-form.php:
|
7266 |
#: includes/core/class-password.php:441
|
7267 |
#: includes/core/class-password.php:519
|
7268 |
msgid "Hello, spam bot!"
|
@@ -7354,13 +7360,13 @@ msgstr ""
|
|
7354 |
|
7355 |
#: includes/core/class-member-directory.php:2245
|
7356 |
#: includes/core/class-member-directory.php:2289
|
7357 |
-
#: includes/core/um-actions-profile.php:
|
7358 |
-
#: includes/core/um-actions-profile.php:
|
7359 |
msgid "Edit Profile"
|
7360 |
msgstr ""
|
7361 |
|
7362 |
#: includes/core/class-member-directory.php:2295
|
7363 |
-
#: includes/core/um-actions-profile.php:
|
7364 |
msgid "My Account"
|
7365 |
msgstr ""
|
7366 |
|
@@ -7378,7 +7384,7 @@ msgstr ""
|
|
7378 |
|
7379 |
#: includes/core/class-password.php:543
|
7380 |
#: includes/core/um-actions-account.php:67
|
7381 |
-
#: includes/core/um-actions-register.php:
|
7382 |
msgid "Passwords may not contain the character \"\\\"."
|
7383 |
msgstr ""
|
7384 |
|
@@ -7460,15 +7466,15 @@ msgstr ""
|
|
7460 |
msgid "The \"unassigned\" $status has been removed. Use `UM()->setup()->set_default_user_status()` for setting up default user account status."
|
7461 |
msgstr ""
|
7462 |
|
7463 |
-
#: includes/core/class-shortcodes.php:
|
7464 |
msgid "This content has been restricted to logged in users only. Please <a href=\"{login_referrer}\">login</a> to view this content."
|
7465 |
msgstr ""
|
7466 |
|
7467 |
-
#: includes/core/class-shortcodes.php:
|
7468 |
msgid "You are already registered"
|
7469 |
msgstr ""
|
7470 |
|
7471 |
-
#: includes/core/class-shortcodes.php:
|
7472 |
msgid "Default Template"
|
7473 |
msgstr ""
|
7474 |
|
@@ -7485,10 +7491,13 @@ msgid "Your image is invalid or too large!"
|
|
7485 |
msgstr ""
|
7486 |
|
7487 |
#: includes/core/class-uploader.php:794
|
7488 |
-
#: includes/core/class-uploader.php:796
|
7489 |
msgid "Your photo is too small. It must be at least %spx wide."
|
7490 |
msgstr ""
|
7491 |
|
|
|
|
|
|
|
|
|
7492 |
#: includes/core/class-uploader.php:849
|
7493 |
msgid "This file type is not recognized."
|
7494 |
msgstr ""
|
@@ -7986,38 +7995,38 @@ msgstr ""
|
|
7986 |
msgid "You are not allowed to edit this user."
|
7987 |
msgstr ""
|
7988 |
|
7989 |
-
#: includes/core/um-actions-profile.php:
|
7990 |
msgid "Your choosed %s"
|
7991 |
msgstr ""
|
7992 |
|
7993 |
-
#: includes/core/um-actions-profile.php:
|
7994 |
-
#: includes/core/um-actions-profile.php:
|
7995 |
msgid "Profile photo"
|
7996 |
msgstr ""
|
7997 |
|
7998 |
-
#: includes/core/um-actions-profile.php:
|
7999 |
-
#: includes/core/um-actions-profile.php:
|
8000 |
-
#: includes/core/um-actions-profile.php:
|
8001 |
msgid "Upload a cover photo"
|
8002 |
msgstr ""
|
8003 |
|
8004 |
-
#: includes/core/um-actions-profile.php:
|
8005 |
msgid "Change cover photo"
|
8006 |
msgstr ""
|
8007 |
|
8008 |
-
#: includes/core/um-actions-profile.php:
|
8009 |
msgid "Upload photo"
|
8010 |
msgstr ""
|
8011 |
|
8012 |
-
#: includes/core/um-actions-profile.php:
|
8013 |
msgid "Remove photo"
|
8014 |
msgstr ""
|
8015 |
|
8016 |
-
#: includes/core/um-actions-profile.php:
|
8017 |
msgid "Tell us a bit about yourself..."
|
8018 |
msgstr ""
|
8019 |
|
8020 |
-
#: includes/core/um-actions-profile.php:
|
8021 |
msgid "This user account status is %s"
|
8022 |
msgstr ""
|
8023 |
|
2 |
# This file is distributed under the same license as the Ultimate Member plugin.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Ultimate Member 2.5.1\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/ultimate-member\n"
|
7 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"POT-Creation-Date: 2022-10-26T22:34:52+00:00\n"
|
13 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
+
"X-Generator: WP-CLI 2.7.1\n"
|
15 |
"X-Domain: ultimate-member\n"
|
16 |
|
17 |
#. Plugin Name of the plugin
|
121 |
#: includes/admin/core/class-admin-builder.php:776
|
122 |
#: includes/admin/core/class-admin-dragdrop.php:33
|
123 |
#: includes/admin/core/class-admin-menu.php:106
|
124 |
+
#: includes/core/class-fields.php:4842
|
125 |
msgid "Please login as administrator"
|
126 |
msgstr ""
|
127 |
|
182 |
msgstr ""
|
183 |
|
184 |
#: includes/admin/core/class-admin-builder.php:903
|
185 |
+
#: includes/core/class-builtin.php:1466
|
186 |
msgid "None"
|
187 |
msgstr ""
|
188 |
|
208 |
#: includes/admin/core/class-admin-builder.php:1207
|
209 |
#: includes/core/class-form.php:138
|
210 |
#: includes/core/class-form.php:146
|
211 |
+
#: includes/core/class-form.php:153
|
212 |
+
#: includes/core/class-form.php:235
|
213 |
+
#: includes/core/class-form.php:506
|
214 |
#: includes/core/class-password.php:525
|
215 |
+
#: includes/core/um-actions-profile.php:603
|
216 |
msgid "This is not possible for security reasons."
|
217 |
msgstr ""
|
218 |
|
219 |
+
#: includes/admin/core/class-admin-builder.php:1224
|
220 |
+
msgid "This is not possible for security reasons. Don't use internal PHP functions."
|
221 |
+
msgstr ""
|
222 |
+
|
223 |
#: includes/admin/core/class-admin-columns.php:50
|
224 |
msgid "Status"
|
225 |
msgstr ""
|
267 |
#: includes/admin/templates/form/register_customize.php:89
|
268 |
#: includes/admin/templates/form/register_gdpr.php:31
|
269 |
#: includes/admin/templates/role/profile.php:53
|
270 |
+
#: includes/core/class-builtin.php:1247
|
271 |
+
#: includes/core/class-builtin.php:1266
|
|
|
272 |
#: includes/core/class-builtin.php:1282
|
273 |
+
#: includes/core/class-builtin.php:1285
|
274 |
#: includes/core/um-actions-account.php:332
|
275 |
msgid "No"
|
276 |
msgstr ""
|
299 |
#: includes/admin/templates/form/register_customize.php:90
|
300 |
#: includes/admin/templates/form/register_gdpr.php:32
|
301 |
#: includes/admin/templates/role/profile.php:54
|
302 |
+
#: includes/core/class-builtin.php:1248
|
303 |
+
#: includes/core/class-builtin.php:1267
|
304 |
+
#: includes/core/class-builtin.php:1284
|
305 |
#: includes/core/class-user.php:430
|
306 |
#: includes/core/class-user.php:431
|
307 |
#: includes/core/um-actions-account.php:327
|
319 |
#: includes/admin/core/class-admin-enqueue.php:501
|
320 |
#: includes/core/class-builtin.php:748
|
321 |
#: includes/core/class-builtin.php:751
|
|
|
322 |
#: includes/core/class-builtin.php:1291
|
323 |
+
#: includes/core/class-builtin.php:1294
|
324 |
#: includes/core/um-actions-account.php:623
|
325 |
#: includes/core/um-actions-account.php:695
|
326 |
msgid "Password"
|
378 |
#: includes/admin/core/class-admin-forms.php:1617
|
379 |
#: includes/admin/core/class-admin-forms.php:1639
|
380 |
#: includes/admin/core/class-admin-notices.php:427
|
381 |
+
#: includes/core/um-actions-profile.php:843
|
382 |
#: includes/admin/assets/js/um-admin-forms.js:250
|
383 |
#: includes/admin/assets/js/um-admin-forms.js:315
|
384 |
#: includes/admin/assets/js/um-admin-forms.js:592
|
1322 |
msgstr ""
|
1323 |
|
1324 |
#: includes/admin/core/class-admin-metabox.php:2017
|
1325 |
+
#: includes/core/class-fields.php:1858
|
1326 |
+
#: includes/core/class-fields.php:1899
|
1327 |
+
#: includes/core/class-fields.php:2807
|
1328 |
+
#: includes/core/class-fields.php:2897
|
1329 |
msgid "Upload"
|
1330 |
msgstr ""
|
1331 |
|
2488 |
msgstr ""
|
2489 |
|
2490 |
#: includes/admin/core/class-admin-settings.php:1349
|
2491 |
+
#: includes/core/class-form.php:758
|
2492 |
msgid "Profile"
|
2493 |
msgstr ""
|
2494 |
|
3106 |
msgstr ""
|
3107 |
|
3108 |
#: includes/admin/core/class-admin-users.php:193
|
3109 |
+
#: includes/core/class-fields.php:2877
|
3110 |
msgid "Apply"
|
3111 |
msgstr ""
|
3112 |
|
4293 |
#: includes/admin/templates/modal/forms/fonticons.php:14
|
4294 |
#: includes/admin/templates/role/publish.php:30
|
4295 |
#: includes/class-config.php:254
|
4296 |
+
#: includes/core/class-fields.php:2878
|
4297 |
+
#: includes/core/class-fields.php:2985
|
4298 |
+
#: includes/core/um-actions-profile.php:844
|
4299 |
+
#: includes/core/um-actions-profile.php:856
|
4300 |
+
#: includes/core/um-actions-profile.php:1044
|
4301 |
+
#: includes/core/um-actions-profile.php:1077
|
4302 |
+
#: includes/core/um-actions-profile.php:1420
|
4303 |
+
#: includes/core/um-actions-profile.php:1427
|
4304 |
msgid "Cancel"
|
4305 |
msgstr ""
|
4306 |
|
4636 |
#: includes/class-config.php:264
|
4637 |
#: includes/class-config.php:272
|
4638 |
#: includes/class-config.php:800
|
4639 |
+
#: includes/core/class-form.php:755
|
4640 |
msgid "Login"
|
4641 |
msgstr ""
|
4642 |
|
4644 |
#: includes/class-config.php:262
|
4645 |
#: includes/class-config.php:276
|
4646 |
#: includes/class-config.php:801
|
4647 |
+
#: includes/core/class-form.php:761
|
4648 |
msgid "Register"
|
4649 |
msgstr ""
|
4650 |
|
4651 |
#: includes/class-config.php:135
|
4652 |
#: includes/class-config.php:803
|
4653 |
#: includes/core/class-member-directory.php:2300
|
4654 |
+
#: includes/core/um-actions-profile.php:1426
|
4655 |
#: includes/core/um-actions-user.php:19
|
4656 |
msgid "Logout"
|
4657 |
msgstr ""
|
4833 |
#. translators: %s: Restricted post message.
|
4834 |
#. translators: %s: The message after registration process based on a role data and user status after registration
|
4835 |
#. translators: %s: Restricted taxonomy message.
|
4836 |
+
#: includes/core/class-access.php:738
|
4837 |
+
#: includes/core/class-fields.php:1473
|
4838 |
#: includes/core/um-actions-account.php:495
|
4839 |
#: templates/message.php:8
|
4840 |
#: templates/restricted-taxonomy.php:47
|
4863 |
|
4864 |
#: includes/core/class-account.php:124
|
4865 |
#: includes/core/class-account.php:125
|
|
|
4866 |
#: includes/core/class-builtin.php:1274
|
4867 |
+
#: includes/core/class-builtin.php:1277
|
4868 |
msgid "Delete Account"
|
4869 |
msgstr ""
|
4870 |
|
4963 |
msgstr ""
|
4964 |
|
4965 |
#: includes/core/class-builtin.php:713
|
4966 |
+
#: includes/core/class-user.php:1972
|
4967 |
msgid "Only me"
|
4968 |
msgstr ""
|
4969 |
|
4970 |
#: includes/core/class-builtin.php:737
|
4971 |
#: includes/core/class-builtin.php:740
|
4972 |
+
#: includes/core/class-builtin.php:1208
|
4973 |
msgid "Username or E-mail"
|
4974 |
msgstr ""
|
4975 |
|
4991 |
|
4992 |
#: includes/core/class-builtin.php:793
|
4993 |
#: includes/core/class-builtin.php:796
|
4994 |
+
#: includes/core/class-builtin.php:1486
|
4995 |
msgid "Website URL"
|
4996 |
msgstr ""
|
4997 |
|
5083 |
|
5084 |
#: includes/core/class-builtin.php:989
|
5085 |
#: includes/core/class-builtin.php:992
|
5086 |
+
#: includes/core/class-builtin.php:1478
|
5087 |
msgid "Skype ID"
|
5088 |
msgstr ""
|
5089 |
|
5111 |
msgstr ""
|
5112 |
|
5113 |
#: includes/core/class-builtin.php:1051
|
5114 |
+
#: includes/core/class-builtin.php:1489
|
5115 |
msgid "Discord ID"
|
5116 |
msgstr ""
|
5117 |
|
5118 |
#: includes/core/class-builtin.php:1061
|
5119 |
#: includes/core/class-builtin.php:1064
|
5120 |
+
#: includes/core/class-builtin.php:1072
|
5121 |
msgid "YouTube"
|
5122 |
msgstr ""
|
5123 |
|
|
|
5124 |
#: includes/core/class-builtin.php:1082
|
5125 |
+
#: includes/core/class-builtin.php:1085
|
5126 |
msgid "SoundCloud"
|
5127 |
msgstr ""
|
5128 |
|
|
|
5129 |
#: includes/core/class-builtin.php:1100
|
5130 |
+
#: includes/core/class-builtin.php:1103
|
5131 |
msgid "VKontakte"
|
5132 |
msgstr ""
|
5133 |
|
5134 |
+
#: includes/core/class-builtin.php:1118
|
5135 |
msgid "Roles (Dropdown)"
|
5136 |
msgstr ""
|
5137 |
|
5138 |
+
#: includes/core/class-builtin.php:1121
|
5139 |
+
#: includes/core/class-builtin.php:1133
|
5140 |
msgid "Account Type"
|
5141 |
msgstr ""
|
5142 |
|
5143 |
+
#: includes/core/class-builtin.php:1130
|
5144 |
msgid "Roles (Radio)"
|
5145 |
msgstr ""
|
5146 |
|
5147 |
+
#: includes/core/class-builtin.php:1141
|
5148 |
#: includes/core/class-member-directory.php:346
|
5149 |
msgid "Languages"
|
5150 |
msgstr ""
|
5151 |
|
5152 |
+
#: includes/core/class-builtin.php:1144
|
5153 |
msgid "Languages Spoken"
|
5154 |
msgstr ""
|
5155 |
|
5156 |
+
#: includes/core/class-builtin.php:1145
|
5157 |
msgid "Select languages"
|
5158 |
msgstr ""
|
5159 |
|
|
|
5160 |
#: includes/core/class-builtin.php:1153
|
5161 |
+
#: includes/core/class-builtin.php:1156
|
5162 |
+
#: includes/core/class-builtin.php:1477
|
5163 |
#: includes/core/class-member-directory.php:356
|
5164 |
msgid "Phone Number"
|
5165 |
msgstr ""
|
5166 |
|
|
|
5167 |
#: includes/core/class-builtin.php:1165
|
5168 |
+
#: includes/core/class-builtin.php:1168
|
5169 |
#: includes/core/class-member-directory.php:357
|
5170 |
msgid "Mobile Number"
|
5171 |
msgstr ""
|
5172 |
|
5173 |
+
#: includes/core/class-builtin.php:1179
|
5174 |
msgid "Profile Photo"
|
5175 |
msgstr ""
|
5176 |
|
5177 |
+
#: includes/core/class-builtin.php:1182
|
5178 |
msgid "Change your profile photo"
|
5179 |
msgstr ""
|
5180 |
|
5181 |
+
#: includes/core/class-builtin.php:1183
|
5182 |
msgid "Upload your photo here"
|
5183 |
msgstr ""
|
5184 |
|
5185 |
+
#: includes/core/class-builtin.php:1193
|
5186 |
msgid "Cover Photo"
|
5187 |
msgstr ""
|
5188 |
|
5189 |
+
#: includes/core/class-builtin.php:1196
|
5190 |
+
#: includes/core/um-actions-profile.php:804
|
5191 |
msgid "Change your cover photo"
|
5192 |
msgstr ""
|
5193 |
|
5194 |
+
#: includes/core/class-builtin.php:1197
|
5195 |
msgid "Upload profile cover here"
|
5196 |
msgstr ""
|
5197 |
|
5198 |
+
#: includes/core/class-builtin.php:1211
|
5199 |
msgid "Enter your username or email"
|
5200 |
msgstr ""
|
5201 |
|
|
|
5202 |
#: includes/core/class-builtin.php:1221
|
5203 |
+
#: includes/core/class-builtin.php:1224
|
5204 |
msgid "Profile Privacy"
|
5205 |
msgstr ""
|
5206 |
|
5207 |
+
#: includes/core/class-builtin.php:1225
|
5208 |
msgid "Who can see your public profile?"
|
5209 |
msgstr ""
|
5210 |
|
|
|
5211 |
#: includes/core/class-builtin.php:1237
|
5212 |
+
#: includes/core/class-builtin.php:1240
|
5213 |
msgid "Avoid indexing my profile by search engines"
|
5214 |
msgstr ""
|
5215 |
|
5216 |
+
#: includes/core/class-builtin.php:1241
|
5217 |
msgid "Hide my profile for robots?"
|
5218 |
msgstr ""
|
5219 |
|
|
|
5220 |
#: includes/core/class-builtin.php:1256
|
5221 |
+
#: includes/core/class-builtin.php:1259
|
5222 |
msgid "Hide my profile from directory"
|
5223 |
msgstr ""
|
5224 |
|
5225 |
+
#: includes/core/class-builtin.php:1260
|
5226 |
msgid "Here you can hide yourself from appearing in public directory"
|
5227 |
msgstr ""
|
5228 |
|
5229 |
+
#: includes/core/class-builtin.php:1278
|
5230 |
msgid "If you confirm, everything related to your profile will be deleted permanently from the site"
|
5231 |
msgstr ""
|
5232 |
|
5233 |
+
#: includes/core/class-builtin.php:1467
|
5234 |
msgid "Alphabetic value only"
|
5235 |
msgstr ""
|
5236 |
|
5237 |
+
#: includes/core/class-builtin.php:1468
|
5238 |
msgid "Alpha-numeric value"
|
5239 |
msgstr ""
|
5240 |
|
5241 |
+
#: includes/core/class-builtin.php:1469
|
5242 |
msgid "English letters only"
|
5243 |
msgstr ""
|
5244 |
|
5245 |
+
#: includes/core/class-builtin.php:1470
|
5246 |
msgid "Facebook URL"
|
5247 |
msgstr ""
|
5248 |
|
5249 |
+
#: includes/core/class-builtin.php:1471
|
5250 |
msgid "Google+ URL"
|
5251 |
msgstr ""
|
5252 |
|
5253 |
+
#: includes/core/class-builtin.php:1472
|
5254 |
msgid "Instagram URL"
|
5255 |
msgstr ""
|
5256 |
|
5257 |
+
#: includes/core/class-builtin.php:1473
|
5258 |
msgid "LinkedIn URL"
|
5259 |
msgstr ""
|
5260 |
|
5261 |
+
#: includes/core/class-builtin.php:1474
|
5262 |
msgid "VKontakte URL"
|
5263 |
msgstr ""
|
5264 |
|
5265 |
+
#: includes/core/class-builtin.php:1475
|
5266 |
msgid "Lowercase only"
|
5267 |
msgstr ""
|
5268 |
|
5269 |
+
#: includes/core/class-builtin.php:1476
|
5270 |
msgid "Numeric value only"
|
5271 |
msgstr ""
|
5272 |
|
5273 |
+
#: includes/core/class-builtin.php:1479
|
5274 |
msgid "SoundCloud Profile"
|
5275 |
msgstr ""
|
5276 |
|
5277 |
+
#: includes/core/class-builtin.php:1480
|
5278 |
msgid "Twitter URL"
|
5279 |
msgstr ""
|
5280 |
|
5281 |
+
#: includes/core/class-builtin.php:1481
|
5282 |
msgid "E-mail( Not Unique )"
|
5283 |
msgstr ""
|
5284 |
|
5285 |
+
#: includes/core/class-builtin.php:1482
|
5286 |
msgid "Unique E-mail"
|
5287 |
msgstr ""
|
5288 |
|
5289 |
+
#: includes/core/class-builtin.php:1483
|
5290 |
msgid "Unique Metakey value"
|
5291 |
msgstr ""
|
5292 |
|
5293 |
+
#: includes/core/class-builtin.php:1484
|
5294 |
msgid "Unique Username"
|
5295 |
msgstr ""
|
5296 |
|
5297 |
+
#: includes/core/class-builtin.php:1485
|
5298 |
msgid "Unique Username/E-mail"
|
5299 |
msgstr ""
|
5300 |
|
5301 |
+
#: includes/core/class-builtin.php:1487
|
5302 |
msgid "YouTube Profile"
|
5303 |
msgstr ""
|
5304 |
|
5305 |
+
#: includes/core/class-builtin.php:1488
|
5306 |
msgid "Telegram URL"
|
5307 |
msgstr ""
|
5308 |
|
5309 |
+
#: includes/core/class-builtin.php:1490
|
5310 |
msgid "Custom Validation"
|
5311 |
msgstr ""
|
5312 |
|
5313 |
+
#: includes/core/class-builtin.php:1529
|
5314 |
msgid "Afar"
|
5315 |
msgstr ""
|
5316 |
|
5317 |
+
#: includes/core/class-builtin.php:1530
|
5318 |
msgid "Abkhazian"
|
5319 |
msgstr ""
|
5320 |
|
5321 |
+
#: includes/core/class-builtin.php:1531
|
5322 |
msgid "Avestan"
|
5323 |
msgstr ""
|
5324 |
|
5325 |
+
#: includes/core/class-builtin.php:1532
|
5326 |
msgid "Afrikaans"
|
5327 |
msgstr ""
|
5328 |
|
5329 |
+
#: includes/core/class-builtin.php:1533
|
5330 |
msgid "Akan"
|
5331 |
msgstr ""
|
5332 |
|
5333 |
+
#: includes/core/class-builtin.php:1534
|
5334 |
msgid "Amharic"
|
5335 |
msgstr ""
|
5336 |
|
5337 |
+
#: includes/core/class-builtin.php:1535
|
5338 |
msgid "Aragonese"
|
5339 |
msgstr ""
|
5340 |
|
5341 |
+
#: includes/core/class-builtin.php:1536
|
5342 |
msgid "Arabic"
|
5343 |
msgstr ""
|
5344 |
|
5345 |
+
#: includes/core/class-builtin.php:1537
|
5346 |
msgid "Assamese"
|
5347 |
msgstr ""
|
5348 |
|
5349 |
+
#: includes/core/class-builtin.php:1538
|
5350 |
msgid "Avaric"
|
5351 |
msgstr ""
|
5352 |
|
5353 |
+
#: includes/core/class-builtin.php:1539
|
5354 |
msgid "Aymara"
|
5355 |
msgstr ""
|
5356 |
|
5357 |
+
#: includes/core/class-builtin.php:1540
|
5358 |
msgid "Azerbaijani"
|
5359 |
msgstr ""
|
5360 |
|
5361 |
+
#: includes/core/class-builtin.php:1541
|
5362 |
msgid "Bashkir"
|
5363 |
msgstr ""
|
5364 |
|
5365 |
+
#: includes/core/class-builtin.php:1542
|
5366 |
msgid "Belarusian"
|
5367 |
msgstr ""
|
5368 |
|
5369 |
+
#: includes/core/class-builtin.php:1543
|
5370 |
msgid "Bulgarian"
|
5371 |
msgstr ""
|
5372 |
|
5373 |
+
#: includes/core/class-builtin.php:1544
|
5374 |
msgid "Bihari"
|
5375 |
msgstr ""
|
5376 |
|
5377 |
+
#: includes/core/class-builtin.php:1545
|
5378 |
msgid "Bislama"
|
5379 |
msgstr ""
|
5380 |
|
5381 |
+
#: includes/core/class-builtin.php:1546
|
5382 |
msgid "Bambara"
|
5383 |
msgstr ""
|
5384 |
|
5385 |
+
#: includes/core/class-builtin.php:1547
|
5386 |
msgid "Bengali"
|
5387 |
msgstr ""
|
5388 |
|
5389 |
+
#: includes/core/class-builtin.php:1548
|
5390 |
msgid "Tibetan"
|
5391 |
msgstr ""
|
5392 |
|
5393 |
+
#: includes/core/class-builtin.php:1549
|
5394 |
msgid "Breton"
|
5395 |
msgstr ""
|
5396 |
|
5397 |
+
#: includes/core/class-builtin.php:1550
|
5398 |
msgid "Bosnian"
|
5399 |
msgstr ""
|
5400 |
|
5401 |
+
#: includes/core/class-builtin.php:1551
|
5402 |
msgid "Catalan"
|
5403 |
msgstr ""
|
5404 |
|
5405 |
+
#: includes/core/class-builtin.php:1552
|
5406 |
msgid "Chechen"
|
5407 |
msgstr ""
|
5408 |
|
5409 |
+
#: includes/core/class-builtin.php:1553
|
5410 |
msgid "Chamorro"
|
5411 |
msgstr ""
|
5412 |
|
5413 |
+
#: includes/core/class-builtin.php:1554
|
5414 |
msgid "Corsican"
|
5415 |
msgstr ""
|
5416 |
|
5417 |
+
#: includes/core/class-builtin.php:1555
|
5418 |
msgid "Cree"
|
5419 |
msgstr ""
|
5420 |
|
5421 |
+
#: includes/core/class-builtin.php:1556
|
5422 |
msgid "Czech"
|
5423 |
msgstr ""
|
5424 |
|
5425 |
+
#: includes/core/class-builtin.php:1557
|
5426 |
msgid "Church Slavic"
|
5427 |
msgstr ""
|
5428 |
|
5429 |
+
#: includes/core/class-builtin.php:1558
|
5430 |
msgid "Chuvash"
|
5431 |
msgstr ""
|
5432 |
|
5433 |
+
#: includes/core/class-builtin.php:1559
|
5434 |
msgid "Welsh"
|
5435 |
msgstr ""
|
5436 |
|
5437 |
+
#: includes/core/class-builtin.php:1560
|
5438 |
msgid "Danish"
|
5439 |
msgstr ""
|
5440 |
|
5441 |
+
#: includes/core/class-builtin.php:1561
|
5442 |
msgid "German"
|
5443 |
msgstr ""
|
5444 |
|
5445 |
+
#: includes/core/class-builtin.php:1562
|
5446 |
msgid "Divehi"
|
5447 |
msgstr ""
|
5448 |
|
5449 |
+
#: includes/core/class-builtin.php:1563
|
5450 |
msgid "Dzongkha"
|
5451 |
msgstr ""
|
5452 |
|
5453 |
+
#: includes/core/class-builtin.php:1564
|
5454 |
msgid "Ewe"
|
5455 |
msgstr ""
|
5456 |
|
5457 |
+
#: includes/core/class-builtin.php:1565
|
5458 |
msgid "Greek"
|
5459 |
msgstr ""
|
5460 |
|
5461 |
+
#: includes/core/class-builtin.php:1566
|
5462 |
msgid "English"
|
5463 |
msgstr ""
|
5464 |
|
5465 |
+
#: includes/core/class-builtin.php:1567
|
5466 |
msgid "Esperanto"
|
5467 |
msgstr ""
|
5468 |
|
5469 |
+
#: includes/core/class-builtin.php:1568
|
5470 |
msgid "Spanish"
|
5471 |
msgstr ""
|
5472 |
|
5473 |
+
#: includes/core/class-builtin.php:1569
|
5474 |
msgid "Estonian"
|
5475 |
msgstr ""
|
5476 |
|
5477 |
+
#: includes/core/class-builtin.php:1570
|
5478 |
msgid "Basque"
|
5479 |
msgstr ""
|
5480 |
|
5481 |
+
#: includes/core/class-builtin.php:1571
|
5482 |
msgid "Persian"
|
5483 |
msgstr ""
|
5484 |
|
5485 |
+
#: includes/core/class-builtin.php:1572
|
5486 |
msgid "Fulah"
|
5487 |
msgstr ""
|
5488 |
|
5489 |
+
#: includes/core/class-builtin.php:1573
|
5490 |
msgid "Finnish"
|
5491 |
msgstr ""
|
5492 |
|
5493 |
+
#: includes/core/class-builtin.php:1574
|
5494 |
msgid "Fijian"
|
5495 |
msgstr ""
|
5496 |
|
5497 |
+
#: includes/core/class-builtin.php:1575
|
5498 |
msgid "Faroese"
|
5499 |
msgstr ""
|
5500 |
|
5501 |
+
#: includes/core/class-builtin.php:1576
|
5502 |
msgid "French"
|
5503 |
msgstr ""
|
5504 |
|
5505 |
+
#: includes/core/class-builtin.php:1577
|
5506 |
msgid "Western Frisian"
|
5507 |
msgstr ""
|
5508 |
|
5509 |
+
#: includes/core/class-builtin.php:1578
|
5510 |
msgid "Irish"
|
5511 |
msgstr ""
|
5512 |
|
5513 |
+
#: includes/core/class-builtin.php:1579
|
5514 |
msgid "Scottish Gaelic"
|
5515 |
msgstr ""
|
5516 |
|
5517 |
+
#: includes/core/class-builtin.php:1580
|
5518 |
msgid "Galician"
|
5519 |
msgstr ""
|
5520 |
|
5521 |
+
#: includes/core/class-builtin.php:1581
|
5522 |
msgid "Guarani"
|
5523 |
msgstr ""
|
5524 |
|
5525 |
+
#: includes/core/class-builtin.php:1582
|
5526 |
msgid "Gujarati"
|
5527 |
msgstr ""
|
5528 |
|
5529 |
+
#: includes/core/class-builtin.php:1583
|
5530 |
msgid "Manx"
|
5531 |
msgstr ""
|
5532 |
|
5533 |
+
#: includes/core/class-builtin.php:1584
|
5534 |
msgid "Hausa"
|
5535 |
msgstr ""
|
5536 |
|
5537 |
+
#: includes/core/class-builtin.php:1585
|
5538 |
msgid "Hebrew"
|
5539 |
msgstr ""
|
5540 |
|
5541 |
+
#: includes/core/class-builtin.php:1586
|
5542 |
msgid "Hindi"
|
5543 |
msgstr ""
|
5544 |
|
5545 |
+
#: includes/core/class-builtin.php:1587
|
5546 |
msgid "Hiri Motu"
|
5547 |
msgstr ""
|
5548 |
|
5549 |
+
#: includes/core/class-builtin.php:1588
|
5550 |
msgid "Croatian"
|
5551 |
msgstr ""
|
5552 |
|
5553 |
+
#: includes/core/class-builtin.php:1589
|
5554 |
msgid "Haitian"
|
5555 |
msgstr ""
|
5556 |
|
5557 |
+
#: includes/core/class-builtin.php:1590
|
5558 |
msgid "Hungarian"
|
5559 |
msgstr ""
|
5560 |
|
5561 |
+
#: includes/core/class-builtin.php:1591
|
5562 |
msgid "Armenian"
|
5563 |
msgstr ""
|
5564 |
|
5565 |
+
#: includes/core/class-builtin.php:1592
|
5566 |
msgid "Herero"
|
5567 |
msgstr ""
|
5568 |
|
5569 |
+
#: includes/core/class-builtin.php:1593
|
5570 |
msgid "Interlingua (International Auxiliary Language Association)"
|
5571 |
msgstr ""
|
5572 |
|
5573 |
+
#: includes/core/class-builtin.php:1594
|
5574 |
msgid "Indonesian"
|
5575 |
msgstr ""
|
5576 |
|
5577 |
+
#: includes/core/class-builtin.php:1595
|
5578 |
msgid "Interlingue"
|
5579 |
msgstr ""
|
5580 |
|
5581 |
+
#: includes/core/class-builtin.php:1596
|
5582 |
msgid "Igbo"
|
5583 |
msgstr ""
|
5584 |
|
5585 |
+
#: includes/core/class-builtin.php:1597
|
5586 |
msgid "Sichuan Yi"
|
5587 |
msgstr ""
|
5588 |
|
5589 |
+
#: includes/core/class-builtin.php:1598
|
5590 |
msgid "Inupiaq"
|
5591 |
msgstr ""
|
5592 |
|
5593 |
+
#: includes/core/class-builtin.php:1599
|
5594 |
msgid "Ido"
|
5595 |
msgstr ""
|
5596 |
|
5597 |
+
#: includes/core/class-builtin.php:1600
|
5598 |
msgid "Icelandic"
|
5599 |
msgstr ""
|
5600 |
|
5601 |
+
#: includes/core/class-builtin.php:1601
|
5602 |
msgid "Italian"
|
5603 |
msgstr ""
|
5604 |
|
5605 |
+
#: includes/core/class-builtin.php:1602
|
5606 |
msgid "Inuktitut"
|
5607 |
msgstr ""
|
5608 |
|
5609 |
+
#: includes/core/class-builtin.php:1603
|
5610 |
msgid "Japanese"
|
5611 |
msgstr ""
|
5612 |
|
5613 |
+
#: includes/core/class-builtin.php:1604
|
5614 |
msgid "Javanese"
|
5615 |
msgstr ""
|
5616 |
|
5617 |
+
#: includes/core/class-builtin.php:1605
|
5618 |
msgid "Kartuli"
|
5619 |
msgstr ""
|
5620 |
|
5621 |
+
#: includes/core/class-builtin.php:1606
|
5622 |
msgid "Kongo"
|
5623 |
msgstr ""
|
5624 |
|
5625 |
+
#: includes/core/class-builtin.php:1607
|
5626 |
msgid "Kikuyu"
|
5627 |
msgstr ""
|
5628 |
|
5629 |
+
#: includes/core/class-builtin.php:1608
|
5630 |
msgid "Kwanyama"
|
5631 |
msgstr ""
|
5632 |
|
5633 |
+
#: includes/core/class-builtin.php:1609
|
5634 |
msgid "Kazakh"
|
5635 |
msgstr ""
|
5636 |
|
5637 |
+
#: includes/core/class-builtin.php:1610
|
5638 |
msgid "Kalaallisut"
|
5639 |
msgstr ""
|
5640 |
|
5641 |
+
#: includes/core/class-builtin.php:1611
|
5642 |
msgid "Khmer"
|
5643 |
msgstr ""
|
5644 |
|
5645 |
+
#: includes/core/class-builtin.php:1612
|
5646 |
msgid "Kannada"
|
5647 |
msgstr ""
|
5648 |
|
5649 |
+
#: includes/core/class-builtin.php:1613
|
5650 |
msgid "Korean"
|
5651 |
msgstr ""
|
5652 |
|
5653 |
+
#: includes/core/class-builtin.php:1614
|
5654 |
msgid "Kanuri"
|
5655 |
msgstr ""
|
5656 |
|
5657 |
+
#: includes/core/class-builtin.php:1615
|
5658 |
msgid "Kashmiri"
|
5659 |
msgstr ""
|
5660 |
|
5661 |
+
#: includes/core/class-builtin.php:1616
|
5662 |
msgid "Kurdish"
|
5663 |
msgstr ""
|
5664 |
|
5665 |
+
#: includes/core/class-builtin.php:1617
|
5666 |
msgid "Komi"
|
5667 |
msgstr ""
|
5668 |
|
5669 |
+
#: includes/core/class-builtin.php:1618
|
5670 |
msgid "Cornish"
|
5671 |
msgstr ""
|
5672 |
|
5673 |
+
#: includes/core/class-builtin.php:1619
|
5674 |
msgid "Kirghiz"
|
5675 |
msgstr ""
|
5676 |
|
5677 |
+
#: includes/core/class-builtin.php:1620
|
5678 |
msgid "Latin"
|
5679 |
msgstr ""
|
5680 |
|
5681 |
+
#: includes/core/class-builtin.php:1621
|
5682 |
msgid "Luxembourgish"
|
5683 |
msgstr ""
|
5684 |
|
5685 |
+
#: includes/core/class-builtin.php:1622
|
5686 |
msgid "Ganda"
|
5687 |
msgstr ""
|
5688 |
|
5689 |
+
#: includes/core/class-builtin.php:1623
|
5690 |
msgid "Limburgish"
|
5691 |
msgstr ""
|
5692 |
|
5693 |
+
#: includes/core/class-builtin.php:1624
|
5694 |
msgid "Lingala"
|
5695 |
msgstr ""
|
5696 |
|
5697 |
+
#: includes/core/class-builtin.php:1625
|
5698 |
msgid "Lao"
|
5699 |
msgstr ""
|
5700 |
|
5701 |
+
#: includes/core/class-builtin.php:1626
|
5702 |
msgid "Lithuanian"
|
5703 |
msgstr ""
|
5704 |
|
5705 |
+
#: includes/core/class-builtin.php:1627
|
5706 |
msgid "Luba-Katanga"
|
5707 |
msgstr ""
|
5708 |
|
5709 |
+
#: includes/core/class-builtin.php:1628
|
5710 |
msgid "Latvian"
|
5711 |
msgstr ""
|
5712 |
|
5713 |
+
#: includes/core/class-builtin.php:1629
|
5714 |
msgid "Malagasy"
|
5715 |
msgstr ""
|
5716 |
|
5717 |
+
#: includes/core/class-builtin.php:1630
|
5718 |
msgid "Marshallese"
|
5719 |
msgstr ""
|
5720 |
|
5721 |
+
#: includes/core/class-builtin.php:1631
|
5722 |
msgid "Maori"
|
5723 |
msgstr ""
|
5724 |
|
5725 |
+
#: includes/core/class-builtin.php:1632
|
5726 |
msgid "Macedonian"
|
5727 |
msgstr ""
|
5728 |
|
5729 |
+
#: includes/core/class-builtin.php:1633
|
5730 |
msgid "Malayalam"
|
5731 |
msgstr ""
|
5732 |
|
5733 |
+
#: includes/core/class-builtin.php:1634
|
5734 |
msgid "Mongolian"
|
5735 |
msgstr ""
|
5736 |
|
5737 |
+
#: includes/core/class-builtin.php:1635
|
5738 |
msgid "Marathi"
|
5739 |
msgstr ""
|
5740 |
|
5741 |
+
#: includes/core/class-builtin.php:1636
|
5742 |
msgid "Malay"
|
5743 |
msgstr ""
|
5744 |
|
5745 |
+
#: includes/core/class-builtin.php:1637
|
5746 |
msgid "Maltese"
|
5747 |
msgstr ""
|
5748 |
|
5749 |
+
#: includes/core/class-builtin.php:1638
|
5750 |
msgid "Burmese"
|
5751 |
msgstr ""
|
5752 |
|
5753 |
+
#: includes/core/class-builtin.php:1639
|
5754 |
+
#: includes/core/class-builtin.php:1870
|
5755 |
msgid "Nauru"
|
5756 |
msgstr ""
|
5757 |
|
5758 |
+
#: includes/core/class-builtin.php:1640
|
5759 |
msgid "Norwegian Bokmal"
|
5760 |
msgstr ""
|
5761 |
|
5762 |
+
#: includes/core/class-builtin.php:1641
|
5763 |
msgid "North Ndebele"
|
5764 |
msgstr ""
|
5765 |
|
5766 |
+
#: includes/core/class-builtin.php:1642
|
5767 |
msgid "Nepali"
|
5768 |
msgstr ""
|
5769 |
|
5770 |
+
#: includes/core/class-builtin.php:1643
|
5771 |
msgid "Ndonga"
|
5772 |
msgstr ""
|
5773 |
|
5774 |
+
#: includes/core/class-builtin.php:1644
|
5775 |
msgid "Dutch"
|
5776 |
msgstr ""
|
5777 |
|
5778 |
+
#: includes/core/class-builtin.php:1645
|
5779 |
msgid "Norwegian Nynorsk"
|
5780 |
msgstr ""
|
5781 |
|
5782 |
+
#: includes/core/class-builtin.php:1646
|
5783 |
msgid "Norwegian"
|
5784 |
msgstr ""
|
5785 |
|
5786 |
+
#: includes/core/class-builtin.php:1647
|
5787 |
msgid "South Ndebele"
|
5788 |
msgstr ""
|
5789 |
|
5790 |
+
#: includes/core/class-builtin.php:1648
|
5791 |
msgid "Navajo"
|
5792 |
msgstr ""
|
5793 |
|
5794 |
+
#: includes/core/class-builtin.php:1649
|
5795 |
msgid "Chichewa"
|
5796 |
msgstr ""
|
5797 |
|
5798 |
+
#: includes/core/class-builtin.php:1650
|
5799 |
msgid "Occitan"
|
5800 |
msgstr ""
|
5801 |
|
5802 |
+
#: includes/core/class-builtin.php:1651
|
5803 |
msgid "Ojibwa"
|
5804 |
msgstr ""
|
5805 |
|
5806 |
+
#: includes/core/class-builtin.php:1652
|
5807 |
msgid "Oromo"
|
5808 |
msgstr ""
|
5809 |
|
5810 |
+
#: includes/core/class-builtin.php:1653
|
5811 |
msgid "Oriya"
|
5812 |
msgstr ""
|
5813 |
|
5814 |
+
#: includes/core/class-builtin.php:1654
|
5815 |
msgid "Ossetian"
|
5816 |
msgstr ""
|
5817 |
|
5818 |
+
#: includes/core/class-builtin.php:1655
|
5819 |
msgid "Panjabi"
|
5820 |
msgstr ""
|
5821 |
|
5822 |
+
#: includes/core/class-builtin.php:1656
|
5823 |
msgid "Pali"
|
5824 |
msgstr ""
|
5825 |
|
5826 |
+
#: includes/core/class-builtin.php:1657
|
5827 |
msgid "Polish"
|
5828 |
msgstr ""
|
5829 |
|
5830 |
+
#: includes/core/class-builtin.php:1658
|
5831 |
msgid "Pashto"
|
5832 |
msgstr ""
|
5833 |
|
5834 |
+
#: includes/core/class-builtin.php:1659
|
5835 |
msgid "Portuguese"
|
5836 |
msgstr ""
|
5837 |
|
5838 |
+
#: includes/core/class-builtin.php:1660
|
5839 |
msgid "Quechua"
|
5840 |
msgstr ""
|
5841 |
|
5842 |
+
#: includes/core/class-builtin.php:1661
|
5843 |
msgid "Raeto-Romance"
|
5844 |
msgstr ""
|
5845 |
|
5846 |
+
#: includes/core/class-builtin.php:1662
|
5847 |
msgid "Kirundi"
|
5848 |
msgstr ""
|
5849 |
|
5850 |
+
#: includes/core/class-builtin.php:1663
|
5851 |
msgid "Romanian"
|
5852 |
msgstr ""
|
5853 |
|
5854 |
+
#: includes/core/class-builtin.php:1664
|
5855 |
msgid "Russian"
|
5856 |
msgstr ""
|
5857 |
|
5858 |
+
#: includes/core/class-builtin.php:1665
|
5859 |
msgid "Kinyarwanda"
|
5860 |
msgstr ""
|
5861 |
|
5862 |
+
#: includes/core/class-builtin.php:1666
|
5863 |
msgid "Sanskrit"
|
5864 |
msgstr ""
|
5865 |
|
5866 |
+
#: includes/core/class-builtin.php:1667
|
5867 |
msgid "Sardinian"
|
5868 |
msgstr ""
|
5869 |
|
5870 |
+
#: includes/core/class-builtin.php:1668
|
5871 |
msgid "Sindhi"
|
5872 |
msgstr ""
|
5873 |
|
5874 |
+
#: includes/core/class-builtin.php:1669
|
5875 |
msgid "Northern Sami"
|
5876 |
msgstr ""
|
5877 |
|
5878 |
+
#: includes/core/class-builtin.php:1670
|
5879 |
msgid "Sango"
|
5880 |
msgstr ""
|
5881 |
|
5882 |
+
#: includes/core/class-builtin.php:1671
|
5883 |
msgid "Sinhala"
|
5884 |
msgstr ""
|
5885 |
|
5886 |
+
#: includes/core/class-builtin.php:1672
|
5887 |
msgid "Slovak"
|
5888 |
msgstr ""
|
5889 |
|
5890 |
+
#: includes/core/class-builtin.php:1673
|
5891 |
msgid "Slovenian"
|
5892 |
msgstr ""
|
5893 |
|
5894 |
+
#: includes/core/class-builtin.php:1674
|
5895 |
msgid "Samoan"
|
5896 |
msgstr ""
|
5897 |
|
5898 |
+
#: includes/core/class-builtin.php:1675
|
5899 |
msgid "Shona"
|
5900 |
msgstr ""
|
5901 |
|
5902 |
+
#: includes/core/class-builtin.php:1676
|
5903 |
msgid "Somali"
|
5904 |
msgstr ""
|
5905 |
|
5906 |
+
#: includes/core/class-builtin.php:1677
|
5907 |
msgid "Albanian"
|
5908 |
msgstr ""
|
5909 |
|
5910 |
+
#: includes/core/class-builtin.php:1678
|
5911 |
msgid "Serbian"
|
5912 |
msgstr ""
|
5913 |
|
5914 |
+
#: includes/core/class-builtin.php:1679
|
5915 |
msgid "Swati"
|
5916 |
msgstr ""
|
5917 |
|
5918 |
+
#: includes/core/class-builtin.php:1680
|
5919 |
msgid "Southern Sotho"
|
5920 |
msgstr ""
|
5921 |
|
5922 |
+
#: includes/core/class-builtin.php:1681
|
5923 |
msgid "Sundanese"
|
5924 |
msgstr ""
|
5925 |
|
5926 |
+
#: includes/core/class-builtin.php:1682
|
5927 |
msgid "Swedish"
|
5928 |
msgstr ""
|
5929 |
|
5930 |
+
#: includes/core/class-builtin.php:1683
|
5931 |
msgid "Swahili"
|
5932 |
msgstr ""
|
5933 |
|
5934 |
+
#: includes/core/class-builtin.php:1684
|
5935 |
msgid "Tamil"
|
5936 |
msgstr ""
|
5937 |
|
5938 |
+
#: includes/core/class-builtin.php:1685
|
5939 |
msgid "Telugu"
|
5940 |
msgstr ""
|
5941 |
|
5942 |
+
#: includes/core/class-builtin.php:1686
|
5943 |
msgid "Tajik"
|
5944 |
msgstr ""
|
5945 |
|
5946 |
+
#: includes/core/class-builtin.php:1687
|
5947 |
msgid "Thai"
|
5948 |
msgstr ""
|
5949 |
|
5950 |
+
#: includes/core/class-builtin.php:1688
|
5951 |
msgid "Tigrinya"
|
5952 |
msgstr ""
|
5953 |
|
5954 |
+
#: includes/core/class-builtin.php:1689
|
5955 |
msgid "Turkmen"
|
5956 |
msgstr ""
|
5957 |
|
5958 |
+
#: includes/core/class-builtin.php:1690
|
5959 |
msgid "Tagalog"
|
5960 |
msgstr ""
|
5961 |
|
5962 |
+
#: includes/core/class-builtin.php:1691
|
5963 |
msgid "Tswana"
|
5964 |
msgstr ""
|
5965 |
|
5966 |
+
#: includes/core/class-builtin.php:1692
|
5967 |
+
#: includes/core/class-builtin.php:1940
|
5968 |
msgid "Tonga"
|
5969 |
msgstr ""
|
5970 |
|
5971 |
+
#: includes/core/class-builtin.php:1693
|
5972 |
msgid "Turkish"
|
5973 |
msgstr ""
|
5974 |
|
5975 |
+
#: includes/core/class-builtin.php:1694
|
5976 |
msgid "Tsonga"
|
5977 |
msgstr ""
|
5978 |
|
5979 |
+
#: includes/core/class-builtin.php:1695
|
5980 |
msgid "Tatar"
|
5981 |
msgstr ""
|
5982 |
|
5983 |
+
#: includes/core/class-builtin.php:1696
|
5984 |
msgid "Twi"
|
5985 |
msgstr ""
|
5986 |
|
5987 |
+
#: includes/core/class-builtin.php:1697
|
5988 |
msgid "Tahitian"
|
5989 |
msgstr ""
|
5990 |
|
5991 |
+
#: includes/core/class-builtin.php:1698
|
5992 |
msgid "Uighur"
|
5993 |
msgstr ""
|
5994 |
|
5995 |
+
#: includes/core/class-builtin.php:1699
|
5996 |
msgid "Ukrainian"
|
5997 |
msgstr ""
|
5998 |
|
5999 |
+
#: includes/core/class-builtin.php:1700
|
6000 |
msgid "Urdu"
|
6001 |
msgstr ""
|
6002 |
|
6003 |
+
#: includes/core/class-builtin.php:1701
|
6004 |
msgid "Uzbek"
|
6005 |
msgstr ""
|
6006 |
|
6007 |
+
#: includes/core/class-builtin.php:1702
|
6008 |
msgid "Venda"
|
6009 |
msgstr ""
|
6010 |
|
6011 |
+
#: includes/core/class-builtin.php:1703
|
6012 |
msgid "Vietnamese"
|
6013 |
msgstr ""
|
6014 |
|
6015 |
+
#: includes/core/class-builtin.php:1704
|
6016 |
msgid "Volapuk"
|
6017 |
msgstr ""
|
6018 |
|
6019 |
+
#: includes/core/class-builtin.php:1705
|
6020 |
msgid "Walloon"
|
6021 |
msgstr ""
|
6022 |
|
6023 |
+
#: includes/core/class-builtin.php:1706
|
6024 |
msgid "Wolof"
|
6025 |
msgstr ""
|
6026 |
|
6027 |
+
#: includes/core/class-builtin.php:1707
|
6028 |
msgid "Xhosa"
|
6029 |
msgstr ""
|
6030 |
|
6031 |
+
#: includes/core/class-builtin.php:1708
|
6032 |
msgid "Yiddish"
|
6033 |
msgstr ""
|
6034 |
|
6035 |
+
#: includes/core/class-builtin.php:1709
|
6036 |
msgid "Yoruba"
|
6037 |
msgstr ""
|
6038 |
|
6039 |
+
#: includes/core/class-builtin.php:1710
|
6040 |
msgid "Zhuang"
|
6041 |
msgstr ""
|
6042 |
|
6043 |
+
#: includes/core/class-builtin.php:1711
|
6044 |
msgid "Chinese"
|
6045 |
msgstr ""
|
6046 |
|
6047 |
+
#: includes/core/class-builtin.php:1712
|
6048 |
msgid "Zulu"
|
6049 |
msgstr ""
|
6050 |
|
6051 |
+
#: includes/core/class-builtin.php:1718
|
6052 |
msgid "Afghanistan"
|
6053 |
msgstr ""
|
6054 |
|
6055 |
+
#: includes/core/class-builtin.php:1719
|
6056 |
msgid "Åland Islands"
|
6057 |
msgstr ""
|
6058 |
|
6059 |
+
#: includes/core/class-builtin.php:1720
|
6060 |
msgid "Albania"
|
6061 |
msgstr ""
|
6062 |
|
6063 |
+
#: includes/core/class-builtin.php:1721
|
6064 |
msgid "Algeria"
|
6065 |
msgstr ""
|
6066 |
|
6067 |
+
#: includes/core/class-builtin.php:1722
|
6068 |
msgid "American Samoa"
|
6069 |
msgstr ""
|
6070 |
|
6071 |
+
#: includes/core/class-builtin.php:1723
|
6072 |
msgid "Andorra"
|
6073 |
msgstr ""
|
6074 |
|
6075 |
+
#: includes/core/class-builtin.php:1724
|
6076 |
msgid "Angola"
|
6077 |
msgstr ""
|
6078 |
|
6079 |
+
#: includes/core/class-builtin.php:1725
|
6080 |
msgid "Anguilla"
|
6081 |
msgstr ""
|
6082 |
|
6083 |
+
#: includes/core/class-builtin.php:1726
|
6084 |
msgid "Antarctica"
|
6085 |
msgstr ""
|
6086 |
|
6087 |
+
#: includes/core/class-builtin.php:1727
|
6088 |
msgid "Antigua and Barbuda"
|
6089 |
msgstr ""
|
6090 |
|
6091 |
+
#: includes/core/class-builtin.php:1728
|
6092 |
msgid "Argentina"
|
6093 |
msgstr ""
|
6094 |
|
6095 |
+
#: includes/core/class-builtin.php:1729
|
6096 |
msgid "Armenia"
|
6097 |
msgstr ""
|
6098 |
|
6099 |
+
#: includes/core/class-builtin.php:1730
|
6100 |
msgid "Aruba"
|
6101 |
msgstr ""
|
6102 |
|
6103 |
+
#: includes/core/class-builtin.php:1731
|
6104 |
msgid "Australia"
|
6105 |
msgstr ""
|
6106 |
|
6107 |
+
#: includes/core/class-builtin.php:1732
|
6108 |
msgid "Austria"
|
6109 |
msgstr ""
|
6110 |
|
6111 |
+
#: includes/core/class-builtin.php:1733
|
6112 |
msgid "Azerbaijan"
|
6113 |
msgstr ""
|
6114 |
|
6115 |
+
#: includes/core/class-builtin.php:1734
|
6116 |
msgid "Bahamas"
|
6117 |
msgstr ""
|
6118 |
|
6119 |
+
#: includes/core/class-builtin.php:1735
|
6120 |
msgid "Bahrain"
|
6121 |
msgstr ""
|
6122 |
|
6123 |
+
#: includes/core/class-builtin.php:1736
|
6124 |
msgid "Bangladesh"
|
6125 |
msgstr ""
|
6126 |
|
6127 |
+
#: includes/core/class-builtin.php:1737
|
6128 |
msgid "Barbados"
|
6129 |
msgstr ""
|
6130 |
|
6131 |
+
#: includes/core/class-builtin.php:1738
|
6132 |
msgid "Belarus"
|
6133 |
msgstr ""
|
6134 |
|
6135 |
+
#: includes/core/class-builtin.php:1739
|
6136 |
msgid "Belgium"
|
6137 |
msgstr ""
|
6138 |
|
6139 |
+
#: includes/core/class-builtin.php:1740
|
6140 |
msgid "Belize"
|
6141 |
msgstr ""
|
6142 |
|
6143 |
+
#: includes/core/class-builtin.php:1741
|
6144 |
msgid "Benin"
|
6145 |
msgstr ""
|
6146 |
|
6147 |
+
#: includes/core/class-builtin.php:1742
|
6148 |
msgid "Bermuda"
|
6149 |
msgstr ""
|
6150 |
|
6151 |
+
#: includes/core/class-builtin.php:1743
|
6152 |
msgid "Bhutan"
|
6153 |
msgstr ""
|
6154 |
|
6155 |
+
#: includes/core/class-builtin.php:1744
|
6156 |
msgid "Bolivia, Plurinational State of"
|
6157 |
msgstr ""
|
6158 |
|
6159 |
+
#: includes/core/class-builtin.php:1745
|
6160 |
msgid "Bosnia and Herzegovina"
|
6161 |
msgstr ""
|
6162 |
|
6163 |
+
#: includes/core/class-builtin.php:1746
|
6164 |
msgid "Botswana"
|
6165 |
msgstr ""
|
6166 |
|
6167 |
+
#: includes/core/class-builtin.php:1747
|
6168 |
msgid "Bouvet Island"
|
6169 |
msgstr ""
|
6170 |
|
6171 |
+
#: includes/core/class-builtin.php:1748
|
6172 |
msgid "Brazil"
|
6173 |
msgstr ""
|
6174 |
|
6175 |
+
#: includes/core/class-builtin.php:1749
|
6176 |
msgid "British Indian Ocean Territory"
|
6177 |
msgstr ""
|
6178 |
|
6179 |
+
#: includes/core/class-builtin.php:1750
|
6180 |
msgid "Brunei Darussalam"
|
6181 |
msgstr ""
|
6182 |
|
6183 |
+
#: includes/core/class-builtin.php:1751
|
6184 |
msgid "Bulgaria"
|
6185 |
msgstr ""
|
6186 |
|
6187 |
+
#: includes/core/class-builtin.php:1752
|
6188 |
msgid "Burkina Faso"
|
6189 |
msgstr ""
|
6190 |
|
6191 |
+
#: includes/core/class-builtin.php:1753
|
6192 |
msgid "Burundi"
|
6193 |
msgstr ""
|
6194 |
|
6195 |
+
#: includes/core/class-builtin.php:1754
|
6196 |
msgid "Cambodia"
|
6197 |
msgstr ""
|
6198 |
|
6199 |
+
#: includes/core/class-builtin.php:1755
|
6200 |
msgid "Cameroon"
|
6201 |
msgstr ""
|
6202 |
|
6203 |
+
#: includes/core/class-builtin.php:1756
|
6204 |
msgid "Canada"
|
6205 |
msgstr ""
|
6206 |
|
6207 |
+
#: includes/core/class-builtin.php:1757
|
6208 |
msgid "Cape Verde"
|
6209 |
msgstr ""
|
6210 |
|
6211 |
+
#: includes/core/class-builtin.php:1758
|
6212 |
msgid "Cayman Islands"
|
6213 |
msgstr ""
|
6214 |
|
6215 |
+
#: includes/core/class-builtin.php:1759
|
6216 |
msgid "Central African Republic"
|
6217 |
msgstr ""
|
6218 |
|
6219 |
+
#: includes/core/class-builtin.php:1760
|
6220 |
msgid "Chad"
|
6221 |
msgstr ""
|
6222 |
|
6223 |
+
#: includes/core/class-builtin.php:1761
|
6224 |
msgid "Chile"
|
6225 |
msgstr ""
|
6226 |
|
6227 |
+
#: includes/core/class-builtin.php:1762
|
6228 |
msgid "China"
|
6229 |
msgstr ""
|
6230 |
|
6231 |
+
#: includes/core/class-builtin.php:1763
|
6232 |
msgid "Christmas Island"
|
6233 |
msgstr ""
|
6234 |
|
6235 |
+
#: includes/core/class-builtin.php:1764
|
6236 |
msgid "Cocos (Keeling) Islands"
|
6237 |
msgstr ""
|
6238 |
|
6239 |
+
#: includes/core/class-builtin.php:1765
|
6240 |
msgid "Colombia"
|
6241 |
msgstr ""
|
6242 |
|
6243 |
+
#: includes/core/class-builtin.php:1766
|
6244 |
msgid "Comoros"
|
6245 |
msgstr ""
|
6246 |
|
6247 |
+
#: includes/core/class-builtin.php:1767
|
6248 |
msgid "Congo"
|
6249 |
msgstr ""
|
6250 |
|
6251 |
+
#: includes/core/class-builtin.php:1768
|
6252 |
msgid "Congo, the Democratic Republic of the"
|
6253 |
msgstr ""
|
6254 |
|
6255 |
+
#: includes/core/class-builtin.php:1769
|
6256 |
msgid "Cook Islands"
|
6257 |
msgstr ""
|
6258 |
|
6259 |
+
#: includes/core/class-builtin.php:1770
|
6260 |
msgid "Costa Rica"
|
6261 |
msgstr ""
|
6262 |
|
6263 |
+
#: includes/core/class-builtin.php:1771
|
6264 |
msgid "Côte d'Ivoire"
|
6265 |
msgstr ""
|
6266 |
|
6267 |
+
#: includes/core/class-builtin.php:1772
|
6268 |
msgid "Croatia"
|
6269 |
msgstr ""
|
6270 |
|
6271 |
+
#: includes/core/class-builtin.php:1773
|
6272 |
msgid "Cuba"
|
6273 |
msgstr ""
|
6274 |
|
6275 |
+
#: includes/core/class-builtin.php:1774
|
6276 |
msgid "Cyprus"
|
6277 |
msgstr ""
|
6278 |
|
6279 |
+
#: includes/core/class-builtin.php:1775
|
6280 |
msgid "Czech Republic"
|
6281 |
msgstr ""
|
6282 |
|
6283 |
+
#: includes/core/class-builtin.php:1776
|
6284 |
msgid "Denmark"
|
6285 |
msgstr ""
|
6286 |
|
6287 |
+
#: includes/core/class-builtin.php:1777
|
6288 |
msgid "Djibouti"
|
6289 |
msgstr ""
|
6290 |
|
6291 |
+
#: includes/core/class-builtin.php:1778
|
6292 |
msgid "Dominica"
|
6293 |
msgstr ""
|
6294 |
|
6295 |
+
#: includes/core/class-builtin.php:1779
|
6296 |
msgid "Dominican Republic"
|
6297 |
msgstr ""
|
6298 |
|
6299 |
+
#: includes/core/class-builtin.php:1780
|
6300 |
msgid "Ecuador"
|
6301 |
msgstr ""
|
6302 |
|
6303 |
+
#: includes/core/class-builtin.php:1781
|
6304 |
msgid "Egypt"
|
6305 |
msgstr ""
|
6306 |
|
6307 |
+
#: includes/core/class-builtin.php:1782
|
6308 |
msgid "El Salvador"
|
6309 |
msgstr ""
|
6310 |
|
6311 |
+
#: includes/core/class-builtin.php:1783
|
6312 |
msgid "Equatorial Guinea"
|
6313 |
msgstr ""
|
6314 |
|
6315 |
+
#: includes/core/class-builtin.php:1784
|
6316 |
msgid "Eritrea"
|
6317 |
msgstr ""
|
6318 |
|
6319 |
+
#: includes/core/class-builtin.php:1785
|
6320 |
msgid "Estonia"
|
6321 |
msgstr ""
|
6322 |
|
6323 |
+
#: includes/core/class-builtin.php:1786
|
6324 |
msgid "Ethiopia"
|
6325 |
msgstr ""
|
6326 |
|
6327 |
+
#: includes/core/class-builtin.php:1787
|
6328 |
msgid "Falkland Islands (Malvinas)"
|
6329 |
msgstr ""
|
6330 |
|
6331 |
+
#: includes/core/class-builtin.php:1788
|
6332 |
msgid "Faroe Islands"
|
6333 |
msgstr ""
|
6334 |
|
6335 |
+
#: includes/core/class-builtin.php:1789
|
6336 |
msgid "Fiji"
|
6337 |
msgstr ""
|
6338 |
|
6339 |
+
#: includes/core/class-builtin.php:1790
|
6340 |
msgid "Finland"
|
6341 |
msgstr ""
|
6342 |
|
6343 |
+
#: includes/core/class-builtin.php:1791
|
6344 |
msgid "France"
|
6345 |
msgstr ""
|
6346 |
|
6347 |
+
#: includes/core/class-builtin.php:1792
|
6348 |
msgid "French Guiana"
|
6349 |
msgstr ""
|
6350 |
|
6351 |
+
#: includes/core/class-builtin.php:1793
|
6352 |
msgid "French Polynesia"
|
6353 |
msgstr ""
|
6354 |
|
6355 |
+
#: includes/core/class-builtin.php:1794
|
6356 |
msgid "French Southern Territories"
|
6357 |
msgstr ""
|
6358 |
|
6359 |
+
#: includes/core/class-builtin.php:1795
|
6360 |
msgid "Gabon"
|
6361 |
msgstr ""
|
6362 |
|
6363 |
+
#: includes/core/class-builtin.php:1796
|
6364 |
msgid "Gambia"
|
6365 |
msgstr ""
|
6366 |
|
6367 |
+
#: includes/core/class-builtin.php:1797
|
6368 |
msgid "Sakartvelo"
|
6369 |
msgstr ""
|
6370 |
|
6371 |
+
#: includes/core/class-builtin.php:1798
|
6372 |
msgid "Germany"
|
6373 |
msgstr ""
|
6374 |
|
6375 |
+
#: includes/core/class-builtin.php:1799
|
6376 |
msgid "Ghana"
|
6377 |
msgstr ""
|
6378 |
|
6379 |
+
#: includes/core/class-builtin.php:1800
|
6380 |
msgid "Gibraltar"
|
6381 |
msgstr ""
|
6382 |
|
6383 |
+
#: includes/core/class-builtin.php:1801
|
6384 |
msgid "Greece"
|
6385 |
msgstr ""
|
6386 |
|
6387 |
+
#: includes/core/class-builtin.php:1802
|
6388 |
msgid "Greenland"
|
6389 |
msgstr ""
|
6390 |
|
6391 |
+
#: includes/core/class-builtin.php:1803
|
6392 |
msgid "Grenada"
|
6393 |
msgstr ""
|
6394 |
|
6395 |
+
#: includes/core/class-builtin.php:1804
|
6396 |
msgid "Guadeloupe"
|
6397 |
msgstr ""
|
6398 |
|
6399 |
+
#: includes/core/class-builtin.php:1805
|
6400 |
msgid "Guam"
|
6401 |
msgstr ""
|
6402 |
|
6403 |
+
#: includes/core/class-builtin.php:1806
|
6404 |
msgid "Guatemala"
|
6405 |
msgstr ""
|
6406 |
|
6407 |
+
#: includes/core/class-builtin.php:1807
|
6408 |
msgid "Guernsey"
|
6409 |
msgstr ""
|
6410 |
|
6411 |
+
#: includes/core/class-builtin.php:1808
|
6412 |
msgid "Guinea"
|
6413 |
msgstr ""
|
6414 |
|
6415 |
+
#: includes/core/class-builtin.php:1809
|
6416 |
msgid "Guinea-Bissau"
|
6417 |
msgstr ""
|
6418 |
|
6419 |
+
#: includes/core/class-builtin.php:1810
|
6420 |
msgid "Guyana"
|
6421 |
msgstr ""
|
6422 |
|
6423 |
+
#: includes/core/class-builtin.php:1811
|
6424 |
msgid "Haiti"
|
6425 |
msgstr ""
|
6426 |
|
6427 |
+
#: includes/core/class-builtin.php:1812
|
6428 |
msgid "Heard Island and McDonald Islands"
|
6429 |
msgstr ""
|
6430 |
|
6431 |
+
#: includes/core/class-builtin.php:1813
|
6432 |
msgid "Holy See (Vatican City State)"
|
6433 |
msgstr ""
|
6434 |
|
6435 |
+
#: includes/core/class-builtin.php:1814
|
6436 |
msgid "Honduras"
|
6437 |
msgstr ""
|
6438 |
|
6439 |
+
#: includes/core/class-builtin.php:1815
|
6440 |
msgid "Hong Kong"
|
6441 |
msgstr ""
|
6442 |
|
6443 |
+
#: includes/core/class-builtin.php:1816
|
6444 |
msgid "Hungary"
|
6445 |
msgstr ""
|
6446 |
|
6447 |
+
#: includes/core/class-builtin.php:1817
|
6448 |
msgid "Iceland"
|
6449 |
msgstr ""
|
6450 |
|
6451 |
+
#: includes/core/class-builtin.php:1818
|
6452 |
msgid "India"
|
6453 |
msgstr ""
|
6454 |
|
6455 |
+
#: includes/core/class-builtin.php:1819
|
6456 |
msgid "Indonesia"
|
6457 |
msgstr ""
|
6458 |
|
6459 |
+
#: includes/core/class-builtin.php:1820
|
6460 |
msgid "Iran, Islamic Republic of"
|
6461 |
msgstr ""
|
6462 |
|
6463 |
+
#: includes/core/class-builtin.php:1821
|
6464 |
msgid "Iraq"
|
6465 |
msgstr ""
|
6466 |
|
6467 |
+
#: includes/core/class-builtin.php:1822
|
6468 |
msgid "Ireland"
|
6469 |
msgstr ""
|
6470 |
|
6471 |
+
#: includes/core/class-builtin.php:1823
|
6472 |
msgid "Isle of Man"
|
6473 |
msgstr ""
|
6474 |
|
6475 |
+
#: includes/core/class-builtin.php:1824
|
6476 |
msgid "Israel"
|
6477 |
msgstr ""
|
6478 |
|
6479 |
+
#: includes/core/class-builtin.php:1825
|
6480 |
msgid "Italy"
|
6481 |
msgstr ""
|
6482 |
|
6483 |
+
#: includes/core/class-builtin.php:1826
|
6484 |
msgid "Jamaica"
|
6485 |
msgstr ""
|
6486 |
|
6487 |
+
#: includes/core/class-builtin.php:1827
|
6488 |
msgid "Japan"
|
6489 |
msgstr ""
|
6490 |
|
6491 |
+
#: includes/core/class-builtin.php:1828
|
6492 |
msgid "Jersey"
|
6493 |
msgstr ""
|
6494 |
|
6495 |
+
#: includes/core/class-builtin.php:1829
|
6496 |
msgid "Jordan"
|
6497 |
msgstr ""
|
6498 |
|
6499 |
+
#: includes/core/class-builtin.php:1830
|
6500 |
msgid "Kazakhstan"
|
6501 |
msgstr ""
|
6502 |
|
6503 |
+
#: includes/core/class-builtin.php:1831
|
6504 |
msgid "Kenya"
|
6505 |
msgstr ""
|
6506 |
|
6507 |
+
#: includes/core/class-builtin.php:1832
|
6508 |
msgid "Kiribati"
|
6509 |
msgstr ""
|
6510 |
|
6511 |
+
#: includes/core/class-builtin.php:1833
|
6512 |
msgid "Korea, Democratic People's Republic of"
|
6513 |
msgstr ""
|
6514 |
|
6515 |
+
#: includes/core/class-builtin.php:1834
|
6516 |
msgid "Korea, Republic of"
|
6517 |
msgstr ""
|
6518 |
|
6519 |
+
#: includes/core/class-builtin.php:1835
|
6520 |
msgid "Kuwait"
|
6521 |
msgstr ""
|
6522 |
|
6523 |
+
#: includes/core/class-builtin.php:1836
|
6524 |
msgid "Kyrgyzstan"
|
6525 |
msgstr ""
|
6526 |
|
6527 |
+
#: includes/core/class-builtin.php:1837
|
6528 |
msgid "Lao People's Democratic Republic"
|
6529 |
msgstr ""
|
6530 |
|
6531 |
+
#: includes/core/class-builtin.php:1838
|
6532 |
msgid "Latvia"
|
6533 |
msgstr ""
|
6534 |
|
6535 |
+
#: includes/core/class-builtin.php:1839
|
6536 |
msgid "Lebanon"
|
6537 |
msgstr ""
|
6538 |
|
6539 |
+
#: includes/core/class-builtin.php:1840
|
6540 |
msgid "Lesotho"
|
6541 |
msgstr ""
|
6542 |
|
6543 |
+
#: includes/core/class-builtin.php:1841
|
6544 |
msgid "Liberia"
|
6545 |
msgstr ""
|
6546 |
|
6547 |
+
#: includes/core/class-builtin.php:1842
|
6548 |
msgid "Libyan Arab Jamahiriya"
|
6549 |
msgstr ""
|
6550 |
|
6551 |
+
#: includes/core/class-builtin.php:1843
|
6552 |
msgid "Liechtenstein"
|
6553 |
msgstr ""
|
6554 |
|
6555 |
+
#: includes/core/class-builtin.php:1844
|
6556 |
msgid "Lithuania"
|
6557 |
msgstr ""
|
6558 |
|
6559 |
+
#: includes/core/class-builtin.php:1845
|
6560 |
msgid "Luxembourg"
|
6561 |
msgstr ""
|
6562 |
|
6563 |
+
#: includes/core/class-builtin.php:1846
|
6564 |
msgid "Macao"
|
6565 |
msgstr ""
|
6566 |
|
6567 |
+
#: includes/core/class-builtin.php:1847
|
6568 |
msgid "Macedonia, the former Yugoslav Republic of"
|
6569 |
msgstr ""
|
6570 |
|
6571 |
+
#: includes/core/class-builtin.php:1848
|
6572 |
msgid "Madagascar"
|
6573 |
msgstr ""
|
6574 |
|
6575 |
+
#: includes/core/class-builtin.php:1849
|
6576 |
msgid "Malawi"
|
6577 |
msgstr ""
|
6578 |
|
6579 |
+
#: includes/core/class-builtin.php:1850
|
6580 |
msgid "Malaysia"
|
6581 |
msgstr ""
|
6582 |
|
6583 |
+
#: includes/core/class-builtin.php:1851
|
6584 |
msgid "Maldives"
|
6585 |
msgstr ""
|
6586 |
|
6587 |
+
#: includes/core/class-builtin.php:1852
|
6588 |
msgid "Mali"
|
6589 |
msgstr ""
|
6590 |
|
6591 |
+
#: includes/core/class-builtin.php:1853
|
6592 |
msgid "Malta"
|
6593 |
msgstr ""
|
6594 |
|
6595 |
+
#: includes/core/class-builtin.php:1854
|
6596 |
msgid "Marshall Islands"
|
6597 |
msgstr ""
|
6598 |
|
6599 |
+
#: includes/core/class-builtin.php:1855
|
6600 |
msgid "Martinique"
|
6601 |
msgstr ""
|
6602 |
|
6603 |
+
#: includes/core/class-builtin.php:1856
|
6604 |
msgid "Mauritania"
|
6605 |
msgstr ""
|
6606 |
|
6607 |
+
#: includes/core/class-builtin.php:1857
|
6608 |
msgid "Mauritius"
|
6609 |
msgstr ""
|
6610 |
|
6611 |
+
#: includes/core/class-builtin.php:1858
|
6612 |
msgid "Mayotte"
|
6613 |
msgstr ""
|
6614 |
|
6615 |
+
#: includes/core/class-builtin.php:1859
|
6616 |
msgid "Mexico"
|
6617 |
msgstr ""
|
6618 |
|
6619 |
+
#: includes/core/class-builtin.php:1860
|
6620 |
msgid "Micronesia, Federated States of"
|
6621 |
msgstr ""
|
6622 |
|
6623 |
+
#: includes/core/class-builtin.php:1861
|
6624 |
msgid "Moldova, Republic of"
|
6625 |
msgstr ""
|
6626 |
|
6627 |
+
#: includes/core/class-builtin.php:1862
|
6628 |
msgid "Monaco"
|
6629 |
msgstr ""
|
6630 |
|
6631 |
+
#: includes/core/class-builtin.php:1863
|
6632 |
msgid "Mongolia"
|
6633 |
msgstr ""
|
6634 |
|
6635 |
+
#: includes/core/class-builtin.php:1864
|
6636 |
msgid "Montenegro"
|
6637 |
msgstr ""
|
6638 |
|
6639 |
+
#: includes/core/class-builtin.php:1865
|
6640 |
msgid "Montserrat"
|
6641 |
msgstr ""
|
6642 |
|
6643 |
+
#: includes/core/class-builtin.php:1866
|
6644 |
msgid "Morocco"
|
6645 |
msgstr ""
|
6646 |
|
6647 |
+
#: includes/core/class-builtin.php:1867
|
6648 |
msgid "Mozambique"
|
6649 |
msgstr ""
|
6650 |
|
6651 |
+
#: includes/core/class-builtin.php:1868
|
6652 |
msgid "Myanmar"
|
6653 |
msgstr ""
|
6654 |
|
6655 |
+
#: includes/core/class-builtin.php:1869
|
6656 |
msgid "Namibia"
|
6657 |
msgstr ""
|
6658 |
|
6659 |
+
#: includes/core/class-builtin.php:1871
|
6660 |
msgid "Nepal"
|
6661 |
msgstr ""
|
6662 |
|
6663 |
+
#: includes/core/class-builtin.php:1872
|
6664 |
msgid "Netherlands"
|
6665 |
msgstr ""
|
6666 |
|
6667 |
+
#: includes/core/class-builtin.php:1873
|
6668 |
msgid "Netherlands Antilles"
|
6669 |
msgstr ""
|
6670 |
|
6671 |
+
#: includes/core/class-builtin.php:1874
|
6672 |
msgid "New Caledonia"
|
6673 |
msgstr ""
|
6674 |
|
6675 |
+
#: includes/core/class-builtin.php:1875
|
6676 |
msgid "New Zealand"
|
6677 |
msgstr ""
|
6678 |
|
6679 |
+
#: includes/core/class-builtin.php:1876
|
6680 |
msgid "Nicaragua"
|
6681 |
msgstr ""
|
6682 |
|
6683 |
+
#: includes/core/class-builtin.php:1877
|
6684 |
msgid "Niger"
|
6685 |
msgstr ""
|
6686 |
|
6687 |
+
#: includes/core/class-builtin.php:1878
|
6688 |
msgid "Nigeria"
|
6689 |
msgstr ""
|
6690 |
|
6691 |
+
#: includes/core/class-builtin.php:1879
|
6692 |
msgid "Niue"
|
6693 |
msgstr ""
|
6694 |
|
6695 |
+
#: includes/core/class-builtin.php:1880
|
6696 |
msgid "Norfolk Island"
|
6697 |
msgstr ""
|
6698 |
|
6699 |
+
#: includes/core/class-builtin.php:1881
|
6700 |
msgid "Northern Mariana Islands"
|
6701 |
msgstr ""
|
6702 |
|
6703 |
+
#: includes/core/class-builtin.php:1882
|
6704 |
msgid "Norway"
|
6705 |
msgstr ""
|
6706 |
|
6707 |
+
#: includes/core/class-builtin.php:1883
|
6708 |
msgid "Oman"
|
6709 |
msgstr ""
|
6710 |
|
6711 |
+
#: includes/core/class-builtin.php:1884
|
6712 |
msgid "Pakistan"
|
6713 |
msgstr ""
|
6714 |
|
6715 |
+
#: includes/core/class-builtin.php:1885
|
6716 |
msgid "Palau"
|
6717 |
msgstr ""
|
6718 |
|
6719 |
+
#: includes/core/class-builtin.php:1886
|
6720 |
msgid "Palestine"
|
6721 |
msgstr ""
|
6722 |
|
6723 |
+
#: includes/core/class-builtin.php:1887
|
6724 |
msgid "Panama"
|
6725 |
msgstr ""
|
6726 |
|
6727 |
+
#: includes/core/class-builtin.php:1888
|
6728 |
msgid "Papua New Guinea"
|
6729 |
msgstr ""
|
6730 |
|
6731 |
+
#: includes/core/class-builtin.php:1889
|
6732 |
msgid "Paraguay"
|
6733 |
msgstr ""
|
6734 |
|
6735 |
+
#: includes/core/class-builtin.php:1890
|
6736 |
msgid "Peru"
|
6737 |
msgstr ""
|
6738 |
|
6739 |
+
#: includes/core/class-builtin.php:1891
|
6740 |
msgid "Philippines"
|
6741 |
msgstr ""
|
6742 |
|
6743 |
+
#: includes/core/class-builtin.php:1892
|
6744 |
msgid "Pitcairn"
|
6745 |
msgstr ""
|
6746 |
|
6747 |
+
#: includes/core/class-builtin.php:1893
|
6748 |
msgid "Poland"
|
6749 |
msgstr ""
|
6750 |
|
6751 |
+
#: includes/core/class-builtin.php:1894
|
6752 |
msgid "Portugal"
|
6753 |
msgstr ""
|
6754 |
|
6755 |
+
#: includes/core/class-builtin.php:1895
|
6756 |
msgid "Puerto Rico"
|
6757 |
msgstr ""
|
6758 |
|
6759 |
+
#: includes/core/class-builtin.php:1896
|
6760 |
msgid "Qatar"
|
6761 |
msgstr ""
|
6762 |
|
6763 |
+
#: includes/core/class-builtin.php:1897
|
6764 |
msgid "Réunion"
|
6765 |
msgstr ""
|
6766 |
|
6767 |
+
#: includes/core/class-builtin.php:1898
|
6768 |
msgid "Romania"
|
6769 |
msgstr ""
|
6770 |
|
6771 |
+
#: includes/core/class-builtin.php:1899
|
6772 |
msgid "Russian Federation"
|
6773 |
msgstr ""
|
6774 |
|
6775 |
+
#: includes/core/class-builtin.php:1900
|
6776 |
msgid "Rwanda"
|
6777 |
msgstr ""
|
6778 |
|
6779 |
+
#: includes/core/class-builtin.php:1901
|
6780 |
msgid "Saint Barthélemy"
|
6781 |
msgstr ""
|
6782 |
|
6783 |
+
#: includes/core/class-builtin.php:1902
|
6784 |
msgid "Saint Helena"
|
6785 |
msgstr ""
|
6786 |
|
6787 |
+
#: includes/core/class-builtin.php:1903
|
6788 |
msgid "Saint Kitts and Nevis"
|
6789 |
msgstr ""
|
6790 |
|
6791 |
+
#: includes/core/class-builtin.php:1904
|
6792 |
msgid "Saint Lucia"
|
6793 |
msgstr ""
|
6794 |
|
6795 |
+
#: includes/core/class-builtin.php:1905
|
6796 |
msgid "Saint Martin (French part)"
|
6797 |
msgstr ""
|
6798 |
|
6799 |
+
#: includes/core/class-builtin.php:1906
|
6800 |
msgid "Saint Pierre and Miquelon"
|
6801 |
msgstr ""
|
6802 |
|
6803 |
+
#: includes/core/class-builtin.php:1907
|
6804 |
msgid "Saint Vincent and the Grenadines"
|
6805 |
msgstr ""
|
6806 |
|
6807 |
+
#: includes/core/class-builtin.php:1908
|
6808 |
msgid "Samoa"
|
6809 |
msgstr ""
|
6810 |
|
6811 |
+
#: includes/core/class-builtin.php:1909
|
6812 |
msgid "San Marino"
|
6813 |
msgstr ""
|
6814 |
|
6815 |
+
#: includes/core/class-builtin.php:1910
|
6816 |
msgid "Sao Tome and Principe"
|
6817 |
msgstr ""
|
6818 |
|
6819 |
+
#: includes/core/class-builtin.php:1911
|
6820 |
msgid "Saudi Arabia"
|
6821 |
msgstr ""
|
6822 |
|
6823 |
+
#: includes/core/class-builtin.php:1912
|
6824 |
msgid "Senegal"
|
6825 |
msgstr ""
|
6826 |
|
6827 |
+
#: includes/core/class-builtin.php:1913
|
6828 |
msgid "Serbia"
|
6829 |
msgstr ""
|
6830 |
|
6831 |
+
#: includes/core/class-builtin.php:1914
|
6832 |
msgid "Seychelles"
|
6833 |
msgstr ""
|
6834 |
|
6835 |
+
#: includes/core/class-builtin.php:1915
|
6836 |
msgid "Sierra Leone"
|
6837 |
msgstr ""
|
6838 |
|
6839 |
+
#: includes/core/class-builtin.php:1916
|
6840 |
msgid "Singapore"
|
6841 |
msgstr ""
|
6842 |
|
6843 |
+
#: includes/core/class-builtin.php:1917
|
6844 |
msgid "Slovakia"
|
6845 |
msgstr ""
|
6846 |
|
6847 |
+
#: includes/core/class-builtin.php:1918
|
6848 |
msgid "Slovenia"
|
6849 |
msgstr ""
|
6850 |
|
6851 |
+
#: includes/core/class-builtin.php:1919
|
6852 |
msgid "Solomon Islands"
|
6853 |
msgstr ""
|
6854 |
|
6855 |
+
#: includes/core/class-builtin.php:1920
|
6856 |
msgid "Somalia"
|
6857 |
msgstr ""
|
6858 |
|
6859 |
+
#: includes/core/class-builtin.php:1921
|
6860 |
msgid "South Africa"
|
6861 |
msgstr ""
|
6862 |
|
6863 |
+
#: includes/core/class-builtin.php:1922
|
6864 |
msgid "South Georgia and the South Sandwich Islands"
|
6865 |
msgstr ""
|
6866 |
|
6867 |
+
#: includes/core/class-builtin.php:1923
|
6868 |
msgid "South Sudan"
|
6869 |
msgstr ""
|
6870 |
|
6871 |
+
#: includes/core/class-builtin.php:1924
|
6872 |
msgid "Spain"
|
6873 |
msgstr ""
|
6874 |
|
6875 |
+
#: includes/core/class-builtin.php:1925
|
6876 |
msgid "Sri Lanka"
|
6877 |
msgstr ""
|
6878 |
|
6879 |
+
#: includes/core/class-builtin.php:1926
|
6880 |
msgid "Sudan"
|
6881 |
msgstr ""
|
6882 |
|
6883 |
+
#: includes/core/class-builtin.php:1927
|
6884 |
msgid "Suriname"
|
6885 |
msgstr ""
|
6886 |
|
6887 |
+
#: includes/core/class-builtin.php:1928
|
6888 |
msgid "Svalbard and Jan Mayen"
|
6889 |
msgstr ""
|
6890 |
|
6891 |
+
#: includes/core/class-builtin.php:1929
|
6892 |
msgid "Swaziland"
|
6893 |
msgstr ""
|
6894 |
|
6895 |
+
#: includes/core/class-builtin.php:1930
|
6896 |
msgid "Sweden"
|
6897 |
msgstr ""
|
6898 |
|
6899 |
+
#: includes/core/class-builtin.php:1931
|
6900 |
msgid "Switzerland"
|
6901 |
msgstr ""
|
6902 |
|
6903 |
+
#: includes/core/class-builtin.php:1932
|
6904 |
msgid "Syrian Arab Republic"
|
6905 |
msgstr ""
|
6906 |
|
6907 |
+
#: includes/core/class-builtin.php:1933
|
6908 |
msgid "Taiwan, Province of China"
|
6909 |
msgstr ""
|
6910 |
|
6911 |
+
#: includes/core/class-builtin.php:1934
|
6912 |
msgid "Tajikistan"
|
6913 |
msgstr ""
|
6914 |
|
6915 |
+
#: includes/core/class-builtin.php:1935
|
6916 |
msgid "Tanzania, United Republic of"
|
6917 |
msgstr ""
|
6918 |
|
6919 |
+
#: includes/core/class-builtin.php:1936
|
6920 |
msgid "Thailand"
|
6921 |
msgstr ""
|
6922 |
|
6923 |
+
#: includes/core/class-builtin.php:1937
|
6924 |
msgid "Timor-Leste"
|
6925 |
msgstr ""
|
6926 |
|
6927 |
+
#: includes/core/class-builtin.php:1938
|
6928 |
msgid "Togo"
|
6929 |
msgstr ""
|
6930 |
|
6931 |
+
#: includes/core/class-builtin.php:1939
|
6932 |
msgid "Tokelau"
|
6933 |
msgstr ""
|
6934 |
|
6935 |
+
#: includes/core/class-builtin.php:1941
|
6936 |
msgid "Trinidad and Tobago"
|
6937 |
msgstr ""
|
6938 |
|
6939 |
+
#: includes/core/class-builtin.php:1942
|
6940 |
msgid "Tunisia"
|
6941 |
msgstr ""
|
6942 |
|
6943 |
+
#: includes/core/class-builtin.php:1943
|
6944 |
msgid "Turkey"
|
6945 |
msgstr ""
|
6946 |
|
6947 |
+
#: includes/core/class-builtin.php:1944
|
6948 |
msgid "Turkmenistan"
|
6949 |
msgstr ""
|
6950 |
|
6951 |
+
#: includes/core/class-builtin.php:1945
|
6952 |
msgid "Turks and Caicos Islands"
|
6953 |
msgstr ""
|
6954 |
|
6955 |
+
#: includes/core/class-builtin.php:1946
|
6956 |
msgid "Tuvalu"
|
6957 |
msgstr ""
|
6958 |
|
6959 |
+
#: includes/core/class-builtin.php:1947
|
6960 |
msgid "Uganda"
|
6961 |
msgstr ""
|
6962 |
|
6963 |
+
#: includes/core/class-builtin.php:1948
|
6964 |
msgid "Ukraine"
|
6965 |
msgstr ""
|
6966 |
|
6967 |
+
#: includes/core/class-builtin.php:1949
|
6968 |
msgid "United Arab Emirates"
|
6969 |
msgstr ""
|
6970 |
|
6971 |
+
#: includes/core/class-builtin.php:1950
|
6972 |
msgid "United Kingdom"
|
6973 |
msgstr ""
|
6974 |
|
6975 |
+
#: includes/core/class-builtin.php:1951
|
6976 |
msgid "United States"
|
6977 |
msgstr ""
|
6978 |
|
6979 |
+
#: includes/core/class-builtin.php:1952
|
6980 |
msgid "United States Minor Outlying Islands"
|
6981 |
msgstr ""
|
6982 |
|
6983 |
+
#: includes/core/class-builtin.php:1953
|
6984 |
msgid "Uruguay"
|
6985 |
msgstr ""
|
6986 |
|
6987 |
+
#: includes/core/class-builtin.php:1954
|
6988 |
msgid "Uzbekistan"
|
6989 |
msgstr ""
|
6990 |
|
6991 |
+
#: includes/core/class-builtin.php:1955
|
6992 |
msgid "Vanuatu"
|
6993 |
msgstr ""
|
6994 |
|
6995 |
+
#: includes/core/class-builtin.php:1956
|
6996 |
msgid "Venezuela, Bolivarian Republic of"
|
6997 |
msgstr ""
|
6998 |
|
6999 |
+
#: includes/core/class-builtin.php:1957
|
7000 |
msgid "Viet Nam"
|
7001 |
msgstr ""
|
7002 |
|
7003 |
+
#: includes/core/class-builtin.php:1958
|
7004 |
msgid "Virgin Islands, British"
|
7005 |
msgstr ""
|
7006 |
|
7007 |
+
#: includes/core/class-builtin.php:1959
|
7008 |
msgid "Virgin Islands, U.S."
|
7009 |
msgstr ""
|
7010 |
|
7011 |
+
#: includes/core/class-builtin.php:1960
|
7012 |
msgid "Wallis and Futuna"
|
7013 |
msgstr ""
|
7014 |
|
7015 |
+
#: includes/core/class-builtin.php:1961
|
7016 |
msgid "Western Sahara"
|
7017 |
msgstr ""
|
7018 |
|
7019 |
+
#: includes/core/class-builtin.php:1962
|
7020 |
msgid "Yemen"
|
7021 |
msgstr ""
|
7022 |
|
7023 |
+
#: includes/core/class-builtin.php:1963
|
7024 |
msgid "Zambia"
|
7025 |
msgstr ""
|
7026 |
|
7027 |
+
#: includes/core/class-builtin.php:1964
|
7028 |
msgid "Zimbabwe"
|
7029 |
msgstr ""
|
7030 |
|
7120 |
msgid "Less than 1 year old"
|
7121 |
msgstr ""
|
7122 |
|
7123 |
+
#: includes/core/class-fields.php:1494
|
7124 |
msgid "Custom Field"
|
7125 |
msgstr ""
|
7126 |
|
7127 |
+
#: includes/core/class-fields.php:1847
|
7128 |
msgid "Please upload a valid image!"
|
7129 |
msgstr ""
|
7130 |
|
7131 |
+
#: includes/core/class-fields.php:1861
|
7132 |
msgid "Sorry this is not a valid image."
|
7133 |
msgstr ""
|
7134 |
|
7135 |
+
#: includes/core/class-fields.php:1864
|
7136 |
msgid "This image is too large!"
|
7137 |
msgstr ""
|
7138 |
|
7139 |
+
#: includes/core/class-fields.php:1867
|
7140 |
msgid "This image is too small!"
|
7141 |
msgstr ""
|
7142 |
|
7143 |
+
#: includes/core/class-fields.php:1870
|
7144 |
msgid "You can only upload one image"
|
7145 |
msgstr ""
|
7146 |
|
7147 |
+
#: includes/core/class-fields.php:1902
|
7148 |
msgid "Sorry this is not a valid file."
|
7149 |
msgstr ""
|
7150 |
|
7151 |
+
#: includes/core/class-fields.php:1905
|
7152 |
msgid "This file is too large!"
|
7153 |
msgstr ""
|
7154 |
|
7155 |
+
#: includes/core/class-fields.php:1908
|
7156 |
msgid "This file is too small!"
|
7157 |
msgstr ""
|
7158 |
|
7159 |
+
#: includes/core/class-fields.php:1911
|
7160 |
msgid "You can only upload one file"
|
7161 |
msgstr ""
|
7162 |
|
7163 |
+
#: includes/core/class-fields.php:2477
|
7164 |
msgid "Current Password"
|
7165 |
msgstr ""
|
7166 |
|
7167 |
+
#: includes/core/class-fields.php:2508
|
7168 |
msgid "New Password"
|
7169 |
msgstr ""
|
7170 |
|
7171 |
+
#: includes/core/class-fields.php:2551
|
7172 |
+
#: includes/core/class-fields.php:2570
|
7173 |
+
#: includes/core/class-fields.php:2572
|
7174 |
msgid "Confirm %s"
|
7175 |
msgstr ""
|
7176 |
|
7177 |
+
#: includes/core/class-fields.php:2817
|
7178 |
msgid "Upload Photo"
|
7179 |
msgstr ""
|
7180 |
|
7181 |
+
#: includes/core/class-fields.php:2844
|
7182 |
+
#: includes/core/class-fields.php:2877
|
7183 |
+
#: includes/core/um-actions-profile.php:1075
|
7184 |
msgid "Change photo"
|
7185 |
msgstr ""
|
7186 |
|
7187 |
+
#: includes/core/class-fields.php:2877
|
7188 |
+
#: includes/core/class-fields.php:2984
|
7189 |
msgid "Processing..."
|
7190 |
msgstr ""
|
7191 |
|
7192 |
+
#: includes/core/class-fields.php:2902
|
7193 |
msgid "Upload File"
|
7194 |
msgstr ""
|
7195 |
|
7196 |
+
#: includes/core/class-fields.php:2946
|
7197 |
#: includes/core/um-filters-fields.php:330
|
7198 |
msgid "This file has been removed."
|
7199 |
msgstr ""
|
7200 |
|
7201 |
+
#: includes/core/class-fields.php:2950
|
7202 |
msgid "Change file"
|
7203 |
msgstr ""
|
7204 |
|
7205 |
+
#: includes/core/class-fields.php:2984
|
7206 |
msgid "Save"
|
7207 |
msgstr ""
|
7208 |
|
7209 |
+
#: includes/core/class-fields.php:4571
|
7210 |
msgid "Your profile is looking a little empty. Why not <a href=\"%s\">add</a> some information!"
|
7211 |
msgstr ""
|
7212 |
|
7213 |
+
#: includes/core/class-fields.php:4573
|
7214 |
msgid "This user has not added any information to their profile yet."
|
7215 |
msgstr ""
|
7216 |
|
7268 |
msgid "Wrong callback."
|
7269 |
msgstr ""
|
7270 |
|
7271 |
+
#: includes/core/class-form.php:451
|
7272 |
#: includes/core/class-password.php:441
|
7273 |
#: includes/core/class-password.php:519
|
7274 |
msgid "Hello, spam bot!"
|
7360 |
|
7361 |
#: includes/core/class-member-directory.php:2245
|
7362 |
#: includes/core/class-member-directory.php:2289
|
7363 |
+
#: includes/core/um-actions-profile.php:1393
|
7364 |
+
#: includes/core/um-actions-profile.php:1424
|
7365 |
msgid "Edit Profile"
|
7366 |
msgstr ""
|
7367 |
|
7368 |
#: includes/core/class-member-directory.php:2295
|
7369 |
+
#: includes/core/um-actions-profile.php:1425
|
7370 |
msgid "My Account"
|
7371 |
msgstr ""
|
7372 |
|
7384 |
|
7385 |
#: includes/core/class-password.php:543
|
7386 |
#: includes/core/um-actions-account.php:67
|
7387 |
+
#: includes/core/um-actions-register.php:277
|
7388 |
msgid "Passwords may not contain the character \"\\\"."
|
7389 |
msgstr ""
|
7390 |
|
7466 |
msgid "The \"unassigned\" $status has been removed. Use `UM()->setup()->set_default_user_status()` for setting up default user account status."
|
7467 |
msgstr ""
|
7468 |
|
7469 |
+
#: includes/core/class-shortcodes.php:367
|
7470 |
msgid "This content has been restricted to logged in users only. Please <a href=\"{login_referrer}\">login</a> to view this content."
|
7471 |
msgstr ""
|
7472 |
|
7473 |
+
#: includes/core/class-shortcodes.php:690
|
7474 |
msgid "You are already registered"
|
7475 |
msgstr ""
|
7476 |
|
7477 |
+
#: includes/core/class-shortcodes.php:948
|
7478 |
msgid "Default Template"
|
7479 |
msgstr ""
|
7480 |
|
7491 |
msgstr ""
|
7492 |
|
7493 |
#: includes/core/class-uploader.php:794
|
|
|
7494 |
msgid "Your photo is too small. It must be at least %spx wide."
|
7495 |
msgstr ""
|
7496 |
|
7497 |
+
#: includes/core/class-uploader.php:796
|
7498 |
+
msgid "Your photo is too small. It must be at least %spx high."
|
7499 |
+
msgstr ""
|
7500 |
+
|
7501 |
#: includes/core/class-uploader.php:849
|
7502 |
msgid "This file type is not recognized."
|
7503 |
msgstr ""
|
7995 |
msgid "You are not allowed to edit this user."
|
7996 |
msgstr ""
|
7997 |
|
7998 |
+
#: includes/core/um-actions-profile.php:357
|
7999 |
msgid "Your choosed %s"
|
8000 |
msgstr ""
|
8001 |
|
8002 |
+
#: includes/core/um-actions-profile.php:766
|
8003 |
+
#: includes/core/um-actions-profile.php:778
|
8004 |
msgid "Profile photo"
|
8005 |
msgstr ""
|
8006 |
|
8007 |
+
#: includes/core/um-actions-profile.php:839
|
8008 |
+
#: includes/core/um-actions-profile.php:855
|
8009 |
+
#: includes/core/um-actions-profile.php:926
|
8010 |
msgid "Upload a cover photo"
|
8011 |
msgstr ""
|
8012 |
|
8013 |
+
#: includes/core/um-actions-profile.php:839
|
8014 |
msgid "Change cover photo"
|
8015 |
msgstr ""
|
8016 |
|
8017 |
+
#: includes/core/um-actions-profile.php:1043
|
8018 |
msgid "Upload photo"
|
8019 |
msgstr ""
|
8020 |
|
8021 |
+
#: includes/core/um-actions-profile.php:1076
|
8022 |
msgid "Remove photo"
|
8023 |
msgstr ""
|
8024 |
|
8025 |
+
#: includes/core/um-actions-profile.php:1239
|
8026 |
msgid "Tell us a bit about yourself..."
|
8027 |
msgstr ""
|
8028 |
|
8029 |
+
#: includes/core/um-actions-profile.php:1254
|
8030 |
msgid "This user account status is %s"
|
8031 |
msgstr ""
|
8032 |
|
readme.txt
CHANGED
@@ -7,7 +7,7 @@ Tags: community, member, membership, user-profile, user-registration
|
|
7 |
Requires PHP: 5.6
|
8 |
Requires at least: 5.0
|
9 |
Tested up to: 6.0
|
10 |
-
Stable tag: 2.5.
|
11 |
License: GNU Version 2 or Any Later Version
|
12 |
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
|
13 |
|
@@ -163,6 +163,31 @@ No, you do not need to use our plugin’s login or registration pages and can us
|
|
163 |
* To learn more about version 2.1 please see this [docs](https://docs.ultimatemember.com/article/1512-upgrade-2-1-0)
|
164 |
* UM2.1+ is a significant update to the Member Directories' code base from 2.0.x. Please make sure you take a full-site backup with restore point before updating the plugin
|
165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
= 2.5.0: August 17, 2022 =
|
167 |
|
168 |
* Enhancements:
|
7 |
Requires PHP: 5.6
|
8 |
Requires at least: 5.0
|
9 |
Tested up to: 6.0
|
10 |
+
Stable tag: 2.5.1
|
11 |
License: GNU Version 2 or Any Later Version
|
12 |
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
|
13 |
|
163 |
* To learn more about version 2.1 please see this [docs](https://docs.ultimatemember.com/article/1512-upgrade-2-1-0)
|
164 |
* UM2.1+ is a significant update to the Member Directories' code base from 2.0.x. Please make sure you take a full-site backup with restore point before updating the plugin
|
165 |
|
166 |
+
= 2.5.1: October 26, 2022 =
|
167 |
+
|
168 |
+
* Enhancements:
|
169 |
+
|
170 |
+
- Added: Custom fields callbacks blacklist. Use `um_dropdown_options_source_blacklist` filter for adding your custom functions to the custom callbacks blacklist. By default there are all PHP internal functions.
|
171 |
+
|
172 |
+
* Bugfixes:
|
173 |
+
|
174 |
+
- Fixed: Posts' restriction that is based on term restriction settings
|
175 |
+
- Fixed: Issue with class name in checkbox and radio. Class name being 'activeright' instead of 'active right'
|
176 |
+
- Fixed: Admin upgrade scripts and upgrades pack validation
|
177 |
+
- Fixed: Directory traversal vulnerabilities
|
178 |
+
- Fixed: Destroying user sessions after changing "Approved" status to something else (e.g. deactivated)
|
179 |
+
- Fixed: Conflict when `wp_get_current_user()` not exists. Transferred restriction settings callbacks to `plugins_loaded` hook
|
180 |
+
- Fixed: Restriction post displaying when 404 is enabled and old restiction logic isn't active
|
181 |
+
- Fixed: PHP warning when nav menu is empty
|
182 |
+
- Fixed: Disable auto-login after user is registered by Administrator and UM Registration form
|
183 |
+
- Fixed: Some typos errors
|
184 |
+
- Fixed: Using an apostrophe symbols in emails for registration and login both
|
185 |
+
- Fixed: Sanitizing YouTube links. Applying both https://youtu.be/xxxxxxx and https://youtube.com/xxxxxxx links
|
186 |
+
|
187 |
+
* Deprecated:
|
188 |
+
|
189 |
+
- Removed: Outdated setting using in code (force_display_name_capitlized). Moved the functionality to extended [repo](https://github.com/ultimatemember/Extended/tree/main/um-capitalize-name#readme)
|
190 |
+
|
191 |
= 2.5.0: August 17, 2022 =
|
192 |
|
193 |
* Enhancements:
|
ultimate-member.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Ultimate Member
|
4 |
Plugin URI: http://ultimatemember.com/
|
5 |
Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress
|
6 |
-
Version: 2.5.
|
7 |
Author: Ultimate Member
|
8 |
Author URI: http://ultimatemember.com/
|
9 |
Text Domain: ultimate-member
|
3 |
Plugin Name: Ultimate Member
|
4 |
Plugin URI: http://ultimatemember.com/
|
5 |
Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress
|
6 |
+
Version: 2.5.1
|
7 |
Author: Ultimate Member
|
8 |
Author URI: http://ultimatemember.com/
|
9 |
Text Domain: ultimate-member
|