Ultimate Member – User Profile & Membership Plugin - Version 2.2.0-rc.1

Version Description

Download this release

Release Info

Developer nsinelnikov
Plugin Icon 128x128 Ultimate Member – User Profile & Membership Plugin
Version 2.2.0-rc.1
Comparing to
See all releases

Code changes from version 2.1.21 to 2.2.0-rc.1

Files changed (69) hide show
  1. includes/admin/assets/js/um-admin-forms.js +2 -3
  2. includes/admin/class-admin-functions.php +12 -10
  3. includes/admin/class-admin.php +1956 -461
  4. includes/admin/core/class-admin-builder.php +1223 -1211
  5. includes/admin/core/class-admin-dragdrop.php +25 -20
  6. includes/admin/core/class-admin-enqueue.php +689 -684
  7. includes/admin/core/class-admin-forms.php +4 -3
  8. includes/admin/core/class-admin-menu.php +2 -2
  9. includes/admin/core/class-admin-metabox.php +34 -11
  10. includes/admin/core/class-admin-navmenu.php +4 -4
  11. includes/admin/core/class-admin-notices.php +3 -3
  12. includes/admin/core/class-admin-settings.php +1532 -1113
  13. includes/admin/core/class-admin-users.php +24 -25
  14. includes/admin/core/list-tables/roles-list-table.php +41 -34
  15. includes/admin/core/packages/2.0-beta1/functions.php +16 -16
  16. includes/admin/core/packages/2.1.3-beta3/functions.php +4 -4
  17. includes/admin/templates/directory/appearance.php +20 -15
  18. includes/admin/templates/directory/general.php +104 -96
  19. includes/admin/templates/directory/pagination.php +67 -63
  20. includes/admin/templates/directory/profile.php +112 -109
  21. includes/admin/templates/directory/search.php +91 -88
  22. includes/admin/templates/directory/shortcode.php +4 -2
  23. includes/admin/templates/directory/sorting.php +56 -53
  24. includes/admin/templates/form/builder.php +8 -7
  25. includes/admin/templates/form/login_customize.php +97 -93
  26. includes/admin/templates/form/login_settings.php +32 -28
  27. includes/admin/templates/form/mode.php +17 -9
  28. includes/admin/templates/form/profile_customize.php +197 -194
  29. includes/admin/templates/form/profile_settings.php +31 -26
  30. includes/admin/templates/form/register_customize.php +91 -87
  31. includes/admin/templates/form/register_gdpr.php +68 -66
  32. includes/admin/templates/role/publish.php +20 -14
  33. includes/admin/templates/role/role-edit.php +50 -171
  34. includes/admin/templates/role/wp-capabilities.php +3 -2
  35. includes/class-functions.php +2 -2
  36. includes/core/class-access.php +136 -6
  37. includes/core/class-account.php +3 -1
  38. includes/core/class-builtin.php +1915 -1890
  39. includes/core/class-fields.php +12 -9
  40. includes/core/class-files.php +17 -15
  41. includes/core/class-form.php +749 -667
  42. includes/core/class-logout.php +4 -4
  43. includes/core/class-member-directory-meta.php +16 -5
  44. includes/core/class-member-directory.php +44 -26
  45. includes/core/class-options.php +3 -2
  46. includes/core/class-password.php +45 -46
  47. includes/core/class-permalinks.php +4 -4
  48. includes/core/class-profile.php +27 -22
  49. includes/core/class-query.php +2 -2
  50. includes/core/class-roles-capabilities.php +10 -6
  51. includes/core/class-shortcodes.php +5 -7
  52. includes/core/class-user-posts.php +3 -3
  53. includes/core/class-user.php +2177 -2177
  54. includes/core/um-actions-account.php +175 -133
  55. includes/core/um-actions-ajax.php +2 -2
  56. includes/core/um-actions-core.php +21 -24
  57. includes/core/um-actions-login.php +5 -5
  58. includes/core/um-actions-misc.php +11 -11
  59. includes/core/um-actions-profile.php +5 -5
  60. includes/core/um-actions-wpadmin.php +4 -5
  61. includes/core/um-filters-fields.php +12 -14
  62. includes/core/um-filters-login.php +13 -9
  63. includes/um-short-functions.php +7 -7
  64. includes/widgets/class-um-search-widget.php +111 -110
  65. readme.txt +25 -0
  66. templates/email/checkmail_email.php +1 -1
  67. templates/members.php +4 -4
  68. templates/password-reset.php +8 -6
  69. ultimate-member.php +24 -24
includes/admin/assets/js/um-admin-forms.js CHANGED
@@ -557,7 +557,6 @@ jQuery(document).ready( function() {
557
  jQuery( '.um-multi-text-add-option' ).on('click', function() {
558
  var list = jQuery(this).siblings( 'ul.um-multi-text-list' );
559
 
560
- var field_id = list.data( 'field_id' );
561
  var k = 0;
562
  if ( list.find( 'li:last input.um-forms-field' ).length > 0 ) {
563
  k = list.find( 'li:last input.um-forms-field' ).attr('id').split("-");
@@ -566,7 +565,7 @@ jQuery(document).ready( function() {
566
 
567
  var text_html = jQuery( '<div>' ).append( list.siblings('.um-hidden-multi-text').clone() ).html();
568
 
569
- var classes = list.find('li:last').attr('class');
570
 
571
  list.append(
572
  '<li class="' + classes + '"><span class="um-field-wrapper">' + text_html +
@@ -986,4 +985,4 @@ jQuery(document).ready( function() {
986
  return false;
987
  }
988
 
989
- });
557
  jQuery( '.um-multi-text-add-option' ).on('click', function() {
558
  var list = jQuery(this).siblings( 'ul.um-multi-text-list' );
559
 
 
560
  var k = 0;
561
  if ( list.find( 'li:last input.um-forms-field' ).length > 0 ) {
562
  k = list.find( 'li:last input.um-forms-field' ).attr('id').split("-");
565
 
566
  var text_html = jQuery( '<div>' ).append( list.siblings('.um-hidden-multi-text').clone() ).html();
567
 
568
+ var classes = list.data('item_class');
569
 
570
  list.append(
571
  '<li class="' + classes + '"><span class="um-field-wrapper">' + text_html +
985
  return false;
986
  }
987
 
988
+ });
includes/admin/class-admin-functions.php CHANGED
@@ -28,7 +28,7 @@ if ( ! class_exists( 'um\admin\Admin_Functions' ) ) {
28
  * @param bool $action
29
  */
30
  function check_ajax_nonce( $action = false ) {
31
- $nonce = isset( $_REQUEST['nonce'] ) ? $_REQUEST['nonce'] : '';
32
  $action = empty( $action ) ? 'um-admin-nonce' : $action;
33
 
34
  if ( ! wp_verify_nonce( $nonce, $action ) ) {
@@ -44,16 +44,18 @@ if ( ! class_exists( 'um\admin\Admin_Functions' ) ) {
44
  */
45
  function is_um_screen() {
46
  global $current_screen;
47
- $screen_id = $current_screen->id;
48
 
49
  $is_um_screen = false;
50
 
51
- if ( strstr( $screen_id, 'ultimatemember') ||
52
- strstr( $screen_id, 'um_') ||
53
- strstr( $screen_id, 'user' ) ||
54
- strstr( $screen_id, 'profile' ) ||
55
- $screen_id == 'nav-menus' ) {
56
- $is_um_screen = true;
 
 
 
57
  }
58
 
59
  if ( $this->is_plugin_post_type() ) {
@@ -81,7 +83,7 @@ if ( ! class_exists( 'um\admin\Admin_Functions' ) ) {
81
  if ( in_array( $post_type, $cpt ) ) {
82
  return true;
83
  }
84
- } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'edit' ) {
85
  $post_type = get_post_type();
86
  if ( in_array( $post_type, $cpt ) ) {
87
  return true;
@@ -113,4 +115,4 @@ if ( ! class_exists( 'um\admin\Admin_Functions' ) ) {
113
  return false;
114
  }
115
  }
116
- }
28
  * @param bool $action
29
  */
30
  function check_ajax_nonce( $action = false ) {
31
+ $nonce = isset( $_REQUEST['nonce'] ) ? sanitize_text_field( $_REQUEST['nonce'] ) : '';
32
  $action = empty( $action ) ? 'um-admin-nonce' : $action;
33
 
34
  if ( ! wp_verify_nonce( $nonce, $action ) ) {
44
  */
45
  function is_um_screen() {
46
  global $current_screen;
 
47
 
48
  $is_um_screen = false;
49
 
50
+ if ( ! empty( $current_screen ) ) {
51
+ $screen_id = $current_screen->id;
52
+ if ( strstr( $screen_id, 'ultimatemember' ) ||
53
+ strstr( $screen_id, 'um_' ) ||
54
+ strstr( $screen_id, 'user' ) ||
55
+ strstr( $screen_id, 'profile' ) ||
56
+ $screen_id == 'nav-menus' ) {
57
+ $is_um_screen = true;
58
+ }
59
  }
60
 
61
  if ( $this->is_plugin_post_type() ) {
83
  if ( in_array( $post_type, $cpt ) ) {
84
  return true;
85
  }
86
+ } elseif ( isset( $_REQUEST['action'] ) && sanitize_key( $_REQUEST['action'] ) == 'edit' ) {
87
  $post_type = get_post_type();
88
  if ( in_array( $post_type, $cpt ) ) {
89
  return true;
115
  return false;
116
  }
117
  }
118
+ }
includes/admin/class-admin.php CHANGED
@@ -1,461 +1,1956 @@
1
- <?php
2
- namespace um\admin;
3
-
4
- // Exit if accessed directly.
5
- if ( ! defined( 'ABSPATH' ) ) exit;
6
-
7
- if ( ! class_exists( 'um\admin\Admin' ) ) {
8
-
9
-
10
- /**
11
- * Class Admin
12
- * @package um\admin
13
- */
14
- class Admin extends Admin_Functions {
15
-
16
-
17
- /**
18
- * @var string
19
- */
20
- var $templates_path;
21
-
22
-
23
- /**
24
- * Admin constructor.
25
- */
26
- function __construct() {
27
- parent::__construct();
28
-
29
- $this->templates_path = um_path . 'includes/admin/templates/';
30
-
31
- add_action( 'admin_init', array( &$this, 'admin_init' ), 0 );
32
-
33
- $prefix = is_network_admin() ? 'network_admin_' : '';
34
- add_filter( "{$prefix}plugin_action_links_" . um_plugin, array( &$this, 'plugin_links' ) );
35
-
36
- add_action( 'um_admin_do_action__user_cache', array( &$this, 'user_cache' ) );
37
- add_action( 'um_admin_do_action__purge_temp', array( &$this, 'purge_temp' ) );
38
- add_action( 'um_admin_do_action__manual_upgrades_request', array( &$this, 'manual_upgrades_request' ) );
39
- add_action( 'um_admin_do_action__duplicate_form', array( &$this, 'duplicate_form' ) );
40
- add_action( 'um_admin_do_action__um_hide_locale_notice', array( &$this, 'um_hide_notice' ) );
41
- add_action( 'um_admin_do_action__um_can_register_notice', array( &$this, 'um_hide_notice' ) );
42
- add_action( 'um_admin_do_action__um_hide_exif_notice', array( &$this, 'um_hide_notice' ) );
43
- add_action( 'um_admin_do_action__user_action', array( &$this, 'user_action' ) );
44
-
45
- add_action( 'um_admin_do_action__install_core_pages', array( &$this, 'install_core_pages' ) );
46
-
47
- add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ), 999 );
48
-
49
- add_action( 'parent_file', array( &$this, 'parent_file' ), 9 );
50
- add_filter( 'gettext', array( &$this, 'gettext' ), 10, 4 );
51
- add_filter( 'post_updated_messages', array( &$this, 'post_updated_messages' ) );
52
- }
53
-
54
-
55
- /**
56
- * Adds class to our admin pages
57
- *
58
- * @param $classes
59
- *
60
- * @return string
61
- */
62
- function admin_body_class( $classes ) {
63
- if ( $this->is_um_screen() ) {
64
- return "$classes um-admin";
65
- }
66
- return $classes;
67
- }
68
-
69
-
70
- /**
71
- *
72
- */
73
- function manual_upgrades_request() {
74
- if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
75
- die();
76
- }
77
-
78
- $last_request = get_option( 'um_last_manual_upgrades_request', false );
79
-
80
- if ( empty( $last_request ) || time() > $last_request + DAY_IN_SECONDS ) {
81
-
82
- if ( is_multisite() ) {
83
- $blogs_ids = get_sites();
84
- foreach( $blogs_ids as $b ) {
85
- switch_to_blog( $b->blog_id );
86
- wp_clean_update_cache();
87
-
88
- UM()->plugin_updater()->um_checklicenses();
89
-
90
- update_option( 'um_last_manual_upgrades_request', time() );
91
- restore_current_blog();
92
- }
93
- } else {
94
- wp_clean_update_cache();
95
-
96
- UM()->plugin_updater()->um_checklicenses();
97
-
98
- update_option( 'um_last_manual_upgrades_request', time() );
99
- }
100
-
101
- $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'got_updates' ), admin_url( 'admin.php' ) );
102
- } else {
103
- $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'often_updates' ), admin_url( 'admin.php' ) );
104
- }
105
- exit( wp_redirect( $url ) );
106
- }
107
-
108
-
109
- /**
110
- * Core pages installation
111
- */
112
- function install_core_pages() {
113
- if ( ! is_admin() ) {
114
- die();
115
- }
116
-
117
- UM()->setup()->install_default_pages();
118
-
119
- //check empty pages in settings
120
- $empty_pages = array();
121
-
122
- $pages = UM()->config()->permalinks;
123
- if ( $pages && is_array( $pages ) ) {
124
- foreach ( $pages as $slug => $page_id ) {
125
- $page = get_post( $page_id );
126
-
127
- if ( ! isset( $page->ID ) && in_array( $slug, array_keys( UM()->config()->core_pages ) ) ) {
128
- $empty_pages[] = $slug;
129
- }
130
- }
131
- }
132
-
133
- //if there aren't empty pages - then hide pages notice
134
- if ( empty( $empty_pages ) ) {
135
- $hidden_notices = get_option( 'um_hidden_admin_notices', array() );
136
- $hidden_notices[] = 'wrong_pages';
137
-
138
- update_option( 'um_hidden_admin_notices', $hidden_notices );
139
- }
140
-
141
- $url = add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) );
142
- exit( wp_redirect( $url ) );
143
- }
144
-
145
-
146
- /**
147
- * Clear all users cache
148
- *
149
- * @param $action
150
- */
151
- function user_cache( $action ) {
152
- global $wpdb;
153
- if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
154
- die();
155
- }
156
-
157
- $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" );
158
-
159
- $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'cleared_cache' ), admin_url( 'admin.php' ) );
160
- exit( wp_redirect( $url ) );
161
- }
162
-
163
-
164
- /**
165
- * Purge temp uploads dir
166
- * @param $action
167
- */
168
- function purge_temp( $action ) {
169
- if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
170
- die();
171
- }
172
-
173
- UM()->files()->remove_dir( UM()->files()->upload_temp );
174
-
175
- $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'purged_temp' ), admin_url( 'admin.php' ) );
176
- exit( wp_redirect( $url ) );
177
- }
178
-
179
-
180
- /**
181
- * Duplicate form
182
- *
183
- * @param $action
184
- */
185
- function duplicate_form( $action ) {
186
- if ( ! is_admin() || ! current_user_can('manage_options') ) {
187
- die();
188
- }
189
- if ( ! isset( $_REQUEST['post_id'] ) || ! is_numeric( $_REQUEST['post_id'] ) ) {
190
- die();
191
- }
192
-
193
- $post_id = absint( $_REQUEST['post_id'] );
194
-
195
- $n = array(
196
- 'post_type' => 'um_form',
197
- 'post_title' => sprintf( __( 'Duplicate of %s', 'ultimate-member' ), get_the_title( $post_id ) ),
198
- 'post_status' => 'publish',
199
- 'post_author' => get_current_user_id(),
200
- );
201
-
202
- $n_id = wp_insert_post( $n );
203
-
204
- $n_fields = get_post_custom( $post_id );
205
- foreach ( $n_fields as $key => $value ) {
206
-
207
- if ( $key == '_um_custom_fields' ) {
208
- $the_value = unserialize( $value[0] );
209
- } else {
210
- $the_value = $value[0];
211
- }
212
-
213
- update_post_meta( $n_id, $key, $the_value );
214
-
215
- }
216
-
217
- delete_post_meta( $n_id, '_um_core' );
218
-
219
- $url = admin_url( 'edit.php?post_type=um_form' );
220
- $url = add_query_arg( 'update', 'form_duplicated', $url );
221
-
222
- exit( wp_redirect( $url ) );
223
-
224
- }
225
-
226
-
227
- /**
228
- * Action to hide notices in admin
229
- *
230
- * @param $action
231
- */
232
- function um_hide_notice( $action ) {
233
- if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
234
- die();
235
- }
236
-
237
- update_option( $action, 1 );
238
- exit( wp_redirect( remove_query_arg( 'um_adm_action' ) ) );
239
- }
240
-
241
-
242
- /**
243
- * Various user actions
244
- *
245
- * @param $action
246
- */
247
- function user_action( $action ) {
248
- if ( ! is_admin() || ! current_user_can( 'edit_users' ) ) {
249
- die();
250
- }
251
- if ( ! isset( $_REQUEST['sub'] ) ) {
252
- die();
253
- }
254
- if ( ! isset( $_REQUEST['user_id'] ) ) {
255
- die();
256
- }
257
-
258
- um_fetch_user( absint( $_REQUEST['user_id'] ) );
259
-
260
- $subaction = sanitize_key( $_REQUEST['sub'] );
261
-
262
- /**
263
- * UM hook
264
- *
265
- * @type action
266
- * @title um_admin_user_action_hook
267
- * @description Action on bulk user subaction
268
- * @input_vars
269
- * [{"var":"$subaction","type":"string","desc":"Bulk Subaction"}]
270
- * @change_log
271
- * ["Since: 2.0"]
272
- * @usage add_action( 'um_admin_user_action_hook', 'function_name', 10, 1 );
273
- * @example
274
- * <?php
275
- * add_action( 'um_admin_user_action_hook', 'my_admin_user_action', 10, 1 );
276
- * function my_admin_user_action( $subaction ) {
277
- * // your code here
278
- * }
279
- * ?>
280
- */
281
- do_action( 'um_admin_user_action_hook', $subaction );
282
- /**
283
- * UM hook
284
- *
285
- * @type action
286
- * @title um_admin_user_action_{$subaction}_hook
287
- * @description Action on bulk user subaction
288
- * @change_log
289
- * ["Since: 2.0"]
290
- * @usage add_action( 'um_admin_user_action_{$subaction}_hook', 'function_name', 10 );
291
- * @example
292
- * <?php
293
- * add_action( 'um_admin_user_action_{$subaction}_hook', 'my_admin_user_action', 10 );
294
- * function my_admin_user_action() {
295
- * // your code here
296
- * }
297
- * ?>
298
- */
299
- do_action( "um_admin_user_action_{$subaction}_hook" );
300
-
301
- um_reset_user();
302
-
303
- wp_redirect( add_query_arg( 'update', 'user_updated', admin_url( '?page=ultimatemember' ) ) );
304
- exit;
305
-
306
- }
307
-
308
-
309
- /**
310
- * Add any custom links to plugin page
311
- *
312
- * @param array $links
313
- *
314
- * @return array
315
- */
316
- function plugin_links( $links ) {
317
- $more_links[] = '<a href="http://docs.ultimatemember.com/">' . __( 'Docs', 'ultimate-member' ) . '</a>';
318
- $more_links[] = '<a href="'.admin_url().'admin.php?page=um_options">' . __( 'Settings', 'ultimate-member' ) . '</a>';
319
-
320
- $links = $more_links + $links;
321
- return $links;
322
- }
323
-
324
-
325
- /**
326
- * Init admin action/filters + request handlers
327
- */
328
- function admin_init() {
329
- if ( is_admin() && current_user_can( 'manage_options' ) && ! empty( $_REQUEST['um_adm_action'] ) ) {
330
- $action = sanitize_key( $_REQUEST['um_adm_action'] );
331
-
332
- /**
333
- * UM hook
334
- *
335
- * @type action
336
- * @title um_admin_do_action__
337
- * @description Make some action on custom admin action
338
- * @input_vars
339
- * [{"var":"$action","type":"string","desc":"Admin Action"}]
340
- * @change_log
341
- * ["Since: 2.0"]
342
- * @usage add_action( 'um_admin_do_action__', 'function_name', 10, 1 );
343
- * @example
344
- * <?php
345
- * add_action( 'um_admin_do_action__', 'my_admin_do_action', 10, 1 );
346
- * function my_admin_do_action( $action ) {
347
- * // your code here
348
- * }
349
- * ?>
350
- */
351
- do_action( 'um_admin_do_action__', $action );
352
- /**
353
- * UM hook
354
- *
355
- * @type action
356
- * @title um_admin_do_action__{$action}
357
- * @description Make some action on custom admin $action
358
- * @input_vars
359
- * [{"var":"$action","type":"string","desc":"Admin Action"}]
360
- * @change_log
361
- * ["Since: 2.0"]
362
- * @usage add_action( 'um_admin_do_action__{$action}', 'function_name', 10, 1 );
363
- * @example
364
- * <?php
365
- * add_action( 'um_admin_do_action__{$action}', 'my_admin_do_action', 10, 1 );
366
- * function my_admin_do_action( $action ) {
367
- * // your code here
368
- * }
369
- * ?>
370
- */
371
- do_action( "um_admin_do_action__{$action}", $action );
372
- }
373
- }
374
-
375
-
376
- /**
377
- * Updated post messages
378
- *
379
- * @param array $messages
380
- *
381
- * @return array
382
- */
383
- function post_updated_messages( $messages ) {
384
- global $post_ID;
385
-
386
- $post_type = get_post_type( $post_ID );
387
-
388
- if ( $post_type == 'um_form' ) {
389
- $messages['um_form'] = array(
390
- 0 => '',
391
- 1 => __( 'Form updated.', 'ultimate-member' ),
392
- 2 => __( 'Custom field updated.', 'ultimate-member' ),
393
- 3 => __( 'Custom field deleted.', 'ultimate-member' ),
394
- 4 => __( 'Form updated.', 'ultimate-member' ),
395
- 5 => isset( $_GET['revision'] ) ? __( 'Form restored to revision.', 'ultimate-member' ) : false,
396
- 6 => __( 'Form created.', 'ultimate-member' ),
397
- 7 => __( 'Form saved.', 'ultimate-member' ),
398
- 8 => __( 'Form submitted.', 'ultimate-member' ),
399
- 9 => __( 'Form scheduled.', 'ultimate-member' ),
400
- 10 => __( 'Form draft updated.', 'ultimate-member' ),
401
- );
402
- }
403
-
404
- return $messages;
405
- }
406
-
407
-
408
- /**
409
- * Gettext filters
410
- *
411
- * @param $translation
412
- * @param $text
413
- * @param $domain
414
- *
415
- * @return string
416
- */
417
- function gettext( $translation, $text, $domain ) {
418
- global $post;
419
- if ( isset( $post->post_type ) && $this->is_plugin_post_type() ) {
420
- $translations = get_translations_for_domain( $domain );
421
- if ( $text == 'Publish' ) {
422
- return $translations->translate( 'Create' );
423
- } elseif ( $text == 'Move to Trash' ) {
424
- return $translations->translate( 'Delete' );
425
- }
426
- }
427
-
428
- return $translation;
429
- }
430
-
431
-
432
- /**
433
- * Fix parent file for correct highlighting
434
- *
435
- * @param $parent_file
436
- *
437
- * @return string
438
- */
439
- function parent_file( $parent_file ) {
440
- global $current_screen;
441
- $screen_id = $current_screen->id;
442
- if ( strstr( $screen_id, 'um_' ) ) {
443
- $parent_file = 'ultimatemember';
444
- }
445
- return $parent_file;
446
- }
447
-
448
-
449
- /**
450
- * @since 2.0
451
- *
452
- * @return core\Admin_Notices()
453
- */
454
- function notices() {
455
- if ( empty( UM()->classes['admin_notices'] ) ) {
456
- UM()->classes['admin_notices'] = new core\Admin_Notices();
457
- }
458
- return UM()->classes['admin_notices'];
459
- }
460
- }
461
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace um\admin;
3
+
4
+ // Exit if accessed directly.
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit;
7
+ }
8
+
9
+ if ( ! class_exists( 'um\admin\Admin' ) ) {
10
+
11
+
12
+ /**
13
+ * Class Admin
14
+ * @package um\admin
15
+ */
16
+ class Admin extends Admin_Functions {
17
+
18
+
19
+ /**
20
+ * @var string
21
+ */
22
+ public $templates_path;
23
+
24
+
25
+ /**
26
+ * @var array
27
+ */
28
+ public $role_meta;
29
+
30
+
31
+ /**
32
+ * @var array
33
+ */
34
+ public $restriction_term_meta;
35
+
36
+
37
+ /**
38
+ * @var array
39
+ */
40
+ public $member_directory_meta;
41
+
42
+
43
+ /**
44
+ * @var array
45
+ */
46
+ public $form_meta;
47
+
48
+
49
+ /**
50
+ * @var array
51
+ */
52
+ public $builder_input;
53
+
54
+
55
+ /**
56
+ * @var array
57
+ */
58
+ public $restriction_post_meta;
59
+
60
+
61
+ /**
62
+ * Admin constructor.
63
+ */
64
+ public function __construct() {
65
+ parent::__construct();
66
+
67
+ $this->templates_path = um_path . 'includes/admin/templates/';
68
+
69
+ $this->role_meta = apply_filters(
70
+ 'um_role_meta_map',
71
+ array(
72
+ '_um_priority' => array(
73
+ 'sanitize' => 'int',
74
+ ),
75
+ '_um_can_access_wpadmin' => array(
76
+ 'sanitize' => 'bool',
77
+ ),
78
+ '_um_can_not_see_adminbar' => array(
79
+ 'sanitize' => 'bool',
80
+ ),
81
+ '_um_can_edit_everyone' => array(
82
+ 'sanitize' => 'bool',
83
+ ),
84
+ '_um_can_edit_roles' => array(
85
+ 'sanitize' => array( $this, 'sanitize_existed_role' ),
86
+ ),
87
+ '_um_can_delete_everyone' => array(
88
+ 'sanitize' => 'bool',
89
+ ),
90
+ '_um_can_delete_roles' => array(
91
+ 'sanitize' => array( $this, 'sanitize_existed_role' ),
92
+ ),
93
+ '_um_can_edit_profile' => array(
94
+ 'sanitize' => 'bool',
95
+ ),
96
+ '_um_can_delete_profile' => array(
97
+ 'sanitize' => 'bool',
98
+ ),
99
+ '_um_can_view_all' => array(
100
+ 'sanitize' => 'bool',
101
+ ),
102
+ '_um_can_view_roles' => array(
103
+ 'sanitize' => array( $this, 'sanitize_existed_role' ),
104
+ ),
105
+ '_um_can_make_private_profile' => array(
106
+ 'sanitize' => 'bool',
107
+ ),
108
+ '_um_can_access_private_profile' => array(
109
+ 'sanitize' => 'bool',
110
+ ),
111
+ '_um_profile_noindex' => array(
112
+ 'sanitize' => array( $this, 'sanitize_profile_noindex' ),
113
+ ),
114
+ '_um_default_homepage' => array(
115
+ 'sanitize' => 'bool',
116
+ ),
117
+ '_um_redirect_homepage' => array(
118
+ 'sanitize' => 'url',
119
+ ),
120
+ '_um_status' => array(
121
+ 'sanitize' => 'sanitize_array_key',
122
+ 'default' => 'approved',
123
+ 'array' => array( 'approved', 'checkmail', 'pending' ),
124
+ ),
125
+ '_um_auto_approve_act' => array(
126
+ 'sanitize' => 'sanitize_array_key',
127
+ 'default' => 'redirect_profile',
128
+ 'array' => array( 'redirect_profile', 'redirect_url' ),
129
+ ),
130
+ '_um_auto_approve_url' => array(
131
+ 'sanitize' => 'url',
132
+ ),
133
+ '_um_login_email_activate' => array(
134
+ 'sanitize' => 'bool',
135
+ ),
136
+ '_um_checkmail_action' => array(
137
+ 'sanitize' => 'sanitize_array_key',
138
+ 'default' => 'show_message',
139
+ 'array' => array( 'show_message', 'redirect_url' ),
140
+ ),
141
+ '_um_checkmail_message' => array(
142
+ 'sanitize' => 'textarea',
143
+ ),
144
+ '_um_checkmail_url' => array(
145
+ 'sanitize' => 'url',
146
+ ),
147
+ '_um_url_email_activate' => array(
148
+ 'sanitize' => 'url',
149
+ ),
150
+ '_um_pending_action' => array(
151
+ 'sanitize' => 'sanitize_array_key',
152
+ 'default' => 'show_message',
153
+ 'array' => array( 'show_message', 'redirect_url' ),
154
+ ),
155
+ '_um_pending_message' => array(
156
+ 'sanitize' => 'textarea',
157
+ ),
158
+ '_um_pending_url' => array(
159
+ 'sanitize' => 'url',
160
+ ),
161
+ '_um_after_login' => array(
162
+ 'sanitize' => 'sanitize_array_key',
163
+ 'default' => 'redirect_profile',
164
+ 'array' => array( 'redirect_profile', 'redirect_url', 'refresh', 'redirect_admin' ),
165
+ ),
166
+ '_um_login_redirect_url' => array(
167
+ 'sanitize' => 'url',
168
+ ),
169
+ '_um_after_logout' => array(
170
+ 'sanitize' => 'sanitize_array_key',
171
+ 'default' => 'redirect_home',
172
+ 'array' => array( 'redirect_home', 'redirect_url' ),
173
+ ),
174
+ '_um_logout_redirect_url' => array(
175
+ 'sanitize' => 'url',
176
+ ),
177
+ '_um_after_delete' => array(
178
+ 'sanitize' => 'sanitize_array_key',
179
+ 'default' => 'redirect_home',
180
+ 'array' => array( 'redirect_home', 'redirect_url' ),
181
+ ),
182
+ '_um_delete_redirect_url' => array(
183
+ 'sanitize' => 'url',
184
+ ),
185
+ 'wp_capabilities' => array(
186
+ 'sanitize' => array( $this, 'sanitize_wp_capabilities' ),
187
+ ),
188
+ )
189
+ );
190
+
191
+ $this->restriction_post_meta = apply_filters(
192
+ 'um_restriction_post_meta_map',
193
+ array(
194
+ '_um_custom_access_settings' => array(
195
+ 'sanitize' => 'bool',
196
+ ),
197
+ '_um_accessible' => array(
198
+ 'sanitize' => 'int',
199
+ ),
200
+ '_um_access_roles' => array(
201
+ 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
202
+ ),
203
+ '_um_noaccess_action' => array(
204
+ 'sanitize' => 'int',
205
+ ),
206
+ '_um_restrict_by_custom_message' => array(
207
+ 'sanitize' => 'int',
208
+ ),
209
+ '_um_restrict_custom_message' => array(
210
+ 'sanitize' => 'textarea',
211
+ ),
212
+ '_um_access_redirect' => array(
213
+ 'sanitize' => 'int',
214
+ ),
215
+ '_um_access_redirect_url' => array(
216
+ 'sanitize' => 'url',
217
+ ),
218
+ '_um_access_hide_from_queries' => array(
219
+ 'sanitize' => 'bool',
220
+ ),
221
+ )
222
+ );
223
+
224
+ $this->restriction_term_meta = apply_filters(
225
+ 'um_restriction_term_meta_map',
226
+ array(
227
+ '_um_custom_access_settings' => array(
228
+ 'sanitize' => 'bool',
229
+ ),
230
+ '_um_accessible' => array(
231
+ 'sanitize' => 'int',
232
+ ),
233
+ '_um_access_roles' => array(
234
+ 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
235
+ ),
236
+ '_um_noaccess_action' => array(
237
+ 'sanitize' => 'int',
238
+ ),
239
+ '_um_restrict_by_custom_message' => array(
240
+ 'sanitize' => 'int',
241
+ ),
242
+ '_um_restrict_custom_message' => array(
243
+ 'sanitize' => 'textarea',
244
+ ),
245
+ '_um_access_redirect' => array(
246
+ 'sanitize' => 'int',
247
+ ),
248
+ '_um_access_redirect_url' => array(
249
+ 'sanitize' => 'url',
250
+ ),
251
+ '_um_access_hide_from_queries' => array(
252
+ 'sanitize' => 'bool',
253
+ ),
254
+ )
255
+ );
256
+
257
+ $this->member_directory_meta = apply_filters(
258
+ 'um_member_directory_meta_map',
259
+ array(
260
+ '_um_directory_template' => array(
261
+ 'sanitize' => 'text',
262
+ ),
263
+ '_um_mode' => array(
264
+ 'sanitize' => 'key',
265
+ ),
266
+ '_um_view_types' => array(
267
+ 'sanitize' => array( $this, 'sanitize_md_view_types' ),
268
+ ),
269
+ '_um_default_view' => array(
270
+ 'sanitize' => 'key',
271
+ ),
272
+ '_um_roles' => array(
273
+ 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
274
+ ),
275
+ '_um_has_profile_photo' => array(
276
+ 'sanitize' => 'bool',
277
+ ),
278
+ '_um_show_these_users' => array(
279
+ 'sanitize' => 'textarea',
280
+ ),
281
+ '_um_exclude_these_users' => array(
282
+ 'sanitize' => 'textarea',
283
+ ),
284
+ '_um_must_search' => array(
285
+ 'sanitize' => 'bool',
286
+ ),
287
+ '_um_max_users' => array(
288
+ 'sanitize' => 'absint',
289
+ ),
290
+ '_um_profiles_per_page' => array(
291
+ 'sanitize' => 'absint',
292
+ ),
293
+ '_um_profiles_per_page_mobile' => array(
294
+ 'sanitize' => 'absint',
295
+ ),
296
+ '_um_directory_header' => array(
297
+ 'sanitize' => 'text',
298
+ ),
299
+ '_um_directory_header_single' => array(
300
+ 'sanitize' => 'text',
301
+ ),
302
+ '_um_directory_no_users' => array(
303
+ 'sanitize' => 'text',
304
+ ),
305
+ '_um_profile_photo' => array(
306
+ 'sanitize' => 'bool',
307
+ ),
308
+ '_um_cover_photos' => array(
309
+ 'sanitize' => 'bool',
310
+ ),
311
+ '_um_show_name' => array(
312
+ 'sanitize' => 'bool',
313
+ ),
314
+ '_um_show_tagline' => array(
315
+ 'sanitize' => 'bool',
316
+ ),
317
+ '_um_tagline_fields' => array(
318
+ 'sanitize' => array( $this, 'sanitize_user_field' ),
319
+ ),
320
+ '_um_show_userinfo' => array(
321
+ 'sanitize' => 'bool',
322
+ ),
323
+ '_um_reveal_fields' => array(
324
+ 'sanitize' => array( $this, 'sanitize_user_field' ),
325
+ ),
326
+ '_um_show_social' => array(
327
+ 'sanitize' => 'bool',
328
+ ),
329
+ '_um_userinfo_animate' => array(
330
+ 'sanitize' => 'bool',
331
+ ),
332
+ '_um_search' => array(
333
+ 'sanitize' => 'bool',
334
+ ),
335
+ '_um_roles_can_search' => array(
336
+ 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
337
+ ),
338
+ '_um_filters' => array(
339
+ 'sanitize' => 'bool',
340
+ ),
341
+ '_um_roles_can_filter' => array(
342
+ 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ),
343
+ ),
344
+ '_um_search_fields' => array(
345
+ 'sanitize' => array( $this, 'sanitize_filter_fields' ),
346
+ ),
347
+ '_um_filters_expanded' => array(
348
+ 'sanitize' => 'bool',
349
+ ),
350
+ '_um_filters_is_collapsible' => array(
351
+ 'sanitize' => 'bool',
352
+ ),
353
+ '_um_search_filters' => array(
354
+ 'sanitize' => array( $this, 'sanitize_filter_fields' ),
355
+ ),
356
+ '_um_sortby' => array(
357
+ 'sanitize' => 'text',
358
+ ),
359
+ '_um_sortby_custom' => array(
360
+ 'sanitize' => 'text',
361
+ ),
362
+ '_um_sortby_custom_label' => array(
363
+ 'sanitize' => 'text',
364
+ ),
365
+ '_um_enable_sorting' => array(
366
+ 'sanitize' => 'bool',
367
+ ),
368
+ '_um_sorting_fields' => array(
369
+ 'sanitize' => array( $this, 'sanitize_md_sorting_fields' ),
370
+ ),
371
+ )
372
+ );
373
+
374
+ $this->form_meta = apply_filters(
375
+ 'um_form_meta_map',
376
+ array(
377
+ '_um_mode' => array(
378
+ 'sanitize' => 'key',
379
+ ),
380
+ '_um_register_use_gdpr' => array(
381
+ 'sanitize' => 'bool',
382
+ ),
383
+ '_um_register_use_gdpr_content_id' => array(
384
+ 'sanitize' => 'absint',
385
+ ),
386
+ '_um_register_use_gdpr_toggle_show' => array(
387
+ 'sanitize' => 'text',
388
+ ),
389
+ '_um_register_use_gdpr_toggle_hide' => array(
390
+ 'sanitize' => 'text',
391
+ ),
392
+ '_um_register_use_gdpr_agreement' => array(
393
+ 'sanitize' => 'text',
394
+ ),
395
+ '_um_register_use_gdpr_error_text' => array(
396
+ 'sanitize' => 'text',
397
+ ),
398
+ '_um_register_use_custom_settings' => array(
399
+ 'sanitize' => 'bool',
400
+ ),
401
+ '_um_register_role' => array(
402
+ 'sanitize' => 'key',
403
+ ),
404
+ '_um_register_template' => array(
405
+ 'sanitize' => 'text',
406
+ ),
407
+ '_um_register_max_width' => array(
408
+ 'sanitize' => 'absint',
409
+ ),
410
+ '_um_register_icons' => array(
411
+ 'sanitize' => 'key',
412
+ ),
413
+ '_um_register_primary_btn_word' => array(
414
+ 'sanitize' => 'text',
415
+ ),
416
+ '_um_register_secondary_btn' => array(
417
+ 'sanitize' => 'bool',
418
+ ),
419
+ '_um_register_secondary_btn_word' => array(
420
+ 'sanitize' => 'text',
421
+ ),
422
+ '_um_login_after_login' => array(
423
+ 'sanitize' => 'key',
424
+ ),
425
+ '_um_login_redirect_url' => array(
426
+ 'sanitize' => 'url',
427
+ ),
428
+ '_um_login_use_custom_settings' => array(
429
+ 'sanitize' => 'bool',
430
+ ),
431
+ '_um_login_template' => array(
432
+ 'sanitize' => 'text',
433
+ ),
434
+ '_um_login_max_width' => array(
435
+ 'sanitize' => 'absint',
436
+ ),
437
+ '_um_login_icons' => array(
438
+ 'sanitize' => 'key',
439
+ ),
440
+ '_um_login_primary_btn_word' => array(
441
+ 'sanitize' => 'text',
442
+ ),
443
+ '_um_login_secondary_btn' => array(
444
+ 'sanitize' => 'bool',
445
+ ),
446
+ '_um_login_secondary_btn_word' => array(
447
+ 'sanitize' => 'text',
448
+ ),
449
+ '_um_login_forgot_pass_link' => array(
450
+ 'sanitize' => 'bool',
451
+ ),
452
+ '_um_login_show_rememberme' => array(
453
+ 'sanitize' => 'bool',
454
+ ),
455
+ '_um_profile_metafields' => array(
456
+ 'sanitize' => array( $this, 'sanitize_user_field' ),
457
+ ),
458
+ '_um_profile_use_custom_settings' => array(
459
+ 'sanitize' => 'bool',
460
+ ),
461
+ '_um_profile_role' => array(
462
+ 'sanitize' => array( $this, 'sanitize_existed_role' ),
463
+ ),
464
+ '_um_profile_template' => array(
465
+ 'sanitize' => 'text',
466
+ ),
467
+ '_um_profile_max_width' => array(
468
+ 'sanitize' => 'absint',
469
+ ),
470
+ '_um_profile_area_max_width' => array(
471
+ 'sanitize' => 'absint',
472
+ ),
473
+ '_um_profile_icons' => array(
474
+ 'sanitize' => 'key',
475
+ ),
476
+ '_um_profile_primary_btn_word' => array(
477
+ 'sanitize' => 'text',
478
+ ),
479
+ '_um_profile_secondary_btn' => array(
480
+ 'sanitize' => 'bool',
481
+ ),
482
+ '_um_profile_secondary_btn_word' => array(
483
+ 'sanitize' => 'text',
484
+ ),
485
+ '_um_profile_cover_enabled' => array(
486
+ 'sanitize' => 'bool',
487
+ ),
488
+ '_um_profile_coversize' => array(
489
+ 'sanitize' => 'absint',
490
+ ),
491
+ '_um_profile_cover_ratio' => array(
492
+ 'sanitize' => 'text',
493
+ ),
494
+ '_um_profile_disable_photo_upload' => array(
495
+ 'sanitize' => 'bool',
496
+ ),
497
+ '_um_profile_photosize' => array(
498
+ 'sanitize' => array( $this, 'sanitize_photosize' ),
499
+ ),
500
+ '_um_profile_photo_required' => array(
501
+ 'sanitize' => 'bool',
502
+ ),
503
+ '_um_profile_show_name' => array(
504
+ 'sanitize' => 'bool',
505
+ ),
506
+ '_um_profile_show_social_links' => array(
507
+ 'sanitize' => 'bool',
508
+ ),
509
+ '_um_profile_show_bio' => array(
510
+ 'sanitize' => 'bool',
511
+ ),
512
+
513
+ )
514
+ );
515
+
516
+ $this->builder_input = apply_filters(
517
+ 'um_builder_input_map',
518
+ array(
519
+ '_in_row' => array(
520
+ 'sanitize' => 'key',
521
+ ),
522
+ '_in_sub_row' => array(
523
+ 'sanitize' => 'absint',
524
+ ),
525
+ '_in_column' => array(
526
+ 'sanitize' => 'absint',
527
+ ),
528
+ '_in_group' => array(
529
+ 'sanitize' => 'absint',
530
+ ),
531
+ '_visibility' => array(
532
+ 'sanitize' => 'key',
533
+ ),
534
+ '_conditional_action' => array(
535
+ 'sanitize' => 'key',
536
+ ),
537
+ '_conditional_action1' => array(
538
+ 'sanitize' => 'key',
539
+ ),
540
+ '_conditional_action2' => array(
541
+ 'sanitize' => 'key',
542
+ ),
543
+ '_conditional_action3' => array(
544
+ 'sanitize' => 'key',
545
+ ),
546
+ '_conditional_action4' => array(
547
+ 'sanitize' => 'key',
548
+ ),
549
+ '_conditional_field' => array(
550
+ 'sanitize' => 'text',
551
+ ),
552
+ '_conditional_field1' => array(
553
+ 'sanitize' => 'text',
554
+ ),
555
+ '_conditional_field2' => array(
556
+ 'sanitize' => 'text',
557
+ ),
558
+ '_conditional_field3' => array(
559
+ 'sanitize' => 'text',
560
+ ),
561
+ '_conditional_field4' => array(
562
+ 'sanitize' => 'text',
563
+ ),
564
+ '_conditional_operator' => array(
565
+ 'sanitize' => 'text',
566
+ ),
567
+ '_conditional_operator1' => array(
568
+ 'sanitize' => 'text',
569
+ ),
570
+ '_conditional_operator2' => array(
571
+ 'sanitize' => 'text',
572
+ ),
573
+ '_conditional_operator3' => array(
574
+ 'sanitize' => 'text',
575
+ ),
576
+ '_conditional_operator4' => array(
577
+ 'sanitize' => 'text',
578
+ ),
579
+ '_conditional_value' => array(
580
+ 'sanitize' => 'text',
581
+ ),
582
+ '_conditional_value1' => array(
583
+ 'sanitize' => 'text',
584
+ ),
585
+ '_conditional_value2' => array(
586
+ 'sanitize' => 'text',
587
+ ),
588
+ '_conditional_value3' => array(
589
+ 'sanitize' => 'text',
590
+ ),
591
+ '_conditional_value4' => array(
592
+ 'sanitize' => 'text',
593
+ ),
594
+ '_validate' => array(
595
+ 'sanitize' => 'key',
596
+ ),
597
+ '_custom_validate' => array(
598
+ 'sanitize' => 'text',
599
+ ),
600
+ '_icon' => array(
601
+ 'sanitize' => 'key',
602
+ ),
603
+ '_css_class' => array(
604
+ 'sanitize' => 'text',
605
+ ),
606
+ '_width' => array(
607
+ 'sanitize' => 'absint',
608
+ ),
609
+ '_divider_text' => array(
610
+ 'sanitize' => 'text',
611
+ ),
612
+ '_padding' => array(
613
+ 'sanitize' => 'text',
614
+ ),
615
+ '_margin' => array(
616
+ 'sanitize' => 'text',
617
+ ),
618
+ '_border' => array(
619
+ 'sanitize' => 'text',
620
+ ),
621
+ '_borderstyle' => array(
622
+ 'sanitize' => 'key',
623
+ ),
624
+ '_borderradius' => array(
625
+ 'sanitize' => 'text',
626
+ ),
627
+ '_bordercolor' => array(
628
+ 'sanitize' => 'text',
629
+ ),
630
+ '_heading' => array(
631
+ 'sanitize' => 'bool',
632
+ ),
633
+ '_heading_text' => array(
634
+ 'sanitize' => 'text',
635
+ ),
636
+ '_background' => array(
637
+ 'sanitize' => 'text',
638
+ ),
639
+ '_heading_background_color' => array(
640
+ 'sanitize' => 'text',
641
+ ),
642
+ '_heading_text_color' => array(
643
+ 'sanitize' => 'text',
644
+ ),
645
+ '_text_color' => array(
646
+ 'sanitize' => 'text',
647
+ ),
648
+ '_icon_color' => array(
649
+ 'sanitize' => 'text',
650
+ ),
651
+ '_color' => array(
652
+ 'sanitize' => 'text',
653
+ ),
654
+ '_url_text' => array(
655
+ 'sanitize' => 'text',
656
+ ),
657
+ '_url_target' => array(
658
+ 'sanitize' => 'key',
659
+ ),
660
+ '_url_rel' => array(
661
+ 'sanitize' => 'key',
662
+ ),
663
+ '_force_good_pass' => array(
664
+ 'sanitize' => 'bool',
665
+ ),
666
+ '_force_confirm_pass' => array(
667
+ 'sanitize' => 'bool',
668
+ ),
669
+ '_style' => array(
670
+ 'sanitize' => 'key',
671
+ ),
672
+ '_intervals' => array(
673
+ 'sanitize' => 'absint',
674
+ ),
675
+ '_format' => array(
676
+ 'sanitize' => 'text',
677
+ ),
678
+ '_format_custom' => array(
679
+ 'sanitize' => 'text',
680
+ ),
681
+ '_pretty_format' => array(
682
+ 'sanitize' => 'bool',
683
+ ),
684
+ '_disabled_weekdays' => array(
685
+ 'sanitize' => 'absint',
686
+ ),
687
+ '_years' => array(
688
+ 'sanitize' => 'absint',
689
+ ),
690
+ '_years_x' => array(
691
+ 'sanitize' => 'key',
692
+ ),
693
+ '_range_start' => array(
694
+ 'sanitize' => 'text',
695
+ ),
696
+ '_range_end' => array(
697
+ 'sanitize' => 'text',
698
+ ),
699
+ '_range' => array(
700
+ 'sanitize' => 'key',
701
+ ),
702
+ '_content' => array(
703
+ 'sanitize' => 'textarea',
704
+ ),
705
+ '_crop' => array(
706
+ 'sanitize' => 'int',
707
+ ),
708
+ '_allowed_types' => array(
709
+ 'sanitize' => 'key',
710
+ ),
711
+ '_upload_text' => array(
712
+ 'sanitize' => 'text',
713
+ ),
714
+ '_upload_help_text' => array(
715
+ 'sanitize' => 'text',
716
+ ),
717
+ '_button_text' => array(
718
+ 'sanitize' => 'text',
719
+ ),
720
+ '_max_size' => array(
721
+ 'sanitize' => 'absint',
722
+ ),
723
+ '_height' => array(
724
+ 'sanitize' => 'text',
725
+ ),
726
+ '_spacing' => array(
727
+ 'sanitize' => 'text',
728
+ ),
729
+ '_is_multi' => array(
730
+ 'sanitize' => 'bool',
731
+ ),
732
+ '_max_selections' => array(
733
+ 'sanitize' => 'absint',
734
+ ),
735
+ '_min_selections' => array(
736
+ 'sanitize' => 'absint',
737
+ ),
738
+ '_max_entries' => array(
739
+ 'sanitize' => 'absint',
740
+ ),
741
+ '_max_words' => array(
742
+ 'sanitize' => 'absint',
743
+ ),
744
+ '_min' => array(
745
+ 'sanitize' => 'absint',
746
+ ),
747
+ '_max' => array(
748
+ 'sanitize' => 'absint',
749
+ ),
750
+ '_min_chars' => array(
751
+ 'sanitize' => 'absint',
752
+ ),
753
+ '_max_chars' => array(
754
+ 'sanitize' => 'absint',
755
+ ),
756
+ '_html' => array(
757
+ 'sanitize' => 'bool',
758
+ ),
759
+ '_options' => array(
760
+ 'sanitize' => 'textarea',
761
+ ),
762
+ '_title' => array(
763
+ 'sanitize' => 'text',
764
+ ),
765
+ '_id' => array(
766
+ 'sanitize' => 'text',
767
+ ),
768
+ '_metakey' => array(
769
+ 'sanitize' => 'text',
770
+ ),
771
+ '_help' => array(
772
+ 'sanitize' => 'text',
773
+ ),
774
+ '_default' => array(
775
+ 'sanitize' => 'text',
776
+ ),
777
+ '_label' => array(
778
+ 'sanitize' => 'text',
779
+ ),
780
+ '_label_confirm_pass' => array(
781
+ 'sanitize' => 'text',
782
+ ),
783
+ '_placeholder' => array(
784
+ 'sanitize' => 'text',
785
+ ),
786
+ '_public' => array(
787
+ 'sanitize' => 'text',
788
+ ),
789
+ '_roles' => array(
790
+ 'sanitize' => array( $this, 'sanitize_existed_role' ),
791
+ ),
792
+ '_required' => array(
793
+ 'sanitize' => 'bool',
794
+ ),
795
+ '_editable' => array(
796
+ 'sanitize' => 'bool',
797
+ ),
798
+ '_number' => array(
799
+ 'sanitize' => 'absint',
800
+ ),
801
+ '_custom_dropdown_options_source' => array(
802
+ 'sanitize' => 'text',
803
+ ),
804
+ '_parent_dropdown_relationship' => array(
805
+ 'sanitize' => 'text',
806
+ ),
807
+ )
808
+ );
809
+
810
+ add_action( 'admin_init', array( &$this, 'admin_init' ), 0 );
811
+
812
+ $prefix = is_network_admin() ? 'network_admin_' : '';
813
+ add_filter( "{$prefix}plugin_action_links_" . um_plugin, array( &$this, 'plugin_links' ) );
814
+
815
+ add_action( 'um_admin_do_action__user_cache', array( &$this, 'user_cache' ) );
816
+ add_action( 'um_admin_do_action__purge_temp', array( &$this, 'purge_temp' ) );
817
+ add_action( 'um_admin_do_action__manual_upgrades_request', array( &$this, 'manual_upgrades_request' ) );
818
+ add_action( 'um_admin_do_action__duplicate_form', array( &$this, 'duplicate_form' ) );
819
+ add_action( 'um_admin_do_action__um_hide_locale_notice', array( &$this, 'um_hide_notice' ) );
820
+ add_action( 'um_admin_do_action__um_can_register_notice', array( &$this, 'um_hide_notice' ) );
821
+ add_action( 'um_admin_do_action__um_hide_exif_notice', array( &$this, 'um_hide_notice' ) );
822
+ add_action( 'um_admin_do_action__user_action', array( &$this, 'user_action' ) );
823
+
824
+ add_action( 'um_admin_do_action__install_core_pages', array( &$this, 'install_core_pages' ) );
825
+
826
+ add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ), 999 );
827
+
828
+ add_action( 'parent_file', array( &$this, 'parent_file' ), 9 );
829
+ add_filter( 'gettext', array( &$this, 'gettext' ), 10, 4 );
830
+ add_filter( 'post_updated_messages', array( &$this, 'post_updated_messages' ) );
831
+ }
832
+
833
+
834
+ /**
835
+ * @param array|string $value
836
+ *
837
+ * @return array|string
838
+ */
839
+ public function sanitize_md_sorting_fields( $value ) {
840
+ $filter_fields = array_merge( UM()->member_directory()->sort_fields, array( 'other' => __( 'Other (Custom Field)', 'ultimate-member' ) ) );
841
+ $filter_fields = array_keys( $filter_fields );
842
+
843
+ if ( '' !== $value ) {
844
+ $value = array_filter(
845
+ $value,
846
+ function( $v, $k ) use ( $filter_fields ) {
847
+ if ( 'other_data' === $k ) {
848
+ return true;
849
+ } else {
850
+ return in_array( sanitize_text_field( $v ), $filter_fields, true );
851
+ }
852
+ },
853
+ ARRAY_FILTER_USE_BOTH
854
+ );
855
+
856
+ $value = array_map(
857
+ function( $item ) {
858
+ if ( is_array( $item ) ) {
859
+ if ( isset( $item['meta_key'] ) ) {
860
+ $item['meta_key'] = sanitize_text_field( $item['meta_key'] );
861
+ }
862
+ if ( isset( $item['label'] ) ) {
863
+ $item['label'] = sanitize_text_field( $item['label'] );
864
+ }
865
+
866
+ return $item;
867
+ } else {
868
+ return sanitize_text_field( $item );
869
+ }
870
+ },
871
+ $value
872
+ );
873
+ }
874
+
875
+ return $value;
876
+ }
877
+
878
+
879
+ /**
880
+ * @param array|string $value
881
+ *
882
+ * @return array|string
883
+ */
884
+ public function sanitize_filter_fields( $value ) {
885
+ $filter_fields = array_keys( UM()->member_directory()->filter_fields );
886
+
887
+ if ( '' !== $value ) {
888
+ $value = array_filter(
889
+ $value,
890
+ function( $v, $k ) use ( $filter_fields ) {
891
+ return in_array( sanitize_text_field( $v ), $filter_fields, true );
892
+ },
893
+ ARRAY_FILTER_USE_BOTH
894
+ );
895
+
896
+ $value = array_map( 'sanitize_text_field', $value );
897
+ }
898
+
899
+ return $value;
900
+ }
901
+
902
+
903
+ /**
904
+ * @param array|string $value
905
+ *
906
+ * @return array|string
907
+ */
908
+ public function sanitize_user_field( $value ) {
909
+ $user_fields = array_keys( UM()->builtin()->all_user_fields() );
910
+
911
+ if ( '' !== $value ) {
912
+ $value = array_filter(
913
+ $value,
914
+ function( $v, $k ) use ( $user_fields ) {
915
+ return in_array( sanitize_text_field( $v ), $user_fields, true );
916
+ },
917
+ ARRAY_FILTER_USE_BOTH
918
+ );
919
+
920
+ $value = array_map( 'sanitize_text_field', $value );
921
+ }
922
+
923
+ return $value;
924
+ }
925
+
926
+
927
+ /**
928
+ * @param array|string $value
929
+ *
930
+ * @return array|string
931
+ */
932
+ public function sanitize_md_view_types( $value ) {
933
+ $view_types = array_map(
934
+ function ( $item ) {
935
+ return $item['title'];
936
+ },
937
+ UM()->member_directory()->view_types
938
+ );
939
+ $view_types = array_keys( $view_types );
940
+
941
+ if ( '' !== $value ) {
942
+ $value = array_filter(
943
+ $value,
944
+ function( $v, $k ) use ( $view_types ) {
945
+ return in_array( sanitize_key( $k ), $view_types, true ) && 1 === (int) $v;
946
+ },
947
+ ARRAY_FILTER_USE_BOTH
948
+ );
949
+
950
+ $value = array_map( 'sanitize_key', $value );
951
+ }
952
+
953
+ return $value;
954
+ }
955
+
956
+
957
+ /**
958
+ * @param array|string $value
959
+ *
960
+ * @return array|string
961
+ */
962
+ public function sanitize_photosize( $value ) {
963
+ $sizes = UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' );
964
+ $sizes = array_keys( $sizes );
965
+
966
+ if ( '' !== $value ) {
967
+ $value = in_array( absint( $value ), $sizes, true ) ? absint( $value ) : '';
968
+ }
969
+
970
+ return $value;
971
+ }
972
+
973
+
974
+ /**
975
+ * @param array|string $value
976
+ *
977
+ * @return array|string
978
+ */
979
+ public function sanitize_cover_photosize( $value ) {
980
+ $sizes = UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' );
981
+ $sizes = array_keys( $sizes );
982
+
983
+ if ( '' !== $value ) {
984
+ $value = in_array( absint( $value ), $sizes, true ) ? absint( $value ) : '';
985
+ }
986
+
987
+ return $value;
988
+ }
989
+
990
+
991
+ /**
992
+ * @param array|string $value
993
+ *
994
+ * @return array|string
995
+ */
996
+ public function sanitize_restriction_existed_role( $value ) {
997
+ $all_roles = array_keys( UM()->roles()->get_roles() );
998
+
999
+ if ( '' !== $value ) {
1000
+ $value = array_filter(
1001
+ $value,
1002
+ function( $v, $k ) use ( $all_roles ) {
1003
+ return in_array( sanitize_key( $k ), $all_roles, true ) && 1 === (int) $v;
1004
+ },
1005
+ ARRAY_FILTER_USE_BOTH
1006
+ );
1007
+
1008
+ $value = array_map( 'sanitize_key', $value );
1009
+ }
1010
+
1011
+ return $value;
1012
+ }
1013
+
1014
+
1015
+ /**
1016
+ * @param array|string $value
1017
+ *
1018
+ * @return array|string
1019
+ */
1020
+ public function sanitize_existed_role( $value ) {
1021
+ $all_roles = array_keys( UM()->roles()->get_roles() );
1022
+
1023
+ if ( '' !== $value ) {
1024
+ $value = array_filter(
1025
+ $value,
1026
+ function( $v, $k ) use ( $all_roles ) {
1027
+ return in_array( sanitize_key( $v ), $all_roles, true );
1028
+ },
1029
+ ARRAY_FILTER_USE_BOTH
1030
+ );
1031
+
1032
+ $value = array_map( 'sanitize_key', $value );
1033
+ }
1034
+
1035
+ return $value;
1036
+ }
1037
+
1038
+
1039
+ /**
1040
+ * @param array|string $value
1041
+ *
1042
+ * @return array|string
1043
+ */
1044
+ public function sanitize_tabs_privacy( $value ) {
1045
+ $all_privacy = array_keys( UM()->profile()->tabs_privacy() );
1046
+
1047
+ if ( '' !== $value ) {
1048
+ $value = in_array( absint( $value ), $all_privacy, true ) ? absint( $value ) : '';
1049
+ }
1050
+
1051
+ return $value;
1052
+ }
1053
+
1054
+
1055
+ /**
1056
+ * @param $value
1057
+ *
1058
+ * @return bool|string
1059
+ */
1060
+ public function sanitize_profile_noindex( $value ) {
1061
+ $value = '' !== $value ? (bool) $value : $value;
1062
+ return $value;
1063
+ }
1064
+
1065
+
1066
+ /**
1067
+ * @param $value
1068
+ *
1069
+ * @return array
1070
+ */
1071
+ public function sanitize_wp_capabilities( $value ) {
1072
+ $value = array_map( 'boolval', array_filter( $value ) );
1073
+ return $value;
1074
+ }
1075
+
1076
+
1077
+ /**
1078
+ * Sanitize role meta fields when wp-admin form has been submitted
1079
+ *
1080
+ * @param array $data
1081
+ *
1082
+ * @return array
1083
+ */
1084
+ public function sanitize_role_meta( $data ) {
1085
+ $sanitized = array();
1086
+ foreach ( $data as $k => $v ) {
1087
+ if ( ! array_key_exists( $k, $this->role_meta ) ) {
1088
+ // @todo remove since 2.2.x and leave only continue
1089
+ $sanitized[ $k ] = $v;
1090
+ continue;
1091
+ }
1092
+
1093
+ if ( ! array_key_exists( 'sanitize', $this->role_meta[ $k ] ) ) {
1094
+ // @todo remove since 2.2.x and leave only continue
1095
+ $sanitized[ $k ] = $v;
1096
+ continue;
1097
+ }
1098
+
1099
+ if ( is_callable( $this->role_meta[ $k ]['sanitize'], true, $callable_name ) ) {
1100
+ add_filter( 'um_role_meta_sanitize_' . $k, $this->role_meta[ $k ]['sanitize'], 10, 1 );
1101
+ }
1102
+
1103
+ switch ( $this->role_meta[ $k ]['sanitize'] ) {
1104
+ default:
1105
+ $sanitized[ $k ] = apply_filters( 'um_role_meta_sanitize_' . $k, $data[ $k ] );
1106
+ break;
1107
+ case 'int':
1108
+ $sanitized[ $k ] = (int) $v;
1109
+ break;
1110
+ case 'bool':
1111
+ $sanitized[ $k ] = (bool) $v;
1112
+ break;
1113
+ case 'url':
1114
+ $sanitized[ $k ] = esc_url_raw( $v );
1115
+ break;
1116
+ case 'textarea':
1117
+ $sanitized[ $k ] = sanitize_textarea_field( $v );
1118
+ break;
1119
+ case 'sanitize_array_key':
1120
+ if ( ! array_key_exists( 'default', $this->role_meta[ $k ] ) || ! array_key_exists( 'array', $this->role_meta[ $k ] ) ) {
1121
+ continue 2;
1122
+ }
1123
+
1124
+ $sanitized[ $k ] = ! in_array( sanitize_key( $v ), $this->role_meta[ $k ]['array'], true ) ? $this->role_meta[ $k ]['default'] : sanitize_key( $v );
1125
+ break;
1126
+ }
1127
+ }
1128
+
1129
+ $data = $sanitized;
1130
+
1131
+ $data = apply_filters( 'um_save_role_meta_sanitize', $data );
1132
+
1133
+ return $data;
1134
+ }
1135
+
1136
+
1137
+ /**
1138
+ * Sanitize post restriction meta fields when wp-admin form has been submitted
1139
+ *
1140
+ * @param array $data
1141
+ *
1142
+ * @return array
1143
+ */
1144
+ public function sanitize_post_restriction_meta( $data ) {
1145
+ $sanitized = array();
1146
+ foreach ( $data as $k => $v ) {
1147
+ if ( ! array_key_exists( $k, $this->restriction_post_meta ) ) {
1148
+ // @todo remove since 2.2.x and leave only continue
1149
+ $sanitized[ $k ] = $v;
1150
+ continue;
1151
+ }
1152
+
1153
+ if ( ! array_key_exists( 'sanitize', $this->restriction_post_meta[ $k ] ) ) {
1154
+ // @todo remove since 2.2.x and leave only continue
1155
+ $sanitized[ $k ] = $v;
1156
+ continue;
1157
+ }
1158
+
1159
+ if ( is_callable( $this->restriction_post_meta[ $k ]['sanitize'], true, $callable_name ) ) {
1160
+ add_filter( 'um_restriction_post_meta_sanitize_' . $k, $this->restriction_post_meta[ $k ]['sanitize'], 10, 1 );
1161
+ }
1162
+
1163
+ switch ( $this->restriction_post_meta[ $k ]['sanitize'] ) {
1164
+ default:
1165
+ $sanitized[ $k ] = apply_filters( 'um_restriction_post_meta_sanitize_' . $k, $data[ $k ] );
1166
+ break;
1167
+ case 'int':
1168
+ $sanitized[ $k ] = (int) $v;
1169
+ break;
1170
+ case 'bool':
1171
+ $sanitized[ $k ] = (bool) $v;
1172
+ break;
1173
+ case 'url':
1174
+ $sanitized[ $k ] = esc_url_raw( $v );
1175
+ break;
1176
+ case 'textarea':
1177
+ $sanitized[ $k ] = sanitize_textarea_field( $v );
1178
+ break;
1179
+ }
1180
+ }
1181
+
1182
+ $data = $sanitized;
1183
+
1184
+ $data = apply_filters( 'um_save_restriction_post_meta_sanitize', $data );
1185
+
1186
+ return $data;
1187
+ }
1188
+
1189
+
1190
+ /**
1191
+ * Sanitize term restriction meta fields when wp-admin form has been submitted
1192
+ *
1193
+ * @param array $data
1194
+ *
1195
+ * @return array
1196
+ */
1197
+ public function sanitize_term_restriction_meta( $data ) {
1198
+ $sanitized = array();
1199
+ foreach ( $data as $k => $v ) {
1200
+ if ( ! array_key_exists( $k, $this->restriction_term_meta ) ) {
1201
+ // @todo remove since 2.2.x and leave only continue
1202
+ $sanitized[ $k ] = $v;
1203
+ continue;
1204
+ }
1205
+
1206
+ if ( ! array_key_exists( 'sanitize', $this->restriction_term_meta[ $k ] ) ) {
1207
+ // @todo remove since 2.2.x and leave only continue
1208
+ $sanitized[ $k ] = $v;
1209
+ continue;
1210
+ }
1211
+
1212
+ if ( is_callable( $this->restriction_term_meta[ $k ]['sanitize'], true, $callable_name ) ) {
1213
+ add_filter( 'um_restriction_term_meta_sanitize_' . $k, $this->restriction_term_meta[ $k ]['sanitize'], 10, 1 );
1214
+ }
1215
+
1216
+ switch ( $this->restriction_term_meta[ $k ]['sanitize'] ) {
1217
+ default:
1218
+ $sanitized[ $k ] = apply_filters( 'um_restriction_term_meta_sanitize_' . $k, $data[ $k ] );
1219
+ break;
1220
+ case 'int':
1221
+ $sanitized[ $k ] = (int) $v;
1222
+ break;
1223
+ case 'bool':
1224
+ $sanitized[ $k ] = (bool) $v;
1225
+ break;
1226
+ case 'url':
1227
+ $sanitized[ $k ] = esc_url_raw( $v );
1228
+ break;
1229
+ case 'textarea':
1230
+ $sanitized[ $k ] = sanitize_textarea_field( $v );
1231
+ break;
1232
+ }
1233
+ }
1234
+
1235
+ $data = $sanitized;
1236
+
1237
+ $data = apply_filters( 'um_save_restriction_term_meta_sanitize', $data );
1238
+
1239
+ return $data;
1240
+ }
1241
+
1242
+
1243
+ /**
1244
+ * Sanitize member directory meta when wp-admin form has been submitted
1245
+ *
1246
+ * @todo checking all sanitize types
1247
+ *
1248
+ * @param array $data
1249
+ *
1250
+ * @return array
1251
+ */
1252
+ public function sanitize_member_directory_meta( $data ) {
1253
+ $sanitized = array();
1254
+ foreach ( $data as $k => $v ) {
1255
+ if ( ! array_key_exists( $k, $this->member_directory_meta ) ) {
1256
+ // @todo remove since 2.2.x and leave only continue
1257
+ $sanitized[ $k ] = $v;
1258
+ continue;
1259
+ }
1260
+
1261
+ if ( ! array_key_exists( 'sanitize', $this->member_directory_meta[ $k ] ) ) {
1262
+ // @todo remove since 2.2.x and leave only continue
1263
+ $sanitized[ $k ] = $v;
1264
+ continue;
1265
+ }
1266
+
1267
+ if ( is_callable( $this->member_directory_meta[ $k ]['sanitize'], true, $callable_name ) ) {
1268
+ add_filter( 'um_member_directory_meta_sanitize_' . $k, $this->member_directory_meta[ $k ]['sanitize'], 10, 1 );
1269
+ }
1270
+
1271
+ switch ( $this->member_directory_meta[ $k ]['sanitize'] ) {
1272
+ default:
1273
+ $sanitized[ $k ] = apply_filters( 'um_member_directory_meta_sanitize_' . $k, $data[ $k ] );
1274
+ break;
1275
+ case 'int':
1276
+ $sanitized[ $k ] = (int) $v;
1277
+ break;
1278
+ case 'bool':
1279
+ $sanitized[ $k ] = (bool) $v;
1280
+ break;
1281
+ case 'url':
1282
+ if ( is_array( $v ) ) {
1283
+ $sanitized[ $k ] = array_map( 'esc_url_raw', $v );
1284
+ } else {
1285
+ $sanitized[ $k ] = esc_url_raw( $v );
1286
+ }
1287
+ break;
1288
+ case 'text':
1289
+ $sanitized[ $k ] = sanitize_text_field( $v );
1290
+ break;
1291
+ case 'textarea':
1292
+ $sanitized[ $k ] = sanitize_textarea_field( $v );
1293
+ break;
1294
+ case 'key':
1295
+ if ( is_array( $v ) ) {
1296
+ $sanitized[ $k ] = array_map( 'sanitize_key', $v );
1297
+ } else {
1298
+ $sanitized[ $k ] = sanitize_key( $v );
1299
+ }
1300
+ break;
1301
+ case 'absint':
1302
+ if ( is_array( $v ) ) {
1303
+ $sanitized[ $k ] = array_map( 'absint', $v );
1304
+ } else {
1305
+ $sanitized[ $k ] = absint( $v );
1306
+ }
1307
+ break;
1308
+ }
1309
+ }
1310
+
1311
+ $data = $sanitized;
1312
+
1313
+ $data = apply_filters( 'um_save_member_directory_meta_sanitize', $data );
1314
+
1315
+ return $data;
1316
+ }
1317
+
1318
+
1319
+ /**
1320
+ * Sanitize builder field meta when wp-admin form has been submitted
1321
+ *
1322
+ * @todo checking all sanitize types
1323
+ *
1324
+ * @param array $data
1325
+ *
1326
+ * @return array
1327
+ */
1328
+ public function sanitize_builder_field_meta( $data ) {
1329
+ $sanitized = array();
1330
+ foreach ( $data as $k => $v ) {
1331
+ if ( ! array_key_exists( $k, $this->builder_input ) ) {
1332
+ // @todo remove since 2.2.x and leave only continue
1333
+ $sanitized[ $k ] = $v;
1334
+ continue;
1335
+ }
1336
+
1337
+ if ( ! array_key_exists( 'sanitize', $this->builder_input[ $k ] ) ) {
1338
+ // @todo remove since 2.2.x and leave only continue
1339
+ $sanitized[ $k ] = $v;
1340
+ continue;
1341
+ }
1342
+
1343
+ if ( is_callable( $this->builder_input[ $k ]['sanitize'], true, $callable_name ) ) {
1344
+ add_filter( 'um_builder_input_sanitize_' . $k, $this->builder_input[ $k ]['sanitize'], 10, 1 );
1345
+ }
1346
+
1347
+ switch ( $this->builder_input[ $k ]['sanitize'] ) {
1348
+ default:
1349
+ $sanitized[ $k ] = apply_filters( 'um_builder_input_sanitize_' . $k, $data[ $k ] );
1350
+ break;
1351
+ case 'int':
1352
+ $sanitized[ $k ] = (int) $v;
1353
+ break;
1354
+ case 'bool':
1355
+ $sanitized[ $k ] = (bool) $v;
1356
+ break;
1357
+ case 'url':
1358
+ if ( is_array( $v ) ) {
1359
+ $sanitized[ $k ] = array_map( 'esc_url_raw', $v );
1360
+ } else {
1361
+ $sanitized[ $k ] = esc_url_raw( $v );
1362
+ }
1363
+ break;
1364
+ case 'text':
1365
+ $sanitized[ $k ] = sanitize_text_field( $v );
1366
+ break;
1367
+ case 'textarea':
1368
+ $sanitized[ $k ] = sanitize_textarea_field( $v );
1369
+ break;
1370
+ case 'key':
1371
+ if ( is_array( $v ) ) {
1372
+ $sanitized[ $k ] = array_map( 'sanitize_key', $v );
1373
+ } else {
1374
+ $sanitized[ $k ] = sanitize_key( $v );
1375
+ }
1376
+ break;
1377
+ case 'absint':
1378
+ if ( is_array( $v ) ) {
1379
+ $sanitized[ $k ] = array_map( 'absint', $v );
1380
+ } else {
1381
+ $sanitized[ $k ] = absint( $v );
1382
+ }
1383
+ break;
1384
+ }
1385
+ }
1386
+
1387
+ $data = $sanitized;
1388
+
1389
+ $data = apply_filters( 'um_save_builder_input_sanitize', $data );
1390
+
1391
+ return $data;
1392
+ }
1393
+
1394
+
1395
+ /**
1396
+ * Sanitize form meta when wp-admin form has been submitted
1397
+ *
1398
+ * @todo checking all sanitize types
1399
+ *
1400
+ * @param array $data
1401
+ *
1402
+ * @return array
1403
+ */
1404
+ public function sanitize_form_meta( $data ) {
1405
+ $sanitized = array();
1406
+ foreach ( $data as $k => $v ) {
1407
+ if ( ! array_key_exists( $k, $this->form_meta ) ) {
1408
+ // @todo remove since 2.2.x and leave only continue
1409
+ $sanitized[ $k ] = $v;
1410
+ continue;
1411
+ }
1412
+
1413
+ if ( ! array_key_exists( 'sanitize', $this->form_meta[ $k ] ) ) {
1414
+ // @todo remove since 2.2.x and leave only continue
1415
+ $sanitized[ $k ] = $v;
1416
+ continue;
1417
+ }
1418
+
1419
+ if ( is_callable( $this->form_meta[ $k ]['sanitize'], true, $callable_name ) ) {
1420
+ add_filter( 'um_form_meta_sanitize_' . $k, $this->form_meta[ $k ]['sanitize'], 10, 1 );
1421
+ }
1422
+
1423
+ switch ( $this->form_meta[ $k ]['sanitize'] ) {
1424
+ default:
1425
+ $sanitized[ $k ] = apply_filters( 'um_form_meta_sanitize_' . $k, $data[ $k ] );
1426
+ break;
1427
+ case 'int':
1428
+ $sanitized[ $k ] = (int) $v;
1429
+ break;
1430
+ case 'bool':
1431
+ $sanitized[ $k ] = (bool) $v;
1432
+ break;
1433
+ case 'url':
1434
+ if ( is_array( $v ) ) {
1435
+ $sanitized[ $k ] = array_map( 'esc_url_raw', $v );
1436
+ } else {
1437
+ $sanitized[ $k ] = esc_url_raw( $v );
1438
+ }
1439
+ break;
1440
+ case 'text':
1441
+ $sanitized[ $k ] = sanitize_text_field( $v );
1442
+ break;
1443
+ case 'textarea':
1444
+ $sanitized[ $k ] = sanitize_textarea_field( $v );
1445
+ break;
1446
+ case 'key':
1447
+ if ( is_array( $v ) ) {
1448
+ $sanitized[ $k ] = array_map( 'sanitize_key', $v );
1449
+ } else {
1450
+ $sanitized[ $k ] = sanitize_key( $v );
1451
+ }
1452
+ break;
1453
+ case 'absint':
1454
+ if ( is_array( $v ) ) {
1455
+ $sanitized[ $k ] = array_map( 'absint', $v );
1456
+ } else {
1457
+ $sanitized[ $k ] = absint( $v );
1458
+ }
1459
+ break;
1460
+ }
1461
+ }
1462
+
1463
+ $data = $sanitized;
1464
+
1465
+ $data = apply_filters( 'um_save_form_meta_sanitize', $data );
1466
+
1467
+ return $data;
1468
+ }
1469
+
1470
+
1471
+ /**
1472
+ * Sanitize options when wp-admin form has been submitted
1473
+ *
1474
+ * @todo checking all sanitize types
1475
+ *
1476
+ * @param array $data
1477
+ *
1478
+ * @return array
1479
+ */
1480
+ public function sanitize_options( $data ) {
1481
+ $sanitized = array();
1482
+ foreach ( $data as $k => $v ) {
1483
+ if ( ! array_key_exists( $k, UM()->admin_settings()->settings_map ) ) {
1484
+ // @todo remove since 2.2.x and leave only continue
1485
+ $sanitized[ $k ] = $v;
1486
+ continue;
1487
+ }
1488
+
1489
+ if ( ! array_key_exists( 'sanitize', UM()->admin_settings()->settings_map[ $k ] ) ) {
1490
+ // @todo remove since 2.2.x and leave only continue
1491
+ $sanitized[ $k ] = $v;
1492
+ continue;
1493
+ }
1494
+
1495
+ if ( is_callable( UM()->admin_settings()->settings_map[ $k ]['sanitize'], true, $callable_name ) ) {
1496
+ add_filter( 'um_settings_sanitize_' . $k, UM()->admin_settings()->settings_map[ $k ]['sanitize'], 10, 1 );
1497
+ }
1498
+
1499
+ switch ( UM()->admin_settings()->settings_map[ $k ]['sanitize'] ) {
1500
+ default:
1501
+ $sanitized[ $k ] = apply_filters( 'um_settings_sanitize_' . $k, $v );
1502
+ break;
1503
+ case 'int':
1504
+ $sanitized[ $k ] = (int) $v;
1505
+ break;
1506
+ case 'absint':
1507
+ if ( is_array( $v ) ) {
1508
+ $sanitized[ $k ] = array_map( 'absint', $v );
1509
+ } else {
1510
+ $sanitized[ $k ] = absint( $v );
1511
+ }
1512
+ break;
1513
+ case 'key':
1514
+ if ( is_array( $v ) ) {
1515
+ $sanitized[ $k ] = array_map( 'sanitize_key', $v );
1516
+ } else {
1517
+ $sanitized[ $k ] = sanitize_key( $v );
1518
+ }
1519
+ break;
1520
+ case 'bool':
1521
+ $sanitized[ $k ] = (bool) $v;
1522
+ break;
1523
+ case 'url':
1524
+ if ( is_array( $v ) ) {
1525
+ $sanitized[ $k ] = array_map( 'esc_url_raw', $v );
1526
+ } else {
1527
+ $sanitized[ $k ] = esc_url_raw( $v );
1528
+ }
1529
+ break;
1530
+ case 'wp_kses':
1531
+ $sanitized[ $k ] = wp_kses_post( $v );
1532
+ break;
1533
+ case 'textarea':
1534
+ $sanitized[ $k ] = sanitize_textarea_field( $v );
1535
+ break;
1536
+ case 'text':
1537
+ $sanitized[ $k ] = sanitize_text_field( $v );
1538
+ break;
1539
+ }
1540
+ }
1541
+
1542
+ $data = $sanitized;
1543
+
1544
+ $data = apply_filters( 'um_save_settings_sanitize', $data );
1545
+
1546
+ return $data;
1547
+ }
1548
+
1549
+
1550
+ /**
1551
+ * Adds class to our admin pages
1552
+ *
1553
+ * @param $classes
1554
+ *
1555
+ * @return string
1556
+ */
1557
+ public function admin_body_class( $classes ) {
1558
+ if ( $this->is_um_screen() ) {
1559
+ return "$classes um-admin";
1560
+ }
1561
+ return $classes;
1562
+ }
1563
+
1564
+
1565
+ /**
1566
+ *
1567
+ */
1568
+ public function manual_upgrades_request() {
1569
+ if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
1570
+ die();
1571
+ }
1572
+
1573
+ $last_request = get_option( 'um_last_manual_upgrades_request', false );
1574
+
1575
+ if ( empty( $last_request ) || time() > $last_request + DAY_IN_SECONDS ) {
1576
+
1577
+ if ( is_multisite() ) {
1578
+ $blogs_ids = get_sites();
1579
+ foreach( $blogs_ids as $b ) {
1580
+ switch_to_blog( $b->blog_id );
1581
+ wp_clean_update_cache();
1582
+
1583
+ UM()->plugin_updater()->um_checklicenses();
1584
+
1585
+ update_option( 'um_last_manual_upgrades_request', time() );
1586
+ restore_current_blog();
1587
+ }
1588
+ } else {
1589
+ wp_clean_update_cache();
1590
+
1591
+ UM()->plugin_updater()->um_checklicenses();
1592
+
1593
+ update_option( 'um_last_manual_upgrades_request', time() );
1594
+ }
1595
+
1596
+ $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'got_updates' ), admin_url( 'admin.php' ) );
1597
+ } else {
1598
+ $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'often_updates' ), admin_url( 'admin.php' ) );
1599
+ }
1600
+ exit( wp_redirect( $url ) );
1601
+ }
1602
+
1603
+
1604
+ /**
1605
+ * Core pages installation
1606
+ */
1607
+ function install_core_pages() {
1608
+ if ( ! is_admin() ) {
1609
+ die();
1610
+ }
1611
+
1612
+ UM()->setup()->install_default_pages();
1613
+
1614
+ //check empty pages in settings
1615
+ $empty_pages = array();
1616
+
1617
+ $pages = UM()->config()->permalinks;
1618
+ if ( $pages && is_array( $pages ) ) {
1619
+ foreach ( $pages as $slug => $page_id ) {
1620
+ $page = get_post( $page_id );
1621
+
1622
+ if ( ! isset( $page->ID ) && in_array( $slug, array_keys( UM()->config()->core_pages ) ) ) {
1623
+ $empty_pages[] = $slug;
1624
+ }
1625
+ }
1626
+ }
1627
+
1628
+ //if there aren't empty pages - then hide pages notice
1629
+ if ( empty( $empty_pages ) ) {
1630
+ $hidden_notices = get_option( 'um_hidden_admin_notices', array() );
1631
+ $hidden_notices[] = 'wrong_pages';
1632
+
1633
+ update_option( 'um_hidden_admin_notices', $hidden_notices );
1634
+ }
1635
+
1636
+ $url = add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) );
1637
+ exit( wp_redirect( $url ) );
1638
+ }
1639
+
1640
+
1641
+ /**
1642
+ * Clear all users cache
1643
+ *
1644
+ * @param $action
1645
+ */
1646
+ function user_cache( $action ) {
1647
+ global $wpdb;
1648
+ if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
1649
+ die();
1650
+ }
1651
+
1652
+ $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" );
1653
+
1654
+ $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'cleared_cache' ), admin_url( 'admin.php' ) );
1655
+ exit( wp_redirect( $url ) );
1656
+ }
1657
+
1658
+
1659
+ /**
1660
+ * Purge temp uploads dir
1661
+ * @param $action
1662
+ */
1663
+ function purge_temp( $action ) {
1664
+ if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
1665
+ die();
1666
+ }
1667
+
1668
+ UM()->files()->remove_dir( UM()->files()->upload_temp );
1669
+
1670
+ $url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'purged_temp' ), admin_url( 'admin.php' ) );
1671
+ exit( wp_redirect( $url ) );
1672
+ }
1673
+
1674
+
1675
+ /**
1676
+ * Duplicate form
1677
+ *
1678
+ * @param $action
1679
+ */
1680
+ function duplicate_form( $action ) {
1681
+ if ( ! is_admin() || ! current_user_can('manage_options') ) {
1682
+ die();
1683
+ }
1684
+ if ( ! isset( $_REQUEST['post_id'] ) || ! is_numeric( $_REQUEST['post_id'] ) ) {
1685
+ die();
1686
+ }
1687
+
1688
+ $post_id = absint( $_REQUEST['post_id'] );
1689
+
1690
+ $n = array(
1691
+ 'post_type' => 'um_form',
1692
+ 'post_title' => sprintf( __( 'Duplicate of %s', 'ultimate-member' ), get_the_title( $post_id ) ),
1693
+ 'post_status' => 'publish',
1694
+ 'post_author' => get_current_user_id(),
1695
+ );
1696
+
1697
+ $n_id = wp_insert_post( $n );
1698
+
1699
+ $n_fields = get_post_custom( $post_id );
1700
+ foreach ( $n_fields as $key => $value ) {
1701
+
1702
+ if ( $key == '_um_custom_fields' ) {
1703
+ $the_value = unserialize( $value[0] );
1704
+ } else {
1705
+ $the_value = $value[0];
1706
+ }
1707
+
1708
+ update_post_meta( $n_id, $key, $the_value );
1709
+
1710
+ }
1711
+
1712
+ delete_post_meta( $n_id, '_um_core' );
1713
+
1714
+ $url = admin_url( 'edit.php?post_type=um_form' );
1715
+ $url = add_query_arg( 'update', 'form_duplicated', $url );
1716
+
1717
+ exit( wp_redirect( $url ) );
1718
+
1719
+ }
1720
+
1721
+
1722
+ /**
1723
+ * Action to hide notices in admin
1724
+ *
1725
+ * @param $action
1726
+ */
1727
+ function um_hide_notice( $action ) {
1728
+ if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
1729
+ die();
1730
+ }
1731
+
1732
+ update_option( $action, 1 );
1733
+ exit( wp_redirect( remove_query_arg( 'um_adm_action' ) ) );
1734
+ }
1735
+
1736
+
1737
+ /**
1738
+ * Various user actions
1739
+ *
1740
+ * @param $action
1741
+ */
1742
+ function user_action( $action ) {
1743
+ if ( ! is_admin() || ! current_user_can( 'edit_users' ) ) {
1744
+ die();
1745
+ }
1746
+ if ( ! isset( $_REQUEST['sub'] ) ) {
1747
+ die();
1748
+ }
1749
+ if ( ! isset( $_REQUEST['user_id'] ) ) {
1750
+ die();
1751
+ }
1752
+
1753
+ um_fetch_user( absint( $_REQUEST['user_id'] ) );
1754
+
1755
+ $subaction = sanitize_key( $_REQUEST['sub'] );
1756
+
1757
+ /**
1758
+ * UM hook
1759
+ *
1760
+ * @type action
1761
+ * @title um_admin_user_action_hook
1762
+ * @description Action on bulk user subaction
1763
+ * @input_vars
1764
+ * [{"var":"$subaction","type":"string","desc":"Bulk Subaction"}]
1765
+ * @change_log
1766
+ * ["Since: 2.0"]
1767
+ * @usage add_action( 'um_admin_user_action_hook', 'function_name', 10, 1 );
1768
+ * @example
1769
+ * <?php
1770
+ * add_action( 'um_admin_user_action_hook', 'my_admin_user_action', 10, 1 );
1771
+ * function my_admin_user_action( $subaction ) {
1772
+ * // your code here
1773
+ * }
1774
+ * ?>
1775
+ */
1776
+ do_action( 'um_admin_user_action_hook', $subaction );
1777
+ /**
1778
+ * UM hook
1779
+ *
1780
+ * @type action
1781
+ * @title um_admin_user_action_{$subaction}_hook
1782
+ * @description Action on bulk user subaction
1783
+ * @change_log
1784
+ * ["Since: 2.0"]
1785
+ * @usage add_action( 'um_admin_user_action_{$subaction}_hook', 'function_name', 10 );
1786
+ * @example
1787
+ * <?php
1788
+ * add_action( 'um_admin_user_action_{$subaction}_hook', 'my_admin_user_action', 10 );
1789
+ * function my_admin_user_action() {
1790
+ * // your code here
1791
+ * }
1792
+ * ?>
1793
+ */
1794
+ do_action( "um_admin_user_action_{$subaction}_hook" );
1795
+
1796
+ um_reset_user();
1797
+
1798
+ wp_redirect( add_query_arg( 'update', 'user_updated', admin_url( '?page=ultimatemember' ) ) );
1799
+ exit;
1800
+
1801
+ }
1802
+
1803
+
1804
+ /**
1805
+ * Add any custom links to plugin page
1806
+ *
1807
+ * @param array $links
1808
+ *
1809
+ * @return array
1810
+ */
1811
+ function plugin_links( $links ) {
1812
+ $more_links[] = '<a href="http://docs.ultimatemember.com/">' . __( 'Docs', 'ultimate-member' ) . '</a>';
1813
+ $more_links[] = '<a href="'.admin_url().'admin.php?page=um_options">' . __( 'Settings', 'ultimate-member' ) . '</a>';
1814
+
1815
+ $links = $more_links + $links;
1816
+ return $links;
1817
+ }
1818
+
1819
+
1820
+ /**
1821
+ * Init admin action/filters + request handlers
1822
+ */
1823
+ function admin_init() {
1824
+ if ( is_admin() && current_user_can( 'manage_options' ) && ! empty( $_REQUEST['um_adm_action'] ) ) {
1825
+ $action = sanitize_key( $_REQUEST['um_adm_action'] );
1826
+
1827
+ /**
1828
+ * UM hook
1829
+ *
1830
+ * @type action
1831
+ * @title um_admin_do_action__
1832
+ * @description Make some action on custom admin action
1833
+ * @input_vars
1834
+ * [{"var":"$action","type":"string","desc":"Admin Action"}]
1835
+ * @change_log
1836
+ * ["Since: 2.0"]
1837
+ * @usage add_action( 'um_admin_do_action__', 'function_name', 10, 1 );
1838
+ * @example
1839
+ * <?php
1840
+ * add_action( 'um_admin_do_action__', 'my_admin_do_action', 10, 1 );
1841
+ * function my_admin_do_action( $action ) {
1842
+ * // your code here
1843
+ * }
1844
+ * ?>
1845
+ */
1846
+ do_action( 'um_admin_do_action__', $action );
1847
+ /**
1848
+ * UM hook
1849
+ *
1850
+ * @type action
1851
+ * @title um_admin_do_action__{$action}
1852
+ * @description Make some action on custom admin $action
1853
+ * @input_vars
1854
+ * [{"var":"$action","type":"string","desc":"Admin Action"}]
1855
+ * @change_log
1856
+ * ["Since: 2.0"]
1857
+ * @usage add_action( 'um_admin_do_action__{$action}', 'function_name', 10, 1 );
1858
+ * @example
1859
+ * <?php
1860
+ * add_action( 'um_admin_do_action__{$action}', 'my_admin_do_action', 10, 1 );
1861
+ * function my_admin_do_action( $action ) {
1862
+ * // your code here
1863
+ * }
1864
+ * ?>
1865
+ */
1866
+ do_action( "um_admin_do_action__{$action}", $action );
1867
+ }
1868
+ }
1869
+
1870
+
1871
+ /**
1872
+ * Updated post messages
1873
+ *
1874
+ * @param array $messages
1875
+ *
1876
+ * @return array
1877
+ */
1878
+ function post_updated_messages( $messages ) {
1879
+ global $post_ID;
1880
+
1881
+ $post_type = get_post_type( $post_ID );
1882
+
1883
+ if ( $post_type == 'um_form' ) {
1884
+ $messages['um_form'] = array(
1885
+ 0 => '',
1886
+ 1 => __( 'Form updated.', 'ultimate-member' ),
1887
+ 2 => __( 'Custom field updated.', 'ultimate-member' ),
1888
+ 3 => __( 'Custom field deleted.', 'ultimate-member' ),
1889
+ 4 => __( 'Form updated.', 'ultimate-member' ),
1890
+ 5 => isset( $_GET['revision'] ) ? __( 'Form restored to revision.', 'ultimate-member' ) : false,
1891
+ 6 => __( 'Form created.', 'ultimate-member' ),
1892
+ 7 => __( 'Form saved.', 'ultimate-member' ),
1893
+ 8 => __( 'Form submitted.', 'ultimate-member' ),
1894
+ 9 => __( 'Form scheduled.', 'ultimate-member' ),
1895
+ 10 => __( 'Form draft updated.', 'ultimate-member' ),
1896
+ );
1897
+ }
1898
+
1899
+ return $messages;
1900
+ }
1901
+
1902
+
1903
+ /**
1904
+ * Gettext filters
1905
+ *
1906
+ * @param $translation
1907
+ * @param $text
1908
+ * @param $domain
1909
+ *
1910
+ * @return string
1911
+ */
1912
+ function gettext( $translation, $text, $domain ) {
1913
+ global $post;
1914
+ if ( isset( $post->post_type ) && $this->is_plugin_post_type() ) {
1915
+ $translations = get_translations_for_domain( $domain );
1916
+ if ( $text == 'Publish' ) {
1917
+ return $translations->translate( 'Create' );
1918
+ } elseif ( $text == 'Move to Trash' ) {
1919
+ return $translations->translate( 'Delete' );
1920
+ }
1921
+ }
1922
+
1923
+ return $translation;
1924
+ }
1925
+
1926
+
1927
+ /**
1928
+ * Fix parent file for correct highlighting
1929
+ *
1930
+ * @param $parent_file
1931
+ *
1932
+ * @return string
1933
+ */
1934
+ function parent_file( $parent_file ) {
1935
+ global $current_screen;
1936
+ $screen_id = $current_screen->id;
1937
+ if ( strstr( $screen_id, 'um_' ) ) {
1938
+ $parent_file = 'ultimatemember';
1939
+ }
1940
+ return $parent_file;
1941
+ }
1942
+
1943
+
1944
+ /**
1945
+ * @since 2.0
1946
+ *
1947
+ * @return core\Admin_Notices()
1948
+ */
1949
+ function notices() {
1950
+ if ( empty( UM()->classes['admin_notices'] ) ) {
1951
+ UM()->classes['admin_notices'] = new core\Admin_Notices();
1952
+ }
1953
+ return UM()->classes['admin_notices'];
1954
+ }
1955
+ }
1956
+ }
includes/admin/core/class-admin-builder.php CHANGED
@@ -1,1211 +1,1223 @@
1
- <?php
2
- namespace um\admin\core;
3
-
4
-
5
- if ( ! defined( 'ABSPATH' ) ) exit;
6
-
7
-
8
- if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
9
-
10
-
11
- /**
12
- * Class Admin_Builder
13
- * @package um\admin\core
14
- */
15
- class Admin_Builder {
16
-
17
-
18
- /**
19
- * @var
20
- */
21
- var $form_id;
22
-
23
-
24
- /**
25
- * Admin_Builder constructor.
26
- */
27
- function __construct() {
28
- add_action( 'um_admin_field_modal_header', array( &$this, 'add_message_handlers' ) );
29
- add_action( 'um_admin_field_modal_footer', array( &$this, 'add_conditional_support' ), 10, 4 );
30
- add_filter( 'um_admin_builder_skip_field_validation', array( &$this, 'skip_field_validation' ), 10, 3 );
31
- add_filter( 'um_admin_pre_save_field_to_form', array( &$this, 'um_admin_pre_save_field_to_form' ), 1 );
32
- add_filter( 'um_admin_pre_save_fields_hook', array( &$this, 'um_admin_pre_save_fields_hook' ), 1 );
33
- add_filter( 'um_admin_field_update_error_handling', array( &$this, 'um_admin_field_update_error_handling' ), 1, 2 );
34
- }
35
-
36
-
37
- /**
38
- * Apply a filter to handle errors for field updating in backend
39
- *
40
- * @param $errors
41
- * @param $array
42
- *
43
- * @return mixed
44
- */
45
- function um_admin_field_update_error_handling( $errors, $array ) {
46
- /**
47
- * @var $field_type
48
- */
49
- extract( $array );
50
-
51
- $field_attr = UM()->builtin()->get_core_field_attrs( $field_type );
52
-
53
- if ( isset( $field_attr['validate'] ) ) {
54
-
55
- $validate = $field_attr['validate'];
56
- foreach ( $validate as $post_input => $arr ) {
57
-
58
- $skip = apply_filters( 'um_admin_builder_skip_field_validation', false, $post_input, $array );
59
- if ( $skip ) {
60
- continue;
61
- }
62
-
63
- $mode = $arr['mode'];
64
-
65
- switch ( $mode ) {
66
-
67
- case 'numeric':
68
- if ( ! empty( $array['post'][ $post_input ] ) && ! is_numeric( $array['post'][ $post_input ] ) ){
69
- $errors[ $post_input ] = $validate[ $post_input ]['error'];
70
- }
71
- break;
72
-
73
- case 'unique':
74
- if ( ! isset( $array['post']['edit_mode'] ) ) {
75
- if ( UM()->builtin()->unique_field_err( $array['post'][ $post_input ] ) ) {
76
- $errors[ $post_input ] = UM()->builtin()->unique_field_err( $array['post'][ $post_input ] );
77
- }
78
- }
79
- break;
80
-
81
- case 'required':
82
- if ( $array['post'][ $post_input ] == '' ) {
83
- $errors[ $post_input ] = $validate[ $post_input ]['error'];
84
- }
85
- break;
86
-
87
- case 'range-start':
88
- if ( UM()->builtin()->date_range_start_err( $array['post'][ $post_input ] ) && $array['post']['_range'] == 'date_range' ) {
89
- $errors[ $post_input ] = UM()->builtin()->date_range_start_err( $array['post'][ $post_input ] );
90
- }
91
- break;
92
-
93
- case 'range-end':
94
- if ( UM()->builtin()->date_range_end_err( $array['post'][ $post_input ], $array['post']['_range_start'] ) && $array['post']['_range'] == 'date_range' ) {
95
- $errors[ $post_input ] = UM()->builtin()->date_range_end_err( $array['post'][ $post_input ], $array['post']['_range_start'] );
96
- }
97
- break;
98
-
99
- }
100
-
101
- }
102
-
103
- }
104
-
105
- return $errors;
106
-
107
- }
108
-
109
-
110
- /**
111
- * Some fields may require extra fields before saving
112
- *
113
- * @param $array
114
- *
115
- * @return mixed
116
- */
117
- function um_admin_pre_save_fields_hook( $array ) {
118
- /**
119
- * @var $form_id
120
- * @var $field_type
121
- */
122
- extract( $array );
123
-
124
- $fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
125
-
126
- $fields = UM()->query()->get_attr( 'custom_fields', $form_id );
127
- $count = 1;
128
- if ( ! empty( $fields ) ) {
129
- $count = count( $fields ) + 1;
130
- }
131
-
132
- // set unique meta key
133
- if ( in_array( $field_type, $fields_without_metakey ) && ! isset( $array['post']['_metakey'] ) ) {
134
- $array['post']['_metakey'] = "um_{$field_type}_{$form_id}_{$count}";
135
- }
136
-
137
- // set position
138
- if ( ! isset( $array['post']['_position'] ) ) {
139
- $array['post']['_position'] = $count;
140
- }
141
-
142
- return $array;
143
- }
144
-
145
-
146
- /**
147
- * Modify field args just before it is saved into form
148
- *
149
- * @param $array
150
- *
151
- * @return mixed
152
- */
153
- function um_admin_pre_save_field_to_form( $array ){
154
- unset( $array['conditions'] );
155
- if ( isset($array['conditional_field']) && ! empty( $array['conditional_action'] ) && ! empty( $array['conditional_operator'] ) ) {
156
- $array['conditional_value'] = isset( $array['conditional_value'] ) ? $array['conditional_value'] : '';
157
- $array['conditions'][] = array( $array['conditional_action'], $array['conditional_field'], $array['conditional_operator'], $array['conditional_value'] );
158
- }
159
-
160
- if ( isset( $array['conditional_field1'] ) && ! empty( $array['conditional_action1'] ) && ! empty( $array['conditional_operator1'] ) ) {
161
- $array['conditional_value1'] = isset( $array['conditional_value1'] ) ? $array['conditional_value1'] : '';
162
- $array['conditions'][] = array( $array['conditional_action1'], $array['conditional_field1'], $array['conditional_operator1'], $array['conditional_value1'] );
163
- }
164
-
165
- if ( isset( $array['conditional_field2'] ) && ! empty( $array['conditional_action2'] ) && ! empty( $array['conditional_operator2'] ) ) {
166
- $array['conditional_value2'] = isset( $array['conditional_value2'] ) ? $array['conditional_value2'] : '';
167
- $array['conditions'][] = array( $array['conditional_action2'], $array['conditional_field2'], $array['conditional_operator2'], $array['conditional_value2'] );
168
- }
169
-
170
- if ( isset( $array['conditional_field3'] ) && ! empty( $array['conditional_action3'] ) && ! empty( $array['conditional_operator3'] ) ) {
171
- $array['conditional_value3'] = isset( $array['conditional_value3'] ) ? $array['conditional_value3'] : '';
172
- $array['conditions'][] = array( $array['conditional_action3'], $array['conditional_field3'], $array['conditional_operator3'], $array['conditional_value3'] );
173
- }
174
-
175
- if ( isset( $array['conditional_field4'] ) && ! empty( $array['conditional_action4'] ) && ! empty( $array['conditional_operator4'] ) ) {
176
- $array['conditional_value4'] = isset( $array['conditional_value4'] ) ? $array['conditional_value4'] : '';
177
- $array['conditions'][] = array( $array['conditional_action4'], $array['conditional_field4'], $array['conditional_operator4'], $array['conditional_value4'] );
178
- }
179
-
180
- return $array;
181
- }
182
-
183
-
184
- /**
185
- * Put status handler in modal
186
- */
187
- function add_message_handlers() {
188
- ?>
189
- <div class="um-admin-error-block"></div>
190
- <div class="um-admin-success-block"></div>
191
- <?php
192
- }
193
-
194
-
195
- /**
196
- * Footer of modal
197
- *
198
- * @param $form_id
199
- * @param $field_args
200
- * @param $in_edit
201
- * @param $edit_array
202
- */
203
- function add_conditional_support( $form_id, $field_args, $in_edit, $edit_array ) {
204
- $metabox = UM()->metabox();
205
-
206
- if ( isset( $field_args['conditional_support'] ) && $field_args['conditional_support'] == 0 ) {
207
- return;
208
- } ?>
209
-
210
- <div class="um-admin-btn-toggle">
211
-
212
- <?php if ( $in_edit ) { $metabox->in_edit = true; $metabox->edit_array = $edit_array; ?>
213
- <a href="javascript:void(0);"><i class="um-icon-plus"></i><?php _e( 'Manage conditional fields support' ); ?></a> <?php UM()->tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
214
- <?php } else { ?>
215
- <a href="javascript:void(0);"><i class="um-icon-plus"></i><?php _e( 'Add conditional fields support' ); ?></a> <?php UM()->tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
216
- <?php } ?>
217
-
218
- <div class="um-admin-btn-content">
219
- <div class="um-admin-cur-condition-template">
220
-
221
- <?php $metabox->field_input( '_conditional_action', $form_id ); ?>
222
- <?php $metabox->field_input( '_conditional_field', $form_id ); ?>
223
- <?php $metabox->field_input( '_conditional_operator', $form_id ); ?>
224
- <?php $metabox->field_input( '_conditional_value', $form_id ); ?>
225
-
226
- <p><a href="javascript:void(0);" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
227
-
228
- <div class="um-admin-clear"></div>
229
- </div>
230
- <p class="um-admin-conditions-notice">
231
- <small>
232
- <?php _e( 'Use the condition operator `equals to` or `not equals` if the parent field has a single option.', 'ultimate-member' ); ?>
233
- <br><?php _e( 'Use the condition operator `greater than` or `less than` if the parent field is a number.', 'ultimate-member' ); ?>
234
- <br><?php _e( 'Use the condition operator `contains` if the parent field has multiple options.', 'ultimate-member' ); ?>
235
- </small>
236
- </p>
237
- <p><a href="javascript:void(0);" class="um-admin-new-condition button button-primary um-admin-tipsy-n" title="Add new condition"><?php _e( 'Add new rule', 'ultimate-member' ); ?></a></p>
238
- <p class="um-admin-reset-conditions"><a href="javascript:void(0);" class="button"><?php _e( 'Reset all rules', 'ultimate-member' ); ?></a></p>
239
-
240
- <div class="um-admin-clear"></div>
241
-
242
- <?php if ( isset( $edit_array['conditions'] ) && count( $edit_array['conditions'] ) != 0 ) {
243
-
244
- foreach ( $edit_array['conditions'] as $k => $arr ) {
245
-
246
- if ( $k == 0 ) $k = ''; ?>
247
-
248
- <div class="um-admin-cur-condition">
249
-
250
- <?php $metabox->field_input( '_conditional_action' . $k, $form_id ); ?>
251
- <?php $metabox->field_input( '_conditional_field' . $k , $form_id ); ?>
252
- <?php $metabox->field_input( '_conditional_operator' . $k, $form_id ); ?>
253
- <?php $metabox->field_input( '_conditional_value' . $k, $form_id ); ?>
254
-
255
- <p><a href="#" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
256
-
257
- <div class="um-admin-clear"></div>
258
- </div>
259
-
260
- <?php
261
- }
262
-
263
- } else { ?>
264
-
265
- <div class="um-admin-cur-condition">
266
-
267
- <?php $metabox->field_input( '_conditional_action', $form_id ); ?>
268
- <?php $metabox->field_input( '_conditional_field', $form_id ); ?>
269
- <?php $metabox->field_input( '_conditional_operator', $form_id ); ?>
270
- <?php $metabox->field_input( '_conditional_value', $form_id ); ?>
271
-
272
- <p><a href="#" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
273
-
274
- <div class="um-admin-clear"></div>
275
- </div>
276
-
277
- <?php } ?>
278
- </div>
279
- </div>
280
-
281
- <?php
282
- }
283
-
284
-
285
- /**
286
- * Update the builder area
287
- */
288
- function update_builder() {
289
- UM()->admin()->check_ajax_nonce();
290
-
291
- if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
292
- wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
293
- }
294
-
295
- ob_start();
296
-
297
- $this->form_id = absint( $_POST['form_id'] );
298
-
299
- $this->show_builder();
300
-
301
- $output = ob_get_clean();
302
-
303
- if ( is_array( $output ) ) {
304
- print_r( $output );
305
- } else {
306
- echo $output;
307
- }
308
- die;
309
- }
310
-
311
-
312
- /**
313
- * Sort array function
314
- *
315
- * @param array $arr
316
- * @param string $col
317
- * @param int $dir
318
- *
319
- * @return array
320
- */
321
- function array_sort_by_column( $arr, $col, $dir = SORT_ASC ) {
322
- $sort_col = array();
323
-
324
- foreach ( $arr as $key => $row ) {
325
- if ( ! empty( $row[ $col ] ) ) {
326
- $sort_col[ $key ] = $row[ $col ];
327
- }
328
- }
329
-
330
- if ( ! empty( $sort_col ) ) {
331
- array_multisort( $sort_col, $dir, $arr );
332
- }
333
-
334
- return $arr;
335
- }
336
-
337
-
338
- /**
339
- * Get fields in row
340
- *
341
- * @param $row_id
342
- *
343
- * @return string
344
- */
345
- function get_fields_by_row( $row_id ) {
346
-
347
- if ( empty( $this->global_fields ) || ! is_array( $this->global_fields ) ) {
348
- $this->global_fields = array();
349
- }
350
-
351
- foreach ( $this->global_fields as $key => $array ) {
352
- if ( ! isset( $array['in_row'] ) || ( isset( $array['in_row'] ) && $array['in_row'] == $row_id ) ) {
353
- $results[ $key ] = $array;
354
- unset( $this->global_fields[ $key ] );
355
- }
356
- }
357
-
358
- return ( isset ( $results ) ) ? $results : '';
359
- }
360
-
361
-
362
- /**
363
- * Get fields by sub row
364
- *
365
- * @param $row_fields
366
- * @param $subrow_id
367
- *
368
- * @return string
369
- */
370
- function get_fields_in_subrow( $row_fields, $subrow_id ) {
371
- if ( ! is_array( $row_fields ) ) {
372
- return '';
373
- }
374
-
375
- foreach( $row_fields as $key => $array ) {
376
- if ( ! isset( $array['in_sub_row'] ) || ( isset( $array['in_sub_row'] ) && $array['in_sub_row'] == $subrow_id ) ) {
377
- $results[ $key ] = $array;
378
- unset( $this->global_fields[ $key ] );
379
- }
380
- }
381
-
382
- return ( isset ( $results ) ) ? $results : '';
383
- }
384
-
385
-
386
- /**
387
- * Display the builder
388
- */
389
- function show_builder() {
390
-
391
- $fields = UM()->query()->get_attr( 'custom_fields', $this->form_id );
392
-
393
- if ( !isset( $fields ) || empty( $fields ) ) { ?>
394
-
395
- <div class="um-admin-drag-row">
396
-
397
- <!-- Master Row Actions -->
398
- <div class="um-admin-drag-row-icons">
399
- <a href="javascript:void(0);" class="um-admin-drag-rowsub-add um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Row', 'ultimate-member' ); ?>" data-row_action="add_subrow"><i class="um-icon-plus"></i></a>
400
- <a href="javascript:void(0);" class="um-admin-drag-row-edit um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit Row', 'ultimate-member' ); ?>" data-modal="UM_edit_row" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="row" data-arg2="<?php echo esc_attr( $this->form_id ); ?>" data-arg3="_um_row_1"><i class="um-faicon-pencil"></i></a>
401
- <span class="um-admin-drag-row-start"><i class="um-icon-arrow-move"></i></span>
402
- </div>
403
- <div class="um-admin-clear"></div>
404
-
405
- <div class="um-admin-drag-rowsubs">
406
- <div class="um-admin-drag-rowsub">
407
-
408
- <!-- Column Layout -->
409
- <div class="um-admin-drag-ctrls columns">
410
- <a href="javascript:void(0);" class="active" data-cols="1"></a>
411
- <a href="javascript:void(0);" data-cols="2"></a>
412
- <a href="javascript:void(0);" data-cols="3"></a>
413
- </div>
414
-
415
- <!-- Sub Row Actions -->
416
- <div class="um-admin-drag-rowsub-icons">
417
- <span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
418
- </div><div class="um-admin-clear"></div>
419
-
420
- <!-- Columns -->
421
- <div class="um-admin-drag-col">
422
-
423
- </div>
424
-
425
- <div class="um-admin-drag-col-dynamic"></div>
426
-
427
- <div class="um-admin-clear"></div>
428
-
429
- </div>
430
- </div>
431
-
432
- </div>
433
-
434
- <?php
435
-
436
- } else {
437
-
438
- if ( empty( $fields ) || ! is_array( $fields ) ) {
439
- $this->global_fields = array();
440
- } else {
441
- $this->global_fields = $fields;
442
- }
443
-
444
- foreach ( $this->global_fields as $key => $array ) {
445
- if ( $array['type'] == 'row' ) {
446
- $rows[ $key ] = $array;
447
- unset( $this->global_fields[ $key ] ); // not needed now
448
- }
449
-
450
- }
451
-
452
- if ( ! isset( $rows ) ) {
453
- $rows = array(
454
- '_um_row_1' => array(
455
- 'type' => 'row',
456
- 'id' => '_um_row_1',
457
- 'sub_rows' => 1,
458
- 'cols' => 1
459
- ),
460
- );
461
- }
462
-
463
- foreach ( $rows as $row_id => $array ) { ?>
464
-
465
- <div class="um-admin-drag-row" data-original="<?php echo esc_attr( $row_id ); ?>">
466
-
467
- <!-- Master Row Actions -->
468
- <div class="um-admin-drag-row-icons">
469
- <a href="javascript:void(0);" class="um-admin-drag-rowsub-add um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Row', 'ultimate-member' ); ?>" data-row_action="add_subrow"><i class="um-icon-plus"></i></a>
470
- <a href="javascript:void(0);" class="um-admin-drag-row-edit um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit Row', 'ultimate-member'); ?>" data-modal="UM_edit_row" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="row" data-arg2="<?php echo esc_attr( $this->form_id ); ?>" data-arg3="<?php echo esc_attr( $row_id ); ?>"><i class="um-faicon-pencil"></i></a>
471
- <span class="um-admin-drag-row-start"><i class="um-icon-arrow-move"></i></span>
472
- <?php if ( $row_id != '_um_row_1' ) {?>
473
- <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Row', 'ultimate-member' ); ?>" data-remove_element="um-admin-drag-row"><i class="um-faicon-trash-o"></i></a>
474
- <?php } ?>
475
- </div><div class="um-admin-clear"></div>
476
-
477
- <div class="um-admin-drag-rowsubs">
478
-
479
- <?php $row_fields = $this->get_fields_by_row( $row_id );
480
-
481
- $sub_rows = ( isset( $array['sub_rows'] ) ) ? $array['sub_rows'] : 1;
482
- for ( $c = 0; $c < $sub_rows; $c++ ) {
483
-
484
- $subrow_fields = $this->get_fields_in_subrow( $row_fields, $c );
485
-
486
- ?>
487
-
488
- <div class="um-admin-drag-rowsub">
489
-
490
- <!-- Column Layout -->
491
- <div class="um-admin-drag-ctrls columns">
492
-
493
- <?php
494
-
495
- if ( !isset( $array['cols'] ) ){
496
- $col_num = 1;
497
- } else {
498
-
499
- $col_split = explode(':', $array['cols'] );
500
- $col_num = $col_split[$c];
501
-
502
- }
503
-
504
- for ( $i = 1; $i <= 3; $i++ ) {
505
- echo '<a href="javascript:void(0);" data-cols="'.$i.'" ';
506
- if ( $col_num == $i ) echo 'class="active"';
507
- echo '></a>';
508
- }
509
-
510
- ?>
511
-
512
- </div>
513
-
514
- <!-- Sub Row Actions -->
515
- <div class="um-admin-drag-rowsub-icons">
516
- <span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
517
- <?php if ( $c > 0 ) { ?><a href="javascript:void(0);" class="um-admin-tipsy-n" title="Delete Row" data-remove_element="um-admin-drag-rowsub"><i class="um-faicon-trash-o"></i></a><?php } ?>
518
- </div>
519
- <div class="um-admin-clear"></div>
520
-
521
- <!-- Columns -->
522
- <div class="um-admin-drag-col">
523
-
524
- <?php
525
-
526
- if ( is_array( $subrow_fields ) ) {
527
-
528
- $subrow_fields = $this->array_sort_by_column( $subrow_fields, 'position');
529
-
530
- foreach( $subrow_fields as $key => $keyarray ) {
531
- /**
532
- * @var $type
533
- * @var $title
534
- */
535
- extract( $keyarray );
536
-
537
- ?>
538
-
539
- <div class="um-admin-drag-fld um-admin-delete-area um-field-type-<?php echo $type; ?> <?php echo $key; ?>" data-group="<?php echo (isset($keyarray['in_group'])) ? $keyarray['in_group'] : ''; ?>" data-key="<?php echo $key; ?>" data-column="<?php echo ( isset($keyarray['in_column']) ) ? $keyarray['in_column'] : 1; ?>">
540
-
541
- <div class="um-admin-drag-fld-title um-field-type-<?php echo $type; ?>">
542
- <?php if ( $type == 'group' ) { ?>
543
- <i class="um-icon-plus"></i>
544
- <?php } else if ( isset($keyarray['icon']) && !empty( $keyarray['icon'] ) ) { ?>
545
- <i class="<?php echo $keyarray['icon']; ?>"></i>
546
- <?php } ?><?php echo ! empty( $keyarray['title'] ) ? $keyarray['title'] : __( '(no title)', 'ultimate-member' ); ?></div>
547
- <?php $field_name = isset( UM()->builtin()->core_fields[$type]['name'] ) ? UM()->builtin()->core_fields[$type]['name'] : ''; ?>
548
- <div class="um-admin-drag-fld-type um-field-type-<?php echo $type; ?>"><?php echo $field_name; ?></div>
549
- <div class="um-admin-drag-fld-icons um-field-type-<?php echo $type; ?>">
550
-
551
- <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit', 'ultimate-member' ) ?>" data-modal="UM_edit_field" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="<?php echo $type; ?>" data-arg2="<?php echo $this->form_id; ?>" data-arg3="<?php echo $key; ?>"><i class="um-faicon-pencil"></i></a>
552
-
553
- <a href="javascript:void(0);" class="um-admin-tipsy-n um_admin_duplicate_field" title="<?php esc_attr_e( 'Duplicate', 'ultimate-member' ) ?>" data-silent_action="um_admin_duplicate_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-files-o"></i></a>
554
-
555
- <?php if ( $type == 'group' ) { ?>
556
-
557
- <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Group', 'ultimate-member' ) ?>" data-remove_element="um-admin-drag-fld.um-field-type-group" data-silent_action="um_admin_remove_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-trash-o"></i></a>
558
- <?php } else { ?>
559
-
560
- <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete', 'ultimate-member' ) ?>" data-silent_action="um_admin_remove_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-trash-o"></i></a>
561
-
562
- <?php } ?>
563
-
564
- </div><div class="um-admin-clear"></div>
565
-
566
- <?php if ( $type == 'group' ) { ?>
567
- <div class="um-admin-drag-group">
568
-
569
- </div>
570
- <?php } ?>
571
-
572
- </div>
573
-
574
- <?php
575
-
576
- } // end foreach
577
-
578
- } // end if
579
-
580
- ?>
581
-
582
- </div>
583
-
584
- <div class="um-admin-drag-col-dynamic"></div>
585
-
586
- <div class="um-admin-clear"></div>
587
-
588
- </div>
589
-
590
- <?php } ?>
591
-
592
- </div>
593
-
594
- </div>
595
-
596
- <?php
597
-
598
- } // rows loop
599
-
600
- } // if fields exist
601
-
602
- }
603
-
604
-
605
- /**
606
- *
607
- */
608
- function update_field() {
609
- UM()->admin()->check_ajax_nonce();
610
-
611
- if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
612
- wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
613
- }
614
-
615
- $output['error'] = null;
616
-
617
- $array = array(
618
- 'field_type' => sanitize_key( $_POST['_type'] ),
619
- 'form_id' => absint( $_POST['post_id'] ),
620
- 'args' => UM()->builtin()->get_core_field_attrs( sanitize_key( $_POST['_type'] ) ),
621
- 'post' => $_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
- $save[ $_metakey ]['content'] = $val;
693
- }
694
-
695
- }
696
-
697
- $field_ID = $_metakey;
698
- $field_args = $save[ $_metakey ];
699
-
700
- /**
701
- * UM hook
702
- *
703
- * @type filter
704
- * @title um_admin_pre_save_field_to_form
705
- * @description Change field options before save to form
706
- * @input_vars
707
- * [{"var":"$field_args","type":"array","desc":"Field Options"}]
708
- * @change_log
709
- * ["Since: 2.0"]
710
- * @usage add_filter( 'um_admin_pre_save_field_to_form', 'function_name', 10, 1 );
711
- * @example
712
- * <?php
713
- * add_filter( 'um_admin_pre_save_field_to_form', 'my_admin_pre_save_field_to_form', 10, 1 );
714
- * function my_admin_pre_save_field_to_form( $field_args ) {
715
- * // your code here
716
- * return $field_args;
717
- * }
718
- * ?>
719
- */
720
- $field_args = apply_filters( 'um_admin_pre_save_field_to_form', $field_args );
721
-
722
- UM()->fields()->update_field( $field_ID, $field_args, $post_id );
723
-
724
- /**
725
- * UM hook
726
- *
727
- * @type filter
728
- * @title um_admin_pre_save_field_to_db
729
- * @description Change field options before save to DB
730
- * @input_vars
731
- * [{"var":"$field_args","type":"array","desc":"Field Options"}]
732
- * @change_log
733
- * ["Since: 2.0"]
734
- * @usage add_filter( 'um_admin_pre_save_field_to_db', 'function_name', 10, 1 );
735
- * @example
736
- * <?php
737
- * add_filter( 'um_admin_pre_save_field_to_db', 'my_admin_pre_save_field_to_db', 10, 1 );
738
- * function my_admin_pre_save_field_to_form( $field_args ) {
739
- * // your code here
740
- * return $field_args;
741
- * }
742
- * ?>
743
- */
744
- $field_args = apply_filters( 'um_admin_pre_save_field_to_db', $field_args );
745
-
746
- if ( ! isset( $array['args']['form_only'] ) ) {
747
- if ( ! isset( UM()->builtin()->predefined_fields[ $field_ID ] ) ) {
748
- UM()->fields()->globally_update_field( $field_ID, $field_args );
749
- }
750
- }
751
-
752
- }
753
-
754
- $output = json_encode( $output );
755
- if ( is_array( $output ) ) {
756
- print_r( $output );
757
- } else {
758
- echo $output;
759
- }
760
- die;
761
- }
762
-
763
-
764
- /**
765
- *
766
- */
767
- function dynamic_modal_content() {
768
- UM()->admin()->check_ajax_nonce();
769
-
770
- if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
771
- wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
772
- }
773
-
774
- $metabox = UM()->metabox();
775
-
776
- /**
777
- * @var $act_id
778
- * @var $arg1
779
- * @var $arg2
780
- * @var $arg3
781
- */
782
- extract( $_POST );
783
-
784
- switch ( $act_id ) {
785
-
786
- default:
787
-
788
- ob_start();
789
-
790
- /**
791
- * UM hook
792
- *
793
- * @type action
794
- * @title um_admin_ajax_modal_content__hook
795
- * @description Integration hook on ajax popup admin builder modal content
796
- * @input_vars
797
- * [{"var":"$act_id","type":"string","desc":"Ajax Action"}]
798
- * @change_log
799
- * ["Since: 2.0"]
800
- * @usage add_action( 'um_admin_ajax_modal_content__hook', 'function_name', 10, 1 );
801
- * @example
802
- * <?php
803
- * add_action( 'um_admin_ajax_modal_content__hook', 'my_admin_custom_hook', 10, 1 );
804
- * function um_admin_ajax_modal_content__hook( $act_id ) {
805
- * // your code here
806
- * }
807
- * ?>
808
- */
809
- do_action( 'um_admin_ajax_modal_content__hook', $act_id );
810
- /**
811
- * UM hook
812
- *
813
- * @type action
814
- * @title um_admin_ajax_modal_content__hook_{$act_id}
815
- * @description Integration hook on ajax popup admin builder modal content
816
- * @change_log
817
- * ["Since: 2.0"]
818
- * @usage add_action( 'um_admin_ajax_modal_content__hook_{$act_id}', 'function_name', 10 );
819
- * @example
820
- * <?php
821
- * add_action( 'um_admin_ajax_modal_content__hook_{$act_id}', 'my_admin_ajax_modal_content', 10 );
822
- * function my_admin_ajax_modal_content() {
823
- * // your code here
824
- * }
825
- * ?>
826
- */
827
- do_action( "um_admin_ajax_modal_content__hook_{$act_id}" );
828
-
829
- $output = ob_get_clean();
830
- break;
831
-
832
- case 'um_admin_fonticon_selector':
833
-
834
- ob_start(); ?>
835
-
836
- <div class="um-admin-metabox">
837
- <p class="_icon_search"><input type="text" name="_icon_search" id="_icon_search" value="" placeholder="<?php esc_attr_e('Search Icons...', 'ultimate-member' ); ?>" /></p>
838
- </div>
839
-
840
- <div class="um-admin-icons">
841
- <?php foreach( UM()->fonticons()->all as $icon ) { ?>
842
- <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>
843
- <?php } ?>
844
- </div><div class="um-admin-clear"></div>
845
-
846
- <?php $output = ob_get_clean();
847
- break;
848
-
849
- case 'um_admin_show_fields':
850
-
851
- ob_start();
852
- $form_fields = UM()->query()->get_attr( 'custom_fields', $arg2 );
853
- $form_fields = array_values( array_filter( array_keys( $form_fields ) ) );
854
- //$form_fields = array_keys( $form_fields );
855
- ?>
856
-
857
- <h4><?php _e('Setup New Field','ultimate-member'); ?></h4>
858
- <div class="um-admin-btns">
859
-
860
- <?php if ( UM()->builtin()->core_fields ) {
861
- foreach ( UM()->builtin()->core_fields as $field_type => $array ) {
862
-
863
- if ( isset( $array['in_fields'] ) && $array['in_fields'] == false ) {
864
- continue;
865
- } ?>
866
-
867
- <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>
868
-
869
- <?php }
870
- } ?>
871
-
872
- </div>
873
-
874
- <h4><?php _e('Predefined Fields','ultimate-member'); ?></h4>
875
- <div class="um-admin-btns">
876
-
877
- <?php if ( UM()->builtin()->predefined_fields ) {
878
- foreach ( UM()->builtin()->predefined_fields as $field_key => $array ) {
879
- if ( ! isset( $array['account_only'] ) && ! isset( $array['private_use'] ) ) { ?>
880
-
881
- <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>
882
-
883
- <?php }
884
- }
885
- } else {
886
- echo '<p>' . __( 'None', 'ultimate-member' ) . '</p>';
887
- } ?>
888
-
889
- </div>
890
-
891
- <h4><?php _e( 'Custom Fields', 'ultimate-member' ); ?></h4>
892
- <div class="um-admin-btns">
893
-
894
- <?php
895
- if ( UM()->builtin()->custom_fields ) {
896
- foreach ( UM()->builtin()->custom_fields as $field_key => $array ) {
897
- if ( empty( $array['title'] ) || empty( $array['type'] ) ) {
898
- continue;
899
- } ?>
900
-
901
- <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>
902
-
903
- <?php }
904
- } else {
905
- echo '<p>' . __( 'You did not create any custom fields', 'ultimate-member' ) . '</p>';
906
- } ?>
907
-
908
- </div>
909
-
910
- <?php $output = ob_get_clean();
911
- break;
912
-
913
- case 'um_admin_edit_field_popup':
914
-
915
- ob_start();
916
-
917
- $args = UM()->builtin()->get_core_field_attrs( $arg1 );
918
-
919
- $form_fields = UM()->query()->get_attr( 'custom_fields', $arg2 );
920
-
921
- $metabox->set_field_type = $arg1;
922
- $metabox->in_edit = true;
923
- $metabox->edit_array = $form_fields[ $arg3 ];
924
-
925
- if ( !isset( $metabox->edit_array['metakey'] ) ){
926
- $metabox->edit_array['metakey'] = $metabox->edit_array['id'];
927
- }
928
-
929
- if ( !isset( $metabox->edit_array['position'] ) ){
930
- $metabox->edit_array['position'] = $metabox->edit_array['id'];
931
- }
932
-
933
- extract( $args );
934
-
935
- if ( ! isset( $col1 ) ) {
936
-
937
- echo '<p>'. __( 'This field type is not setup correcty.', 'ultimate-member' ) . '</p>';
938
-
939
- } else {
940
-
941
- ?>
942
-
943
- <?php if ( isset( $metabox->edit_array['in_group'] ) ) { ?>
944
- <input type="hidden" name="_in_row" id="_in_row" value="<?php echo $metabox->edit_array['in_row']; ?>" />
945
- <input type="hidden" name="_in_sub_row" id="_in_sub_row" value="<?php echo $metabox->edit_array['in_sub_row']; ?>" />
946
- <input type="hidden" name="_in_column" id="_in_column" value="<?php echo $metabox->edit_array['in_column']; ?>" />
947
- <input type="hidden" name="_in_group" id="_in_group" value="<?php echo $metabox->edit_array['in_group']; ?>" />
948
- <?php } ?>
949
-
950
- <input type="hidden" name="_type" id="_type" value="<?php echo $arg1; ?>" />
951
-
952
- <input type="hidden" name="post_id" id="post_id" value="<?php echo $arg2; ?>" />
953
-
954
- <input type="hidden" name="edit_mode" id="edit_mode" value="true" />
955
-
956
- <input type="hidden" name="_metakey" id="_metakey" value="<?php echo $metabox->edit_array['metakey']; ?>" />
957
-
958
- <input type="hidden" name="_position" id="_position" value="<?php echo $metabox->edit_array['position']; ?>" />
959
-
960
- <?php if ( isset( $args['mce_content'] ) ) { ?>
961
- <div class="dynamic-mce-content"><?php echo ! empty( $metabox->edit_array['content'] ) ? $metabox->edit_array['content'] : ''; ?></div>
962
- <?php } ?>
963
-
964
- <?php $this->modal_header(); ?>
965
-
966
- <div class="um-admin-half">
967
-
968
- <?php if ( isset( $col1 ) ) { foreach( $col1 as $opt ) $metabox->field_input ( $opt, null, $metabox->edit_array ); } ?>
969
-
970
- </div>
971
-
972
- <div class="um-admin-half um-admin-right">
973
-
974
- <?php if ( isset( $col2 ) ) { foreach( $col2 as $opt ) $metabox->field_input ( $opt, null, $metabox->edit_array ); } ?>
975
-
976
- </div><div class="um-admin-clear"></div>
977
-
978
- <?php if ( isset( $col3 ) ) { foreach( $col3 as $opt ) $metabox->field_input ( $opt, null, $metabox->edit_array ); } ?>
979
-
980
- <div class="um-admin-clear"></div>
981
-
982
- <?php if ( isset( $col_full ) ) {foreach( $col_full as $opt ) $metabox->field_input ( $opt, null, $metabox->edit_array ); } ?>
983
-
984
- <?php $this->modal_footer( $arg2, $args, $metabox ); ?>
985
-
986
- <?php
987
-
988
- }
989
-
990
- $output = ob_get_clean();
991
- break;
992
-
993
- case 'um_admin_new_field_popup':
994
-
995
- ob_start();
996
-
997
- $args = UM()->builtin()->get_core_field_attrs( $arg1 );
998
-
999
- $metabox->set_field_type = $arg1;
1000
-
1001
- /**
1002
- * @var $in_row
1003
- * @var $in_sub_row
1004
- * @var $in_column
1005
- * @var $in_group
1006
- */
1007
- extract( $args );
1008
-
1009
- if ( ! isset( $col1 ) ) {
1010
-
1011
- echo '<p>'. __( 'This field type is not setup correcty.', 'ultimate-member' ) . '</p>';
1012
-
1013
- } else {
1014
-
1015
- if ( $in_column ) { ?>
1016
- <input type="hidden" name="_in_row" id="_in_row" value="_um_row_<?php echo $in_row + 1; ?>" />
1017
- <input type="hidden" name="_in_sub_row" id="_in_sub_row" value="<?php echo $in_sub_row; ?>" />
1018
- <input type="hidden" name="_in_column" id="_in_column" value="<?php echo $in_column; ?>" />
1019
- <input type="hidden" name="_in_group" id="_in_group" value="<?php echo $in_group; ?>" />
1020
- <?php } ?>
1021
-
1022
- <input type="hidden" name="_type" id="_type" value="<?php echo $arg1; ?>" />
1023
-
1024
- <input type="hidden" name="post_id" id="post_id" value="<?php echo $arg2; ?>" />
1025
-
1026
- <?php $this->modal_header(); ?>
1027
-
1028
- <div class="um-admin-half">
1029
-
1030
- <?php if ( isset( $col1 ) ) { foreach( $col1 as $opt ) $metabox->field_input ( $opt ); } ?>
1031
-
1032
- </div>
1033
-
1034
- <div class="um-admin-half um-admin-right">
1035
-
1036
- <?php if ( isset( $col2 ) ) { foreach( $col2 as $opt ) $metabox->field_input ( $opt ); } ?>
1037
-
1038
- </div><div class="um-admin-clear"></div>
1039
-
1040
- <?php if ( isset( $col3 ) ) { foreach( $col3 as $opt ) $metabox->field_input ( $opt ); } ?>
1041
-
1042
- <div class="um-admin-clear"></div>
1043
-
1044
- <?php if ( isset( $col_full ) ) { foreach( $col_full as $opt ) $metabox->field_input ( $opt ); } ?>
1045
-
1046
- <?php $this->modal_footer( $arg2, $args, $metabox ); ?>
1047
-
1048
- <?php
1049
-
1050
- }
1051
-
1052
- $output = ob_get_clean();
1053
- break;
1054
-
1055
- case 'um_admin_preview_form':
1056
-
1057
- UM()->user()->preview = true;
1058
-
1059
- $mode = UM()->query()->get_attr('mode', $arg1 );
1060
-
1061
- if ( $mode == 'profile' ) {
1062
- UM()->fields()->editing = true;
1063
- }
1064
-
1065
- $output = '<div class="um-admin-preview-overlay"></div>';
1066
-
1067
- if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
1068
- $output .= do_shortcode('[ultimatemember form_id="' . $arg1 . '" /]');
1069
- } else {
1070
- $output .= apply_shortcodes('[ultimatemember form_id="' . $arg1 . '" /]');
1071
- }
1072
-
1073
- break;
1074
-
1075
- case 'um_admin_review_registration':
1076
- //$user_id = $arg1;
1077
-
1078
- if ( ! current_user_can( 'administrator' ) ) {
1079
- if ( ! um_can_view_profile( $arg1 ) ) {
1080
- $output = '';
1081
- break;
1082
- }
1083
- }
1084
-
1085
- um_fetch_user( $arg1 );
1086
-
1087
- UM()->user()->preview = true;
1088
-
1089
- $output = um_user_submitted_registration_formatted( true );
1090
-
1091
- um_reset_user();
1092
-
1093
- break;
1094
-
1095
- }
1096
-
1097
- if ( is_array( $output ) ) {
1098
- print_r( $output );
1099
- } else {
1100
- echo $output;
1101
- }
1102
- die;
1103
- }
1104
-
1105
-
1106
- /**
1107
- *
1108
- */
1109
- function modal_header() {
1110
- /**
1111
- * UM hook
1112
- *
1113
- * @type action
1114
- * @title um_admin_field_modal_header
1115
- * @description Modal Window Header
1116
- * @change_log
1117
- * ["Since: 2.0"]
1118
- * @usage add_action( 'um_admin_field_modal_header', 'function_name', 10 );
1119
- * @example
1120
- * <?php
1121
- * add_action( 'um_admin_field_modal_header', 'my_admin_field_modal_header', 10 );
1122
- * function my_admin_field_modal_header() {
1123
- * // your code here
1124
- * }
1125
- * ?>
1126
- */
1127
- do_action( 'um_admin_field_modal_header' );
1128
- }
1129
-
1130
-
1131
- /**
1132
- * Modal Footer loading
1133
- *
1134
- * @param $arg2
1135
- * @param $args
1136
- * @param $metabox
1137
- */
1138
- function modal_footer( $arg2, $args, $metabox ) {
1139
- /**
1140
- * UM hook
1141
- *
1142
- * @type action
1143
- * @title um_admin_field_modal_footer
1144
- * @description Modal Window Footer
1145
- * @input_vars
1146
- * [{"var":"$arg2","type":"string","desc":"Ajax Action"},
1147
- * {"var":"$args","type":"array","desc":"Modal window arguments"},
1148
- * {"var":"$in_edit","type":"bool","desc":"Is edit mode?"},
1149
- * {"var":"$edit_array","type":"array","desc":"Edit Array"}]
1150
- * @change_log
1151
- * ["Since: 2.0"]
1152
- * @usage add_action( 'um_admin_field_modal_footer', 'function_name', 10, 4 );
1153
- * @example
1154
- * <?php
1155
- * add_action( 'um_admin_field_modal_footer', 'my_admin_field_modal_footer', 10, 4 );
1156
- * function my_admin_field_modal_footer( $arg2, $args, $in_edit, $edit_array ) {
1157
- * // your code here
1158
- * }
1159
- * ?>
1160
- */
1161
- do_action( 'um_admin_field_modal_footer', $arg2, $args, $metabox->in_edit, ( isset( $metabox->edit_array ) ) ? $metabox->edit_array : '' );
1162
- }
1163
-
1164
-
1165
- /**
1166
- * Skip field validation for:
1167
- * - '_options' if Choices Callback specified
1168
- *
1169
- * @param boolean $skip
1170
- * @param string $post_input
1171
- * @param array $array
1172
- * @return boolean
1173
- */
1174
- public function skip_field_validation( $skip, $post_input, $array ) {
1175
- if ( $post_input === '_options' && isset( $array['post']['_custom_dropdown_options_source'] ) ) {
1176
- $skip = function_exists( $array['post']['_custom_dropdown_options_source'] );
1177
- }
1178
-
1179
- return $skip;
1180
- }
1181
-
1182
-
1183
- /**
1184
- * Retrieves dropdown/multi-select options from a callback function
1185
- */
1186
- function populate_dropdown_options() {
1187
- UM()->admin()->check_ajax_nonce();
1188
-
1189
- if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
1190
- wp_send_json_error( __( 'This is not possible for security reasons.', 'ultimate-member' ) );
1191
- }
1192
-
1193
- $arr_options = array();
1194
-
1195
- $um_callback_func = sanitize_key( $_POST['um_option_callback'] );
1196
- if ( empty( $um_callback_func ) ) {
1197
- $arr_options['status'] = 'empty';
1198
- $arr_options['function_name'] = $um_callback_func;
1199
- $arr_options['function_exists'] = function_exists( $um_callback_func );
1200
- }
1201
-
1202
- $arr_options['data'] = array();
1203
- if ( function_exists( $um_callback_func ) ) {
1204
- $arr_options['data'] = call_user_func( $um_callback_func );
1205
- }
1206
-
1207
- wp_send_json( $arr_options );
1208
- }
1209
-
1210
- }
1211
- }
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace um\admin\core;
3
+
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) exit;
6
+
7
+
8
+ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
9
+
10
+
11
+ /**
12
+ * Class Admin_Builder
13
+ * @package um\admin\core
14
+ */
15
+ class Admin_Builder {
16
+
17
+
18
+ /**
19
+ * @var
20
+ */
21
+ var $form_id;
22
+
23
+
24
+ /**
25
+ * Admin_Builder constructor.
26
+ */
27
+ function __construct() {
28
+ add_action( 'um_admin_field_modal_header', array( &$this, 'add_message_handlers' ) );
29
+ add_action( 'um_admin_field_modal_footer', array( &$this, 'add_conditional_support' ), 10, 4 );
30
+ add_filter( 'um_admin_builder_skip_field_validation', array( &$this, 'skip_field_validation' ), 10, 3 );
31
+ add_filter( 'um_admin_pre_save_field_to_form', array( &$this, 'um_admin_pre_save_field_to_form' ), 1 );
32
+ add_filter( 'um_admin_pre_save_fields_hook', array( &$this, 'um_admin_pre_save_fields_hook' ), 1 );
33
+ add_filter( 'um_admin_field_update_error_handling', array( &$this, 'um_admin_field_update_error_handling' ), 1, 2 );
34
+ }
35
+
36
+
37
+ /**
38
+ * Apply a filter to handle errors for field updating in backend
39
+ *
40
+ * @param $errors
41
+ * @param $array
42
+ *
43
+ * @return mixed
44
+ */
45
+ function um_admin_field_update_error_handling( $errors, $array ) {
46
+ /**
47
+ * @var $field_type
48
+ */
49
+ extract( $array );
50
+
51
+ $field_attr = UM()->builtin()->get_core_field_attrs( $field_type );
52
+
53
+ if ( isset( $field_attr['validate'] ) ) {
54
+
55
+ $validate = $field_attr['validate'];
56
+ foreach ( $validate as $post_input => $arr ) {
57
+
58
+ $skip = apply_filters( 'um_admin_builder_skip_field_validation', false, $post_input, $array );
59
+ if ( $skip ) {
60
+ continue;
61
+ }
62
+
63
+ $mode = $arr['mode'];
64
+
65
+ switch ( $mode ) {
66
+
67
+ case 'numeric':
68
+ if ( ! empty( $array['post'][ $post_input ] ) && ! is_numeric( $array['post'][ $post_input ] ) ){
69
+ $errors[ $post_input ] = $validate[ $post_input ]['error'];
70
+ }
71
+ break;
72
+
73
+ case 'unique':
74
+ if ( ! isset( $array['post']['edit_mode'] ) ) {
75
+ if ( UM()->builtin()->unique_field_err( $array['post'][ $post_input ] ) ) {
76
+ $errors[ $post_input ] = UM()->builtin()->unique_field_err( $array['post'][ $post_input ] );
77
+ }
78
+ }
79
+ break;
80
+
81
+ case 'required':
82
+ if ( $array['post'][ $post_input ] == '' ) {
83
+ $errors[ $post_input ] = $validate[ $post_input ]['error'];
84
+ }
85
+ break;
86
+
87
+ case 'range-start':
88
+ if ( UM()->builtin()->date_range_start_err( $array['post'][ $post_input ] ) && $array['post']['_range'] == 'date_range' ) {
89
+ $errors[ $post_input ] = UM()->builtin()->date_range_start_err( $array['post'][ $post_input ] );
90
+ }
91
+ break;
92
+
93
+ case 'range-end':
94
+ if ( UM()->builtin()->date_range_end_err( $array['post'][ $post_input ], $array['post']['_range_start'] ) && $array['post']['_range'] == 'date_range' ) {
95
+ $errors[ $post_input ] = UM()->builtin()->date_range_end_err( $array['post'][ $post_input ], $array['post']['_range_start'] );
96
+ }
97
+ break;
98
+
99
+ }
100
+
101
+ }
102
+
103
+ }
104
+
105
+ return $errors;
106
+
107
+ }
108
+
109
+
110
+ /**
111
+ * Some fields may require extra fields before saving
112
+ *
113
+ * @param $array
114
+ *
115
+ * @return mixed
116
+ */
117
+ function um_admin_pre_save_fields_hook( $array ) {
118
+ /**
119
+ * @var $form_id
120
+ * @var $field_type
121
+ */
122
+ extract( $array );
123
+
124
+ $fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
125
+
126
+ $fields = UM()->query()->get_attr( 'custom_fields', $form_id );
127
+ $count = 1;
128
+ if ( ! empty( $fields ) ) {
129
+ $count = count( $fields ) + 1;
130
+ }
131
+
132
+ // set unique meta key
133
+ if ( in_array( $field_type, $fields_without_metakey ) && ! isset( $array['post']['_metakey'] ) ) {
134
+ $array['post']['_metakey'] = "um_{$field_type}_{$form_id}_{$count}";
135
+ }
136
+
137
+ // set position
138
+ if ( ! isset( $array['post']['_position'] ) ) {
139
+ $array['post']['_position'] = $count;
140
+ }
141
+
142
+ return $array;
143
+ }
144
+
145
+
146
+ /**
147
+ * Modify field args just before it is saved into form
148
+ *
149
+ * @param $array
150
+ *
151
+ * @return mixed
152
+ */
153
+ function um_admin_pre_save_field_to_form( $array ){
154
+ unset( $array['conditions'] );
155
+ if ( isset($array['conditional_field']) && ! empty( $array['conditional_action'] ) && ! empty( $array['conditional_operator'] ) ) {
156
+ $array['conditional_value'] = isset( $array['conditional_value'] ) ? $array['conditional_value'] : '';
157
+ $array['conditions'][] = array( $array['conditional_action'], $array['conditional_field'], $array['conditional_operator'], $array['conditional_value'] );
158
+ }
159
+
160
+ if ( isset( $array['conditional_field1'] ) && ! empty( $array['conditional_action1'] ) && ! empty( $array['conditional_operator1'] ) ) {
161
+ $array['conditional_value1'] = isset( $array['conditional_value1'] ) ? $array['conditional_value1'] : '';
162
+ $array['conditions'][] = array( $array['conditional_action1'], $array['conditional_field1'], $array['conditional_operator1'], $array['conditional_value1'] );
163
+ }
164
+
165
+ if ( isset( $array['conditional_field2'] ) && ! empty( $array['conditional_action2'] ) && ! empty( $array['conditional_operator2'] ) ) {
166
+ $array['conditional_value2'] = isset( $array['conditional_value2'] ) ? $array['conditional_value2'] : '';
167
+ $array['conditions'][] = array( $array['conditional_action2'], $array['conditional_field2'], $array['conditional_operator2'], $array['conditional_value2'] );
168
+ }
169
+
170
+ if ( isset( $array['conditional_field3'] ) && ! empty( $array['conditional_action3'] ) && ! empty( $array['conditional_operator3'] ) ) {
171
+ $array['conditional_value3'] = isset( $array['conditional_value3'] ) ? $array['conditional_value3'] : '';
172
+ $array['conditions'][] = array( $array['conditional_action3'], $array['conditional_field3'], $array['conditional_operator3'], $array['conditional_value3'] );
173
+ }
174
+
175
+ if ( isset( $array['conditional_field4'] ) && ! empty( $array['conditional_action4'] ) && ! empty( $array['conditional_operator4'] ) ) {
176
+ $array['conditional_value4'] = isset( $array['conditional_value4'] ) ? $array['conditional_value4'] : '';
177
+ $array['conditions'][] = array( $array['conditional_action4'], $array['conditional_field4'], $array['conditional_operator4'], $array['conditional_value4'] );
178
+ }
179
+
180
+ return $array;
181
+ }
182
+
183
+
184
+ /**
185
+ * Put status handler in modal
186
+ */
187
+ function add_message_handlers() {
188
+ ?>
189
+ <div class="um-admin-error-block"></div>
190
+ <div class="um-admin-success-block"></div>
191
+ <?php
192
+ }
193
+
194
+
195
+ /**
196
+ * Footer of modal
197
+ *
198
+ * @param $form_id
199
+ * @param $field_args
200
+ * @param $in_edit
201
+ * @param $edit_array
202
+ */
203
+ function add_conditional_support( $form_id, $field_args, $in_edit, $edit_array ) {
204
+ $metabox = UM()->metabox();
205
+
206
+ if ( isset( $field_args['conditional_support'] ) && $field_args['conditional_support'] == 0 ) {
207
+ return;
208
+ } ?>
209
+
210
+ <div class="um-admin-btn-toggle">
211
+
212
+ <?php if ( $in_edit ) { $metabox->in_edit = true; $metabox->edit_array = $edit_array; ?>
213
+ <a href="javascript:void(0);"><i class="um-icon-plus"></i><?php _e( 'Manage conditional fields support' ); ?></a> <?php UM()->tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
214
+ <?php } else { ?>
215
+ <a href="javascript:void(0);"><i class="um-icon-plus"></i><?php _e( 'Add conditional fields support' ); ?></a> <?php UM()->tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
216
+ <?php } ?>
217
+
218
+ <div class="um-admin-btn-content">
219
+ <div class="um-admin-cur-condition-template">
220
+
221
+ <?php $metabox->field_input( '_conditional_action', $form_id ); ?>
222
+ <?php $metabox->field_input( '_conditional_field', $form_id ); ?>
223
+ <?php $metabox->field_input( '_conditional_operator', $form_id ); ?>
224
+ <?php $metabox->field_input( '_conditional_value', $form_id ); ?>
225
+
226
+ <p><a href="javascript:void(0);" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
227
+
228
+ <div class="um-admin-clear"></div>
229
+ </div>
230
+ <p class="um-admin-conditions-notice">
231
+ <small>
232
+ <?php _e( 'Use the condition operator `equals to` or `not equals` if the parent field has a single option.', 'ultimate-member' ); ?>
233
+ <br><?php _e( 'Use the condition operator `greater than` or `less than` if the parent field is a number.', 'ultimate-member' ); ?>
234
+ <br><?php _e( 'Use the condition operator `contains` if the parent field has multiple options.', 'ultimate-member' ); ?>
235
+ </small>
236
+ </p>
237
+ <p><a href="javascript:void(0);" class="um-admin-new-condition button button-primary um-admin-tipsy-n" title="Add new condition"><?php _e( 'Add new rule', 'ultimate-member' ); ?></a></p>
238
+ <p class="um-admin-reset-conditions"><a href="javascript:void(0);" class="button"><?php _e( 'Reset all rules', 'ultimate-member' ); ?></a></p>
239
+
240
+ <div class="um-admin-clear"></div>
241
+
242
+ <?php if ( isset( $edit_array['conditions'] ) && count( $edit_array['conditions'] ) != 0 ) {
243
+
244
+ foreach ( $edit_array['conditions'] as $k => $arr ) {
245
+
246
+ if ( $k == 0 ) $k = ''; ?>
247
+
248
+ <div class="um-admin-cur-condition">
249
+
250
+ <?php $metabox->field_input( '_conditional_action' . $k, $form_id ); ?>
251
+ <?php $metabox->field_input( '_conditional_field' . $k , $form_id ); ?>
252
+ <?php $metabox->field_input( '_conditional_operator' . $k, $form_id ); ?>
253
+ <?php $metabox->field_input( '_conditional_value' . $k, $form_id ); ?>
254
+
255
+ <p><a href="#" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
256
+
257
+ <div class="um-admin-clear"></div>
258
+ </div>
259
+
260
+ <?php
261
+ }
262
+
263
+ } else { ?>
264
+
265
+ <div class="um-admin-cur-condition">
266
+
267
+ <?php $metabox->field_input( '_conditional_action', $form_id ); ?>
268
+ <?php $metabox->field_input( '_conditional_field', $form_id ); ?>
269
+ <?php $metabox->field_input( '_conditional_operator', $form_id ); ?>
270
+ <?php $metabox->field_input( '_conditional_value', $form_id ); ?>
271
+
272
+ <p><a href="#" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
273
+
274
+ <div class="um-admin-clear"></div>
275
+ </div>
276
+
277
+ <?php } ?>
278
+ </div>
279
+ </div>
280
+
281
+ <?php
282
+ }
283
+
284
+
285
+ /**
286
+ * Update the builder area
287
+ */
288
+ function update_builder() {
289
+ UM()->admin()->check_ajax_nonce();
290
+
291
+ if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
292
+ wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
293
+ }
294
+
295
+ ob_start();
296
+
297
+ $this->form_id = absint( $_POST['form_id'] );
298
+
299
+ $this->show_builder();
300
+
301
+ $output = ob_get_clean();
302
+
303
+ if ( is_array( $output ) ) {
304
+ print_r( $output );
305
+ } else {
306
+ echo $output;
307
+ }
308
+ die;
309
+ }
310
+
311
+
312
+ /**
313
+ * Sort array function
314
+ *
315
+ * @param array $arr
316
+ * @param string $col
317
+ * @param int $dir
318
+ *
319
+ * @return array
320
+ */
321
+ function array_sort_by_column( $arr, $col, $dir = SORT_ASC ) {
322
+ $sort_col = array();
323
+
324
+ foreach ( $arr as $key => $row ) {
325
+ if ( ! empty( $row[ $col ] ) ) {
326
+ $sort_col[ $key ] = $row[ $col ];
327
+ }
328
+ }
329
+
330
+ if ( ! empty( $sort_col ) ) {
331
+ array_multisort( $sort_col, $dir, $arr );
332
+ }
333
+
334
+ return $arr;
335
+ }
336
+
337
+
338
+ /**
339
+ * Get fields in row
340
+ *
341
+ * @param $row_id
342
+ *
343
+ * @return string
344
+ */
345
+ function get_fields_by_row( $row_id ) {
346
+
347
+ if ( empty( $this->global_fields ) || ! is_array( $this->global_fields ) ) {
348
+ $this->global_fields = array();
349
+ }
350
+
351
+ foreach ( $this->global_fields as $key => $array ) {
352
+ if ( ! isset( $array['in_row'] ) || ( isset( $array['in_row'] ) && $array['in_row'] == $row_id ) ) {
353
+ $results[ $key ] = $array;
354
+ unset( $this->global_fields[ $key ] );
355
+ }
356
+ }
357
+
358
+ return ( isset ( $results ) ) ? $results : '';
359
+ }
360
+
361
+
362
+ /**
363
+ * Get fields by sub row
364
+ *
365
+ * @param $row_fields
366
+ * @param $subrow_id
367
+ *
368
+ * @return string
369
+ */
370
+ function get_fields_in_subrow( $row_fields, $subrow_id ) {
371
+ if ( ! is_array( $row_fields ) ) {
372
+ return '';
373
+ }
374
+
375
+ foreach( $row_fields as $key => $array ) {
376
+ if ( ! isset( $array['in_sub_row'] ) || ( isset( $array['in_sub_row'] ) && $array['in_sub_row'] == $subrow_id ) ) {
377
+ $results[ $key ] = $array;
378
+ unset( $this->global_fields[ $key ] );
379
+ }
380
+ }
381
+
382
+ return ( isset ( $results ) ) ? $results : '';
383
+ }
384
+
385
+
386
+ /**
387
+ * Display the builder
388
+ */
389
+ function show_builder() {
390
+
391
+ $fields = UM()->query()->get_attr( 'custom_fields', $this->form_id );
392
+
393
+ if ( !isset( $fields ) || empty( $fields ) ) { ?>
394
+
395
+ <div class="um-admin-drag-row">
396
+
397
+ <!-- Master Row Actions -->
398
+ <div class="um-admin-drag-row-icons">
399
+ <a href="javascript:void(0);" class="um-admin-drag-rowsub-add um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Row', 'ultimate-member' ); ?>" data-row_action="add_subrow"><i class="um-icon-plus"></i></a>
400
+ <a href="javascript:void(0);" class="um-admin-drag-row-edit um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit Row', 'ultimate-member' ); ?>" data-modal="UM_edit_row" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="row" data-arg2="<?php echo esc_attr( $this->form_id ); ?>" data-arg3="_um_row_1"><i class="um-faicon-pencil"></i></a>
401
+ <span class="um-admin-drag-row-start"><i class="um-icon-arrow-move"></i></span>
402
+ </div>
403
+ <div class="um-admin-clear"></div>
404
+
405
+ <div class="um-admin-drag-rowsubs">
406
+ <div class="um-admin-drag-rowsub">
407
+
408
+ <!-- Column Layout -->
409
+ <div class="um-admin-drag-ctrls columns">
410
+ <a href="javascript:void(0);" class="active" data-cols="1"></a>
411
+ <a href="javascript:void(0);" data-cols="2"></a>
412
+ <a href="javascript:void(0);" data-cols="3"></a>
413
+ </div>
414
+
415
+ <!-- Sub Row Actions -->
416
+ <div class="um-admin-drag-rowsub-icons">
417
+ <span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
418
+ </div><div class="um-admin-clear"></div>
419
+
420
+ <!-- Columns -->
421
+ <div class="um-admin-drag-col">
422
+
423
+ </div>
424
+
425
+ <div class="um-admin-drag-col-dynamic"></div>
426
+
427
+ <div class="um-admin-clear"></div>
428
+
429
+ </div>
430
+ </div>
431
+
432
+ </div>
433
+
434
+ <?php
435
+
436
+ } else {
437
+
438
+ if ( empty( $fields ) || ! is_array( $fields ) ) {
439
+ $this->global_fields = array();
440
+ } else {
441
+ $this->global_fields = $fields;
442
+ }
443
+
444
+ foreach ( $this->global_fields as $key => $array ) {
445
+ if ( $array['type'] == 'row' ) {
446
+ $rows[ $key ] = $array;
447
+ unset( $this->global_fields[ $key ] ); // not needed now
448
+ }
449
+
450
+ }
451
+
452
+ if ( ! isset( $rows ) ) {
453
+ $rows = array(
454
+ '_um_row_1' => array(
455
+ 'type' => 'row',
456
+ 'id' => '_um_row_1',
457
+ 'sub_rows' => 1,
458
+ 'cols' => 1
459
+ ),
460
+ );
461
+ }
462
+
463
+ foreach ( $rows as $row_id => $array ) { ?>
464
+
465
+ <div class="um-admin-drag-row" data-original="<?php echo esc_attr( $row_id ); ?>">
466
+
467
+ <!-- Master Row Actions -->
468
+ <div class="um-admin-drag-row-icons">
469
+ <a href="javascript:void(0);" class="um-admin-drag-rowsub-add um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Row', 'ultimate-member' ); ?>" data-row_action="add_subrow"><i class="um-icon-plus"></i></a>
470
+ <a href="javascript:void(0);" class="um-admin-drag-row-edit um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit Row', 'ultimate-member'); ?>" data-modal="UM_edit_row" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="row" data-arg2="<?php echo esc_attr( $this->form_id ); ?>" data-arg3="<?php echo esc_attr( $row_id ); ?>"><i class="um-faicon-pencil"></i></a>
471
+ <span class="um-admin-drag-row-start"><i class="um-icon-arrow-move"></i></span>
472
+ <?php if ( $row_id != '_um_row_1' ) {?>
473
+ <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Row', 'ultimate-member' ); ?>" data-remove_element="um-admin-drag-row"><i class="um-faicon-trash-o"></i></a>
474
+ <?php } ?>
475
+ </div><div class="um-admin-clear"></div>
476
+
477
+ <div class="um-admin-drag-rowsubs">
478
+
479
+ <?php $row_fields = $this->get_fields_by_row( $row_id );
480
+
481
+ $sub_rows = ( isset( $array['sub_rows'] ) ) ? $array['sub_rows'] : 1;
482
+ for ( $c = 0; $c < $sub_rows; $c++ ) {
483
+
484
+ $subrow_fields = $this->get_fields_in_subrow( $row_fields, $c );
485
+
486
+ ?>
487
+
488
+ <div class="um-admin-drag-rowsub">
489
+
490
+ <!-- Column Layout -->
491
+ <div class="um-admin-drag-ctrls columns">
492
+
493
+ <?php
494
+
495
+ if ( !isset( $array['cols'] ) ){
496
+ $col_num = 1;
497
+ } else {
498
+
499
+ $col_split = explode(':', $array['cols'] );
500
+ $col_num = $col_split[$c];
501
+
502
+ }
503
+
504
+ for ( $i = 1; $i <= 3; $i++ ) {
505
+ echo '<a href="javascript:void(0);" data-cols="'.$i.'" ';
506
+ if ( $col_num == $i ) echo 'class="active"';
507
+ echo '></a>';
508
+ }
509
+
510
+ ?>
511
+
512
+ </div>
513
+
514
+ <!-- Sub Row Actions -->
515
+ <div class="um-admin-drag-rowsub-icons">
516
+ <span class="um-admin-drag-rowsub-start"><i class="um-icon-arrow-move"></i></span>
517
+ <?php if ( $c > 0 ) { ?><a href="javascript:void(0);" class="um-admin-tipsy-n" title="Delete Row" data-remove_element="um-admin-drag-rowsub"><i class="um-faicon-trash-o"></i></a><?php } ?>
518
+ </div>
519
+ <div class="um-admin-clear"></div>
520
+
521
+ <!-- Columns -->
522
+ <div class="um-admin-drag-col">
523
+
524
+ <?php
525
+
526
+ if ( is_array( $subrow_fields ) ) {
527
+
528
+ $subrow_fields = $this->array_sort_by_column( $subrow_fields, 'position');
529
+
530
+ foreach( $subrow_fields as $key => $keyarray ) {
531
+ /**
532
+ * @var $type
533
+ * @var $title
534
+ */
535
+ extract( $keyarray );
536
+
537
+ ?>
538
+
539
+ <div class="um-admin-drag-fld um-admin-delete-area um-field-type-<?php echo $type; ?> <?php echo $key; ?>" data-group="<?php echo (isset($keyarray['in_group'])) ? $keyarray['in_group'] : ''; ?>" data-key="<?php echo $key; ?>" data-column="<?php echo ( isset($keyarray['in_column']) ) ? $keyarray['in_column'] : 1; ?>">
540
+
541
+ <div class="um-admin-drag-fld-title um-field-type-<?php echo $type; ?>">
542
+ <?php if ( $type == 'group' ) { ?>
543
+ <i class="um-icon-plus"></i>
544
+ <?php } else if ( isset($keyarray['icon']) && !empty( $keyarray['icon'] ) ) { ?>
545
+ <i class="<?php echo $keyarray['icon']; ?>"></i>
546
+ <?php } ?><?php echo ! empty( $keyarray['title'] ) ? $keyarray['title'] : __( '(no title)', 'ultimate-member' ); ?></div>
547
+ <?php $field_name = isset( UM()->builtin()->core_fields[$type]['name'] ) ? UM()->builtin()->core_fields[$type]['name'] : ''; ?>
548
+ <div class="um-admin-drag-fld-type um-field-type-<?php echo $type; ?>"><?php echo $field_name; ?></div>
549
+ <div class="um-admin-drag-fld-icons um-field-type-<?php echo $type; ?>">
550
+
551
+ <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Edit', 'ultimate-member' ) ?>" data-modal="UM_edit_field" data-modal-size="normal" data-dynamic-content="um_admin_edit_field_popup" data-arg1="<?php echo $type; ?>" data-arg2="<?php echo $this->form_id; ?>" data-arg3="<?php echo $key; ?>"><i class="um-faicon-pencil"></i></a>
552
+
553
+ <a href="javascript:void(0);" class="um-admin-tipsy-n um_admin_duplicate_field" title="<?php esc_attr_e( 'Duplicate', 'ultimate-member' ) ?>" data-silent_action="um_admin_duplicate_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-files-o"></i></a>
554
+
555
+ <?php if ( $type == 'group' ) { ?>
556
+
557
+ <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete Group', 'ultimate-member' ) ?>" data-remove_element="um-admin-drag-fld.um-field-type-group" data-silent_action="um_admin_remove_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-trash-o"></i></a>
558
+ <?php } else { ?>
559
+
560
+ <a href="javascript:void(0);" class="um-admin-tipsy-n" title="<?php esc_attr_e( 'Delete', 'ultimate-member' ) ?>" data-silent_action="um_admin_remove_field" data-arg1="<?php echo $key; ?>" data-arg2="<?php echo $this->form_id; ?>"><i class="um-faicon-trash-o"></i></a>
561
+
562
+ <?php } ?>
563
+
564
+ </div><div class="um-admin-clear"></div>
565
+
566
+ <?php if ( $type == 'group' ) { ?>
567
+ <div class="um-admin-drag-group">
568
+
569
+ </div>
570
+ <?php } ?>
571
+
572
+ </div>
573
+
574
+ <?php
575
+
576
+ } // end foreach
577
+
578
+ } // end if
579
+
580
+ ?>
581
+
582
+ </div>
583
+
584
+ <div class="um-admin-drag-col-dynamic"></div>
585
+
586
+ <div class="um-admin-clear"></div>
587
+
588
+ </div>
589
+
590
+ <?php } ?>
591
+
592
+ </div>
593
+
594
+ </div>
595
+
596
+ <?php
597
+
598
+ } // rows loop
599
+
600
+ } // if fields exist
601
+
602
+ }
603
+
604
+
605
+ /**
606
+ *
607
+ */
608
+ function update_field() {
609
+ UM()->admin()->check_ajax_nonce();
610
+
611
+ if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
612
+ wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
613
+ }
614
+
615
+ $output['error'] = null;
616
+
617
+ $array = array(
618
+ 'field_type' => sanitize_key( $_POST['_type'] ),
619
+ 'form_id' => absint( $_POST['post_id'] ),
620
+ 'args' => UM()->builtin()->get_core_field_attrs( sanitize_key( $_POST['_type'] ) ),
621
+ 'post' => UM()->admin()->sanitize_builder_field_meta( $_POST ),
622
+ );
623
+
624
+ /**
625
+ * UM hook
626
+ *
627
+ * @type filter
628
+ * @title um_admin_pre_save_fields_hook
629
+ * @description Filter field data before save
630
+ * @input_vars
631
+ * [{"var":"$array","type":"array","desc":"Save Field data"}]
632
+ * @change_log
633
+ * ["Since: 2.0"]
634
+ * @usage add_filter( 'um_admin_pre_save_fields_hook', 'function_name', 10, 1 );
635
+ * @example
636
+ * <?php
637
+ * add_filter( 'um_admin_pre_save_fields_hook', 'my_admin_pre_save_fields', 10, 1 );
638
+ * function my_admin_pre_save_fields( $array ) {
639
+ * // your code here
640
+ * return $array;
641
+ * }
642
+ * ?>
643
+ */
644
+ $array = apply_filters( 'um_admin_pre_save_fields_hook', $array );
645
+
646
+ /**
647
+ * UM hook
648
+ *
649
+ * @type filter
650
+ * @title um_admin_field_update_error_handling
651
+ * @description Change error string on save field
652
+ * @input_vars
653
+ * [{"var":"$error","type":"string","desc":"Error String"},
654
+ * {"var":"$array","type":"array","desc":"Save Field data"}]
655
+ * @change_log
656
+ * ["Since: 2.0"]
657
+ * @usage add_filter( 'um_admin_field_update_error_handling', 'function_name', 10, 2 );
658
+ * @example
659
+ * <?php
660
+ * add_filter( 'um_admin_field_update_error_handling', 'my_admin_field_update_error', 10, 2 );
661
+ * function my_admin_field_update_error( $error, $array ) {
662
+ * // your code here
663
+ * return $error;
664
+ * }
665
+ * ?>
666
+ */
667
+ $output['error'] = apply_filters( 'um_admin_field_update_error_handling', $output['error'], $array );
668
+
669
+ /**
670
+ * @var $_metakey
671
+ * @var $post_id
672
+ */
673
+ extract( $array['post'] );
674
+
675
+ if ( empty( $output['error'] ) ) {
676
+
677
+ $save = array();
678
+ $save[ $_metakey ] = null;
679
+ foreach ( $array['post'] as $key => $val ) {
680
+
681
+ if ( substr( $key, 0, 1 ) === '_' && $val != '' ) { // field attribute
682
+ $new_key = ltrim ($key,'_');
683
+
684
+ if ( $new_key == 'options' ) {
685
+ //$save[ $_metakey ][$new_key] = explode(PHP_EOL, $val);
686
+ $save[ $_metakey ][ $new_key ] = preg_split( '/[\r\n]+/', $val, -1, PREG_SPLIT_NO_EMPTY );
687
+ } else {
688
+ $save[ $_metakey ][ $new_key ] = $val;
689
+ }
690
+
691
+ } elseif ( strstr( $key, 'um_editor' ) ) {
692
+ $save[ $_metakey ]['content'] = $val;
693
+ }
694
+
695
+ }
696
+
697
+ $field_ID = $_metakey;
698
+ $field_args = $save[ $_metakey ];
699
+
700
+ /**
701
+ * UM hook
702
+ *
703
+ * @type filter
704
+ * @title um_admin_pre_save_field_to_form
705
+ * @description Change field options before save to form
706
+ * @input_vars
707
+ * [{"var":"$field_args","type":"array","desc":"Field Options"}]
708
+ * @change_log
709
+ * ["Since: 2.0"]
710
+ * @usage add_filter( 'um_admin_pre_save_field_to_form', 'function_name', 10, 1 );
711
+ * @example
712
+ * <?php
713
+ * add_filter( 'um_admin_pre_save_field_to_form', 'my_admin_pre_save_field_to_form', 10, 1 );
714
+ * function my_admin_pre_save_field_to_form( $field_args ) {
715
+ * // your code here
716
+ * return $field_args;
717
+ * }
718
+ * ?>
719
+ */
720
+ $field_args = apply_filters( 'um_admin_pre_save_field_to_form', $field_args );
721
+
722
+ UM()->fields()->update_field( $field_ID, $field_args, $post_id );
723
+
724
+ /**
725
+ * UM hook
726
+ *
727
+ * @type filter
728
+ * @title um_admin_pre_save_field_to_db
729
+ * @description Change field options before save to DB
730
+ * @input_vars
731
+ * [{"var":"$field_args","type":"array","desc":"Field Options"}]
732
+ * @change_log
733
+ * ["Since: 2.0"]
734
+ * @usage add_filter( 'um_admin_pre_save_field_to_db', 'function_name', 10, 1 );
735
+ * @example
736
+ * <?php
737
+ * add_filter( 'um_admin_pre_save_field_to_db', 'my_admin_pre_save_field_to_db', 10, 1 );
738
+ * function my_admin_pre_save_field_to_form( $field_args ) {
739
+ * // your code here
740
+ * return $field_args;
741
+ * }
742
+ * ?>
743
+ */
744
+ $field_args = apply_filters( 'um_admin_pre_save_field_to_db', $field_args );
745
+
746
+ if ( ! isset( $array['args']['form_only'] ) ) {
747
+ if ( ! isset( UM()->builtin()->predefined_fields[ $field_ID ] ) ) {
748
+ UM()->fields()->globally_update_field( $field_ID, $field_args );
749
+ }
750
+ }
751
+
752
+ }
753
+
754
+ $output = json_encode( $output );
755
+ if ( is_array( $output ) ) {
756
+ print_r( $output );
757
+ } else {
758
+ echo $output;
759
+ }
760
+ die;
761
+ }
762
+
763
+
764
+ /**
765
+ *
766
+ */
767
+ function dynamic_modal_content() {
768
+ UM()->admin()->check_ajax_nonce();
769
+
770
+ if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
771
+ wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
772
+ }
773
+
774
+ $metabox = UM()->metabox();
775
+
776
+ /**
777
+ * @var $act_id
778
+ * @var $arg1
779
+ * @var $arg2
780
+ * @var $arg3
781
+ */
782
+ extract( $_POST );
783
+
784
+ if ( isset( $arg1 ) ) {
785
+ $arg1 = sanitize_text_field( $arg1 );
786
+ }
787
+
788
+ if ( isset( $arg2 ) ) {
789
+ $arg2 = sanitize_text_field( $arg2 );
790
+ }
791
+
792
+ if ( isset( $arg3 ) ) {
793
+ $arg3 = sanitize_text_field( $arg3 );
794
+ }
795
+
796
+ switch ( sanitize_key( $act_id ) ) {
797
+
798
+ default:
799
+
800
+ ob_start();
801
+
802
+ /**
803
+ * UM hook
804
+ *
805
+ * @type action
806
+ * @title um_admin_ajax_modal_content__hook
807
+ * @description Integration hook on ajax popup admin builder modal content
808
+ * @input_vars
809
+ * [{"var":"$act_id","type":"string","desc":"Ajax Action"}]
810
+ * @change_log
811
+ * ["Since: 2.0"]
812
+ * @usage add_action( 'um_admin_ajax_modal_content__hook', 'function_name', 10, 1 );
813
+ * @example
814
+ * <?php
815
+ * add_action( 'um_admin_ajax_modal_content__hook', 'my_admin_custom_hook', 10, 1 );
816
+ * function um_admin_ajax_modal_content__hook( $act_id ) {
817
+ * // your code here
818
+ * }
819
+ * ?>
820
+ */
821
+ do_action( 'um_admin_ajax_modal_content__hook', sanitize_key( $act_id ) );
822
+ /**
823
+ * UM hook
824
+ *
825
+ * @type action
826
+ * @title um_admin_ajax_modal_content__hook_{$act_id}
827
+ * @description Integration hook on ajax popup admin builder modal content
828
+ * @change_log
829
+ * ["Since: 2.0"]
830
+ * @usage add_action( 'um_admin_ajax_modal_content__hook_{$act_id}', 'function_name', 10 );
831
+ * @example
832
+ * <?php
833
+ * add_action( 'um_admin_ajax_modal_content__hook_{$act_id}', 'my_admin_ajax_modal_content', 10 );
834
+ * function my_admin_ajax_modal_content() {
835
+ * // your code here
836
+ * }
837
+ * ?>
838
+ */
839
+ do_action( "um_admin_ajax_modal_content__hook_" . sanitize_key( $act_id ) );
840
+
841
+ $output = ob_get_clean();
842
+ break;
843
+
844
+ case 'um_admin_fonticon_selector':
845
+
846
+ ob_start(); ?>
847
+
848
+ <div class="um-admin-metabox">
849
+ <p class="_icon_search"><input type="text" name="_icon_search" id="_icon_search" value="" placeholder="<?php esc_attr_e('Search Icons...', 'ultimate-member' ); ?>" /></p>
850
+ </div>
851
+
852
+ <div class="um-admin-icons">
853
+ <?php foreach( UM()->fonticons()->all as $icon ) { ?>
854
+ <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>
855
+ <?php } ?>
856
+ </div><div class="um-admin-clear"></div>
857
+
858
+ <?php $output = ob_get_clean();
859
+ break;
860
+
861
+ case 'um_admin_show_fields':
862
+
863
+ ob_start();
864
+ $form_fields = UM()->query()->get_attr( 'custom_fields', $arg2 );
865
+ $form_fields = array_values( array_filter( array_keys( $form_fields ) ) );
866
+ //$form_fields = array_keys( $form_fields );
867
+ ?>
868
+
869
+ <h4><?php _e('Setup New Field','ultimate-member'); ?></h4>
870
+ <div class="um-admin-btns">
871
+
872
+ <?php if ( UM()->builtin()->core_fields ) {
873
+ foreach ( UM()->builtin()->core_fields as $field_type => $array ) {
874
+
875
+ if ( isset( $array['in_fields'] ) && $array['in_fields'] == false ) {
876
+ continue;
877
+ } ?>
878
+
879
+ <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>
880
+
881
+ <?php }
882
+ } ?>
883
+
884
+ </div>
885
+
886
+ <h4><?php _e('Predefined Fields','ultimate-member'); ?></h4>
887
+ <div class="um-admin-btns">
888
+
889
+ <?php if ( UM()->builtin()->predefined_fields ) {
890
+ foreach ( UM()->builtin()->predefined_fields as $field_key => $array ) {
891
+ if ( ! isset( $array['account_only'] ) && ! isset( $array['private_use'] ) ) { ?>
892
+
893
+ <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>
894
+
895
+ <?php }
896
+ }
897
+ } else {
898
+ echo '<p>' . __( 'None', 'ultimate-member' ) . '</p>';
899
+ } ?>
900
+
901
+ </div>
902
+
903
+ <h4><?php _e( 'Custom Fields', 'ultimate-member' ); ?></h4>
904
+ <div class="um-admin-btns">
905
+
906
+ <?php
907
+ if ( UM()->builtin()->custom_fields ) {
908
+ foreach ( UM()->builtin()->custom_fields as $field_key => $array ) {
909
+ if ( empty( $array['title'] ) || empty( $array['type'] ) ) {
910
+ continue;
911
+ } ?>
912
+
913
+ <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>
914
+
915
+ <?php }
916
+ } else {
917
+ echo '<p>' . __( 'You did not create any custom fields', 'ultimate-member' ) . '</p>';
918
+ } ?>
919
+
920
+ </div>
921
+
922
+ <?php $output = ob_get_clean();
923
+ break;
924
+
925
+ case 'um_admin_edit_field_popup':
926
+
927
+ ob_start();
928
+
929
+ $args = UM()->builtin()->get_core_field_attrs( $arg1 );
930
+
931
+ $form_fields = UM()->query()->get_attr( 'custom_fields', $arg2 );
932
+
933
+ $metabox->set_field_type = $arg1;
934
+ $metabox->in_edit = true;
935
+ $metabox->edit_array = $form_fields[ $arg3 ];
936
+
937
+ if ( !isset( $metabox->edit_array['metakey'] ) ){
938
+ $metabox->edit_array['metakey'] = $metabox->edit_array['id'];
939
+ }
940
+
941
+ if ( !isset( $metabox->edit_array['position'] ) ){
942
+ $metabox->edit_array['position'] = $metabox->edit_array['id'];
943
+ }
944
+
945
+ extract( $args );
946
+
947
+ if ( ! isset( $col1 ) ) {
948
+
949
+ echo '<p>'. __( 'This field type is not setup correcty.', 'ultimate-member' ) . '</p>';
950
+
951
+ } else {
952
+
953
+ ?>
954
+
955
+ <?php if ( isset( $metabox->edit_array['in_group'] ) ) { ?>
956
+ <input type="hidden" name="_in_row" id="_in_row" value="<?php echo $metabox->edit_array['in_row']; ?>" />
957
+ <input type="hidden" name="_in_sub_row" id="_in_sub_row" value="<?php echo $metabox->edit_array['in_sub_row']; ?>" />
958
+ <input type="hidden" name="_in_column" id="_in_column" value="<?php echo $metabox->edit_array['in_column']; ?>" />
959
+ <input type="hidden" name="_in_group" id="_in_group" value="<?php echo $metabox->edit_array['in_group']; ?>" />
960
+ <?php } ?>
961
+
962
+ <input type="hidden" name="_type" id="_type" value="<?php echo $arg1; ?>" />
963
+
964
+ <input type="hidden" name="post_id" id="post_id" value="<?php echo $arg2; ?>" />
965
+
966
+ <input type="hidden" name="edit_mode" id="edit_mode" value="true" />
967
+
968
+ <input type="hidden" name="_metakey" id="_metakey" value="<?php echo $metabox->edit_array['metakey']; ?>" />
969
+
970
+ <input type="hidden" name="_position" id="_position" value="<?php echo $metabox->edit_array['position']; ?>" />
971
+
972
+ <?php if ( isset( $args['mce_content'] ) ) { ?>
973
+ <div class="dynamic-mce-content"><?php echo ! empty( $metabox->edit_array['content'] ) ? $metabox->edit_array['content'] : ''; ?></div>
974
+ <?php } ?>
975
+
976
+ <?php $this->modal_header(); ?>
977
+
978
+ <div class="um-admin-half">
979
+
980
+ <?php if ( isset( $col1 ) ) { foreach( $col1 as $opt ) $metabox->field_input ( $opt, null, $metabox->edit_array ); } ?>
981
+
982
+ </div>
983
+
984
+ <div class="um-admin-half um-admin-right">
985
+
986
+ <?php if ( isset( $col2 ) ) { foreach( $col2 as $opt ) $metabox->field_input ( $opt, null, $metabox->edit_array ); } ?>
987
+
988
+ </div><div class="um-admin-clear"></div>
989
+
990
+ <?php if ( isset( $col3 ) ) { foreach( $col3 as $opt ) $metabox->field_input ( $opt, null, $metabox->edit_array ); } ?>
991
+
992
+ <div class="um-admin-clear"></div>
993
+
994
+ <?php if ( isset( $col_full ) ) {foreach( $col_full as $opt ) $metabox->field_input ( $opt, null, $metabox->edit_array ); } ?>
995
+
996
+ <?php $this->modal_footer( $arg2, $args, $metabox ); ?>
997
+
998
+ <?php
999
+
1000
+ }
1001
+
1002
+ $output = ob_get_clean();
1003
+ break;
1004
+
1005
+ case 'um_admin_new_field_popup':
1006
+
1007
+ ob_start();
1008
+
1009
+ $args = UM()->builtin()->get_core_field_attrs( $arg1 );
1010
+
1011
+ $metabox->set_field_type = $arg1;
1012
+
1013
+ /**
1014
+ * @var $in_row
1015
+ * @var $in_sub_row
1016
+ * @var $in_column
1017
+ * @var $in_group
1018
+ */
1019
+ extract( $args );
1020
+
1021
+ if ( ! isset( $col1 ) ) {
1022
+
1023
+ echo '<p>'. __( 'This field type is not setup correcty.', 'ultimate-member' ) . '</p>';
1024
+
1025
+ } else {
1026
+
1027
+ if ( $in_column ) { ?>
1028
+ <input type="hidden" name="_in_row" id="_in_row" value="_um_row_<?php echo $in_row + 1; ?>" />
1029
+ <input type="hidden" name="_in_sub_row" id="_in_sub_row" value="<?php echo $in_sub_row; ?>" />
1030
+ <input type="hidden" name="_in_column" id="_in_column" value="<?php echo $in_column; ?>" />
1031
+ <input type="hidden" name="_in_group" id="_in_group" value="<?php echo $in_group; ?>" />
1032
+ <?php } ?>
1033
+
1034
+ <input type="hidden" name="_type" id="_type" value="<?php echo $arg1; ?>" />
1035
+
1036
+ <input type="hidden" name="post_id" id="post_id" value="<?php echo $arg2; ?>" />
1037
+
1038
+ <?php $this->modal_header(); ?>
1039
+
1040
+ <div class="um-admin-half">
1041
+
1042
+ <?php if ( isset( $col1 ) ) { foreach( $col1 as $opt ) $metabox->field_input ( $opt ); } ?>
1043
+
1044
+ </div>
1045
+
1046
+ <div class="um-admin-half um-admin-right">
1047
+
1048
+ <?php if ( isset( $col2 ) ) { foreach( $col2 as $opt ) $metabox->field_input ( $opt ); } ?>
1049
+
1050
+ </div><div class="um-admin-clear"></div>
1051
+
1052
+ <?php if ( isset( $col3 ) ) { foreach( $col3 as $opt ) $metabox->field_input ( $opt ); } ?>
1053
+
1054
+ <div class="um-admin-clear"></div>
1055
+
1056
+ <?php if ( isset( $col_full ) ) { foreach( $col_full as $opt ) $metabox->field_input ( $opt ); } ?>
1057
+
1058
+ <?php $this->modal_footer( $arg2, $args, $metabox ); ?>
1059
+
1060
+ <?php
1061
+
1062
+ }
1063
+
1064
+ $output = ob_get_clean();
1065
+ break;
1066
+
1067
+ case 'um_admin_preview_form':
1068
+
1069
+ UM()->user()->preview = true;
1070
+
1071
+ $mode = UM()->query()->get_attr('mode', $arg1 );
1072
+
1073
+ if ( $mode == 'profile' ) {
1074
+ UM()->fields()->editing = true;
1075
+ }
1076
+
1077
+ $output = '<div class="um-admin-preview-overlay"></div>';
1078
+
1079
+ if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
1080
+ $output .= do_shortcode('[ultimatemember form_id="' . $arg1 . '" /]');
1081
+ } else {
1082
+ $output .= apply_shortcodes('[ultimatemember form_id="' . $arg1 . '" /]');
1083
+ }
1084
+
1085
+ break;
1086
+
1087
+ case 'um_admin_review_registration':
1088
+ //$user_id = $arg1;
1089
+
1090
+ if ( ! current_user_can( 'administrator' ) ) {
1091
+ if ( ! um_can_view_profile( $arg1 ) ) {
1092
+ $output = '';
1093
+ break;
1094
+ }
1095
+ }
1096
+
1097
+ um_fetch_user( $arg1 );
1098
+
1099
+ UM()->user()->preview = true;
1100
+
1101
+ $output = um_user_submitted_registration_formatted( true );
1102
+
1103
+ um_reset_user();
1104
+
1105
+ break;
1106
+
1107
+ }
1108
+
1109
+ if ( is_array( $output ) ) {
1110
+ print_r( $output );
1111
+ } else {
1112
+ echo $output;
1113
+ }
1114
+ die;
1115
+ }
1116
+
1117
+
1118
+ /**
1119
+ *
1120
+ */
1121
+ function modal_header() {
1122
+ /**
1123
+ * UM hook
1124
+ *
1125
+ * @type action
1126
+ * @title um_admin_field_modal_header
1127
+ * @description Modal Window Header
1128
+ * @change_log
1129
+ * ["Since: 2.0"]
1130
+ * @usage add_action( 'um_admin_field_modal_header', 'function_name', 10 );
1131
+ * @example
1132
+ * <?php
1133
+ * add_action( 'um_admin_field_modal_header', 'my_admin_field_modal_header', 10 );
1134
+ * function my_admin_field_modal_header() {
1135
+ * // your code here
1136
+ * }
1137
+ * ?>
1138
+ */
1139
+ do_action( 'um_admin_field_modal_header' );
1140
+ }
1141
+
1142
+
1143
+ /**
1144
+ * Modal Footer loading
1145
+ *
1146
+ * @param $arg2
1147
+ * @param $args
1148
+ * @param $metabox
1149
+ */
1150
+ function modal_footer( $arg2, $args, $metabox ) {
1151
+ /**
1152
+ * UM hook
1153
+ *
1154
+ * @type action
1155
+ * @title um_admin_field_modal_footer
1156
+ * @description Modal Window Footer
1157
+ * @input_vars
1158
+ * [{"var":"$arg2","type":"string","desc":"Ajax Action"},
1159
+ * {"var":"$args","type":"array","desc":"Modal window arguments"},
1160
+ * {"var":"$in_edit","type":"bool","desc":"Is edit mode?"},
1161
+ * {"var":"$edit_array","type":"array","desc":"Edit Array"}]
1162
+ * @change_log
1163
+ * ["Since: 2.0"]
1164
+ * @usage add_action( 'um_admin_field_modal_footer', 'function_name', 10, 4 );
1165
+ * @example
1166
+ * <?php
1167
+ * add_action( 'um_admin_field_modal_footer', 'my_admin_field_modal_footer', 10, 4 );
1168
+ * function my_admin_field_modal_footer( $arg2, $args, $in_edit, $edit_array ) {
1169
+ * // your code here
1170
+ * }
1171
+ * ?>
1172
+ */
1173
+ do_action( 'um_admin_field_modal_footer', $arg2, $args, $metabox->in_edit, ( isset( $metabox->edit_array ) ) ? $metabox->edit_array : '' );
1174
+ }
1175
+
1176
+
1177
+ /**
1178
+ * Skip field validation for:
1179
+ * - '_options' if Choices Callback specified
1180
+ *
1181
+ * @param boolean $skip
1182
+ * @param string $post_input
1183
+ * @param array $array
1184
+ * @return boolean
1185
+ */
1186
+ public function skip_field_validation( $skip, $post_input, $array ) {
1187
+ if ( $post_input === '_options' && isset( $array['post']['_custom_dropdown_options_source'] ) ) {
1188
+ $skip = function_exists( $array['post']['_custom_dropdown_options_source'] );
1189
+ }
1190
+
1191
+ return $skip;
1192
+ }
1193
+
1194
+
1195
+ /**
1196
+ * Retrieves dropdown/multi-select options from a callback function
1197
+ */
1198
+ function populate_dropdown_options() {
1199
+ UM()->admin()->check_ajax_nonce();
1200
+
1201
+ if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
1202
+ wp_send_json_error( __( 'This is not possible for security reasons.', 'ultimate-member' ) );
1203
+ }
1204
+
1205
+ $arr_options = array();
1206
+
1207
+ $um_callback_func = sanitize_key( $_POST['um_option_callback'] );
1208
+ if ( empty( $um_callback_func ) ) {
1209
+ $arr_options['status'] = 'empty';
1210
+ $arr_options['function_name'] = $um_callback_func;
1211
+ $arr_options['function_exists'] = function_exists( $um_callback_func );
1212
+ }
1213
+
1214
+ $arr_options['data'] = array();
1215
+ if ( function_exists( $um_callback_func ) ) {
1216
+ $arr_options['data'] = call_user_func( $um_callback_func );
1217
+ }
1218
+
1219
+ wp_send_json( $arr_options );
1220
+ }
1221
+
1222
+ }
1223
+ }
includes/admin/core/class-admin-dragdrop.php CHANGED
@@ -26,7 +26,7 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
26
  /**
27
  * Update order of fields
28
  */
29
- function update_order() {
30
  UM()->admin()->check_ajax_nonce();
31
 
32
  if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
@@ -38,14 +38,18 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
38
  */
39
  extract( $_POST );
40
 
 
 
 
 
41
  $fields = UM()->query()->get_attr( 'custom_fields', $form_id );
42
 
43
- $this->row_data = get_option( 'um_form_rowdata_' . $form_id, array() );
44
  $this->exist_rows = array();
45
 
46
  if ( ! empty( $fields ) ) {
47
  foreach ( $fields as $key => $array ) {
48
- if ( $array['type'] == 'row' ) {
49
  $this->row_data[ $key ] = $array;
50
  unset( $fields[ $key ] );
51
  }
@@ -56,6 +60,8 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
56
 
57
  foreach ( $_POST as $key => $value ) {
58
 
 
 
59
  // adding rows
60
  if ( 0 === strpos( $key, '_um_row_' ) ) {
61
 
@@ -64,18 +70,18 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
64
  $row_id = str_replace( '_um_row_', '', $key );
65
 
66
  $row_array = array(
67
- 'type' => 'row',
68
- 'id' => $value,
69
- 'sub_rows' => $_POST[ '_um_rowsub_' . $row_id . '_rows' ],
70
- 'cols' => $_POST[ '_um_rowcols_' . $row_id . '_cols' ],
71
- 'origin' => $_POST[ '_um_roworigin_' . $row_id . '_val' ],
72
  );
73
 
74
  $row_args = $row_array;
75
 
76
  if ( isset( $this->row_data[ $row_array['origin'] ] ) ) {
77
  foreach ( $this->row_data[ $row_array['origin'] ] as $k => $v ) {
78
- if ( $k != 'position' && $k != 'metakey' ) {
79
  $update_args[ $k ] = $v;
80
  }
81
  }
@@ -93,7 +99,7 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
93
  if ( 0 === strpos( $key, 'um_position_' ) ) {
94
  $field_key = str_replace( 'um_position_', '', $key );
95
  if ( isset( $fields[ $field_key ] ) ) {
96
- $fields[ $field_key ]['position'] = $value;
97
  }
98
  }
99
 
@@ -101,7 +107,7 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
101
  if ( 0 === strpos( $key, 'um_row_' ) ) {
102
  $field_key = str_replace( 'um_row_', '', $key );
103
  if ( isset( $fields[ $field_key ] ) ) {
104
- $fields[ $field_key ]['in_row'] = $value;
105
  }
106
  }
107
 
@@ -109,7 +115,7 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
109
  if ( 0 === strpos( $key, 'um_subrow_' ) ) {
110
  $field_key = str_replace( 'um_subrow_', '', $key );
111
  if ( isset( $fields[ $field_key ] ) ) {
112
- $fields[ $field_key ]['in_sub_row'] = $value;
113
  }
114
  }
115
 
@@ -117,7 +123,7 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
117
  if ( 0 === strpos( $key, 'um_col_' ) ) {
118
  $field_key = str_replace( 'um_col_', '', $key );
119
  if ( isset( $fields[ $field_key ] ) ) {
120
- $fields[ $field_key ]['in_column'] = $value;
121
  }
122
  }
123
 
@@ -125,21 +131,20 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
125
  if ( 0 === strpos( $key, 'um_group_' ) ) {
126
  $field_key = str_replace( 'um_group_', '', $key );
127
  if ( isset( $fields[ $field_key ] ) ) {
128
- $fields[ $field_key ]['in_group'] = $value;
129
  }
130
  }
131
-
132
  }
133
 
134
  foreach ( $this->row_data as $k => $v ) {
135
- if ( ! in_array( $k, $this->exist_rows ) ) {
136
  unset( $this->row_data[ $k ] );
137
  }
138
  }
139
 
140
  update_option( 'um_existing_rows_' . $form_id, $this->exist_rows );
141
 
142
- update_option( 'um_form_rowdata_' . $form_id , $this->row_data );
143
 
144
  UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
145
 
@@ -149,11 +154,11 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
149
  /**
150
  * Load form to maintain form order
151
  */
152
- function load_field_order() {
153
 
154
  $screen = get_current_screen();
155
 
156
- if ( ! isset( $screen->id ) || $screen->id != 'um_form' ) {
157
  return;
158
  } ?>
159
 
@@ -235,4 +240,4 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
235
  }
236
 
237
  }
238
- }
26
  /**
27
  * Update order of fields
28
  */
29
+ public function update_order() {
30
  UM()->admin()->check_ajax_nonce();
31
 
32
  if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
38
  */
39
  extract( $_POST );
40
 
41
+ if ( isset( $form_id ) ) {
42
+ $form_id = absint( $form_id );
43
+ }
44
+
45
  $fields = UM()->query()->get_attr( 'custom_fields', $form_id );
46
 
47
+ $this->row_data = get_option( 'um_form_rowdata_' . $form_id, array() );
48
  $this->exist_rows = array();
49
 
50
  if ( ! empty( $fields ) ) {
51
  foreach ( $fields as $key => $array ) {
52
+ if ( 'row' === $array['type'] ) {
53
  $this->row_data[ $key ] = $array;
54
  unset( $fields[ $key ] );
55
  }
60
 
61
  foreach ( $_POST as $key => $value ) {
62
 
63
+ $key = sanitize_key( $key );
64
+
65
  // adding rows
66
  if ( 0 === strpos( $key, '_um_row_' ) ) {
67
 
70
  $row_id = str_replace( '_um_row_', '', $key );
71
 
72
  $row_array = array(
73
+ 'type' => 'row',
74
+ 'id' => sanitize_key( $value ),
75
+ 'sub_rows' => absint( $_POST[ '_um_rowsub_' . $row_id . '_rows' ] ),
76
+ 'cols' => absint( $_POST[ '_um_rowcols_' . $row_id . '_cols' ] ),
77
+ 'origin' => sanitize_key( $_POST[ '_um_roworigin_' . $row_id . '_val' ] ),
78
  );
79
 
80
  $row_args = $row_array;
81
 
82
  if ( isset( $this->row_data[ $row_array['origin'] ] ) ) {
83
  foreach ( $this->row_data[ $row_array['origin'] ] as $k => $v ) {
84
+ if ( 'position' !== $k && 'metakey' !== $k ) {
85
  $update_args[ $k ] = $v;
86
  }
87
  }
99
  if ( 0 === strpos( $key, 'um_position_' ) ) {
100
  $field_key = str_replace( 'um_position_', '', $key );
101
  if ( isset( $fields[ $field_key ] ) ) {
102
+ $fields[ $field_key ]['position'] = absint( $value );
103
  }
104
  }
105
 
107
  if ( 0 === strpos( $key, 'um_row_' ) ) {
108
  $field_key = str_replace( 'um_row_', '', $key );
109
  if ( isset( $fields[ $field_key ] ) ) {
110
+ $fields[ $field_key ]['in_row'] = sanitize_key( $value );
111
  }
112
  }
113
 
115
  if ( 0 === strpos( $key, 'um_subrow_' ) ) {
116
  $field_key = str_replace( 'um_subrow_', '', $key );
117
  if ( isset( $fields[ $field_key ] ) ) {
118
+ $fields[ $field_key ]['in_sub_row'] = sanitize_key( $value );
119
  }
120
  }
121
 
123
  if ( 0 === strpos( $key, 'um_col_' ) ) {
124
  $field_key = str_replace( 'um_col_', '', $key );
125
  if ( isset( $fields[ $field_key ] ) ) {
126
+ $fields[ $field_key ]['in_column'] = absint( $value );
127
  }
128
  }
129
 
131
  if ( 0 === strpos( $key, 'um_group_' ) ) {
132
  $field_key = str_replace( 'um_group_', '', $key );
133
  if ( isset( $fields[ $field_key ] ) ) {
134
+ $fields[ $field_key ]['in_group'] = absint( $value );
135
  }
136
  }
 
137
  }
138
 
139
  foreach ( $this->row_data as $k => $v ) {
140
+ if ( ! in_array( $k, $this->exist_rows, true ) ) {
141
  unset( $this->row_data[ $k ] );
142
  }
143
  }
144
 
145
  update_option( 'um_existing_rows_' . $form_id, $this->exist_rows );
146
 
147
+ update_option( 'um_form_rowdata_' . $form_id, $this->row_data );
148
 
149
  UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
150
 
154
  /**
155
  * Load form to maintain form order
156
  */
157
+ public function load_field_order() {
158
 
159
  $screen = get_current_screen();
160
 
161
+ if ( ! isset( $screen->id ) || 'um_form' !== $screen->id ) {
162
  return;
163
  } ?>
164
 
240
  }
241
 
242
  }
243
+ }
includes/admin/core/class-admin-enqueue.php CHANGED
@@ -1,684 +1,689 @@
1
- <?php
2
- namespace um\admin\core;
3
-
4
-
5
- if ( ! defined( 'ABSPATH' ) ) exit;
6
-
7
-
8
- if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
9
-
10
-
11
- /**
12
- * Class Admin_Enqueue
13
- * @package um\admin\core
14
- */
15
- class Admin_Enqueue {
16
-
17
-
18
- /**
19
- * @var string
20
- */
21
- var $js_url;
22
-
23
-
24
- /**
25
- * @var string
26
- */
27
- var $css_url;
28
-
29
-
30
- /**
31
- * @var string
32
- */
33
- var $front_js_baseurl;
34
-
35
-
36
- /**
37
- * @var string
38
- */
39
- var $front_css_baseurl;
40
-
41
-
42
- /**
43
- * @var string
44
- */
45
- var $suffix;
46
-
47
-
48
- /**
49
- * @var bool
50
- */
51
- var $um_cpt_form_screen;
52
-
53
-
54
- /**
55
- * @var bool
56
- */
57
- var $post_page;
58
-
59
-
60
- /**
61
- * Admin_Enqueue constructor.
62
- */
63
- function __construct() {
64
- $this->js_url = um_url . 'includes/admin/assets/js/';
65
- $this->css_url = um_url . 'includes/admin/assets/css/';
66
-
67
- $this->front_js_baseurl = um_url . 'assets/js/';
68
- $this->front_css_baseurl = um_url . 'assets/css/';
69
-
70
- $this->suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || defined( 'UM_SCRIPT_DEBUG' ) ) ? '' : '.min';
71
-
72
- $this->um_cpt_form_screen = false;
73
-
74
- add_action( 'admin_head', array( &$this, 'admin_head' ), 9 );
75
-
76
- add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
77
-
78
- add_filter( 'enter_title_here', array( &$this, 'enter_title_here' ) );
79
-
80
- add_action( 'load-user-new.php', array( &$this, 'enqueue_role_wrapper' ) );
81
- add_action( 'load-user-edit.php', array( &$this, 'enqueue_role_wrapper' ) );
82
-
83
- add_action( 'load-post-new.php', array( &$this, 'enqueue_cpt_scripts' ) );
84
- add_action( 'load-post.php', array( &$this, 'enqueue_cpt_scripts' ) );
85
-
86
- add_filter( 'block_categories', array( &$this, 'blocks_category' ), 10, 2 );
87
- }
88
-
89
-
90
- function enqueue_role_wrapper() {
91
- add_action( 'admin_enqueue_scripts', array( &$this, 'load_role_wrapper' ) );
92
- }
93
-
94
-
95
- /**
96
- *
97
- */
98
- function enqueue_cpt_scripts() {
99
- if ( ( isset( $_GET['post_type'] ) && 'um_form' == sanitize_key( $_GET['post_type'] ) ) ||
100
- ( isset( $_GET['post'] ) && 'um_form' == get_post_type( absint( $_GET['post'] ) ) ) ) {
101
- $this->um_cpt_form_screen = true;
102
- add_action( 'admin_footer', array( $this, 'admin_footer_scripts' ), 20 );
103
- }
104
-
105
- $this->post_page = true;
106
- }
107
-
108
-
109
- /**
110
- *
111
- */
112
- function enqueue_frontend_preview_assets() {
113
- //scripts for FRONTEND PREVIEW
114
- if ( class_exists( 'WooCommerce' ) ) {
115
- wp_dequeue_style( 'select2' );
116
- wp_deregister_style( 'select2' );
117
-
118
- wp_dequeue_script( 'select2' );
119
- wp_deregister_script( 'select2' );
120
- }
121
-
122
-
123
- wp_register_script( 'select2', $this->front_js_baseurl . 'select2/select2.full' . $this->suffix . '.js', array( 'jquery', 'jquery-masonry' ), '4.0.13', true );
124
- wp_register_script( 'um_jquery_form', $this->front_js_baseurl . 'um-jquery-form' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
125
- wp_register_script( 'um_fileupload', $this->front_js_baseurl . 'um-fileupload' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
126
- wp_register_script( 'um_crop', $this->front_js_baseurl . 'um-crop' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
127
- wp_register_script( 'um_tipsy', $this->front_js_baseurl . 'um-tipsy' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
128
- wp_register_script( 'um_functions', $this->front_js_baseurl . 'um-functions' . $this->suffix . '.js', array( 'jquery', 'um_tipsy', 'um_scrollbar' ), ultimatemember_version, true );
129
-
130
- wp_register_script( 'um_datetime', $this->front_js_baseurl . 'pickadate/picker.js', array( 'jquery' ), ultimatemember_version, true );
131
- wp_register_script( 'um_datetime_date', $this->front_js_baseurl . 'pickadate/picker.date.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
132
- wp_register_script( 'um_datetime_time', $this->front_js_baseurl . 'pickadate/picker.time.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
133
- //wp_register_script( 'um_datetime_legacy', $this->front_js_baseurl . 'pickadate/legacy.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
134
- // load a localized version for date/time
135
- $locale = get_locale();
136
- if ( $locale ) {
137
- if ( file_exists( WP_LANG_DIR . '/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js' ) ) {
138
- wp_register_script('um_datetime_locale', content_url() . '/languages/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
139
- } elseif ( file_exists( um_path . 'assets/js/pickadate/translations/' . $locale . '.js' ) ) {
140
- wp_register_script('um_datetime_locale', um_url . 'assets/js/pickadate/translations/' . $locale . '.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
141
- }
142
- }
143
-
144
- wp_register_script( 'um_scripts', $this->front_js_baseurl . 'um-scripts' . $this->suffix . '.js', array( 'um_functions', 'um_crop', 'um_raty', 'select2', 'um_jquery_form', 'um_fileupload', 'um_datetime', 'um_datetime_date', 'um_datetime_time'/*, 'um_datetime_legacy'*/ ), ultimatemember_version, true );
145
- wp_register_script( 'um_responsive', $this->front_js_baseurl . 'um-responsive' . $this->suffix . '.js', array( 'um_scripts' ), ultimatemember_version, true );
146
- wp_register_script( 'um_modal', $this->front_js_baseurl . 'um-modal' . $this->suffix . '.js', array( 'um_responsive' ), ultimatemember_version, true );
147
-
148
-
149
- wp_register_style( 'select2', $this->front_css_baseurl . 'select2/select2' . $this->suffix . '.css', array(), '4.0.13' );
150
- wp_register_style( 'um_datetime', $this->front_css_baseurl . 'pickadate/default.css', array(), ultimatemember_version );
151
- wp_register_style( 'um_datetime_date', $this->front_css_baseurl . 'pickadate/default.date.css', array( 'um_datetime' ), ultimatemember_version );
152
- wp_register_style( 'um_datetime_time', $this->front_css_baseurl . 'pickadate/default.time.css', array( 'um_datetime' ), ultimatemember_version );
153
-
154
- wp_register_style( 'um_scrollbar', $this->front_css_baseurl . 'simplebar.css', array(), ultimatemember_version );
155
- wp_register_style( 'um_crop', $this->front_css_baseurl . 'um-crop.css', array(), ultimatemember_version );
156
- wp_register_style( 'um_tipsy', $this->front_css_baseurl . 'um-tipsy.css', array(), ultimatemember_version );
157
- wp_register_style( 'um_responsive', $this->front_css_baseurl . 'um-responsive.css', array(), ultimatemember_version );
158
- wp_register_style( 'um_modal', $this->front_css_baseurl . 'um-modal.css', array(), ultimatemember_version );
159
- wp_register_style( 'um_styles', $this->front_css_baseurl . 'um-styles.css', array(), ultimatemember_version );
160
- wp_register_style( 'um_members', $this->front_css_baseurl . 'um-members.css', array(), ultimatemember_version );
161
- wp_register_style( 'um_profile', $this->front_css_baseurl . 'um-profile.css', array(), ultimatemember_version );
162
- wp_register_style( 'um_account', $this->front_css_baseurl . 'um-account.css', array(), ultimatemember_version );
163
- wp_register_style( 'um_misc', $this->front_css_baseurl . 'um-misc.css', array(), ultimatemember_version );
164
- wp_register_style( 'um_default_css', $this->front_css_baseurl . 'um-old-default.css', array( 'um_crop', 'um_tipsy', 'um_raty', 'um_responsive', 'um_modal', 'um_styles', 'um_members', 'um_profile', 'um_account', 'um_misc', 'um_datetime_date', 'um_datetime_time', 'um_scrollbar', 'select2' ), ultimatemember_version );
165
-
166
- wp_enqueue_script( 'um_modal' );
167
- wp_enqueue_style( 'um_default_css' );
168
- }
169
-
170
-
171
- /**
172
- * Load js for Add/Edit User form
173
- */
174
- function load_role_wrapper() {
175
- wp_register_script( 'um_admin_role_wrapper', $this->js_url . 'um-admin-role-wrapper.js', array( 'jquery' ), ultimatemember_version, true );
176
- $localize_roles_data = get_option( 'um_roles', array() );
177
- wp_localize_script( 'um_admin_role_wrapper', 'um_roles', (array) $localize_roles_data );
178
- wp_enqueue_script( 'um_admin_role_wrapper' );
179
- }
180
-
181
-
182
- /**
183
- * Enter title placeholder
184
- *
185
- * @param $title
186
- *
187
- * @return string
188
- */
189
- function enter_title_here( $title ) {
190
- $screen = get_current_screen();
191
- if ( 'um_directory' == $screen->post_type ) {
192
- $title = __( 'e.g. Member Directory', 'ultimate-member' );
193
- } elseif ( 'um_form' == $screen->post_type ) {
194
- $title = __( 'e.g. New Registration Form', 'ultimate-member' );
195
- }
196
- return $title;
197
- }
198
-
199
-
200
- /**
201
- * Runs on admin head
202
- */
203
- function admin_head() {
204
- if ( UM()->admin()->is_plugin_post_type() ) { ?>
205
- <style type="text/css">
206
- .um-admin.post-type-<?php echo esc_attr( get_post_type() ); ?> div#slugdiv,
207
- .um-admin.post-type-<?php echo esc_attr( get_post_type() ); ?> div#minor-publishing,
208
- .um-admin.post-type-<?php echo esc_attr( get_post_type() ); ?> div#screen-meta-links
209
- {display:none}
210
- </style>
211
- <?php }
212
- }
213
-
214
-
215
- /**
216
- * Load Form
217
- */
218
- function load_form() {
219
- wp_register_style( 'um_admin_form', $this->css_url . 'um-admin-form.css', array(), ultimatemember_version );
220
- wp_enqueue_style( 'um_admin_form' );
221
-
222
- wp_register_script( 'um_admin_form', $this->js_url . 'um-admin-form.js', array( 'jquery' ), ultimatemember_version, true );
223
- wp_enqueue_script( 'um_admin_form' );
224
- }
225
-
226
-
227
- /**
228
- * Load Forms
229
- */
230
- function load_forms() {
231
- wp_register_style( 'um_ui', $this->front_css_baseurl . 'jquery-ui.css', array(), ultimatemember_version );
232
- wp_register_style( 'um_admin_forms', $this->css_url . 'um-admin-forms.css', array( 'wp-color-picker', 'um_ui' ), ultimatemember_version );
233
- wp_enqueue_style( 'um_admin_forms' );
234
-
235
- wp_register_script( 'um_admin_forms', $this->js_url . 'um-admin-forms.js', array( 'jquery', 'wp-i18n' ), ultimatemember_version, true );
236
-
237
- wp_localize_script( 'um_admin_forms', 'um_forms_data', array(
238
- 'successfully_redirect' => add_query_arg( array( 'page' => 'um_options', 'tab' => 'misc', 'msg' => 'updated' ), admin_url( 'admin.php' ) ),
239
- ) );
240
-
241
- wp_enqueue_script( 'um_admin_forms' );
242
- }
243
-
244
-
245
- /**
246
- * Load dashboard
247
- */
248
- function load_dashboard() {
249
- wp_register_style( 'um_admin_dashboard', $this->css_url . 'um-admin-dashboard.css', array(), ultimatemember_version );
250
- wp_enqueue_style( 'um_admin_dashboard' );
251
- }
252
-
253
-
254
- /**
255
- * Load settings
256
- */
257
- function load_settings() {
258
- wp_register_style( 'um_admin_settings', $this->css_url . 'um-admin-settings.css', array(), ultimatemember_version );
259
- wp_enqueue_style( 'um_admin_settings' );
260
-
261
- wp_register_script( 'um_admin_settings', $this->js_url . 'um-admin-settings.js', array( 'jquery', 'wp-i18n' ), ultimatemember_version, true );
262
- wp_enqueue_script( 'um_admin_settings' );
263
- }
264
-
265
-
266
- /**
267
- * Load modal
268
- */
269
- function load_modal() {
270
- wp_register_style( 'um_admin_modal', $this->css_url . 'um-admin-modal.css', array( 'wp-color-picker' ), ultimatemember_version );
271
- wp_enqueue_style( 'um_admin_modal' );
272
-
273
- wp_register_script( 'um_admin_modal', $this->js_url . 'um-admin-modal.js', array( 'jquery', 'editor', 'wp-util', 'wp-color-picker', 'wp-tinymce', 'wp-i18n' ), ultimatemember_version, true );
274
- wp_enqueue_script( 'um_admin_modal' );
275
- }
276
-
277
-
278
- /**
279
- * Field Processing
280
- */
281
- function load_field() {
282
- wp_register_script( 'um_admin_field', $this->js_url . 'um-admin-field.js', array('jquery', 'wp-util', 'wp-i18n'), ultimatemember_version, true );
283
- wp_enqueue_script( 'um_admin_field' );
284
- }
285
-
286
-
287
- /**
288
- * Load Builder
289
- */
290
- function load_builder() {
291
- wp_register_script( 'um_admin_builder', $this->js_url . 'um-admin-builder.js', array('jquery', 'wp-util'), ultimatemember_version, true );
292
- wp_enqueue_script( 'um_admin_builder' );
293
-
294
- //hide footer text on add/edit UM Forms
295
- //layouts crashed because we load and hide metaboxes
296
- //and WP calculate page height
297
- $hide_footer = false;
298
- global $pagenow, $post;
299
- if ( ( 'post.php' == $pagenow || 'post-new.php' == $pagenow ) &&
300
- ( ( isset( $_GET['post_type'] ) && 'um_form' == sanitize_key( $_GET['post_type'] ) ) ||
301
- ( isset( $post->post_type ) && 'um_form' == $post->post_type ) ) ) {
302
- $hide_footer = true;
303
- }
304
-
305
- $localize_data = array(
306
- 'hide_footer' => $hide_footer,
307
- );
308
- wp_localize_script( 'um_admin_builder', 'um_admin_builder_data', $localize_data );
309
-
310
- wp_register_script( 'um_admin_dragdrop', $this->js_url . 'um-admin-dragdrop.js', array('jquery', 'wp-util'), ultimatemember_version, true );
311
- wp_enqueue_script( 'um_admin_dragdrop' );
312
-
313
- wp_register_style( 'um_admin_builder', $this->css_url . 'um-admin-builder.css', array(), ultimatemember_version );
314
- wp_enqueue_style( 'um_admin_builder' );
315
- }
316
-
317
-
318
- /**
319
- * Load core WP styles/scripts
320
- */
321
- function load_core_wp() {
322
- wp_enqueue_script( 'jquery-ui-draggable' );
323
- wp_enqueue_script( 'jquery-ui-sortable' );
324
-
325
- wp_enqueue_script( 'jquery-ui-tooltip' );
326
- }
327
-
328
-
329
- /**
330
- * Load Admin Styles
331
- */
332
- function load_css() {
333
- wp_register_style( 'um_admin_menu', $this->css_url . 'um-admin-menu.css', array(), ultimatemember_version );
334
- wp_enqueue_style( 'um_admin_menu' );
335
-
336
- wp_register_style( 'um_admin_columns', $this->css_url . 'um-admin-columns.css', array(), ultimatemember_version );
337
- wp_enqueue_style( 'um_admin_columns' );
338
-
339
- wp_register_style( 'um_admin_misc', $this->css_url . 'um-admin-misc.css', array(), ultimatemember_version );
340
- wp_enqueue_style( 'um_admin_misc' );
341
- }
342
-
343
-
344
- /**
345
- * Load functions js
346
- */
347
- function load_functions() {
348
- wp_register_script( 'um_scrollbar', um_url . 'assets/js/simplebar.js', array( 'jquery' ), ultimatemember_version, true );
349
- wp_register_script( 'um_functions', um_url . 'assets/js/um-functions.js', array( 'jquery', 'jquery-masonry', 'wp-util', 'um_scrollbar' ), ultimatemember_version, true );
350
- wp_enqueue_script( 'um_functions' );
351
- }
352
-
353
-
354
- /**
355
- * Load Fonticons
356
- */
357
- function load_fonticons() {
358
- wp_register_style( 'um_fonticons_ii', um_url . 'assets/css/um-fonticons-ii.css', array(), ultimatemember_version );
359
- wp_enqueue_style( 'um_fonticons_ii' );
360
-
361
- wp_register_style( 'um_fonticons_fa', um_url . 'assets/css/um-fonticons-fa.css', array(), ultimatemember_version );
362
- wp_enqueue_style( 'um_fonticons_fa' );
363
- }
364
-
365
-
366
- /**
367
- * Load global css
368
- */
369
- function load_global_scripts() {
370
- wp_register_script( 'um_admin_global', $this->js_url . 'um-admin-global.js', array('jquery'), ultimatemember_version, true );
371
- wp_enqueue_script( 'um_admin_global' );
372
-
373
- wp_register_style( 'um_admin_global', $this->css_url . 'um-admin-global.css', array(), ultimatemember_version );
374
- wp_enqueue_style( 'um_admin_global' );
375
- }
376
-
377
-
378
- /**
379
- * Load jQuery custom code
380
- */
381
- function load_custom_scripts() {
382
- wp_register_script( 'um_datetime', $this->front_js_baseurl . 'pickadate/picker.js', array( 'jquery' ), ultimatemember_version, true );
383
- wp_register_script( 'um_datetime_date', $this->front_js_baseurl . 'pickadate/picker.date.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
384
- wp_register_script( 'um_datetime_time', $this->front_js_baseurl . 'pickadate/picker.time.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
385
- //wp_register_script( 'um_datetime_legacy', $this->front_js_baseurl . 'pickadate/legacy.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
386
- // load a localized version for date/time
387
- $locale = get_locale();
388
- if ( $locale ) {
389
- if ( file_exists( WP_LANG_DIR . '/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js' ) ) {
390
- wp_register_script('um_datetime_locale', content_url() . '/languages/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
391
- } elseif ( file_exists( um_path . 'assets/js/pickadate/translations/' . $locale . '.js' ) ) {
392
- wp_register_script('um_datetime_locale', um_url . 'assets/js/pickadate/translations/' . $locale . '.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
393
- }
394
- }
395
-
396
- wp_register_style( 'um_datetime', $this->front_css_baseurl . 'pickadate/default.css', array(), ultimatemember_version );
397
- wp_register_style( 'um_datetime_date', $this->front_css_baseurl . 'pickadate/default.date.css', array( 'um_datetime' ), ultimatemember_version );
398
- wp_register_style( 'um_datetime_time', $this->front_css_baseurl . 'pickadate/default.time.css', array( 'um_datetime' ), ultimatemember_version );
399
-
400
- wp_enqueue_style( 'um_datetime_date', 'um_datetime_time' );
401
-
402
- wp_register_script( 'um_admin_scripts', $this->js_url . 'um-admin-scripts.js', array('jquery','wp-util', 'wp-color-picker', 'um_datetime', 'um_datetime_date', 'um_datetime_time'/*, 'um_datetime_legacy'*/ ), ultimatemember_version, true );
403
- wp_enqueue_script( 'um_admin_scripts' );
404
- }
405
-
406
-
407
- /**
408
- * Load jQuery custom code
409
- */
410
- function load_nav_manus_scripts() {
411
- wp_register_script( 'um_admin_nav_manus', $this->js_url . 'um-admin-nav-menu.js', array('jquery','wp-util'), ultimatemember_version, true );
412
- wp_enqueue_script( 'um_admin_nav_manus' );
413
- }
414
-
415
-
416
- /**
417
- * Load AJAX
418
- */
419
- function load_ajax_js() {
420
- wp_register_script( 'um_admin_ajax', $this->js_url . 'um-admin-ajax.js', array('jquery','wp-util'), ultimatemember_version, true );
421
- wp_enqueue_script( 'um_admin_ajax' );
422
- }
423
-
424
-
425
- /**
426
- * Load Gutenberg scripts
427
- */
428
- function load_gutenberg_js() {
429
- //disable Gutenberg scripts to avoid the conflicts
430
- $disable_script = apply_filters( 'um_disable_blocks_script', false );
431
- if ( $disable_script ) {
432
- return;
433
- }
434
-
435
- $restricted_blocks = UM()->options()->get( 'restricted_blocks' );
436
- if ( empty( $restricted_blocks ) ) {
437
- return;
438
- }
439
-
440
- wp_register_script( 'um_block_js', $this->js_url . 'um-admin-blocks.js', array( 'wp-i18n', 'wp-blocks', 'wp-components', 'wp-hooks' ), ultimatemember_version, true );
441
- wp_set_script_translations( 'um_block_js', 'ultimate-member' );
442
-
443
- $restrict_options = array();
444
- $roles = UM()->roles()->get_roles( false );
445
- if ( ! empty( $roles ) ) {
446
- foreach ( $roles as $role_key => $title ) {
447
- $restrict_options[] = array(
448
- 'label' => $title,
449
- 'value' => $role_key
450
- );
451
- }
452
- }
453
- wp_localize_script( 'um_block_js', 'um_restrict_roles', $restrict_options );
454
-
455
- wp_enqueue_script( 'um_block_js' );
456
-
457
- do_action( 'um_load_gutenberg_js' );
458
- }
459
-
460
-
461
- /**
462
- * Load Gutenberg blocks js
463
- */
464
- function load_gutenberg_shortcode_blocks() {
465
- if ( ! function_exists( 'register_block_type' ) ) {
466
- // Gutenberg is not active.
467
- return;
468
- }
469
-
470
- //disable Gutenberg scripts to avoid the conflicts
471
- $disable_script = apply_filters( 'um_disable_blocks_script', false );
472
- if ( $disable_script ) {
473
- return;
474
- }
475
-
476
- $enable_blocks = UM()->options()->get( 'enable_blocks' );
477
- if ( empty( $enable_blocks ) ) {
478
- return;
479
- }
480
-
481
- wp_register_script( 'um-blocks-shortcode-js', $this->js_url . 'um-admin-blocks-shortcode.js', array( 'wp-i18n', 'wp-blocks', 'wp-components', /*'rich-text'*/ ), ultimatemember_version, true );
482
- wp_set_script_translations( 'um-blocks-shortcode-js', 'ultimate-member' );
483
- wp_enqueue_script( 'um-blocks-shortcode-js' );
484
-
485
- $account_settings = array(
486
- 'password' => array(
487
- 'label' => __( 'Password', 'ultimate-member' ),
488
- 'enabled' => UM()->options()->get( 'account_tab_password' ),
489
- ),
490
- 'privacy' => array(
491
- 'label' => __( 'Privacy', 'ultimate-member' ),
492
- 'enabled' => UM()->options()->get( 'account_tab_privacy' ),
493
- ),
494
- 'notifications' => array(
495
- 'label' => __( 'Notifications', 'ultimate-member' ),
496
- 'enabled' => UM()->options()->get( 'account_tab_notifications' ),
497
- ),
498
- 'delete' => array(
499
- 'label' => __( 'Delete', 'ultimate-member' ),
500
- 'enabled' => UM()->options()->get( 'account_tab_delete' ),
501
- ),
502
- );
503
- wp_localize_script( 'um-blocks-shortcode-js', 'um_account_settings', $account_settings );
504
-
505
- /**
506
- * create gutenberg blocks
507
- */
508
- register_block_type( 'um-block/um-forms', array(
509
- 'editor_script' => 'um-blocks-shortcode-js',
510
- ) );
511
-
512
- register_block_type( 'um-block/um-member-directories', array(
513
- 'editor_script' => 'um-blocks-shortcode-js',
514
- ) );
515
-
516
- register_block_type( 'um-block/um-password-reset', array(
517
- 'editor_script' => 'um-blocks-shortcode-js',
518
- ) );
519
-
520
- register_block_type( 'um-block/um-account', array(
521
- 'editor_script' => 'um-blocks-shortcode-js',
522
- ) );
523
- }
524
-
525
-
526
- /**
527
- * Add Gutenberg category for UM shortcodes
528
- *
529
- * @param array $categories
530
- * @param $post
531
- *
532
- * @return array
533
- */
534
- function blocks_category( $categories, $post ) {
535
- $enable_blocks = UM()->options()->get( 'enable_blocks' );
536
- if ( empty( $enable_blocks ) ) {
537
- return $categories;
538
- }
539
-
540
- return array_merge(
541
- $categories,
542
- array(
543
- array(
544
- 'slug' => 'um-blocks',
545
- 'title' => __( 'Ultimate Member Blocks', 'ultimate-member' ),
546
- ),
547
- )
548
- );
549
- }
550
-
551
- /**
552
- * Load localize scripts
553
- */
554
- function load_localize_scripts() {
555
-
556
- /**
557
- * UM hook
558
- *
559
- * @type filter
560
- * @title um_admin_enqueue_localize_data
561
- * @description Extend localize data at wp-admin side
562
- * @input_vars
563
- * [{"var":"$localize_data","type":"array","desc":"Localize Data"}]
564
- * @change_log
565
- * ["Since: 2.0"]
566
- * @usage add_filter( 'um_admin_enqueue_localize_data', 'function_name', 10, 1 );
567
- * @example
568
- * <?php
569
- * add_filter( 'um_admin_enqueue_localize_data', 'my_admin_enqueue_localize_data', 10, 1 );
570
- * function my_admin_enqueue_localize_data( $localize_data ) {
571
- * // your code here
572
- * return $localize_data;
573
- * }
574
- * ?>
575
- */
576
- $localize_data = apply_filters( 'um_admin_enqueue_localize_data', array(
577
- 'nonce' => wp_create_nonce( "um-admin-nonce" )
578
- )
579
- );
580
-
581
- wp_localize_script( 'um_admin_global', 'um_admin_scripts', $localize_data );
582
- }
583
-
584
-
585
- /**
586
- * Enqueue scripts and styles
587
- */
588
- function admin_enqueue_scripts() {
589
- if ( UM()->admin()->is_um_screen() ) {
590
-
591
- /*if ( get_post_type() != 'shop_order' ) {
592
- UM()->enqueue()->wp_enqueue_scripts();
593
- }*/
594
-
595
- $modal_deps = array( 'um-admin-scripts' );
596
- if ( $this->um_cpt_form_screen ) {
597
- $this->enqueue_frontend_preview_assets();
598
- $modal_deps[] = 'um-responsive';
599
- }
600
-
601
- $this->load_functions();
602
- $this->load_global_scripts();
603
- $this->load_form();
604
- $this->load_forms();
605
- $this->load_custom_scripts();
606
- $this->load_modal();
607
- $this->load_dashboard();
608
- $this->load_settings();
609
- $this->load_field();
610
- $this->load_builder();
611
- $this->load_css();
612
- $this->load_core_wp();
613
- $this->load_ajax_js();
614
- $this->load_fonticons();
615
- $this->load_localize_scripts();
616
-
617
-
618
- //scripts for frontend preview
619
- UM()->enqueue()->load_imagecrop();
620
- UM()->enqueue()->load_css();
621
- UM()->enqueue()->load_tipsy();
622
- UM()->enqueue()->load_modal();
623
- UM()->enqueue()->load_responsive();
624
-
625
- wp_register_script( 'um_raty', um_url . 'assets/js/um-raty' . UM()->enqueue()->suffix . '.js', array( 'jquery', 'wp-i18n' ), ultimatemember_version, true );
626
- wp_register_style( 'um_raty', um_url . 'assets/css/um-raty.css', array(), ultimatemember_version );
627
-
628
- wp_register_style( 'um_default_css', um_url . 'assets/css/um-old-default.css', '', ultimatemember_version, 'all' );
629
- wp_enqueue_style( 'um_default_css' );
630
-
631
- if ( is_rtl() ) {
632
- wp_register_style( 'um_admin_rtl', $this->css_url . 'um-admin-rtl.css', array(), ultimatemember_version );
633
- wp_enqueue_style( 'um_admin_rtl' );
634
- }
635
-
636
- } else {
637
-
638
- $this->load_global_scripts();
639
- $this->load_localize_scripts();
640
-
641
- }
642
-
643
- global $wp_version, $current_screen;
644
- if ( version_compare( $wp_version, '5.0', '>=' ) && ! empty( $this->post_page ) ) {
645
-
646
- if ( $current_screen->is_block_editor() ) {
647
- $this->load_gutenberg_js();
648
- $this->load_gutenberg_shortcode_blocks();
649
- }
650
- }
651
-
652
- }
653
-
654
-
655
- /**
656
- * Print editor scripts if they are not printed by default
657
- */
658
- function admin_footer_scripts() {
659
- /**
660
- * @var $class \_WP_Editors
661
- */
662
- $class = '\_WP_Editors';
663
-
664
- if ( did_action( 'print_default_editor_scripts' ) ) {
665
- return;
666
- }
667
- if ( did_action( 'wp_tiny_mce_init' ) ) {
668
- return;
669
- }
670
- if ( has_action( 'admin_print_footer_scripts', array( $class, 'editor_js' ) ) ) {
671
- return;
672
- }
673
-
674
- if ( ! class_exists( $class, false ) ) {
675
- require_once( ABSPATH . WPINC . '/class-wp-editor.php' );
676
- }
677
-
678
- $class::force_uncompressed_tinymce();
679
- $class::enqueue_scripts();
680
- $class::editor_js();
681
- }
682
-
683
- }
684
- }
 
 
 
 
 
1
+ <?php
2
+ namespace um\admin\core;
3
+
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) exit;
6
+
7
+
8
+ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
9
+
10
+
11
+ /**
12
+ * Class Admin_Enqueue
13
+ * @package um\admin\core
14
+ */
15
+ class Admin_Enqueue {
16
+
17
+
18
+ /**
19
+ * @var string
20
+ */
21
+ var $js_url;
22
+
23
+
24
+ /**
25
+ * @var string
26
+ */
27
+ var $css_url;
28
+
29
+
30
+ /**
31
+ * @var string
32
+ */
33
+ var $front_js_baseurl;
34
+
35
+
36
+ /**
37
+ * @var string
38
+ */
39
+ var $front_css_baseurl;
40
+
41
+
42
+ /**
43
+ * @var string
44
+ */
45
+ var $suffix;
46
+
47
+
48
+ /**
49
+ * @var bool
50
+ */
51
+ var $um_cpt_form_screen;
52
+
53
+
54
+ /**
55
+ * @var bool
56
+ */
57
+ var $post_page;
58
+
59
+
60
+ /**
61
+ * Admin_Enqueue constructor.
62
+ */
63
+ function __construct() {
64
+ $this->js_url = um_url . 'includes/admin/assets/js/';
65
+ $this->css_url = um_url . 'includes/admin/assets/css/';
66
+
67
+ $this->front_js_baseurl = um_url . 'assets/js/';
68
+ $this->front_css_baseurl = um_url . 'assets/css/';
69
+
70
+ $this->suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || defined( 'UM_SCRIPT_DEBUG' ) ) ? '' : '.min';
71
+
72
+ $this->um_cpt_form_screen = false;
73
+
74
+ add_action( 'admin_head', array( &$this, 'admin_head' ), 9 );
75
+
76
+ add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
77
+
78
+ add_filter( 'enter_title_here', array( &$this, 'enter_title_here' ) );
79
+
80
+ add_action( 'load-user-new.php', array( &$this, 'enqueue_role_wrapper' ) );
81
+ add_action( 'load-user-edit.php', array( &$this, 'enqueue_role_wrapper' ) );
82
+
83
+ add_action( 'load-post-new.php', array( &$this, 'enqueue_cpt_scripts' ) );
84
+ add_action( 'load-post.php', array( &$this, 'enqueue_cpt_scripts' ) );
85
+
86
+ global $wp_version;
87
+ if ( version_compare( $wp_version, '5.8-rc.1', '>=' ) ) {
88
+ add_filter( 'block_categories_all', array( &$this, 'blocks_category' ), 10, 2 );
89
+ } else {
90
+ add_filter( 'block_categories', array( &$this, 'blocks_category' ), 10, 2 );
91
+ }
92
+ }
93
+
94
+
95
+ function enqueue_role_wrapper() {
96
+ add_action( 'admin_enqueue_scripts', array( &$this, 'load_role_wrapper' ) );
97
+ }
98
+
99
+
100
+ /**
101
+ *
102
+ */
103
+ function enqueue_cpt_scripts() {
104
+ if ( ( isset( $_GET['post_type'] ) && 'um_form' === sanitize_key( $_GET['post_type'] ) ) ||
105
+ ( isset( $_GET['post'] ) && 'um_form' === get_post_type( absint( $_GET['post'] ) ) ) ) {
106
+ $this->um_cpt_form_screen = true;
107
+ add_action( 'admin_footer', array( $this, 'admin_footer_scripts' ), 20 );
108
+ }
109
+
110
+ $this->post_page = true;
111
+ }
112
+
113
+
114
+ /**
115
+ *
116
+ */
117
+ function enqueue_frontend_preview_assets() {
118
+ //scripts for FRONTEND PREVIEW
119
+ if ( class_exists( 'WooCommerce' ) ) {
120
+ wp_dequeue_style( 'select2' );
121
+ wp_deregister_style( 'select2' );
122
+
123
+ wp_dequeue_script( 'select2' );
124
+ wp_deregister_script( 'select2' );
125
+ }
126
+
127
+
128
+ wp_register_script( 'select2', $this->front_js_baseurl . 'select2/select2.full' . $this->suffix . '.js', array( 'jquery', 'jquery-masonry' ), '4.0.13', true );
129
+ wp_register_script( 'um_jquery_form', $this->front_js_baseurl . 'um-jquery-form' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
130
+ wp_register_script( 'um_fileupload', $this->front_js_baseurl . 'um-fileupload' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
131
+ wp_register_script( 'um_crop', $this->front_js_baseurl . 'um-crop' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
132
+ wp_register_script( 'um_tipsy', $this->front_js_baseurl . 'um-tipsy' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, true );
133
+ wp_register_script( 'um_functions', $this->front_js_baseurl . 'um-functions' . $this->suffix . '.js', array( 'jquery', 'um_tipsy', 'um_scrollbar' ), ultimatemember_version, true );
134
+
135
+ wp_register_script( 'um_datetime', $this->front_js_baseurl . 'pickadate/picker.js', array( 'jquery' ), ultimatemember_version, true );
136
+ wp_register_script( 'um_datetime_date', $this->front_js_baseurl . 'pickadate/picker.date.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
137
+ wp_register_script( 'um_datetime_time', $this->front_js_baseurl . 'pickadate/picker.time.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
138
+ //wp_register_script( 'um_datetime_legacy', $this->front_js_baseurl . 'pickadate/legacy.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
139
+ // load a localized version for date/time
140
+ $locale = get_locale();
141
+ if ( $locale ) {
142
+ if ( file_exists( WP_LANG_DIR . '/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js' ) ) {
143
+ wp_register_script('um_datetime_locale', content_url() . '/languages/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
144
+ } elseif ( file_exists( um_path . 'assets/js/pickadate/translations/' . $locale . '.js' ) ) {
145
+ wp_register_script('um_datetime_locale', um_url . 'assets/js/pickadate/translations/' . $locale . '.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
146
+ }
147
+ }
148
+
149
+ wp_register_script( 'um_scripts', $this->front_js_baseurl . 'um-scripts' . $this->suffix . '.js', array( 'um_functions', 'um_crop', 'um_raty', 'select2', 'um_jquery_form', 'um_fileupload', 'um_datetime', 'um_datetime_date', 'um_datetime_time'/*, 'um_datetime_legacy'*/ ), ultimatemember_version, true );
150
+ wp_register_script( 'um_responsive', $this->front_js_baseurl . 'um-responsive' . $this->suffix . '.js', array( 'um_scripts' ), ultimatemember_version, true );
151
+ wp_register_script( 'um_modal', $this->front_js_baseurl . 'um-modal' . $this->suffix . '.js', array( 'um_responsive' ), ultimatemember_version, true );
152
+
153
+
154
+ wp_register_style( 'select2', $this->front_css_baseurl . 'select2/select2' . $this->suffix . '.css', array(), '4.0.13' );
155
+ wp_register_style( 'um_datetime', $this->front_css_baseurl . 'pickadate/default.css', array(), ultimatemember_version );
156
+ wp_register_style( 'um_datetime_date', $this->front_css_baseurl . 'pickadate/default.date.css', array( 'um_datetime' ), ultimatemember_version );
157
+ wp_register_style( 'um_datetime_time', $this->front_css_baseurl . 'pickadate/default.time.css', array( 'um_datetime' ), ultimatemember_version );
158
+
159
+ wp_register_style( 'um_scrollbar', $this->front_css_baseurl . 'simplebar.css', array(), ultimatemember_version );
160
+ wp_register_style( 'um_crop', $this->front_css_baseurl . 'um-crop.css', array(), ultimatemember_version );
161
+ wp_register_style( 'um_tipsy', $this->front_css_baseurl . 'um-tipsy.css', array(), ultimatemember_version );
162
+ wp_register_style( 'um_responsive', $this->front_css_baseurl . 'um-responsive.css', array(), ultimatemember_version );
163
+ wp_register_style( 'um_modal', $this->front_css_baseurl . 'um-modal.css', array(), ultimatemember_version );
164
+ wp_register_style( 'um_styles', $this->front_css_baseurl . 'um-styles.css', array(), ultimatemember_version );
165
+ wp_register_style( 'um_members', $this->front_css_baseurl . 'um-members.css', array(), ultimatemember_version );
166
+ wp_register_style( 'um_profile', $this->front_css_baseurl . 'um-profile.css', array(), ultimatemember_version );
167
+ wp_register_style( 'um_account', $this->front_css_baseurl . 'um-account.css', array(), ultimatemember_version );
168
+ wp_register_style( 'um_misc', $this->front_css_baseurl . 'um-misc.css', array(), ultimatemember_version );
169
+ wp_register_style( 'um_default_css', $this->front_css_baseurl . 'um-old-default.css', array( 'um_crop', 'um_tipsy', 'um_raty', 'um_responsive', 'um_modal', 'um_styles', 'um_members', 'um_profile', 'um_account', 'um_misc', 'um_datetime_date', 'um_datetime_time', 'um_scrollbar', 'select2' ), ultimatemember_version );
170
+
171
+ wp_enqueue_script( 'um_modal' );
172
+ wp_enqueue_style( 'um_default_css' );
173
+ }
174
+
175
+
176
+ /**
177
+ * Load js for Add/Edit User form
178
+ */
179
+ function load_role_wrapper() {
180
+ wp_register_script( 'um_admin_role_wrapper', $this->js_url . 'um-admin-role-wrapper.js', array( 'jquery' ), ultimatemember_version, true );
181
+ $localize_roles_data = get_option( 'um_roles', array() );
182
+ wp_localize_script( 'um_admin_role_wrapper', 'um_roles', (array) $localize_roles_data );
183
+ wp_enqueue_script( 'um_admin_role_wrapper' );
184
+ }
185
+
186
+
187
+ /**
188
+ * Enter title placeholder
189
+ *
190
+ * @param $title
191
+ *
192
+ * @return string
193
+ */
194
+ function enter_title_here( $title ) {
195
+ $screen = get_current_screen();
196
+ if ( 'um_directory' == $screen->post_type ) {
197
+ $title = __( 'e.g. Member Directory', 'ultimate-member' );
198
+ } elseif ( 'um_form' == $screen->post_type ) {
199
+ $title = __( 'e.g. New Registration Form', 'ultimate-member' );
200
+ }
201
+ return $title;
202
+ }
203
+
204
+
205
+ /**
206
+ * Runs on admin head
207
+ */
208
+ function admin_head() {
209
+ if ( UM()->admin()->is_plugin_post_type() ) { ?>
210
+ <style type="text/css">
211
+ .um-admin.post-type-<?php echo esc_attr( get_post_type() ); ?> div#slugdiv,
212
+ .um-admin.post-type-<?php echo esc_attr( get_post_type() ); ?> div#minor-publishing,
213
+ .um-admin.post-type-<?php echo esc_attr( get_post_type() ); ?> div#screen-meta-links
214
+ {display:none}
215
+ </style>
216
+ <?php }
217
+ }
218
+
219
+
220
+ /**
221
+ * Load Form
222
+ */
223
+ function load_form() {
224
+ wp_register_style( 'um_admin_form', $this->css_url . 'um-admin-form.css', array(), ultimatemember_version );
225
+ wp_enqueue_style( 'um_admin_form' );
226
+
227
+ wp_register_script( 'um_admin_form', $this->js_url . 'um-admin-form.js', array( 'jquery' ), ultimatemember_version, true );
228
+ wp_enqueue_script( 'um_admin_form' );
229
+ }
230
+
231
+
232
+ /**
233
+ * Load Forms
234
+ */
235
+ function load_forms() {
236
+ wp_register_style( 'um_ui', $this->front_css_baseurl . 'jquery-ui.css', array(), ultimatemember_version );
237
+ wp_register_style( 'um_admin_forms', $this->css_url . 'um-admin-forms.css', array( 'wp-color-picker', 'um_ui' ), ultimatemember_version );
238
+ wp_enqueue_style( 'um_admin_forms' );
239
+
240
+ wp_register_script( 'um_admin_forms', $this->js_url . 'um-admin-forms.js', array( 'jquery', 'wp-i18n' ), ultimatemember_version, true );
241
+
242
+ wp_localize_script( 'um_admin_forms', 'um_forms_data', array(
243
+ 'successfully_redirect' => add_query_arg( array( 'page' => 'um_options', 'tab' => 'misc', 'msg' => 'updated' ), admin_url( 'admin.php' ) ),
244
+ ) );
245
+
246
+ wp_enqueue_script( 'um_admin_forms' );
247
+ }
248
+
249
+
250
+ /**
251
+ * Load dashboard
252
+ */
253
+ function load_dashboard() {
254
+ wp_register_style( 'um_admin_dashboard', $this->css_url . 'um-admin-dashboard.css', array(), ultimatemember_version );
255
+ wp_enqueue_style( 'um_admin_dashboard' );
256
+ }
257
+
258
+
259
+ /**
260
+ * Load settings
261
+ */
262
+ function load_settings() {
263
+ wp_register_style( 'um_admin_settings', $this->css_url . 'um-admin-settings.css', array(), ultimatemember_version );
264
+ wp_enqueue_style( 'um_admin_settings' );
265
+
266
+ wp_register_script( 'um_admin_settings', $this->js_url . 'um-admin-settings.js', array( 'jquery', 'wp-i18n' ), ultimatemember_version, true );
267
+ wp_enqueue_script( 'um_admin_settings' );
268
+ }
269
+
270
+
271
+ /**
272
+ * Load modal
273
+ */
274
+ function load_modal() {
275
+ wp_register_style( 'um_admin_modal', $this->css_url . 'um-admin-modal.css', array( 'wp-color-picker' ), ultimatemember_version );
276
+ wp_enqueue_style( 'um_admin_modal' );
277
+
278
+ wp_register_script( 'um_admin_modal', $this->js_url . 'um-admin-modal.js', array( 'jquery', 'editor', 'wp-util', 'wp-color-picker', 'wp-tinymce', 'wp-i18n' ), ultimatemember_version, true );
279
+ wp_enqueue_script( 'um_admin_modal' );
280
+ }
281
+
282
+
283
+ /**
284
+ * Field Processing
285
+ */
286
+ function load_field() {
287
+ wp_register_script( 'um_admin_field', $this->js_url . 'um-admin-field.js', array('jquery', 'wp-util', 'wp-i18n'), ultimatemember_version, true );
288
+ wp_enqueue_script( 'um_admin_field' );
289
+ }
290
+
291
+
292
+ /**
293
+ * Load Builder
294
+ */
295
+ function load_builder() {
296
+ wp_register_script( 'um_admin_builder', $this->js_url . 'um-admin-builder.js', array('jquery', 'wp-util'), ultimatemember_version, true );
297
+ wp_enqueue_script( 'um_admin_builder' );
298
+
299
+ //hide footer text on add/edit UM Forms
300
+ //layouts crashed because we load and hide metaboxes
301
+ //and WP calculate page height
302
+ $hide_footer = false;
303
+ global $pagenow, $post;
304
+ if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) &&
305
+ ( ( isset( $_GET['post_type'] ) && 'um_form' === sanitize_key( $_GET['post_type'] ) ) ||
306
+ ( isset( $post->post_type ) && 'um_form' === $post->post_type ) ) ) {
307
+ $hide_footer = true;
308
+ }
309
+
310
+ $localize_data = array(
311
+ 'hide_footer' => $hide_footer,
312
+ );
313
+ wp_localize_script( 'um_admin_builder', 'um_admin_builder_data', $localize_data );
314
+
315
+ wp_register_script( 'um_admin_dragdrop', $this->js_url . 'um-admin-dragdrop.js', array('jquery', 'wp-util'), ultimatemember_version, true );
316
+ wp_enqueue_script( 'um_admin_dragdrop' );
317
+
318
+ wp_register_style( 'um_admin_builder', $this->css_url . 'um-admin-builder.css', array(), ultimatemember_version );
319
+ wp_enqueue_style( 'um_admin_builder' );
320
+ }
321
+
322
+
323
+ /**
324
+ * Load core WP styles/scripts
325
+ */
326
+ function load_core_wp() {
327
+ wp_enqueue_script( 'jquery-ui-draggable' );
328
+ wp_enqueue_script( 'jquery-ui-sortable' );
329
+
330
+ wp_enqueue_script( 'jquery-ui-tooltip' );
331
+ }
332
+
333
+
334
+ /**
335
+ * Load Admin Styles
336
+ */
337
+ function load_css() {
338
+ wp_register_style( 'um_admin_menu', $this->css_url . 'um-admin-menu.css', array(), ultimatemember_version );
339
+ wp_enqueue_style( 'um_admin_menu' );
340
+
341
+ wp_register_style( 'um_admin_columns', $this->css_url . 'um-admin-columns.css', array(), ultimatemember_version );
342
+ wp_enqueue_style( 'um_admin_columns' );
343
+
344
+ wp_register_style( 'um_admin_misc', $this->css_url . 'um-admin-misc.css', array(), ultimatemember_version );
345
+ wp_enqueue_style( 'um_admin_misc' );
346
+ }
347
+
348
+
349
+ /**
350
+ * Load functions js
351
+ */
352
+ function load_functions() {
353
+ wp_register_script( 'um_scrollbar', um_url . 'assets/js/simplebar.js', array( 'jquery' ), ultimatemember_version, true );
354
+ wp_register_script( 'um_functions', um_url . 'assets/js/um-functions.js', array( 'jquery', 'jquery-masonry', 'wp-util', 'um_scrollbar' ), ultimatemember_version, true );
355
+ wp_enqueue_script( 'um_functions' );
356
+ }
357
+
358
+
359
+ /**
360
+ * Load Fonticons
361
+ */
362
+ function load_fonticons() {
363
+ wp_register_style( 'um_fonticons_ii', um_url . 'assets/css/um-fonticons-ii.css', array(), ultimatemember_version );
364
+ wp_enqueue_style( 'um_fonticons_ii' );
365
+
366
+ wp_register_style( 'um_fonticons_fa', um_url . 'assets/css/um-fonticons-fa.css', array(), ultimatemember_version );
367
+ wp_enqueue_style( 'um_fonticons_fa' );
368
+ }
369
+
370
+
371
+ /**
372
+ * Load global css
373
+ */
374
+ function load_global_scripts() {
375
+ wp_register_script( 'um_admin_global', $this->js_url . 'um-admin-global.js', array('jquery'), ultimatemember_version, true );
376
+ wp_enqueue_script( 'um_admin_global' );
377
+
378
+ wp_register_style( 'um_admin_global', $this->css_url . 'um-admin-global.css', array(), ultimatemember_version );
379
+ wp_enqueue_style( 'um_admin_global' );
380
+ }
381
+
382
+
383
+ /**
384
+ * Load jQuery custom code
385
+ */
386
+ function load_custom_scripts() {
387
+ wp_register_script( 'um_datetime', $this->front_js_baseurl . 'pickadate/picker.js', array( 'jquery' ), ultimatemember_version, true );
388
+ wp_register_script( 'um_datetime_date', $this->front_js_baseurl . 'pickadate/picker.date.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
389
+ wp_register_script( 'um_datetime_time', $this->front_js_baseurl . 'pickadate/picker.time.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
390
+ //wp_register_script( 'um_datetime_legacy', $this->front_js_baseurl . 'pickadate/legacy.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
391
+ // load a localized version for date/time
392
+ $locale = get_locale();
393
+ if ( $locale ) {
394
+ if ( file_exists( WP_LANG_DIR . '/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js' ) ) {
395
+ wp_register_script('um_datetime_locale', content_url() . '/languages/plugins/ultimate-member/assets/js/pickadate/' . $locale . '.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
396
+ } elseif ( file_exists( um_path . 'assets/js/pickadate/translations/' . $locale . '.js' ) ) {
397
+ wp_register_script('um_datetime_locale', um_url . 'assets/js/pickadate/translations/' . $locale . '.js', array( 'jquery', 'um_datetime' ), ultimatemember_version, true );
398
+ }
399
+ }
400
+
401
+ wp_register_style( 'um_datetime', $this->front_css_baseurl . 'pickadate/default.css', array(), ultimatemember_version );
402
+ wp_register_style( 'um_datetime_date', $this->front_css_baseurl . 'pickadate/default.date.css', array( 'um_datetime' ), ultimatemember_version );
403
+ wp_register_style( 'um_datetime_time', $this->front_css_baseurl . 'pickadate/default.time.css', array( 'um_datetime' ), ultimatemember_version );
404
+
405
+ wp_enqueue_style( 'um_datetime_date', 'um_datetime_time' );
406
+
407
+ wp_register_script( 'um_admin_scripts', $this->js_url . 'um-admin-scripts.js', array('jquery','wp-util', 'wp-color-picker', 'um_datetime', 'um_datetime_date', 'um_datetime_time'/*, 'um_datetime_legacy'*/ ), ultimatemember_version, true );
408
+ wp_enqueue_script( 'um_admin_scripts' );
409
+ }
410
+
411
+
412
+ /**
413
+ * Load jQuery custom code
414
+ */
415
+ function load_nav_manus_scripts() {
416
+ wp_register_script( 'um_admin_nav_manus', $this->js_url . 'um-admin-nav-menu.js', array('jquery','wp-util'), ultimatemember_version, true );
417
+ wp_enqueue_script( 'um_admin_nav_manus' );
418
+ }
419
+
420
+
421
+ /**
422
+ * Load AJAX
423
+ */
424
+ function load_ajax_js() {
425
+ wp_register_script( 'um_admin_ajax', $this->js_url . 'um-admin-ajax.js', array('jquery','wp-util'), ultimatemember_version, true );
426
+ wp_enqueue_script( 'um_admin_ajax' );
427
+ }
428
+
429
+
430
+ /**
431
+ * Load Gutenberg scripts
432
+ */
433
+ function load_gutenberg_js() {
434
+ //disable Gutenberg scripts to avoid the conflicts
435
+ $disable_script = apply_filters( 'um_disable_blocks_script', false );
436
+ if ( $disable_script ) {
437
+ return;
438
+ }
439
+
440
+ $restricted_blocks = UM()->options()->get( 'restricted_blocks' );
441
+ if ( empty( $restricted_blocks ) ) {
442
+ return;
443
+ }
444
+
445
+ wp_register_script( 'um_block_js', $this->js_url . 'um-admin-blocks.js', array( 'wp-i18n', 'wp-blocks', 'wp-components', 'wp-hooks' ), ultimatemember_version, true );
446
+ wp_set_script_translations( 'um_block_js', 'ultimate-member' );
447
+
448
+ $restrict_options = array();
449
+ $roles = UM()->roles()->get_roles( false );
450
+ if ( ! empty( $roles ) ) {
451
+ foreach ( $roles as $role_key => $title ) {
452
+ $restrict_options[] = array(
453
+ 'label' => $title,
454
+ 'value' => $role_key
455
+ );
456
+ }
457
+ }
458
+ wp_localize_script( 'um_block_js', 'um_restrict_roles', $restrict_options );
459
+
460
+ wp_enqueue_script( 'um_block_js' );
461
+
462
+ do_action( 'um_load_gutenberg_js' );
463
+ }
464
+
465
+
466
+ /**
467
+ * Load Gutenberg blocks js
468
+ */
469
+ function load_gutenberg_shortcode_blocks() {
470
+ if ( ! function_exists( 'register_block_type' ) ) {
471
+ // Gutenberg is not active.
472
+ return;
473
+ }
474
+
475
+ //disable Gutenberg scripts to avoid the conflicts
476
+ $disable_script = apply_filters( 'um_disable_blocks_script', false );
477
+ if ( $disable_script ) {
478
+ return;
479
+ }
480
+
481
+ $enable_blocks = UM()->options()->get( 'enable_blocks' );
482
+ if ( empty( $enable_blocks ) ) {
483
+ return;
484
+ }
485
+
486
+ wp_register_script( 'um-blocks-shortcode-js', $this->js_url . 'um-admin-blocks-shortcode.js', array( 'wp-i18n', 'wp-blocks', 'wp-components', /*'rich-text'*/ ), ultimatemember_version, true );
487
+ wp_set_script_translations( 'um-blocks-shortcode-js', 'ultimate-member' );
488
+ wp_enqueue_script( 'um-blocks-shortcode-js' );
489
+
490
+ $account_settings = array(
491
+ 'password' => array(
492
+ 'label' => __( 'Password', 'ultimate-member' ),
493
+ 'enabled' => UM()->options()->get( 'account_tab_password' ),
494
+ ),
495
+ 'privacy' => array(
496
+ 'label' => __( 'Privacy', 'ultimate-member' ),
497
+ 'enabled' => UM()->options()->get( 'account_tab_privacy' ),
498
+ ),
499
+ 'notifications' => array(
500
+ 'label' => __( 'Notifications', 'ultimate-member' ),
501
+ 'enabled' => UM()->options()->get( 'account_tab_notifications' ),
502
+ ),
503
+ 'delete' => array(
504
+ 'label' => __( 'Delete', 'ultimate-member' ),
505
+ 'enabled' => UM()->options()->get( 'account_tab_delete' ),
506
+ ),
507
+ );
508
+ wp_localize_script( 'um-blocks-shortcode-js', 'um_account_settings', $account_settings );
509
+
510
+ /**
511
+ * create gutenberg blocks
512
+ */
513
+ register_block_type( 'um-block/um-forms', array(
514
+ 'editor_script' => 'um-blocks-shortcode-js',
515
+ ) );
516
+
517
+ register_block_type( 'um-block/um-member-directories', array(
518
+ 'editor_script' => 'um-blocks-shortcode-js',
519
+ ) );
520
+
521
+ register_block_type( 'um-block/um-password-reset', array(
522
+ 'editor_script' => 'um-blocks-shortcode-js',
523
+ ) );
524
+
525
+ register_block_type( 'um-block/um-account', array(
526
+ 'editor_script' => 'um-blocks-shortcode-js',
527
+ ) );
528
+ }
529
+
530
+
531
+ /**
532
+ * Add Gutenberg category for UM shortcodes
533
+ *
534
+ * @param array $categories
535
+ * @param \WP_Block_Editor_Context $context
536
+ *
537
+ * @return array
538
+ */
539
+ function blocks_category( $categories, $context ) {
540
+ $enable_blocks = UM()->options()->get( 'enable_blocks' );
541
+ if ( empty( $enable_blocks ) ) {
542
+ return $categories;
543
+ }
544
+
545
+ return array_merge(
546
+ $categories,
547
+ array(
548
+ array(
549
+ 'slug' => 'um-blocks',
550
+ 'title' => __( 'Ultimate Member Blocks', 'ultimate-member' ),
551
+ ),
552
+ )
553
+ );
554
+ }
555
+
556
+ /**
557
+ * Load localize scripts
558
+ */
559
+ function load_localize_scripts() {
560
+
561
+ /**
562
+ * UM hook
563
+ *
564
+ * @type filter
565
+ * @title um_admin_enqueue_localize_data
566
+ * @description Extend localize data at wp-admin side
567
+ * @input_vars
568
+ * [{"var":"$localize_data","type":"array","desc":"Localize Data"}]
569
+ * @change_log
570
+ * ["Since: 2.0"]
571
+ * @usage add_filter( 'um_admin_enqueue_localize_data', 'function_name', 10, 1 );
572
+ * @example
573
+ * <?php
574
+ * add_filter( 'um_admin_enqueue_localize_data', 'my_admin_enqueue_localize_data', 10, 1 );
575
+ * function my_admin_enqueue_localize_data( $localize_data ) {
576
+ * // your code here
577
+ * return $localize_data;
578
+ * }
579
+ * ?>
580
+ */
581
+ $localize_data = apply_filters( 'um_admin_enqueue_localize_data', array(
582
+ 'nonce' => wp_create_nonce( "um-admin-nonce" )
583
+ )
584
+ );
585
+
586
+ wp_localize_script( 'um_admin_global', 'um_admin_scripts', $localize_data );
587
+ }
588
+
589
+
590
+ /**
591
+ * Enqueue scripts and styles
592
+ */
593
+ function admin_enqueue_scripts() {
594
+ if ( UM()->admin()->is_um_screen() ) {
595
+
596
+ /*if ( get_post_type() != 'shop_order' ) {
597
+ UM()->enqueue()->wp_enqueue_scripts();
598
+ }*/
599
+
600
+ $modal_deps = array( 'um-admin-scripts' );
601
+ if ( $this->um_cpt_form_screen ) {
602
+ $this->enqueue_frontend_preview_assets();
603
+ $modal_deps[] = 'um-responsive';
604
+ }
605
+
606
+ $this->load_functions();
607
+ $this->load_global_scripts();
608
+ $this->load_form();
609
+ $this->load_forms();
610
+ $this->load_custom_scripts();
611
+ $this->load_modal();
612
+ $this->load_dashboard();
613
+ $this->load_settings();
614
+ $this->load_field();
615
+ $this->load_builder();
616
+ $this->load_css();
617
+ $this->load_core_wp();
618
+ $this->load_ajax_js();
619
+ $this->load_fonticons();
620
+ $this->load_localize_scripts();
621
+
622
+
623
+ //scripts for frontend preview
624
+ UM()->enqueue()->load_imagecrop();
625
+ UM()->enqueue()->load_css();
626
+ UM()->enqueue()->load_tipsy();
627
+ UM()->enqueue()->load_modal();
628
+ UM()->enqueue()->load_responsive();
629
+
630
+ wp_register_script( 'um_raty', um_url . 'assets/js/um-raty' . UM()->enqueue()->suffix . '.js', array( 'jquery', 'wp-i18n' ), ultimatemember_version, true );
631
+ wp_register_style( 'um_raty', um_url . 'assets/css/um-raty.css', array(), ultimatemember_version );
632
+
633
+ wp_register_style( 'um_default_css', um_url . 'assets/css/um-old-default.css', '', ultimatemember_version, 'all' );
634
+ wp_enqueue_style( 'um_default_css' );
635
+
636
+ if ( is_rtl() ) {
637
+ wp_register_style( 'um_admin_rtl', $this->css_url . 'um-admin-rtl.css', array(), ultimatemember_version );
638
+ wp_enqueue_style( 'um_admin_rtl' );
639
+ }
640
+
641
+ } else {
642
+
643
+ $this->load_global_scripts();
644
+ $this->load_localize_scripts();
645
+
646
+ }
647
+
648
+ global $wp_version, $current_screen;
649
+ if ( version_compare( $wp_version, '5.0', '>=' ) && ! empty( $this->post_page ) ) {
650
+
651
+ if ( $current_screen->is_block_editor() ) {
652
+ $this->load_gutenberg_js();
653
+ $this->load_gutenberg_shortcode_blocks();
654
+ }
655
+ }
656
+
657
+ }
658
+
659
+
660
+ /**
661
+ * Print editor scripts if they are not printed by default
662
+ */
663
+ function admin_footer_scripts() {
664
+ /**
665
+ * @var $class \_WP_Editors
666
+ */
667
+ $class = '\_WP_Editors';
668
+
669
+ if ( did_action( 'print_default_editor_scripts' ) ) {
670
+ return;
671
+ }
672
+ if ( did_action( 'wp_tiny_mce_init' ) ) {
673
+ return;
674
+ }
675
+ if ( has_action( 'admin_print_footer_scripts', array( $class, 'editor_js' ) ) ) {
676
+ return;
677
+ }
678
+
679
+ if ( ! class_exists( $class, false ) ) {
680
+ require_once( ABSPATH . WPINC . '/class-wp-editor.php' );
681
+ }
682
+
683
+ $class::force_uncompressed_tinymce();
684
+ $class::enqueue_scripts();
685
+ $class::editor_js();
686
+ }
687
+
688
+ }
689
+ }
includes/admin/core/class-admin-forms.php CHANGED
@@ -1151,8 +1151,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
1151
  $class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
1152
 
1153
  $data = array(
1154
- 'field_id' => $field_data['id'],
1155
- 'id_attr' => $id
 
1156
  );
1157
 
1158
  $data_attr = '';
@@ -1604,4 +1605,4 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
1604
  return $value;
1605
  }
1606
  }
1607
- }
1151
  $class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
1152
 
1153
  $data = array(
1154
+ 'field_id' => $field_data['id'],
1155
+ 'id_attr' => $id,
1156
+ 'item_class' => "um-multi-text-option-line {$size}",
1157
  );
1158
 
1159
  $data_attr = '';
1605
  return $value;
1606
  }
1607
  }
1608
+ }
includes/admin/core/class-admin-menu.php CHANGED
@@ -191,7 +191,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) {
191
  function um_roles_pages() {
192
  if ( empty( $_GET['tab'] ) ) {
193
  include_once um_path . 'includes/admin/core/list-tables/roles-list-table.php';
194
- } elseif ( sanitize_key( $_GET['tab'] ) == 'add' || sanitize_key( $_GET['tab'] ) == 'edit' ) {
195
  include_once um_path . 'includes/admin/templates/role/role-edit.php';
196
  } else {
197
  um_js_redirect( add_query_arg( array( 'page' => 'um_roles' ), get_admin_url( 'admin.php' ) ) );
@@ -340,4 +340,4 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) {
340
  }
341
 
342
  }
343
- }
191
  function um_roles_pages() {
192
  if ( empty( $_GET['tab'] ) ) {
193
  include_once um_path . 'includes/admin/core/list-tables/roles-list-table.php';
194
+ } elseif ( 'add' === sanitize_key( $_GET['tab'] ) || 'edit' === sanitize_key( $_GET['tab'] ) ) {
195
  include_once um_path . 'includes/admin/templates/role/role-edit.php';
196
  } else {
197
  um_js_redirect( add_query_arg( array( 'page' => 'um_roles' ), get_admin_url( 'admin.php' ) ) );
340
  }
341
 
342
  }
343
+ }
includes/admin/core/class-admin-metabox.php CHANGED
@@ -195,7 +195,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
195
  * @param $post_id
196
  * @param $post
197
  */
198
- function save_metabox_custom( $post_id, $post ) {
199
  // validate nonce
200
  if ( ! isset( $_POST['um_admin_save_metabox_custom_nonce'] ) ||
201
  ! wp_verify_nonce( $_POST['um_admin_save_metabox_custom_nonce'], basename( __FILE__ ) ) ) {
@@ -313,7 +313,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
313
  }
314
 
315
  if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) {
316
- update_post_meta( $post_id, 'um_content_restriction', $_POST['um_content_restriction'] );
 
 
317
  } else {
318
  delete_post_meta( $post_id, 'um_content_restriction' );
319
  }
@@ -340,7 +342,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
340
  }
341
 
342
  if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) {
343
- update_post_meta( $post_id, 'um_content_restriction', $_POST['um_content_restriction'] );
 
 
344
  } else {
345
  delete_post_meta( $post_id, 'um_content_restriction' );
346
  }
@@ -666,7 +670,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
666
  }
667
 
668
  if ( ! empty( $_REQUEST['um_content_restriction'] ) && is_array( $_REQUEST['um_content_restriction'] ) ) {
669
- update_term_meta( $termID, 'um_content_restriction', $_REQUEST['um_content_restriction'] );
 
 
670
  } else {
671
  delete_term_meta( $termID, 'um_content_restriction' );
672
  }
@@ -851,7 +857,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
851
  )
852
  );
853
 
854
- if ( ! isset( $_GET['id'] ) || 'administrator' != sanitize_key( $_GET['id'] ) ) {
855
  $roles_metaboxes[] = array(
856
  'id' => 'um-admin-form-home',
857
  'title' => __( 'Homepage Options', 'ultimate-member' ),
@@ -1093,14 +1099,17 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
1093
  delete_post_meta( $post_id, '_um_search_filters' );
1094
  delete_post_meta( $post_id, '_um_search_filters_gmt' );
1095
 
 
 
1096
  //save metadata
1097
- foreach ( $_POST['um_metadata'] as $k => $v ) {
 
1098
 
1099
- if ( $k == '_um_show_these_users' && trim( $_POST['um_metadata'][ $k ] ) ) {
1100
  $v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
1101
  }
1102
 
1103
- if ( $k == '_um_exclude_these_users' && trim( $_POST['um_metadata'][ $k ] ) ) {
1104
  $v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
1105
  }
1106
 
@@ -1172,7 +1181,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
1172
 
1173
  // save
1174
  delete_post_meta( $post_id, '_um_profile_metafields' );
1175
- foreach ( $_POST['form'] as $k => $v ) {
 
 
 
 
1176
  if ( strstr( $k, '_um_' ) ) {
1177
  if ( $k === '_um_is_default' ) {
1178
  $mode = UM()->query()->get_attr( 'mode', $post_id );
@@ -1732,7 +1745,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
1732
  ?>
1733
 
1734
  <p><label for="_force_confirm_pass"><?php _e( 'Automatically add a confirm password field?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Turn on to add a confirm password field. If turned on the confirm password field will only show on register forms and not on login forms.', 'ultimate-member' ) ); ?></label>
1735
- <input type="checkbox" name="_force_confirm_pass" id="_force_confirm_pass" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> />
1736
  </p>
1737
 
1738
  <?php
@@ -2266,6 +2279,16 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
2266
  <?php
2267
  break;
2268
 
 
 
 
 
 
 
 
 
 
 
2269
  case '_placeholder':
2270
  ?>
2271
 
@@ -2411,4 +2434,4 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
2411
  }
2412
 
2413
  }
2414
- }
195
  * @param $post_id
196
  * @param $post
197
  */
198
+ public function save_metabox_custom( $post_id, $post ) {
199
  // validate nonce
200
  if ( ! isset( $_POST['um_admin_save_metabox_custom_nonce'] ) ||
201
  ! wp_verify_nonce( $_POST['um_admin_save_metabox_custom_nonce'], basename( __FILE__ ) ) ) {
313
  }
314
 
315
  if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) {
316
+ $restriction_meta = UM()->admin()->sanitize_post_restriction_meta( $_POST['um_content_restriction'] );
317
+
318
+ update_post_meta( $post_id, 'um_content_restriction', $restriction_meta );
319
  } else {
320
  delete_post_meta( $post_id, 'um_content_restriction' );
321
  }
342
  }
343
 
344
  if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) {
345
+ $restriction_meta = UM()->admin()->sanitize_post_restriction_meta( $_POST['um_content_restriction'] );
346
+
347
+ update_post_meta( $post_id, 'um_content_restriction', $restriction_meta );
348
  } else {
349
  delete_post_meta( $post_id, 'um_content_restriction' );
350
  }
670
  }
671
 
672
  if ( ! empty( $_REQUEST['um_content_restriction'] ) && is_array( $_REQUEST['um_content_restriction'] ) ) {
673
+ $restriction_meta = UM()->admin()->sanitize_term_restriction_meta( $_REQUEST['um_content_restriction'] );
674
+
675
+ update_term_meta( $termID, 'um_content_restriction', $restriction_meta );
676
  } else {
677
  delete_term_meta( $termID, 'um_content_restriction' );
678
  }
857
  )
858
  );
859
 
860
+ if ( ! isset( $_GET['id'] ) || 'administrator' !== sanitize_key( $_GET['id'] ) ) {
861
  $roles_metaboxes[] = array(
862
  'id' => 'um-admin-form-home',
863
  'title' => __( 'Homepage Options', 'ultimate-member' ),
1099
  delete_post_meta( $post_id, '_um_search_filters' );
1100
  delete_post_meta( $post_id, '_um_search_filters_gmt' );
1101
 
1102
+ delete_post_meta( $post_id, '_um_sorting_fields' );
1103
+
1104
  //save metadata
1105
+ $metadata = UM()->admin()->sanitize_member_directory_meta( $_POST['um_metadata'] );
1106
+ foreach ( $metadata as $k => $v ) {
1107
 
1108
+ if ( $k == '_um_show_these_users' && trim( $v ) ) {
1109
  $v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
1110
  }
1111
 
1112
+ if ( $k == '_um_exclude_these_users' && trim( $v ) ) {
1113
  $v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY );
1114
  }
1115
 
1181
 
1182
  // save
1183
  delete_post_meta( $post_id, '_um_profile_metafields' );
1184
+
1185
+
1186
+ $form_meta = UM()->admin()->sanitize_form_meta( $_POST['form'] );
1187
+
1188
+ foreach ( $form_meta as $k => $v ) {
1189
  if ( strstr( $k, '_um_' ) ) {
1190
  if ( $k === '_um_is_default' ) {
1191
  $mode = UM()->query()->get_attr( 'mode', $post_id );
1745
  ?>
1746
 
1747
  <p><label for="_force_confirm_pass"><?php _e( 'Automatically add a confirm password field?', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'Turn on to add a confirm password field. If turned on the confirm password field will only show on register forms and not on login forms.', 'ultimate-member' ) ); ?></label>
1748
+ <input type="checkbox" name="_force_confirm_pass" id="_force_confirm_pass" value="1" <?php checked( isset( $this->edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_label_confirm_pass" data-cond1-hide="xxx" />
1749
  </p>
1750
 
1751
  <?php
2279
  <?php
2280
  break;
2281
 
2282
+ case '_label_confirm_pass':
2283
+ ?>
2284
+
2285
+ <p><label for="_label_confirm_pass"><?php _e( 'Confirm password field label', 'ultimate-member' ) ?> <?php UM()->tooltip( __( 'This label is the text that appears above the confirm password field. Leave blank to show default label.', 'ultimate-member' ) ); ?></label>
2286
+ <input type="text" name="_label_confirm_pass" id="_label_confirm_pass" value="<?php echo htmlspecialchars( $this->edit_mode_value, ENT_QUOTES ); ?>" />
2287
+ </p>
2288
+
2289
+ <?php
2290
+ break;
2291
+
2292
  case '_placeholder':
2293
  ?>
2294
 
2434
  }
2435
 
2436
  }
2437
+ }
includes/admin/core/class-admin-navmenu.php CHANGED
@@ -146,9 +146,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Navmenu' ) ) {
146
 
147
 
148
  /**
149
- * @param $menu_id
150
- * @param $menu_item_db_id
151
- * @param $menu_item_args
152
  */
153
  function _save( $menu_id, $menu_item_db_id, $menu_item_args ) {
154
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
@@ -167,7 +167,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Navmenu' ) ) {
167
  if ( ! empty( $_POST[ $key ][ $menu_item_db_id ] ) ) {
168
  // Do some checks here...
169
  $value = is_array( $_POST[ $key ][ $menu_item_db_id ] ) ?
170
- array_keys( $_POST[ $key ][ $menu_item_db_id ] ) : $_POST[ $key ][ $menu_item_db_id ];
171
  } else {
172
  $value = null;
173
  }
146
 
147
 
148
  /**
149
+ * @param int $menu_id
150
+ * @param int $menu_item_db_id
151
+ * @param array $menu_item_args
152
  */
153
  function _save( $menu_id, $menu_item_db_id, $menu_item_args ) {
154
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
167
  if ( ! empty( $_POST[ $key ][ $menu_item_db_id ] ) ) {
168
  // Do some checks here...
169
  $value = is_array( $_POST[ $key ][ $menu_item_db_id ] ) ?
170
+ array_map( 'sanitize_key', array_keys( $_POST[ $key ][ $menu_item_db_id ] ) ) : (int) $_POST[ $key ][ $menu_item_db_id ];
171
  } else {
172
  $value = null;
173
  }
includes/admin/core/class-admin-notices.php CHANGED
@@ -580,8 +580,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
580
  'message' => $message,
581
  ), 4 );
582
  } else {
583
- if ( isset( $_GET['msg'] ) && 'updated' == sanitize_key( $_GET['msg'] ) ) {
584
- if ( isset( $_GET['page'] ) && 'um_options' == sanitize_key( $_GET['page'] ) ) {
585
  $this->add_notice( 'settings_upgrade', array(
586
  'class' => 'updated',
587
  'message' => '<p>' . __( 'Settings successfully upgraded', 'ultimate-member' ) . '</p>',
@@ -697,4 +697,4 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
697
  wp_send_json_success();
698
  }
699
  }
700
- }
580
  'message' => $message,
581
  ), 4 );
582
  } else {
583
+ if ( isset( $_GET['msg'] ) && 'updated' === sanitize_key( $_GET['msg'] ) ) {
584
+ if ( isset( $_GET['page'] ) && 'um_options' === sanitize_key( $_GET['page'] ) ) {
585
  $this->add_notice( 'settings_upgrade', array(
586
  'class' => 'updated',
587
  'message' => '<p>' . __( 'Settings successfully upgraded', 'ultimate-member' ) . '</p>',
697
  wp_send_json_success();
698
  }
699
  }
700
+ }
includes/admin/core/class-admin-settings.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  namespace um\admin\core;
3
 
4
-
5
- if ( ! defined( 'ABSPATH' ) ) exit;
6
-
7
 
8
  if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
9
 
@@ -16,30 +16,36 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
16
 
17
 
18
  /**
19
- * @var
 
 
 
 
 
 
20
  */
21
- var $settings_structure;
22
 
23
 
24
  /**
25
  * @var
26
  */
27
- var $previous_licenses;
28
 
29
 
30
  /**
31
  * @var
32
  */
33
- var $need_change_permalinks;
34
 
35
 
36
- var $gravatar_changed = false;
37
 
38
 
39
  /**
40
  * Admin_Settings constructor.
41
  */
42
- function __construct() {
43
  //init settings structure
44
  add_action( 'admin_init', array( &$this, 'init_variables' ), 9 );
45
 
@@ -77,6 +83,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
77
  add_action( 'um_settings_before_save', array( $this, 'before_licenses_save' ) );
78
  add_action( 'um_settings_save', array( $this, 'licenses_save' ) );
79
 
 
80
  add_filter( 'um_change_settings_before_save', array( $this, 'remove_empty_values' ), 10, 1 );
81
 
82
  add_action( 'admin_init', array( &$this, 'um_download_install_info' ) );
@@ -84,7 +91,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
84
 
85
 
86
 
87
- function same_page_update_ajax() {
88
  UM()->admin()->check_ajax_nonce();
89
 
90
  if ( empty( $_POST['cb_func'] ) ) {
@@ -93,7 +100,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
93
 
94
  $cb_func = sanitize_key( $_POST['cb_func'] );
95
 
96
- if ( 'um_usermeta_fields' == $cb_func ) {
97
  //first install metatable
98
  global $wpdb;
99
 
@@ -110,9 +117,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
110
  foreach ( $sites as $blog_id ) {
111
  $metakeys[] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
112
  }
113
-
114
  } else {
115
- $blog_id = get_current_blog_id();
116
  $metakeys[] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
117
  }
118
 
@@ -124,7 +130,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
124
  $metakeys[] = '_reviews_avg';
125
 
126
  //myCred meta
127
- if ( function_exists( 'mycred_get_types' ) ) {
128
  $mycred_types = mycred_get_types();
129
  if ( ! empty( $mycred_types ) ) {
130
  foreach ( array_keys( $mycred_types ) as $point_type ) {
@@ -145,7 +151,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
145
 
146
  foreach ( $custom_val as $sort_value ) {
147
  if ( is_array( $sort_value ) ) {
148
- $field_keys = array_keys( $sort_value );
149
  $sortby_custom_keys[] = $field_keys[0];
150
  }
151
  }
@@ -154,7 +160,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
154
 
155
  if ( ! empty( $sortby_custom_keys ) ) {
156
  $sortby_custom_keys = array_unique( $sortby_custom_keys );
157
- $metakeys = array_merge( $metakeys, $sortby_custom_keys );
158
  }
159
 
160
  $skip_fields = UM()->builtin()->get_fields_without_metakey();
@@ -177,7 +183,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
177
  UM()->options()->update( 'member_directory_own_table', true );
178
 
179
  wp_send_json_success();
180
- } elseif ( 'um_get_metadata' == $cb_func ) {
181
  global $wpdb;
182
 
183
  $wp_usermeta_option = get_option( 'um_usermeta_fields', array() );
@@ -189,41 +195,45 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
189
  );
190
 
191
  wp_send_json_success( array( 'count' => $count ) );
192
- } elseif ( 'um_update_metadata_per_page' == $cb_func ) {
193
 
194
  if ( empty( $_POST['page'] ) ) {
195
  wp_send_json_error( __( 'Wrong data', 'ultimate-member' ) );
196
  }
197
 
198
- $per_page = 500;
199
  $wp_usermeta_option = get_option( 'um_usermeta_fields', array() );
200
 
201
  global $wpdb;
202
- $metadata = $wpdb->get_results( $wpdb->prepare(
203
- "SELECT *
204
- FROM {$wpdb->usermeta}
205
- WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "')
206
- LIMIT %d, %d",
207
- ( absint( $_POST['page'] ) - 1 ) * $per_page,
208
- $per_page
209
- ), ARRAY_A );
 
 
 
210
 
211
  $values = array();
212
  foreach ( $metadata as $metarow ) {
213
- $values[] = $wpdb->prepare('(%d, %s, %s)', $metarow['user_id'], $metarow['meta_key'], $metarow['meta_value'] );
214
  }
215
 
216
  if ( ! empty( $values ) ) {
217
- $wpdb->query(
218
- "INSERT INTO
219
- {$wpdb->prefix}um_metadata(user_id, um_key, um_value)
220
- VALUES " . implode( ',', $values ) );
 
221
  }
222
 
223
  $from = ( absint( $_POST['page'] ) * $per_page ) - $per_page + 1;
224
- $to = absint( $_POST['page'] ) * $per_page;
225
 
226
- wp_send_json_success( array( 'message' => sprintf( __( 'Metadata from %s to %s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
227
  }
228
  }
229
 
@@ -231,58 +241,71 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
231
  /**
232
  *
233
  */
234
- function init_variables() {
 
 
 
235
  $general_pages_fields = array(
236
  array(
237
  'id' => 'pages_settings',
238
  'type' => 'hidden',
239
  'value' => true,
240
- 'is_option' => false
241
- )
242
  );
243
 
244
  $core_pages = UM()->config()->core_pages;
245
 
246
  foreach ( $core_pages as $page_s => $page ) {
247
  $have_pages = UM()->query()->wp_pages();
248
- $page_id = UM()->options()->get_core_page_id( $page_s );
249
 
250
  $page_title = ! empty( $page['title'] ) ? $page['title'] : '';
251
 
252
- if ( 'reached_maximum_limit' == $have_pages ) {
253
  $general_pages_fields[] = array(
254
- 'id' => $page_id,
255
- 'type' => 'text',
256
- 'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ),
257
- 'placeholder' => __( 'Add page ID', 'ultimate-member' ),
258
- 'compiler' => true,
259
- 'size' => 'small'
 
260
  );
261
  } else {
262
  $general_pages_fields[] = array(
263
- 'id' => $page_id,
264
- 'type' => 'select',
265
- 'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ),
266
- 'options' => UM()->query()->wp_pages(),
267
- 'placeholder' => __( 'Choose a page...', 'ultimate-member' ),
268
- 'compiler' => true,
269
- 'size' => 'small'
 
270
  );
271
  }
272
- }
273
 
274
 
 
 
 
 
 
275
  $appearances_profile_menu_fields = array(
276
  array(
277
  'id' => 'profile_menu',
278
  'type' => 'checkbox',
279
  'label' => __( 'Enable profile menu', 'ultimate-member' ),
280
- )
 
 
 
 
281
  );
282
 
283
  $tabs = UM()->profile()->tabs();
284
 
285
- $tabs_options = array();
286
  $tabs_condition = array();
287
  foreach ( $tabs as $id => $tab ) {
288
 
@@ -292,48 +315,70 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
292
 
293
  if ( isset( $tab['name'] ) ) {
294
  $tabs_options[ $id ] = $tab['name'];
295
- $tabs_condition[] = 'profile_tab_' . $id;
296
  }
297
 
298
  if ( isset( $tab['default_privacy'] ) ) {
299
  $fields = array(
300
  array(
301
- 'id' => 'profile_tab_' . $id,
302
- 'type' => 'checkbox',
303
- 'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ),
304
- 'conditional' => array( 'profile_menu', '=', 1 ),
305
- 'data' => array( 'fill_profile_menu_default_tab' => $id ),
 
306
  ),
307
  );
 
 
 
 
308
  } else {
309
 
310
  $fields = array(
311
  array(
312
- 'id' => 'profile_tab_' . $id,
313
- 'type' => 'checkbox',
314
- 'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ),
315
- 'conditional' => array( 'profile_menu', '=', 1 ),
316
- 'data' => array( 'fill_profile_menu_default_tab' => $id ),
 
317
  ),
318
  array(
319
- 'id' => 'profile_tab_' . $id . '_privacy',
320
- 'type' => 'select',
321
- 'label' => sprintf( __( 'Who can see %s Tab?', 'ultimate-member' ), $tab['name'] ),
322
- 'tooltip' => __( 'Select which users can view this tab.', 'ultimate-member' ),
323
- 'options' => UM()->profile()->tabs_privacy(),
324
- 'conditional' => array( 'profile_tab_' . $id, '=', 1 ),
325
- 'size' => 'small'
 
326
  ),
327
  array(
328
- 'id' => 'profile_tab_' . $id . '_roles',
329
- 'type' => 'select',
330
- 'multi' => true,
331
- 'label' => __( 'Allowed roles', 'ultimate-member' ),
332
- 'tooltip' => __( 'Select the the user roles allowed to view this tab.', 'ultimate-member' ),
333
- 'options' => UM()->roles()->get_roles(),
334
- 'placeholder' => __( 'Choose user roles...', 'ultimate-member' ),
335
- 'conditional' => array( 'profile_tab_' . $id . '_privacy', '=', [ '4', '5' ] ),
336
- 'size' => 'small'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337
  )
338
  );
339
  }
@@ -342,42 +387,53 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
342
  }
343
 
344
  $appearances_profile_menu_fields[] = array(
345
- 'id' => 'profile_menu_default_tab',
346
- 'type' => 'select',
347
- 'label' => __( 'Profile menu default tab', 'ultimate-member' ),
348
- 'tooltip' => __( 'This will be the default tab on user profile page', 'ultimate-member' ),
349
- 'options' => $tabs_options,
350
- 'conditional' => array( implode( '|', $tabs_condition ), '~', 1 ),
351
- 'size' => 'small'
 
 
 
 
352
  );
353
 
354
- $appearances_profile_menu_fields = array_merge( $appearances_profile_menu_fields, array(
 
355
  array(
356
- 'id' => 'profile_menu_icons',
357
- 'type' => 'checkbox',
358
- 'label' => __( 'Enable menu icons in desktop view', 'ultimate-member' ),
359
- 'conditional' => array( 'profile_menu', '=', 1 ),
360
- ),
361
- ) );
 
 
 
 
 
 
362
 
363
  $post_types_options = array();
364
- $all_post_types = get_post_types( array( 'public' => true ), 'objects' );
365
  foreach ( $all_post_types as $key => $post_type_data ) {
366
  $post_types_options[ $key ] = $post_type_data->labels->singular_name;
367
  }
368
 
 
369
  $taxonomies_options = array();
370
  $exclude_taxonomies = UM()->excluded_taxonomies();
371
- $all_taxonomies = get_taxonomies( array( 'public' => true ), 'objects' );
372
- $duplicates = array();
373
  foreach ( $all_taxonomies as $key => $taxonomy ) {
374
- if ( in_array( $key , $exclude_taxonomies ) ) {
375
  continue;
376
  }
377
 
378
- if ( ! in_array( $taxonomy->labels->singular_name, $duplicates ) ) {
379
  $duplicates[] = $taxonomy->labels->singular_name;
380
- $label = $taxonomy->labels->singular_name;
381
  } else {
382
  $label = $taxonomy->labels->singular_name . ' (' . $key . ')';
383
  }
@@ -386,7 +442,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
386
  }
387
 
388
  $restricted_access_post_metabox_value = array();
389
- if ( $restricted_access_post_metabox = UM()->options()->get( 'restricted_access_post_metabox' ) ) {
 
390
  foreach ( $restricted_access_post_metabox as $key => $value ) {
391
  if ( $value ) {
392
  $restricted_access_post_metabox_value[] = $key;
@@ -396,7 +453,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
396
 
397
 
398
  $restricted_access_taxonomy_metabox_value = array();
399
- if ( $restricted_access_taxonomy_metabox = UM()->options()->get( 'restricted_access_taxonomy_metabox' ) ) {
 
400
  foreach ( $restricted_access_taxonomy_metabox as $key => $value ) {
401
  if ( $value ) {
402
  $restricted_access_taxonomy_metabox_value[] = $key;
@@ -406,116 +464,447 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
406
 
407
  $access_fields = array(
408
  array(
409
- 'id' => 'accessible',
410
- 'type' => 'select',
411
- 'label' => __( 'Global Site Access', 'ultimate-member' ),
412
- 'tooltip' => __( 'Globally control the access of your site, you can have seperate restrict options per post/page by editing the desired item.', 'ultimate-member' ),
413
- 'options' => array(
414
- 0 => __( 'Site accessible to Everyone', 'ultimate-member' ),
415
- 2 => __( 'Site accessible to Logged In Users', 'ultimate-member' ),
416
- ),
417
- 'size' => 'medium',
418
  ),
419
  array(
420
- 'id' => 'access_redirect',
421
- 'type' => 'text',
422
- 'label' => __( 'Custom Redirect URL', 'ultimate-member' ),
423
- 'tooltip' => __( 'A logged out user will be redirected to this url If he is not permitted to access the site', 'ultimate-member' ),
424
- 'conditional' => array( 'accessible', '=', 2 ),
 
 
 
 
 
 
 
 
 
425
  ),
426
  array(
427
- 'id' => 'access_exclude_uris',
428
- 'type' => 'multi_text',
429
- 'label' => __( 'Exclude the following URLs', 'ultimate-member' ),
430
- 'tooltip' => __( 'Here you can exclude URLs beside the redirect URI to be accessible to everyone', 'ultimate-member' ),
431
- 'add_text' => __( 'Add New URL', 'ultimate-member' ),
432
- 'conditional' => array( 'accessible', '=', 2 ),
433
- 'show_default_number' => 1,
434
  ),
435
  array(
436
- 'id' => 'home_page_accessible',
437
- 'type' => 'checkbox',
438
- 'label' => __( 'Allow Homepage to be accessible', 'ultimate-member' ),
439
- 'conditional' => array( 'accessible', '=', 2 ),
440
  ),
441
  array(
442
- 'id' => 'category_page_accessible',
443
- 'type' => 'checkbox',
444
- 'label' => __( 'Allow Category pages to be accessible', 'ultimate-member' ),
445
- 'conditional' => array( 'accessible', '=', 2 ),
446
  ),
 
 
 
 
447
  array(
448
- 'id' => 'restricted_access_message',
449
- 'type' => 'wp_editor',
450
- 'label' => __( 'Restricted Access Message', 'ultimate-member' ),
451
- 'tooltip' => __( 'This is the message shown to users that do not have permission to view the content', 'ultimate-member' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
452
  )
453
  );
454
 
455
  global $wp_version;
456
  if ( version_compare( $wp_version, '5.0', '>=' ) ) {
457
- $access_fields = array_merge( $access_fields, array( array(
458
- 'id' => 'restricted_blocks',
459
- 'type' => 'checkbox',
460
- 'label' => __( 'Allow Gutenberg Blocks restriction options', 'ultimate-member' ),
461
- ),
462
- array(
463
- 'id' => 'restricted_block_message',
464
- 'type' => 'textarea',
465
- 'label' => __( 'Restricted Block Message', 'ultimate-member' ),
466
- 'tooltip' => __( 'This is the message shown to users that do not have permission to view the block\'s content', 'ultimate-member' ),
467
- 'conditional' => array( 'restricted_blocks', '=', 1 ),
468
- ) ) );
 
 
 
 
 
 
 
 
 
 
 
 
469
  }
470
- $access_fields = array_merge( $access_fields, array(
471
- array(
472
- 'id' => 'restricted_access_post_metabox',
473
- 'type' => 'hidden',
474
- 'value' => '',
475
- ),
476
- array(
477
- 'id' => 'restricted_access_taxonomy_metabox',
478
- 'type' => 'hidden',
479
- 'value' => '',
480
- ),
481
  array(
482
- 'id' => 'restricted_access_post_metabox',
483
- 'type' => 'multi_checkbox',
484
- 'label' => __( 'Restricted Access to Posts', 'ultimate-member' ),
485
- 'tooltip' => __( 'Restriction content of the current Posts', 'ultimate-member' ),
486
- 'options' => $post_types_options,
487
- 'columns' => 3,
488
- 'value' => $restricted_access_post_metabox_value,
489
- 'default' => UM()->options()->get_default( 'restricted_access_post_metabox' ),
490
- ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
491
  array(
492
- 'id' => 'restricted_access_taxonomy_metabox',
493
- 'type' => 'multi_checkbox',
494
- 'label' => __( 'Restricted Access to Taxonomies', 'ultimate-member' ),
495
- 'tooltip' => __( 'Restriction content of the current Taxonomies', 'ultimate-member' ),
496
- 'options' => $taxonomies_options,
497
- 'columns' => 3,
498
- 'value' => $restricted_access_taxonomy_metabox_value,
499
- 'default' => UM()->options()->get_default( 'restricted_access_taxonomy_metabox' ),
500
- ) ) );
501
-
502
- $latest_update = get_option( 'um_member_directory_update_meta', false );
503
  $latest_truncate = get_option( 'um_member_directory_truncated', false );
504
 
505
  $same_page_update = array(
506
- 'id' => 'member_directory_own_table',
507
- 'type' => 'same_page_update',
508
- 'label' => __( 'Enable custom table for usermeta', 'ultimate-member' ),
509
- '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' ),
510
  );
511
 
512
  if ( empty( $latest_update ) || ( ! empty( $latest_truncate ) && $latest_truncate > $latest_update ) ) {
513
- $same_page_update['upgrade_cb'] = 'sync_metatable';
514
  $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>
515
  <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>
516
  <p>' . __( 'If the update was successful, you will see a corresponding message. Otherwise, contact technical support if the update failed.', 'ultimate-member' ) . '</p>';
517
  }
518
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
519
  /**
520
  * UM hook
521
  *
@@ -536,851 +925,852 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
536
  * }
537
  * ?>
538
  */
539
- $this->settings_structure = apply_filters( 'um_settings_structure', array(
540
- '' => array(
541
- 'title' => __( 'General', 'ultimate-member' ),
542
- 'sections' => array(
543
- '' => array(
544
- 'title' => __( 'Pages', 'ultimate-member' ),
545
- 'fields' => $general_pages_fields
546
- ),
547
- 'users' => array(
548
- 'title' => __( 'Users', 'ultimate-member' ),
549
- 'fields' => array(
550
- array(
551
- 'id' => 'permalink_base',
552
- 'type' => 'select',
553
- 'size' => 'small',
554
- 'label' => __( 'Profile Permalink Base','ultimate-member' ),
555
- 'tooltip' => __( 'Here you can control the permalink structure of the user profile URL globally e.g. ' . trailingslashit( um_get_core_page('user') ) . '<strong>username</strong>/','ultimate-member' ),
556
- 'options' => array(
557
- 'user_login' => __( 'Username', 'ultimate-member' ),
558
- 'name' => __( 'First and Last Name with \'.\'', 'ultimate-member' ),
559
- 'name_dash' => __( 'First and Last Name with \'-\'', 'ultimate-member' ),
560
- 'name_plus' => __( 'First and Last Name with \'+\'', 'ultimate-member' ),
561
- 'user_id' => __( 'User ID', 'ultimate-member' ),
562
- ),
563
- 'placeholder' => __( 'Select...', 'ultimate-member' ),
564
- ),
565
- array(
566
- 'id' => 'display_name',
567
- 'type' => 'select',
568
- 'size' => 'medium',
569
- 'label' => __( 'User Display Name', 'ultimate-member' ),
570
- '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' ),
571
- 'options' => array(
572
- 'default' => __( 'Default WP Display Name', 'ultimate-member' ),
573
- 'nickname' => __( 'Nickname', 'ultimate-member' ),
574
- 'username' => __( 'Username', 'ultimate-member' ),
575
- 'full_name' => __( 'First name & last name', 'ultimate-member' ),
576
- 'sur_name' => __( 'Last name & first name', 'ultimate-member' ),
577
- 'initial_name' => __( 'First name & first initial of last name', 'ultimate-member' ),
578
- 'initial_name_f' => __( 'First initial of first name & last name', 'ultimate-member' ),
579
- 'first_name' => __( 'First name only', 'ultimate-member' ),
580
- 'field' => __( 'Custom field(s)', 'ultimate-member' ),
581
- ),
582
- 'placeholder' => __( 'Select...', 'ultimate-member' ),
583
- ),
584
- array(
585
- 'id' => 'display_name_field',
586
- 'type' => 'text',
587
- 'label' => __( 'Display Name Custom Field(s)', 'ultimate-member' ),
588
- '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' ),
589
- 'conditional' => array( 'display_name', '=', 'field' ),
590
- ),
591
- array(
592
- 'id' => 'author_redirect',
593
- 'type' => 'checkbox',
594
- 'label' => __( 'Automatically redirect author page to their profile?', 'ultimate-member' ),
595
- 'tooltip' => __( 'If enabled, author pages will automatically redirect to the user\'s profile page', 'ultimate-member' ),
596
- ),
597
- array(
598
- 'id' => 'members_page',
599
- 'type' => 'checkbox',
600
- 'label' => __( 'Enable Members Directory', 'ultimate-member' ),
601
- 'tooltip' => __( 'Control whether to enable or disable member directories on this site', 'ultimate-member' ),
602
- ),
603
- array(
604
- 'id' => 'use_gravatars',
605
- 'type' => 'checkbox',
606
- 'label' => __( 'Use Gravatars?', 'ultimate-member' ),
607
- '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' ),
608
- ),
609
- array(
610
- 'id' => 'use_um_gravatar_default_builtin_image',
611
- 'type' => 'select',
612
- 'label' => __( 'Use Gravatar builtin image', 'ultimate-member' ),
613
- 'tooltip' => __( 'Gravatar has a number of built in options which you can also use as defaults', 'ultimate-member' ),
614
- 'options' => array(
615
- 'default' => __( 'Default', 'ultimate-member' ),
616
- '404' => __( '404 ( File Not Found response )', 'ultimate-member' ),
617
- 'mm' => __( 'Mystery Man', 'ultimate-member' ),
618
- 'identicon' => __( 'Identicon', 'ultimate-member' ),
619
- 'monsterid' => __( 'Monsterid', 'ultimate-member' ),
620
- 'wavatar' => __( 'Wavatar', 'ultimate-member' ),
621
- 'retro' => __( 'Retro', 'ultimate-member' ),
622
- 'blank' => __( 'Blank ( a transparent PNG image )', 'ultimate-member' ),
623
- ),
624
- 'conditional' => array( 'use_gravatars', '=', 1 ),
625
- 'size' => 'medium'
626
- ),
627
- array(
628
- 'id' => 'use_um_gravatar_default_image',
629
- 'type' => 'checkbox',
630
- 'label' => __( 'Use Default plugin avatar as Gravatar\'s Default avatar', 'ultimate-member' ),
631
- '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' ),
632
- 'conditional' => array( 'use_um_gravatar_default_builtin_image', '=', 'default' ),
633
- ),
634
- array(
635
- 'id' => 'reset_require_strongpass',
636
- 'type' => 'checkbox',
637
- 'label' => __( 'Require a strong password? (when user resets password only)', 'ultimate-member' ),
638
- 'tooltip' => __( 'Enable or disable a strong password rules on password reset and change procedure', 'ultimate-member' ),
639
- ),
640
- array(
641
- 'id' => 'profile_noindex',
642
- 'type' => 'select',
643
- 'size' => 'small',
644
- 'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ),
645
- 'tooltip' => __( 'Hides the profile page for robots. This setting can be overridden by individual role settings.', 'ultimate-member' ),
646
- 'options' => [
647
- '0' => __( 'No', 'ultimate-member' ),
648
- '1' => __( 'Yes', 'ultimate-member' ),
649
- ]
650
- ),
651
- array(
652
- 'id' => 'activation_link_expiry_time',
653
- 'type' => 'number',
654
- 'label' => __( 'Activation link lifetime', 'ultimate-member' ),
655
- 'tooltip' => __( 'How long does an activation link live in seconds? Leave empty for endless links.', 'ultimate-member' ),
656
- 'size' => 'small',
657
- ),
658
- )
659
- ),
660
- 'account' => array(
661
- 'title' => __( 'Account', 'ultimate-member' ),
662
- 'fields' => array(
663
- array(
664
- 'id' => 'account_tab_password',
665
- 'type' => 'checkbox',
666
- 'label' => __( 'Password Account Tab', 'ultimate-member' ),
667
- 'tooltip' => __( 'Enable/disable the Password account tab in account page', 'ultimate-member' ),
668
- ),
669
- array(
670
- 'id' => 'account_tab_privacy',
671
- 'type' => 'checkbox',
672
- 'label' => __( 'Privacy Account Tab', 'ultimate-member' ),
673
- 'tooltip' => __( 'Enable/disable the Privacy account tab in account page', 'ultimate-member' ),
674
- ),
675
- array(
676
- 'id' => 'account_tab_notifications',
677
- 'type' => 'checkbox',
678
- 'label' => __( 'Notifications Account Tab', 'ultimate-member' ),
679
- 'tooltip' => __( 'Enable/disable the Notifications account tab in account page', 'ultimate-member' ),
680
- ),
681
- array(
682
- 'id' => 'account_tab_delete',
683
- 'type' => 'checkbox',
684
- 'label' => __( 'Delete Account Tab', 'ultimate-member' ),
685
- 'tooltip' => __( 'Enable/disable the Delete account tab in account page', 'ultimate-member' ),
686
- ),
687
- array(
688
- 'id' => 'delete_account_text',
689
- 'type' => 'textarea', // bug with wp 4.4? should be editor
690
- 'label' => __( 'Account Deletion Custom Text', 'ultimate-member' ),
691
- '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' ),
692
- 'args' => array(
693
- 'textarea_rows' => 6
694
  ),
695
- ),
696
- array(
697
- 'id' => 'delete_account_no_pass_required_text',
698
- 'type' => 'textarea',
699
- 'label' => __( 'Account Deletion without password Custom Text', 'ultimate-member' ),
700
- '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' ),
701
- 'args' => array(
702
- 'textarea_rows' => 6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
703
  ),
704
  ),
705
- array(
706
- 'id' => 'account_name',
707
- 'type' => 'checkbox',
708
- 'label' => __( 'Add a First & Last Name fields', 'ultimate-member' ),
709
- 'tooltip' => __( 'Whether to enable these fields on the user account page by default or hide them.', 'ultimate-member' ),
710
- ),
711
- array(
712
- 'id' => 'account_name_disable',
713
- 'type' => 'checkbox',
714
- 'label' => __( 'Disable First & Last Name fields', 'ultimate-member' ),
715
- 'tooltip' => __( 'Whether to allow users changing their first and last name in account page.', 'ultimate-member' ),
716
- 'conditional' => array( 'account_name', '=', '1' ),
717
- ),
718
- array(
719
- 'id' => 'account_name_require',
720
- 'type' => 'checkbox',
721
- 'label' => __( 'Require First & Last Name', 'ultimate-member' ),
722
- 'tooltip' => __( 'Require first and last name?', 'ultimate-member' ),
723
- 'conditional' => array( 'account_name', '=', '1' ),
724
- ),
725
- array(
726
- 'id' => 'account_email',
727
- 'type' => 'checkbox',
728
- 'label' => __( 'Allow users to change e-mail', 'ultimate-member' ),
729
- 'tooltip' => __( 'Whether to allow users changing their email in account page.', 'ultimate-member' ),
730
- ),
731
- array(
732
- 'id' => 'account_general_password',
733
- 'type' => 'checkbox',
734
- 'label' => __( 'Password is required?', 'ultimate-member' ),
735
- 'tooltip' => __( 'Password is required to save account data.', 'ultimate-member' ),
736
- ),
737
- array(
738
- 'id' => 'account_require_strongpass',
739
- 'type' => 'checkbox',
740
- 'label' => __( 'Require a strong password?', 'ultimate-member' ),
741
- 'tooltip' => __( 'Enable or disable a strong password rules on account page / change password tab', 'ultimate-member' ),
742
- ),
743
- array(
744
- 'id' => 'account_hide_in_directory',
745
- 'type' => 'checkbox',
746
- 'label' => __( 'Allow users to hide their profiles from directory', 'ultimate-member' ),
747
- 'tooltip' => __( 'Whether to allow users changing their profile visibility from member directory in account page.', 'ultimate-member' ),
748
- 'conditional' => array( 'account_tab_privacy', '=', '1' ),
749
- ),
750
- array(
751
- 'id' => 'account_hide_in_directory_default',
752
- 'type' => 'select',
753
- 'label' => __( 'Hide profiles from directory by default', 'ultimate-member' ),
754
- 'tooltip' => __( 'Set default value for the "Hide my profile from directory" option', 'ultimate-member' ),
755
- 'options' => array(
756
- 'No' => __( 'No', 'ultimate-member' ),
757
- 'Yes' => __( 'Yes', 'ultimate-member' )
758
- ),
759
- 'size' => 'small',
760
- 'conditional' => array( 'account_hide_in_directory', '=', '1' ),
761
- ),
762
- )
763
- ),
764
- 'uploads' => array(
765
- 'title' => __( 'Uploads', 'ultimate-member' ),
766
- 'fields' => array(
767
- array(
768
- 'id' => 'profile_photo_max_size',
769
- 'type' => 'text',
770
- 'size' => 'small',
771
- 'label' => __( 'Profile Photo Maximum File Size (bytes)', 'ultimate-member' ),
772
- 'tooltip' => __( 'Sets a maximum size for the uploaded photo', 'ultimate-member' ),
773
- ),
774
-
775
- array(
776
- 'id' => 'cover_photo_max_size',
777
- 'type' => 'text',
778
- 'size' => 'small',
779
- 'label' => __( 'Cover Photo Maximum File Size (bytes)', 'ultimate-member' ),
780
- 'tooltip' => __( 'Sets a maximum size for the uploaded cover', 'ultimate-member' ),
781
- ),
782
- array(
783
- 'id' => 'photo_thumb_sizes',
784
- 'type' => 'multi_text',
785
- 'size' => 'small',
786
- 'label' => __( 'Profile Photo Thumbnail Sizes (px)', 'ultimate-member' ),
787
- 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each profile photo upload.', 'ultimate-member' ),
788
- 'validate' => 'numeric',
789
- 'add_text' => __( 'Add New Size', 'ultimate-member' ),
790
- 'show_default_number' => 1,
791
- ),
792
- array(
793
- 'id' => 'cover_thumb_sizes',
794
- 'type' => 'multi_text',
795
- 'size' => 'small',
796
- 'label' => __( 'Cover Photo Thumbnail Sizes (px)', 'ultimate-member' ),
797
- 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each cover photo upload.', 'ultimate-member' ),
798
- 'validate' => 'numeric',
799
- 'add_text' => __( 'Add New Size', 'ultimate-member' ),
800
- 'show_default_number' => 1,
801
- ),
802
-
803
- array(
804
- 'id' => 'image_orientation_by_exif',
805
- 'type' => 'checkbox',
806
- 'label' => __( 'Change image orientation', 'ultimate-member' ),
807
- 'tooltip' => __( 'Rotate image to and use orientation by the camera EXIF data.', 'ultimate-member' ),
808
- ),
809
- array(
810
- 'id' => 'image_compression',
811
- 'type' => 'text',
812
- 'size' => 'small',
813
- 'label' => __( 'Image Quality', 'ultimate-member' ),
814
- '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' ),
815
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
816
 
817
- array(
818
- 'id' => 'image_max_width',
819
- 'type' => 'text',
820
- 'size' => 'small',
821
- 'label' => __( 'Image Upload Maximum Width (px)', 'ultimate-member' ),
822
- 'tooltip' => __( 'Any image upload above this width will be resized to this limit automatically.', 'ultimate-member' ),
823
- ),
824
 
825
- array(
826
- 'id' => 'cover_min_width',
827
- 'type' => 'text',
828
- 'size' => 'small',
829
- 'label' => __( 'Cover Photo Minimum Width (px)', 'ultimate-member' ),
830
- 'tooltip' => __( 'This will be the minimum width for cover photo uploads', 'ultimate-member' ),
831
- ),
832
- )
833
- )
834
- )
835
- ),
836
- 'access' => array(
837
- 'title' => __( 'Access', 'ultimate-member' ),
838
- 'sections' => array(
839
- '' => array(
840
- 'title' => __( 'Restriction Content', 'ultimate-member' ),
841
- 'fields' => $access_fields
842
- ),
843
- 'other' => array(
844
- 'title' => __( 'Other', 'ultimate-member' ),
845
- 'fields' => array(
846
- array(
847
- 'id' => 'enable_reset_password_limit',
848
- 'type' => 'checkbox',
849
- 'label' => __( 'Enable the Reset Password Limit?', 'ultimate-member' ),
850
- ),
851
- array(
852
- 'id' => 'reset_password_limit_number',
853
- 'type' => 'text',
854
- 'label' => __( 'Reset Password Limit', 'ultimate-member' ),
855
- 'tooltip' => __( 'Set the maximum reset password limit. If reached the maximum limit, user will be locked from using this.', 'ultimate-member' ),
856
- 'validate' => 'numeric',
857
- 'conditional' => array( 'enable_reset_password_limit', '=', 1 ),
858
- 'size' => 'small',
859
- ),
860
- array(
861
- 'id' => 'blocked_emails',
862
- 'type' => 'textarea',
863
- 'label' => __( 'Blocked Email Addresses', 'ultimate-member' ),
864
- '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' ),
865
  ),
866
- array(
867
- 'id' => 'blocked_words',
868
- 'type' => 'textarea',
869
- 'label' => __( 'Blacklist Words', 'ultimate-member' ),
870
- 'tooltip' => __( 'This option lets you specify blacklist of words to prevent anyone from signing up with such a word as their username', 'ultimate-member' ),
871
- )
872
- )
873
- ),
874
- )
875
- ),
876
- 'email' => array(
877
- 'title' => __( 'Email', 'ultimate-member' ),
878
- 'fields' => array(
879
- array(
880
- 'id' => 'admin_email',
881
- 'type' => 'text',
882
- 'label' => __( 'Admin E-mail Address', 'ultimate-member' ),
883
- 'tooltip' => __( 'e.g. admin@companyname.com','ultimate-member' ),
884
- ),
885
- array(
886
- 'id' => 'mail_from',
887
- 'type' => 'text',
888
- 'label' => __( 'Mail appears from','ultimate-member' ),
889
- 'tooltip' => __( 'e.g. Site Name','ultimate-member' ),
890
- ),
891
- array(
892
- 'id' => 'mail_from_addr',
893
- 'type' => 'text',
894
- 'label' => __( 'Mail appears from address','ultimate-member' ),
895
- 'tooltip' => __( 'e.g. admin@companyname.com','ultimate-member' ),
896
  ),
897
- array(
898
- 'id' => 'email_html',
899
- 'type' => 'checkbox',
900
- 'label' => __( 'Use HTML for E-mails?','ultimate-member' ),
901
- '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'),
902
- )
903
- )
904
- ),
905
- 'appearance' => array(
906
- 'title' => __( 'Appearance', 'ultimate-member' ),
907
- 'sections' => array(
908
- '' => array(
909
- 'title' => __( 'Profile', 'ultimate-member' ),
910
- 'fields' => array(
911
- array(
912
- 'id' => 'profile_template',
913
- 'type' => 'select',
914
- 'label' => __( 'Profile Default Template', 'ultimate-member' ),
915
- 'tooltip' => __( 'This will be the default template to output profile', 'ultimate-member' ),
916
- 'default' => um_get_metadefault( 'profile_template' ),
917
- 'options' => UM()->shortcodes()->get_templates( 'profile' ),
918
- 'size' => 'small'
919
- ),
920
- array(
921
- 'id' => 'profile_max_width',
922
- 'type' => 'text',
923
- 'label' => __( 'Profile Maximum Width', 'ultimate-member' ),
924
- 'default' => um_get_metadefault( 'profile_max_width' ),
925
- 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
926
- 'size' => 'small'
927
- ),
928
-
929
- array(
930
- 'id' => 'profile_area_max_width',
931
- 'type' => 'text',
932
- 'label' => __( 'Profile Area Maximum Width', 'ultimate-member' ),
933
- 'default' => um_get_metadefault( 'profile_area_max_width' ),
934
- 'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ),
935
- 'size' => 'small'
936
- ),
937
- array(
938
- 'id' => 'profile_icons',
939
- 'type' => 'select',
940
- 'label' => __( 'Profile Field Icons', 'ultimate-member' ),
941
- 'tooltip' => __( 'This is applicable for edit mode only', 'ultimate-member' ),
942
- 'default' => um_get_metadefault( 'profile_icons' ),
943
- 'options' => array(
944
- 'field' => __( 'Show inside text field', 'ultimate-member' ),
945
- 'label' => __( 'Show with label', 'ultimate-member' ),
946
- 'off' => __( 'Turn off', 'ultimate-member' ),
947
- ),
948
- 'size' => 'small'
949
- ),
950
- array(
951
- 'id' => 'profile_primary_btn_word',
952
- 'type' => 'text',
953
- 'label' => __( 'Profile Primary Button Text','ultimate-member' ),
954
- 'default' => um_get_metadefault( 'profile_primary_btn_word' ),
955
- 'tooltip' => __( 'The text that is used for updating profile button', 'ultimate-member' ),
956
- 'size' => 'medium'
957
- ),
958
- array(
959
- 'id' => 'profile_secondary_btn',
960
- 'type' => 'checkbox',
961
- 'label' => __( 'Profile Secondary Button', 'ultimate-member' ),
962
- 'default' => um_get_metadefault( 'profile_secondary_btn' ),
963
- 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
964
- ),
965
- array(
966
- 'id' => 'profile_secondary_btn_word',
967
- 'type' => 'text',
968
- 'label' => __( 'Profile Secondary Button Text', 'ultimate-member' ),
969
- 'default' => um_get_metadefault( 'profile_secondary_btn_word' ),
970
- 'tooltip' => __( 'The text that is used for cancelling update profile button', 'ultimate-member' ),
971
- 'conditional' => array( 'profile_secondary_btn', '=', 1 ),
972
- 'size' => 'medium'
973
- ),
974
- array(
975
- 'id' => 'default_avatar',
976
- 'type' => 'media',
977
- 'label' => __( 'Default Profile Photo', 'ultimate-member' ),
978
- 'tooltip' => __( 'You can change the default profile picture globally here. Please make sure that the photo is 300x300px.', 'ultimate-member' ),
979
- 'upload_frame_title' => __( 'Select Default Profile Photo', 'ultimate-member' ),
980
- 'default' => array(
981
- 'url' => um_url . 'assets/img/default_avatar.jpg',
982
  ),
983
  ),
984
- array(
985
- 'id' => 'default_cover',
986
- 'type' => 'media',
987
- 'url' => true,
988
- 'preview' => false,
989
- 'label' => __( 'Default Cover Photo', 'ultimate-member' ),
990
- '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'),
991
- 'upload_frame_title' => __( 'Select Default Cover Photo', 'ultimate-member' ),
992
- ),
993
- array(
994
- 'id' => 'disable_profile_photo_upload',
995
- 'type' => 'checkbox',
996
- 'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ),
997
- 'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ),
998
- 'default' => um_get_metadefault( 'disable_profile_photo_upload' ),
999
- ),
1000
- array(
1001
- 'id' => 'profile_photosize',
1002
- 'type' => 'select',
1003
- 'label' => __( 'Profile Photo Size', 'ultimate-member' ),
1004
- 'default' => um_get_metadefault( 'profile_photosize' ),
1005
- 'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ),
1006
- 'tooltip' => __( 'The global default of profile photo size. This can be overridden by individual form settings', 'ultimate-member' ),
1007
- 'size' => 'small'
1008
- ),
1009
- array(
1010
- 'id' => 'profile_cover_enabled',
1011
- 'type' => 'checkbox',
1012
- 'label' => __( 'Profile Cover Photos', 'ultimate-member' ),
1013
- 'default' => um_get_metadefault( 'profile_cover_enabled' ),
1014
- 'tooltip' => __( 'Switch on/off the profile cover photos', 'ultimate-member' ),
1015
- ),
1016
- array(
1017
- 'id' => 'profile_coversize',
1018
- 'type' => 'select',
1019
- 'label' => __( 'Profile Cover Size', 'ultimate-member' ),
1020
- 'default' => um_get_metadefault( 'profile_coversize' ),
1021
- 'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ),
1022
- 'tooltip' => __( 'The global default width of cover photo size. This can be overridden by individual form settings', 'ultimate-member' ),
1023
- 'conditional' => array( 'profile_cover_enabled', '=', 1 ),
1024
- 'size' => 'small'
1025
- ),
1026
- array(
1027
- 'id' => 'profile_cover_ratio',
1028
- 'type' => 'select',
1029
- 'label' => __( 'Profile Cover Ratio', 'ultimate-member' ),
1030
- 'tooltip' => __( 'Choose global ratio for cover photos of profiles', 'ultimate-member' ),
1031
- 'default' => um_get_metadefault( 'profile_cover_ratio' ),
1032
- 'options' => array(
1033
- '1.6:1' => '1.6:1',
1034
- '2.7:1' => '2.7:1',
1035
- '2.2:1' => '2.2:1',
1036
- '3.2:1' => '3.2:1',
1037
- ),
1038
- 'conditional' => array( 'profile_cover_enabled', '=', 1 ),
1039
- 'size' => 'small'
1040
- ),
1041
- array(
1042
- 'id' => 'profile_show_metaicon',
1043
- 'type' => 'checkbox',
1044
- 'label' => __( 'Profile Header Meta Text Icon', 'ultimate-member' ),
1045
- 'default' => 0,
1046
- 'tooltip' => __( 'Display field icons for related user meta fields in header or not', 'ultimate-member' ),
1047
- ),
1048
- array(
1049
- 'id' => 'profile_show_name',
1050
- 'type' => 'checkbox',
1051
- 'label' => __( 'Show display name in profile header', 'ultimate-member' ),
1052
- 'default' => um_get_metadefault( 'profile_show_name' ),
1053
- 'tooltip' => __( 'Switch on/off the user name on profile header', 'ultimate-member' ),
1054
- ),
1055
- array(
1056
- 'id' => 'profile_show_social_links',
1057
- 'type' => 'checkbox',
1058
- 'label' => __( 'Show social links in profile header', 'ultimate-member' ),
1059
- 'default' => um_get_metadefault( 'profile_show_social_links' ),
1060
- 'tooltip' => __( 'Switch on/off the social links on profile header', 'ultimate-member' ),
1061
- ),
1062
- array(
1063
- 'id' => 'profile_show_bio',
1064
- 'type' => 'checkbox',
1065
- 'label' => __( 'Show user description in header', 'ultimate-member' ),
1066
- 'default' => um_get_metadefault( 'profile_show_bio' ),
1067
- 'tooltip' => __( 'Switch on/off the user description on profile header', 'ultimate-member' ),
1068
- ),
1069
- array(
1070
- 'id' => 'profile_show_html_bio',
1071
- 'type' => 'checkbox',
1072
- 'label' => __( 'Enable HTML support for user description', 'ultimate-member' ),
1073
- 'tooltip' => __( 'Switch on/off to enable/disable support for html tags on user description.', 'ultimate-member' ),
1074
- ),
1075
- array(
1076
- 'id' => 'profile_bio_maxchars',
1077
- 'type' => 'text',
1078
- 'label' => __( 'User description maximum chars', 'ultimate-member' ),
1079
- 'default' => um_get_metadefault( 'profile_bio_maxchars' ),
1080
- 'tooltip' => __( 'Maximum number of characters to allow in user description field in header.', 'ultimate-member' ),
1081
- 'conditional' => array( 'profile_show_bio', '=', 1 ),
1082
- 'size' => 'small'
1083
- ),
1084
- array(
1085
- 'id' => 'profile_header_menu',
1086
- 'type' => 'select',
1087
- 'label' => __( 'Profile Header Menu Position', 'ultimate-member' ),
1088
- 'default' => um_get_metadefault( 'profile_header_menu' ),
1089
- 'tooltip' => __( 'For incompatible themes, please make the menu open from left instead of bottom by default.', 'ultimate-member' ),
1090
- 'options' => array(
1091
- 'bc' => __( 'Bottom of Icon', 'ultimate-member' ),
1092
- 'lc' => __( 'Left of Icon (right for RTL)', 'ultimate-member' ),
1093
- ),
1094
- 'size' => 'small'
1095
- ),
1096
- array(
1097
- 'id' => 'profile_empty_text',
1098
- 'type' => 'checkbox',
1099
- 'label' => __( 'Show a custom message if profile is empty', 'ultimate-member' ),
1100
- 'default' => um_get_metadefault( 'profile_empty_text' ),
1101
- 'tooltip' => __( 'Switch on/off the custom message that appears when the profile is empty', 'ultimate-member' ),
1102
- ),
1103
- array(
1104
- 'id' => 'profile_empty_text_emo',
1105
- 'type' => 'checkbox',
1106
- 'label' => __( 'Show the emoticon', 'ultimate-member' ),
1107
- 'default' => um_get_metadefault( 'profile_empty_text_emo' ),
1108
- 'tooltip' => __( 'Switch on/off the emoticon (sad face) that appears above the message', 'ultimate-member' ),
1109
- 'conditional' => array( 'profile_empty_text', '=', 1 ),
1110
- )
1111
- )
1112
  ),
1113
- 'profile_menu' => array(
1114
- 'title' => __( 'Profile Menu', 'ultimate-member' ),
1115
- 'fields' => $appearances_profile_menu_fields
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1116
  ),
1117
- 'registration_form' => array(
1118
- 'title' => __( 'Registration Form', 'ultimate-member' ),
1119
- 'fields' => array(
1120
- array(
1121
- 'id' => 'register_template',
1122
- 'type' => 'select',
1123
- 'label' => __( 'Registration Default Template', 'ultimate-member' ),
1124
- 'tooltip' => __( 'This will be the default template to output registration', 'ultimate-member' ),
1125
- 'default' => um_get_metadefault('register_template'),
1126
- 'options' => UM()->shortcodes()->get_templates( 'register' ),
1127
- 'size' => 'small',
1128
- ),
1129
- array(
1130
- 'id' => 'register_max_width',
1131
- 'type' => 'text',
1132
- 'label' => __( 'Registration Maximum Width', 'ultimate-member' ),
1133
- 'default' => um_get_metadefault('register_max_width'),
1134
- 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
1135
- 'size' => 'small'
1136
- ),
1137
- array(
1138
- 'id' => 'register_align',
1139
- 'type' => 'select',
1140
- 'label' => __( 'Registration Shortcode Alignment', 'ultimate-member' ),
1141
- 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
1142
- 'default' => um_get_metadefault( 'register_align' ),
1143
- 'options' => array(
1144
- 'center' => __( 'Centered', 'ultimate-member' ),
1145
- 'left' => __( 'Left aligned', 'ultimate-member' ),
1146
- 'right' => __( 'Right aligned', 'ultimate-member' ),
1147
- ),
1148
- 'size' => 'small'
1149
- ),
1150
- array(
1151
- 'id' => 'register_icons',
1152
- 'type' => 'select',
1153
- 'label' => __( 'Registration Field Icons', 'ultimate-member' ),
1154
- 'tooltip' => __( 'This controls the display of field icons in the registration form', 'ultimate-member' ),
1155
- 'default' => um_get_metadefault( 'register_icons' ),
1156
- 'options' => array(
1157
- 'field' => __( 'Show inside text field', 'ultimate-member' ),
1158
- 'label' => __( 'Show with label', 'ultimate-member' ),
1159
- 'off' => __( 'Turn off', 'ultimate-member' ),
1160
- ),
1161
- 'size' => 'small'
1162
- ),
1163
- array(
1164
- 'id' => 'register_primary_btn_word',
1165
- 'type' => 'text',
1166
- 'label' => __( 'Registration Primary Button Text', 'ultimate-member' ),
1167
- 'default' => um_get_metadefault('register_primary_btn_word'),
1168
- 'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
1169
- 'size' => 'medium'
1170
- ),
1171
- array(
1172
- 'id' => 'register_secondary_btn',
1173
- 'type' => 'checkbox',
1174
- 'label' => __( 'Registration Secondary Button', 'ultimate-member' ),
1175
- 'default' => 1,
1176
- 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1177
  ),
1178
- array(
1179
- 'id' => 'register_secondary_btn_word',
1180
- 'type' => 'text',
1181
- 'label' => __( 'Registration Secondary Button Text', 'ultimate-member' ),
1182
- 'default' => um_get_metadefault( 'register_secondary_btn_word' ),
1183
- 'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
1184
- 'conditional' => array( 'register_secondary_btn', '=', 1 ),
1185
- 'size' => 'medium'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1186
  ),
1187
- array(
1188
- 'id' => 'register_secondary_btn_url',
1189
- 'type' => 'text',
1190
- 'label' => __( 'Registration Secondary Button URL', 'ultimate-member' ),
1191
- 'default' => um_get_metadefault('register_secondary_btn_url'),
1192
- 'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
1193
- 'conditional' => array( 'register_secondary_btn', '=', 1 ),
1194
- 'size' => 'medium'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1195
  ),
1196
- array(
1197
- 'id' => 'register_role',
1198
- 'type' => 'select',
1199
- 'label' => __( 'Registration Default Role', 'ultimate-member' ),
1200
- 'tooltip' => __( 'This will be the default role assigned to users registering thru registration form', 'ultimate-member' ),
1201
- 'default' => um_get_metadefault( 'register_role' ),
1202
- 'options' => UM()->roles()->get_roles( $add_default = 'Default' ),
1203
- 'size' => 'small'
1204
- )
1205
- )
1206
  ),
1207
- 'login_form' => array(
1208
- 'title' => __( 'Login Form', 'ultimate-member' ),
1209
- 'fields' => array(
1210
- array(
1211
- 'id' => 'login_template',
1212
- 'type' => 'select',
1213
- 'label' => __( 'Login Default Template', 'ultimate-member' ),
1214
- 'tooltip' => __( 'This will be the default template to output login', 'ultimate-member' ),
1215
- 'default' => um_get_metadefault( 'login_template' ),
1216
- 'options' => UM()->shortcodes()->get_templates( 'login' ),
1217
- 'size' => 'small'
1218
- ),
1219
- array(
1220
- 'id' => 'login_max_width',
1221
- 'type' => 'text',
1222
- 'label' => __( 'Login Maximum Width', 'ultimate-member' ),
1223
- 'default' => um_get_metadefault( 'login_max_width' ),
1224
- 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
1225
- 'size' => 'small'
1226
- ),
1227
- array(
1228
- 'id' => 'login_align',
1229
- 'type' => 'select',
1230
- 'label' => __( 'Login Shortcode Alignment', 'ultimate-member' ),
1231
- 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
1232
- 'default' => um_get_metadefault( 'login_align' ),
1233
- 'options' => array(
1234
- 'center' => __( 'Centered', 'ultimate-member' ),
1235
- 'left' => __( 'Left aligned', 'ultimate-member' ),
1236
- 'right' => __( 'Right aligned', 'ultimate-member' ),
1237
- ),
1238
- 'size' => 'small'
1239
- ),
1240
- array(
1241
- 'id' => 'login_icons',
1242
- 'type' => 'select',
1243
- 'label' => __( 'Login Field Icons', 'ultimate-member' ),
1244
- 'tooltip' => __( 'This controls the display of field icons in the login form', 'ultimate-member' ),
1245
- 'default' => um_get_metadefault( 'login_icons' ),
1246
- 'options' => array(
1247
- 'field' => __( 'Show inside text field', 'ultimate-member' ),
1248
- 'label' => __( 'Show with label', 'ultimate-member' ),
1249
- 'off' => __( 'Turn off', 'ultimate-member' ),
1250
- ),
1251
- 'size' => 'small'
1252
- ),
1253
- array(
1254
- 'id' => 'login_primary_btn_word',
1255
- 'type' => 'text',
1256
- 'label' => __( 'Login Primary Button Text','ultimate-member' ),
1257
- 'default' => um_get_metadefault( 'login_primary_btn_word' ),
1258
- 'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
1259
- 'size' => 'medium'
1260
- ),
1261
- array(
1262
- 'id' => 'login_secondary_btn',
1263
- 'type' => 'checkbox',
1264
- 'label' => __( 'Login Secondary Button', 'ultimate-member' ),
1265
- 'default' => 1,
1266
- 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
1267
- ),
1268
- array(
1269
- 'id' => 'login_secondary_btn_word',
1270
- 'type' => 'text',
1271
- 'label' => __( 'Login Secondary Button Text', 'ultimate-member' ),
1272
- 'default' => um_get_metadefault( 'login_secondary_btn_word' ),
1273
- 'tooltip' => __('The text that is used for the secondary button text', 'ultimate-member' ),
1274
- 'conditional' => array( 'login_secondary_btn', '=', 1 ),
1275
- 'size' => 'medium'
1276
- ),
1277
- array(
1278
- 'id' => 'login_secondary_btn_url',
1279
- 'type' => 'text',
1280
- 'label' => __( 'Login Secondary Button URL', 'ultimate-member' ),
1281
- 'default' => um_get_metadefault( 'login_secondary_btn_url' ),
1282
- 'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
1283
- 'conditional' => array( 'login_secondary_btn', '=', 1 ),
1284
- 'size' => 'medium'
1285
  ),
1286
- array(
1287
- 'id' => 'login_forgot_pass_link',
1288
- 'type' => 'checkbox',
1289
- 'label' => __( 'Login Forgot Password Link', 'ultimate-member' ),
1290
- 'default' => 1,
1291
- 'tooltip' => __( 'Switch on/off the forgot password link in login form', 'ultimate-member' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1292
  ),
1293
- array(
1294
- 'id' => 'login_show_rememberme',
1295
- 'type' => 'checkbox',
1296
- 'label' => __( 'Show "Remember Me"', 'ultimate-member' ),
1297
- 'default' => 1,
1298
- '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' ),
1299
- )
1300
- )
1301
- )
1302
- )
1303
- ),
1304
- 'extensions' => array(
1305
- 'title' => __( 'Extensions', 'ultimate-member' )
1306
- ),
1307
- 'licenses' => array(
1308
- 'title' => __( 'Licenses', 'ultimate-member' ),
1309
- ),
1310
- 'misc' => array(
1311
- 'title' => __( 'Misc', 'ultimate-member' ),
1312
- 'fields' => array(
1313
- array(
1314
- 'id' => 'form_asterisk',
1315
- 'type' => 'checkbox',
1316
- 'label' => __( 'Show an asterisk for required fields', 'ultimate-member' ),
1317
- ),
1318
- array(
1319
- 'id' => 'profile_title',
1320
- 'type' => 'text',
1321
- 'label' => __( 'User Profile Title', 'ultimate-member' ),
1322
- 'tooltip' => __( 'This is the title that is displayed on a specific user profile', 'ultimate-member' ),
1323
- 'size' => 'medium'
1324
- ),
1325
- array(
1326
- 'id' => 'profile_desc',
1327
- 'type' => 'textarea',
1328
- 'label' => __( 'User Profile Dynamic Meta Description', 'ultimate-member' ),
1329
- 'tooltip' => __( 'This will be used in the meta description that is available for search-engines.', 'ultimate-member' ),
1330
- 'args' => array(
1331
- 'textarea_rows' => 6
1332
- )
1333
- ),
1334
- array(
1335
- 'id' => 'um_profile_object_cache_stop',
1336
- 'type' => 'checkbox',
1337
- 'label' => __( 'Disable Cache User Profile', 'ultimate-member' ),
1338
- 'tooltip' => __( 'Check this box if you would like to disable Ultimate Member user\'s cache.', 'ultimate-member' ),
1339
- ),
1340
- array(
1341
- 'id' => 'enable_blocks',
1342
- 'type' => 'checkbox',
1343
- 'label' => __( 'Enable Gutenberg Blocks', 'ultimate-member' ),
1344
- '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' ),
1345
- ),
1346
- array(
1347
- 'id' => 'rest_api_version',
1348
- 'type' => 'select',
1349
- 'label' => __( 'REST API version','ultimate-member' ),
1350
- 'tooltip' => __( 'This controls the REST API version, we recommend to use the last version', 'ultimate-member' ),
1351
- 'options' => array(
1352
- '1.0' => __( '1.0 version', 'ultimate-member' ),
1353
- '2.0' => __( '2.0 version', 'ultimate-member' ),
1354
  ),
1355
  ),
1356
- $same_page_update,
1357
- array(
1358
- 'id' => 'uninstall_on_delete',
1359
- 'type' => 'checkbox',
1360
- 'label' => __( 'Remove Data on Uninstall?', 'ultimate-member' ),
1361
- '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' ),
1362
- )
1363
- )
1364
- ),
1365
- 'install_info' => array(
1366
- 'title' => __( 'Install Info', 'ultimate-member' ),
1367
- 'fields' => array(
1368
- array(
1369
- 'type' => 'install_info',
1370
  ),
1371
- )
1372
- ),
1373
- ) );
1374
 
1375
  }
1376
 
1377
 
1378
  /**
1379
- * @param $settings
1380
  *
1381
- * @return mixed
1382
  */
1383
- function sorting_licenses_options( $settings ) {
1384
  //sorting licenses
1385
  if ( empty( $settings['licenses']['fields'] ) ) {
1386
  return $settings;
@@ -1388,7 +1778,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
1388
 
1389
  $licenses = $settings['licenses']['fields'];
1390
  @uasort( $licenses, function( $a, $b ) {
1391
- return strnatcasecmp( $a["label"], $b["label"] );
1392
  } );
1393
  $settings['licenses']['fields'] = $licenses;
1394
 
@@ -1399,18 +1789,18 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
1399
 
1400
  $extensions = $settings['extensions']['sections'];
1401
  @uasort( $extensions, function( $a, $b ) {
1402
- return strnatcasecmp( $a["title"], $b["title"] );
1403
  } );
1404
 
1405
  $keys = array_keys( $extensions );
1406
- if ( $keys[0] != "" ) {
1407
- $new_key = strtolower( str_replace( " ", "_", $extensions[""]['title'] ) );
1408
- $temp = $extensions[""];
1409
- $extensions[$new_key] = $temp;
1410
- $extensions[""] = $extensions[$keys[0]];
1411
- unset( $extensions[$keys[0]] );
1412
  @uasort( $extensions, function( $a, $b ) {
1413
- return strnatcasecmp( $a["title"], $b["title"] );
1414
  } );
1415
  }
1416
 
@@ -1650,9 +2040,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
1650
  $current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
1651
  foreach ( $menu_tabs as $name => $label ) {
1652
  $active = ( $current_tab == $name ) ? 'nav-tab-active' : '';
1653
- $tabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $name ) ? '' : '&tab=' . $name ) ) ) . '" class="nav-tab ' . $active . '">' .
1654
- $label .
1655
- '</a>';
1656
  }
1657
 
1658
  break;
@@ -1707,8 +2097,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
1707
  foreach ( $menu_subtabs as $name => $label ) {
1708
  $active = ( $current_subtab == $name ) ? 'current' : '';
1709
  $subtabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $current_tab ) ? '' : '&tab=' . $current_tab ) . ( empty( $name ) ? '' : '&section=' . $name ) ) ) . '" class="' . $active . '">'
1710
- . $label .
1711
- '</a> | ';
1712
  }
1713
 
1714
  return substr( $subtabs, 0, -3 ) . '</ul></div>';
@@ -1722,7 +2112,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
1722
  */
1723
  function save_settings_handler() {
1724
 
1725
- if ( isset( $_POST['um-settings-action'] ) && 'save' == sanitize_key( $_POST['um-settings-action'] ) && ! empty( $_POST['um_options'] ) ) {
1726
 
1727
  $nonce = ! empty( $_POST['__umnonce'] ) ? $_POST['__umnonce'] : '';
1728
 
@@ -1772,6 +2162,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
1772
  */
1773
  $settings = apply_filters( 'um_change_settings_before_save', $_POST['um_options'] );
1774
 
 
 
1775
  foreach ( $settings as $key => $value ) {
1776
  UM()->options()->update( $key, $value );
1777
  }
@@ -1813,6 +2205,28 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
1813
  }
1814
 
1815
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1816
  /**
1817
  * Remove empty values from multi text fields
1818
  *
@@ -1862,7 +2276,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
1862
  */
1863
  function check_permalinks_changes() {
1864
  if ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
1865
- if ( UM()->options()->get( 'permalink_base' ) != $_POST['um_options']['permalink_base'] ) {
1866
  $this->need_change_permalinks = true;
1867
  }
1868
  }
@@ -1981,7 +2395,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
1981
 
1982
  global $wpdb;
1983
 
1984
- if ( $_POST['um_options']['account_hide_in_directory_default'] == 'No' ) {
1985
 
1986
  $results = $wpdb->get_col(
1987
  "SELECT u.ID FROM {$wpdb->users} AS u
@@ -2007,7 +2421,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
2007
  foreach ( $results as $user_id ) {
2008
  $md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
2009
  if ( ! empty( $md_data ) ) {
2010
- $md_data['hide_in_members'] = ( $_POST['um_options']['account_hide_in_directory_default'] == 'No' ) ? false : true;
2011
  update_user_meta( $user_id, 'um_member_directory_data', $md_data );
2012
  }
2013
  }
@@ -2027,7 +2441,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
2027
  }
2028
 
2029
  foreach ( $_POST['um_options'] as $key => $value ) {
2030
- $this->previous_licenses[ $key ] = UM()->options()->get( $key );
2031
  }
2032
  }
2033
 
@@ -2041,6 +2455,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
2041
  }
2042
 
2043
  foreach ( $_POST['um_options'] as $key => $value ) {
 
 
 
2044
  $edd_action = '';
2045
  $license_key = '';
2046
  if ( empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) || ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) && $this->previous_licenses[ $key ] != $value ) ) {
@@ -2642,7 +3059,7 @@ Generate Slugs on Directories: <?php if( UM()->options()->get( 'um_generate_slug
2642
  Force UTF-8 Encoding: <?php if( UM()->options()->get( 'um_force_utf8_strings' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
2643
  JS/CSS Compression: <?php if ( defined('SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
2644
  <?php if( is_multisite() ): ?>
2645
- Network Structure: <?php echo UM()->options()->get( 'network_permalink_structure' ). "\n"; ?>
2646
  <?php endif; ?>
2647
  Port Forwarding in URL: <?php if( UM()->options()->get( 'um_port_forwarding_url' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
2648
  Exclude CSS/JS on Home: <?php if( UM()->options()->get( 'js_css_exlcude_home' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
@@ -2707,7 +3124,7 @@ Redirect author to profile: <?php echo $this->info_value( UM()->options()->get
2707
  Enable Members Directory: <?php echo $this->info_value( UM()->options()->get('members_page'), 'yesno', true ); ?>
2708
  Use Gravatars: <?php echo $this->info_value( UM()->options()->get('use_gravatars'), 'yesno', true ); ?>
2709
  <?php if( UM()->options()->get('use_gravatars') ): ?>Gravatar builtin image: <?php echo UM()->options()->get('use_um_gravatar_default_builtin_image') . "\n"; ?>
2710
- UM Avatar as blank Gravatar: <?php echo $this->info_value( UM()->options()->get('use_um_gravatar_default_image'), 'yesno', true ); ?><?php endif; ?>
2711
  Require a strong password: <?php echo $this->info_value( UM()->options()->get('reset_require_strongpass'), 'onoff', true ); ?>
2712
 
2713
 
@@ -2765,50 +3182,50 @@ Password Changed Email: <?php echo $this->info_value( UM()->options()->get('ch
2765
 
2766
  --- UM Total Users ---
2767
 
2768
- <?php $result = count_users();
2769
- echo 'All Users('.$result['total_users'].")\n";
2770
- foreach( $result['avail_roles'] as $role => $count ) {
2771
- echo $role."(".$count.")\n";
2772
- } ?>
2773
 
2774
 
2775
  --- UM Roles ---
2776
 
2777
- <?php foreach( UM()->roles()->get_roles() as $role_id => $role ) {
2778
- echo $role." ({$role_id})\n";
2779
- } ?>
2780
 
2781
 
2782
  --- UM Custom Templates ---
2783
 
2784
- <?php // Show templates that have been copied to the theme's edd_templates dir
2785
- $dir = get_stylesheet_directory() . '/ultimate-member/templates/*.php';
2786
- if ( ! empty( $dir ) ) {
2787
- $found = glob( $dir );
2788
- if ( ! empty( $found ) ) {
2789
- foreach ( glob( $dir ) as $file ) {
2790
- echo "File: " . $file . "\n";
2791
- }
2792
- } else {
2793
- echo 'N/A'."\n";
2794
- }
2795
- } ?>
2796
 
2797
 
2798
  --- UM Email HTML Templates ---
2799
 
2800
- <?php $dir = get_stylesheet_directory() . '/ultimate-member/templates/emails/*.html';
2801
 
2802
- if ( ! empty( $dir ) ) {
2803
- $found = glob( $dir );
2804
- if ( ! empty( $found ) ){
2805
- foreach ( glob( $dir ) as $file ) {
2806
- echo "File: ". $file . "\n";
2807
- }
2808
- } else {
2809
- echo 'N/A'."\n";
2810
- }
2811
- } ?>
2812
 
2813
 
2814
  --- Web Server Configurations ---
@@ -2854,81 +3271,80 @@ Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ?
2854
 
2855
  --- WordPress Active Plugins ---
2856
 
2857
- <?php $plugins = get_plugins();
2858
- $active_plugins = get_option( 'active_plugins', array() );
2859
 
2860
- foreach ( $plugins as $plugin_path => $plugin ) {
2861
- // If the plugin isn't active, don't show it.
2862
- if ( ! in_array( $plugin_path, $active_plugins ) )
2863
- continue;
2864
 
2865
- echo $plugin['Name'] . ': ' . $plugin['Version'] ."\n";
2866
- }
2867
 
2868
- if ( is_multisite() ) { ?>
2869
 
2870
  --- WordPress Network Active Plugins ---
2871
 
2872
- <?php $plugins = wp_get_active_network_plugins();
2873
- $active_plugins = get_site_option( 'active_sitewide_plugins', array() );
2874
-
2875
- foreach ( $plugins as $plugin_path ) {
2876
- $plugin_base = plugin_basename( $plugin_path );
2877
-
2878
- // If the plugin isn't active, don't show it.
2879
- if ( ! array_key_exists( $plugin_base, $active_plugins ) )
2880
- continue;
2881
-
2882
- $plugin = get_plugin_data( $plugin_path );
2883
-
2884
- echo $plugin['Name'] . ' :' . $plugin['Version'] . "\n";
2885
- }
2886
-
2887
- }
2888
-
2889
- /**
2890
- * UM hook
2891
- *
2892
- * @type action
2893
- * @title um_install_info_after
2894
- * @description After install info
2895
- * @change_log
2896
- * ["Since: 2.0"]
2897
- * @usage add_action( 'um_install_info_after', 'function_name', 10 );
2898
- * @example
2899
- * <?php
2900
- * add_action( 'um_install_info_after', 'my_install_info_after', 10 );
2901
- * function my_install_info_after() {
2902
- * // your code here
2903
- * }
2904
- * ?>
2905
- */
2906
- do_action( 'um_install_info_after' ); ?>
2907
 
2908
  ### End Install Info ###
2909
- </textarea>
2910
- <p class="submit">
2911
- <input type="hidden" name="um-addon-hook" value="download_install_info" />
2912
- <?php submit_button( 'Download Install Info File', 'primary', 'download_install_info', false ); ?>
2913
- </p>
2914
- </form>
2915
 
2916
- <?php }
2917
- }
2918
 
2919
 
2920
  /**
2921
  *
2922
  */
2923
  function um_download_install_info() {
2924
-
2925
  if ( ! empty( $_POST['download_install_info'] ) ) {
2926
  nocache_headers();
2927
 
2928
  header( "Content-type: text/plain" );
2929
  header( 'Content-Disposition: attachment; filename="ultimatemember-install-info.txt"' );
2930
 
2931
- echo wp_strip_all_tags( $_POST['um-install-info'] );
2932
  exit;
2933
  }
2934
  }
@@ -2956,7 +3372,10 @@ Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ?
2956
  /**
2957
  * Render settings section
2958
  *
2959
- * @param $section_fields
 
 
 
2960
  * @return string
2961
  */
2962
  function render_settings_section( $section_fields, $current_tab, $current_subtab ) {
@@ -2975,9 +3394,9 @@ Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ?
2975
 
2976
 
2977
  /**
2978
- * @param $settings
2979
  *
2980
- * @return mixed
2981
  */
2982
  function save_email_templates( $settings ) {
2983
 
@@ -2986,7 +3405,7 @@ Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ?
2986
  }
2987
 
2988
  $template = $settings['um_email_template'];
2989
- $content = stripslashes( $settings[ $template ] );
2990
 
2991
  $theme_template_path = UM()->mail()->get_template_file( 'theme', $template );
2992
 
@@ -3006,4 +3425,4 @@ Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ?
3006
  return $settings;
3007
  }
3008
  }
3009
- }
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
 
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
 
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' ) );
91
 
92
 
93
 
94
+ public function same_page_update_ajax() {
95
  UM()->admin()->check_ajax_nonce();
96
 
97
  if ( empty( $_POST['cb_func'] ) ) {
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
 
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
 
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 ) {
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
  }
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();
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() );
195
  );
196
 
197
  wp_send_json_success( array( 'count' => $count ) );
198
+ } elseif ( 'um_update_metadata_per_page' === $cb_func ) {
199
 
200
  if ( empty( $_POST['page'] ) ) {
201
  wp_send_json_error( __( 'Wrong data', 'ultimate-member' ) );
202
  }
203
 
204
+ $per_page = 500;
205
  $wp_usermeta_option = get_option( 'um_usermeta_fields', array() );
206
 
207
  global $wpdb;
208
+ $metadata = $wpdb->get_results(
209
+ $wpdb->prepare(
210
+ "SELECT *
211
+ FROM {$wpdb->usermeta}
212
+ WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "')
213
+ LIMIT %d, %d",
214
+ ( absint( $_POST['page'] ) - 1 ) * $per_page,
215
+ $per_page
216
+ ),
217
+ ARRAY_A
218
+ );
219
 
220
  $values = array();
221
  foreach ( $metadata as $metarow ) {
222
+ $values[] = $wpdb->prepare( '(%d, %s, %s)', $metarow['user_id'], $metarow['meta_key'], $metarow['meta_value'] );
223
  }
224
 
225
  if ( ! empty( $values ) ) {
226
+ $wpdb->query(
227
+ "INSERT INTO
228
+ {$wpdb->prefix}um_metadata(user_id, um_key, um_value)
229
+ VALUES " . implode( ',', $values )
230
+ );
231
  }
232
 
233
  $from = ( absint( $_POST['page'] ) * $per_page ) - $per_page + 1;
234
+ $to = absint( $_POST['page'] ) * $per_page;
235
 
236
+ wp_send_json_success( array( 'message' => sprintf( __( 'Metadata from %1$s to %2$s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
237
  }
238
  }
239
 
241
  /**
242
  *
243
  */
244
+ public function init_variables() {
245
+
246
+ $settings_map = array();
247
+
248
  $general_pages_fields = array(
249
  array(
250
  'id' => 'pages_settings',
251
  'type' => 'hidden',
252
  'value' => true,
253
+ 'is_option' => false,
254
+ ),
255
  );
256
 
257
  $core_pages = UM()->config()->core_pages;
258
 
259
  foreach ( $core_pages as $page_s => $page ) {
260
  $have_pages = UM()->query()->wp_pages();
261
+ $page_id = UM()->options()->get_core_page_id( $page_s );
262
 
263
  $page_title = ! empty( $page['title'] ) ? $page['title'] : '';
264
 
265
+ if ( 'reached_maximum_limit' === $have_pages ) {
266
  $general_pages_fields[] = array(
267
+ 'id' => $page_id,
268
+ 'type' => 'text',
269
+ // translators: %s: Page title
270
+ 'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ),
271
+ 'placeholder' => __( 'Add page ID', 'ultimate-member' ),
272
+ 'compiler' => true,
273
+ 'size' => 'small',
274
  );
275
  } else {
276
  $general_pages_fields[] = array(
277
+ 'id' => $page_id,
278
+ 'type' => 'select',
279
+ // translators: %s: Page title
280
+ 'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ),
281
+ 'options' => UM()->query()->wp_pages(),
282
+ 'placeholder' => __( 'Choose a page...', 'ultimate-member' ),
283
+ 'compiler' => true,
284
+ 'size' => 'small',
285
  );
286
  }
 
287
 
288
 
289
+ $settings_map[ $page_id ] = array(
290
+ 'sanitize' => 'absint',
291
+ );
292
+ }
293
+
294
  $appearances_profile_menu_fields = array(
295
  array(
296
  'id' => 'profile_menu',
297
  'type' => 'checkbox',
298
  'label' => __( 'Enable profile menu', 'ultimate-member' ),
299
+ ),
300
+ );
301
+
302
+ $settings_map['profile_menu'] = array(
303
+ 'sanitize' => 'bool',
304
  );
305
 
306
  $tabs = UM()->profile()->tabs();
307
 
308
+ $tabs_options = array();
309
  $tabs_condition = array();
310
  foreach ( $tabs as $id => $tab ) {
311
 
315
 
316
  if ( isset( $tab['name'] ) ) {
317
  $tabs_options[ $id ] = $tab['name'];
318
+ $tabs_condition[] = 'profile_tab_' . $id;
319
  }
320
 
321
  if ( isset( $tab['default_privacy'] ) ) {
322
  $fields = array(
323
  array(
324
+ 'id' => 'profile_tab_' . $id,
325
+ 'type' => 'checkbox',
326
+ // translators: %s: Tab title
327
+ 'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ),
328
+ 'conditional' => array( 'profile_menu', '=', 1 ),
329
+ 'data' => array( 'fill_profile_menu_default_tab' => $id ),
330
  ),
331
  );
332
+
333
+ $settings_map[ 'profile_tab_' . $id ] = array(
334
+ 'sanitize' => 'bool',
335
+ );
336
  } else {
337
 
338
  $fields = array(
339
  array(
340
+ 'id' => 'profile_tab_' . $id,
341
+ 'type' => 'checkbox',
342
+ // translators: %s: Tab title
343
+ 'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ),
344
+ 'conditional' => array( 'profile_menu', '=', 1 ),
345
+ 'data' => array( 'fill_profile_menu_default_tab' => $id ),
346
  ),
347
  array(
348
+ 'id' => 'profile_tab_' . $id . '_privacy',
349
+ 'type' => 'select',
350
+ // translators: %s: Tab title
351
+ 'label' => sprintf( __( 'Who can see %s Tab?', 'ultimate-member' ), $tab['name'] ),
352
+ 'tooltip' => __( 'Select which users can view this tab.', 'ultimate-member' ),
353
+ 'options' => UM()->profile()->tabs_privacy(),
354
+ 'conditional' => array( 'profile_tab_' . $id, '=', 1 ),
355
+ 'size' => 'small',
356
  ),
357
  array(
358
+ 'id' => 'profile_tab_' . $id . '_roles',
359
+ 'type' => 'select',
360
+ 'multi' => true,
361
+ 'label' => __( 'Allowed roles', 'ultimate-member' ),
362
+ 'tooltip' => __( 'Select the the user roles allowed to view this tab.', 'ultimate-member' ),
363
+ 'options' => UM()->roles()->get_roles(),
364
+ 'placeholder' => __( 'Choose user roles...', 'ultimate-member' ),
365
+ 'conditional' => array( 'profile_tab_' . $id . '_privacy', '=', array( '4', '5' ) ),
366
+ 'size' => 'small',
367
+ ),
368
+ );
369
+
370
+ $settings_map = array_merge(
371
+ $settings_map,
372
+ array(
373
+ "profile_tab_{$id}" => array(
374
+ 'sanitize' => 'bool',
375
+ ),
376
+ "profile_tab_{$id}_privacy" => array(
377
+ 'sanitize' => array( UM()->admin(), 'sanitize_tabs_privacy' ),
378
+ ),
379
+ "profile_tab_{$id}_roles" => array(
380
+ 'sanitize' => array( UM()->admin(), 'sanitize_existed_role' ),
381
+ ),
382
  )
383
  );
384
  }
387
  }
388
 
389
  $appearances_profile_menu_fields[] = array(
390
+ 'id' => 'profile_menu_default_tab',
391
+ 'type' => 'select',
392
+ 'label' => __( 'Profile menu default tab', 'ultimate-member' ),
393
+ 'tooltip' => __( 'This will be the default tab on user profile page', 'ultimate-member' ),
394
+ 'options' => $tabs_options,
395
+ 'conditional' => array( implode( '|', $tabs_condition ), '~', 1 ),
396
+ 'size' => 'small',
397
+ );
398
+
399
+ $settings_map['profile_menu_default_tab'] = array(
400
+ 'sanitize' => 'key',
401
  );
402
 
403
+ $appearances_profile_menu_fields = array_merge(
404
+ $appearances_profile_menu_fields,
405
  array(
406
+ array(
407
+ 'id' => 'profile_menu_icons',
408
+ 'type' => 'checkbox',
409
+ 'label' => __( 'Enable menu icons in desktop view', 'ultimate-member' ),
410
+ 'conditional' => array( 'profile_menu', '=', 1 ),
411
+ ),
412
+ )
413
+ );
414
+
415
+ $settings_map['profile_menu_icons'] = array(
416
+ 'sanitize' => 'bool',
417
+ );
418
 
419
  $post_types_options = array();
420
+ $all_post_types = get_post_types( array( 'public' => true ), 'objects' );
421
  foreach ( $all_post_types as $key => $post_type_data ) {
422
  $post_types_options[ $key ] = $post_type_data->labels->singular_name;
423
  }
424
 
425
+ $duplicates = array();
426
  $taxonomies_options = array();
427
  $exclude_taxonomies = UM()->excluded_taxonomies();
428
+ $all_taxonomies = get_taxonomies( array( 'public' => true ), 'objects' );
 
429
  foreach ( $all_taxonomies as $key => $taxonomy ) {
430
+ if ( in_array( $key, $exclude_taxonomies, true ) ) {
431
  continue;
432
  }
433
 
434
+ if ( ! in_array( $taxonomy->labels->singular_name, $duplicates, true ) ) {
435
  $duplicates[] = $taxonomy->labels->singular_name;
436
+ $label = $taxonomy->labels->singular_name;
437
  } else {
438
  $label = $taxonomy->labels->singular_name . ' (' . $key . ')';
439
  }
442
  }
443
 
444
  $restricted_access_post_metabox_value = array();
445
+ $restricted_access_post_metabox = UM()->options()->get( 'restricted_access_post_metabox' );
446
+ if ( ! empty( $restricted_access_post_metabox ) && is_array( $restricted_access_post_metabox ) ) {
447
  foreach ( $restricted_access_post_metabox as $key => $value ) {
448
  if ( $value ) {
449
  $restricted_access_post_metabox_value[] = $key;
453
 
454
 
455
  $restricted_access_taxonomy_metabox_value = array();
456
+ $restricted_access_taxonomy_metabox = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
457
+ if ( ! empty( $restricted_access_taxonomy_metabox ) && is_array( $restricted_access_taxonomy_metabox ) ) {
458
  foreach ( $restricted_access_taxonomy_metabox as $key => $value ) {
459
  if ( $value ) {
460
  $restricted_access_taxonomy_metabox_value[] = $key;
464
 
465
  $access_fields = array(
466
  array(
467
+ 'id' => 'accessible',
468
+ 'type' => 'select',
469
+ 'label' => __( 'Global Site Access', 'ultimate-member' ),
470
+ 'tooltip' => __( 'Globally control the access of your site, you can have separate restrict options per post/page by editing the desired item.', 'ultimate-member' ),
471
+ 'options' => array(
472
+ 0 => __( 'Site accessible to Everyone', 'ultimate-member' ),
473
+ 2 => __( 'Site accessible to Logged In Users', 'ultimate-member' ),
474
+ ),
475
+ 'size' => 'medium',
476
  ),
477
  array(
478
+ 'id' => 'access_redirect',
479
+ 'type' => 'text',
480
+ 'label' => __( 'Custom Redirect URL', 'ultimate-member' ),
481
+ 'tooltip' => __( 'A logged out user will be redirected to this url If he is not permitted to access the site', 'ultimate-member' ),
482
+ 'conditional' => array( 'accessible', '=', 2 ),
483
+ ),
484
+ array(
485
+ 'id' => 'access_exclude_uris',
486
+ 'type' => 'multi_text',
487
+ 'label' => __( 'Exclude the following URLs', 'ultimate-member' ),
488
+ 'tooltip' => __( 'Here you can exclude URLs beside the redirect URI to be accessible to everyone', 'ultimate-member' ),
489
+ 'add_text' => __( 'Add New URL', 'ultimate-member' ),
490
+ 'conditional' => array( 'accessible', '=', 2 ),
491
+ 'show_default_number' => 0,
492
  ),
493
  array(
494
+ 'id' => 'home_page_accessible',
495
+ 'type' => 'checkbox',
496
+ 'label' => __( 'Allow Homepage to be accessible', 'ultimate-member' ),
497
+ 'conditional' => array( 'accessible', '=', 2 ),
 
 
 
498
  ),
499
  array(
500
+ 'id' => 'category_page_accessible',
501
+ 'type' => 'checkbox',
502
+ 'label' => __( 'Allow Category pages to be accessible', 'ultimate-member' ),
503
+ 'conditional' => array( 'accessible', '=', 2 ),
504
  ),
505
  array(
506
+ 'id' => 'restricted_access_message',
507
+ 'type' => 'wp_editor',
508
+ 'label' => __( 'Restricted Access Message', 'ultimate-member' ),
509
+ 'tooltip' => __( 'This is the message shown to users that do not have permission to view the content', 'ultimate-member' ),
510
  ),
511
+ );
512
+
513
+ $settings_map = array_merge(
514
+ $settings_map,
515
  array(
516
+ 'accessible' => array(
517
+ 'sanitize' => 'int',
518
+ ),
519
+ 'access_redirect' => array(
520
+ 'sanitize' => 'url',
521
+ ),
522
+ 'access_exclude_uris' => array(
523
+ 'sanitize' => 'url',
524
+ ),
525
+ 'home_page_accessible' => array(
526
+ 'sanitize' => 'bool',
527
+ ),
528
+ 'category_page_accessible' => array(
529
+ 'sanitize' => 'bool',
530
+ ),
531
+ 'restricted_access_message' => array(
532
+ 'sanitize' => 'wp_kses',
533
+ ),
534
  )
535
  );
536
 
537
  global $wp_version;
538
  if ( version_compare( $wp_version, '5.0', '>=' ) ) {
539
+ $access_fields = array_merge(
540
+ $access_fields,
541
+ array(
542
+ array(
543
+ 'id' => 'restricted_blocks',
544
+ 'type' => 'checkbox',
545
+ 'label' => __( 'Allow Gutenberg Blocks restriction options', 'ultimate-member' ),
546
+ ),
547
+ array(
548
+ 'id' => 'restricted_block_message',
549
+ 'type' => 'textarea',
550
+ 'label' => __( 'Restricted Block Message', 'ultimate-member' ),
551
+ 'tooltip' => __( 'This is the message shown to users that do not have permission to view the block\'s content', 'ultimate-member' ),
552
+ 'conditional' => array( 'restricted_blocks', '=', 1 ),
553
+ ),
554
+ )
555
+ );
556
+
557
+ $settings_map['restricted_blocks'] = array(
558
+ 'sanitize' => 'bool',
559
+ );
560
+ $settings_map['restricted_block_message'] = array(
561
+ 'sanitize' => 'textarea',
562
+ );
563
  }
564
+
565
+ $access_fields = array_merge(
566
+ $access_fields,
 
 
 
 
 
 
 
 
567
  array(
568
+ array(
569
+ 'id' => 'restricted_access_post_metabox',
570
+ 'type' => 'hidden',
571
+ 'value' => '',
572
+ ),
573
+ array(
574
+ 'id' => 'restricted_access_taxonomy_metabox',
575
+ 'type' => 'hidden',
576
+ 'value' => '',
577
+ ),
578
+ array(
579
+ 'id' => 'restricted_access_post_metabox',
580
+ 'type' => 'multi_checkbox',
581
+ 'label' => __( 'Restricted Access to Posts', 'ultimate-member' ),
582
+ 'tooltip' => __( 'Restriction content of the current Posts', 'ultimate-member' ),
583
+ 'options' => $post_types_options,
584
+ 'columns' => 3,
585
+ 'value' => $restricted_access_post_metabox_value,
586
+ 'default' => UM()->options()->get_default( 'restricted_access_post_metabox' ),
587
+ ),
588
+ array(
589
+ 'id' => 'restricted_access_taxonomy_metabox',
590
+ 'type' => 'multi_checkbox',
591
+ 'label' => __( 'Restricted Access to Taxonomies', 'ultimate-member' ),
592
+ 'tooltip' => __( 'Restriction content of the current Taxonomies', 'ultimate-member' ),
593
+ 'options' => $taxonomies_options,
594
+ 'columns' => 3,
595
+ 'value' => $restricted_access_taxonomy_metabox_value,
596
+ 'default' => UM()->options()->get_default( 'restricted_access_taxonomy_metabox' ),
597
+ ),
598
+ )
599
+ );
600
+
601
+ $settings_map = array_merge(
602
+ $settings_map,
603
  array(
604
+ 'restricted_access_post_metabox' => array(
605
+ 'sanitize' => 'key',
606
+ ),
607
+ 'restricted_access_taxonomy_metabox' => array(
608
+ 'sanitize' => 'key',
609
+ ),
610
+ )
611
+ );
612
+
613
+ $latest_update = get_option( 'um_member_directory_update_meta', false );
 
614
  $latest_truncate = get_option( 'um_member_directory_truncated', false );
615
 
616
  $same_page_update = array(
617
+ 'id' => 'member_directory_own_table',
618
+ 'type' => 'same_page_update',
619
+ 'label' => __( 'Enable custom table for usermeta', 'ultimate-member' ),
620
+ 'tooltip' => __( 'Check this box if you would like to enable the use of a custom table for user metadata. Improved performance for member directory searches.', 'ultimate-member' ),
621
  );
622
 
623
  if ( empty( $latest_update ) || ( ! empty( $latest_truncate ) && $latest_truncate > $latest_update ) ) {
624
+ $same_page_update['upgrade_cb'] = 'sync_metatable';
625
  $same_page_update['upgrade_description'] = '<p>' . __( 'We recommend creating a backup of your site before running the update process. Do not exit the page before the update process has complete.', 'ultimate-member' ) . '</p>
626
  <p>' . __( 'After clicking the <strong>"Run"</strong> button, the update process will start. All information will be displayed in the field below.', 'ultimate-member' ) . '</p>
627
  <p>' . __( 'If the update was successful, you will see a corresponding message. Otherwise, contact technical support if the update failed.', 'ultimate-member' ) . '</p>';
628
  }
629
 
630
+ $settings_map = array_merge(
631
+ $settings_map,
632
+ array(
633
+ 'permalink_base' => array(
634
+ 'sanitize' => 'key',
635
+ ),
636
+ 'display_name' => array(
637
+ 'sanitize' => 'key',
638
+ ),
639
+ 'display_name_field' => array(
640
+ 'sanitize' => 'text',
641
+ ),
642
+ 'author_redirect' => array(
643
+ 'sanitize' => 'bool',
644
+ ),
645
+ 'members_page' => array(
646
+ 'sanitize' => 'bool',
647
+ ),
648
+ 'use_gravatars' => array(
649
+ 'sanitize' => 'bool',
650
+ ),
651
+ 'use_um_gravatar_default_builtin_image' => array(
652
+ 'sanitize' => 'key',
653
+ ),
654
+ 'use_um_gravatar_default_image' => array(
655
+ 'sanitize' => 'bool',
656
+ ),
657
+ 'reset_require_strongpass' => array(
658
+ 'sanitize' => 'bool',
659
+ ),
660
+ 'profile_noindex' => array(
661
+ 'sanitize' => 'bool',
662
+ ),
663
+ 'activation_link_expiry_time' => array(
664
+ 'sanitize' => 'absint',
665
+ ),
666
+ 'account_tab_password' => array(
667
+ 'sanitize' => 'bool',
668
+ ),
669
+ 'account_tab_privacy' => array(
670
+ 'sanitize' => 'bool',
671
+ ),
672
+ 'account_tab_notifications' => array(
673
+ 'sanitize' => 'bool',
674
+ ),
675
+ 'account_tab_delete' => array(
676
+ 'sanitize' => 'bool',
677
+ ),
678
+ 'delete_account_text' => array(
679
+ 'sanitize' => 'textarea',
680
+ ),
681
+ 'delete_account_no_pass_required_text' => array(
682
+ 'sanitize' => 'textarea',
683
+ ),
684
+ 'account_name' => array(
685
+ 'sanitize' => 'bool',
686
+ ),
687
+ 'account_name_disable' => array(
688
+ 'sanitize' => 'bool',
689
+ ),
690
+ 'account_name_require' => array(
691
+ 'sanitize' => 'bool',
692
+ ),
693
+ 'account_email' => array(
694
+ 'sanitize' => 'bool',
695
+ ),
696
+ 'account_general_password' => array(
697
+ 'sanitize' => 'bool',
698
+ ),
699
+ 'account_require_strongpass' => array(
700
+ 'sanitize' => 'bool',
701
+ ),
702
+ 'account_hide_in_directory' => array(
703
+ 'sanitize' => 'bool',
704
+ ),
705
+ 'account_hide_in_directory_default' => array(
706
+ 'sanitize' => 'text',
707
+ ),
708
+ 'profile_photo_max_size' => array(
709
+ 'sanitize' => 'absint',
710
+ ),
711
+ 'cover_photo_max_size' => array(
712
+ 'sanitize' => 'absint',
713
+ ),
714
+ 'photo_thumb_sizes' => array(
715
+ 'sanitize' => 'absint',
716
+ ),
717
+ 'cover_thumb_sizes' => array(
718
+ 'sanitize' => 'absint',
719
+ ),
720
+ 'image_orientation_by_exif' => array(
721
+ 'sanitize' => 'bool',
722
+ ),
723
+ 'image_compression' => array(
724
+ 'sanitize' => 'absint',
725
+ ),
726
+ 'image_max_width' => array(
727
+ 'sanitize' => 'absint',
728
+ ),
729
+ 'cover_min_width' => array(
730
+ 'sanitize' => 'absint',
731
+ ),
732
+ 'enable_reset_password_limit' => array(
733
+ 'sanitize' => 'bool',
734
+ ),
735
+ 'reset_password_limit_number' => array(
736
+ 'sanitize' => 'absint',
737
+ ),
738
+ 'blocked_emails' => array(
739
+ 'sanitize' => 'textarea',
740
+ ),
741
+ 'blocked_words' => array(
742
+ 'sanitize' => 'textarea',
743
+ ),
744
+ 'admin_email' => array(
745
+ 'sanitize' => 'text',
746
+ ),
747
+ 'mail_from' => array(
748
+ 'sanitize' => 'text',
749
+ ),
750
+ 'mail_from_addr' => array(
751
+ 'sanitize' => 'text',
752
+ ),
753
+ 'email_html' => array(
754
+ 'sanitize' => 'bool',
755
+ ),
756
+ 'profile_template' => array(
757
+ 'sanitize' => 'text',
758
+ ),
759
+ 'profile_max_width' => array(
760
+ 'sanitize' => 'absint',
761
+ ),
762
+ 'profile_area_max_width' => array(
763
+ 'sanitize' => 'absint',
764
+ ),
765
+ 'profile_icons' => array(
766
+ 'sanitize' => 'key',
767
+ ),
768
+ 'profile_primary_btn_word' => array(
769
+ 'sanitize' => 'text',
770
+ ),
771
+ 'profile_secondary_btn' => array(
772
+ 'sanitize' => 'bool',
773
+ ),
774
+ 'profile_secondary_btn_word' => array(
775
+ 'sanitize' => 'text',
776
+ ),
777
+ 'default_avatar' => array(
778
+ 'sanitize' => 'url',
779
+ ),
780
+ 'default_cover' => array(
781
+ 'sanitize' => 'url',
782
+ ),
783
+ 'disable_profile_photo_upload' => array(
784
+ 'sanitize' => 'bool',
785
+ ),
786
+ 'profile_photosize' => array(
787
+ 'sanitize' => array( UM()->admin(), 'sanitize_photosize' ),
788
+ ),
789
+ 'profile_cover_enabled' => array(
790
+ 'sanitize' => 'bool',
791
+ ),
792
+ 'profile_coversize' => array(
793
+ 'sanitize' => array( UM()->admin(), 'sanitize_cover_photosize' ),
794
+ ),
795
+ 'profile_cover_ratio' => array(
796
+ 'sanitize' => 'text',
797
+ ),
798
+ 'profile_show_metaicon' => array(
799
+ 'sanitize' => 'bool',
800
+ ),
801
+ 'profile_show_name' => array(
802
+ 'sanitize' => 'bool',
803
+ ),
804
+ 'profile_show_social_links' => array(
805
+ 'sanitize' => 'bool',
806
+ ),
807
+ 'profile_show_bio' => array(
808
+ 'sanitize' => 'bool',
809
+ ),
810
+ 'profile_show_html_bio' => array(
811
+ 'sanitize' => 'bool',
812
+ ),
813
+ 'profile_bio_maxchars' => array(
814
+ 'sanitize' => 'absint',
815
+ ),
816
+ 'profile_header_menu' => array(
817
+ 'sanitize' => 'key',
818
+ ),
819
+ 'profile_empty_text' => array(
820
+ 'sanitize' => 'bool',
821
+ ),
822
+ 'profile_empty_text_emo' => array(
823
+ 'sanitize' => 'bool',
824
+ ),
825
+ 'register_template' => array(
826
+ 'sanitize' => 'text',
827
+ ),
828
+ 'register_max_width' => array(
829
+ 'sanitize' => 'absint',
830
+ ),
831
+ 'register_align' => array(
832
+ 'sanitize' => 'key',
833
+ ),
834
+ 'register_icons' => array(
835
+ 'sanitize' => 'key',
836
+ ),
837
+ 'register_primary_btn_word' => array(
838
+ 'sanitize' => 'text',
839
+ ),
840
+ 'register_secondary_btn' => array(
841
+ 'sanitize' => 'bool',
842
+ ),
843
+ 'register_secondary_btn_word' => array(
844
+ 'sanitize' => 'text',
845
+ ),
846
+ 'register_secondary_btn_url' => array(
847
+ 'sanitize' => 'url',
848
+ ),
849
+ 'register_role' => array(
850
+ 'sanitize' => 'key',
851
+ ),
852
+ 'login_template' => array(
853
+ 'sanitize' => 'text',
854
+ ),
855
+ 'login_max_width' => array(
856
+ 'sanitize' => 'absint',
857
+ ),
858
+ 'login_align' => array(
859
+ 'sanitize' => 'key',
860
+ ),
861
+ 'login_icons' => array(
862
+ 'sanitize' => 'key',
863
+ ),
864
+ 'login_primary_btn_word' => array(
865
+ 'sanitize' => 'text',
866
+ ),
867
+ 'login_secondary_btn' => array(
868
+ 'sanitize' => 'bool',
869
+ ),
870
+ 'login_secondary_btn_word' => array(
871
+ 'sanitize' => 'text',
872
+ ),
873
+ 'login_secondary_btn_url' => array(
874
+ 'sanitize' => 'url',
875
+ ),
876
+ 'login_forgot_pass_link' => array(
877
+ 'sanitize' => 'bool',
878
+ ),
879
+ 'login_show_rememberme' => array(
880
+ 'sanitize' => 'bool',
881
+ ),
882
+ 'form_asterisk' => array(
883
+ 'sanitize' => 'bool',
884
+ ),
885
+ 'profile_title' => array(
886
+ 'sanitize' => 'text',
887
+ ),
888
+ 'profile_desc' => array(
889
+ 'sanitize' => 'textarea',
890
+ ),
891
+ 'um_profile_object_cache_stop' => array(
892
+ 'sanitize' => 'bool',
893
+ ),
894
+ 'enable_blocks' => array(
895
+ 'sanitize' => 'bool',
896
+ ),
897
+ 'rest_api_version' => array(
898
+ 'sanitize' => 'text',
899
+ ),
900
+ 'uninstall_on_delete' => array(
901
+ 'sanitize' => 'bool',
902
+ ),
903
+ )
904
+ );
905
+
906
+ $this->settings_map = apply_filters( 'um_settings_map', $settings_map );
907
+
908
  /**
909
  * UM hook
910
  *
925
  * }
926
  * ?>
927
  */
928
+ $this->settings_structure = apply_filters(
929
+ 'um_settings_structure',
930
+ array(
931
+ '' => array(
932
+ 'title' => __( 'General', 'ultimate-member' ),
933
+ 'sections' => array(
934
+ '' => array(
935
+ 'title' => __( 'Pages', 'ultimate-member' ),
936
+ 'fields' => $general_pages_fields,
937
+ ),
938
+ 'users' => array(
939
+ 'title' => __( 'Users', 'ultimate-member' ),
940
+ 'fields' => array(
941
+ array(
942
+ 'id' => 'permalink_base',
943
+ 'type' => 'select',
944
+ 'size' => 'small',
945
+ 'label' => __( 'Profile Permalink Base', 'ultimate-member' ),
946
+ // translators: %s: Profile page URL
947
+ 'tooltip' => sprintf( __( 'Here you can control the permalink structure of the user profile URL globally e.g. %s<strong>username</strong>/', 'ultimate-member' ), trailingslashit( um_get_core_page( 'user' ) ) ),
948
+ 'options' => array(
949
+ 'user_login' => __( 'Username', 'ultimate-member' ),
950
+ 'name' => __( 'First and Last Name with \'.\'', 'ultimate-member' ),
951
+ 'name_dash' => __( 'First and Last Name with \'-\'', 'ultimate-member' ),
952
+ 'name_plus' => __( 'First and Last Name with \'+\'', 'ultimate-member' ),
953
+ 'user_id' => __( 'User ID', 'ultimate-member' ),
954
+ ),
955
+ 'placeholder' => __( 'Select...', 'ultimate-member' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
956
  ),
957
+ array(
958
+ 'id' => 'display_name',
959
+ 'type' => 'select',
960
+ 'size' => 'medium',
961
+ 'label' => __( 'User Display Name', 'ultimate-member' ),
962
+ 'tooltip' => __( 'This is the name that will be displayed for users on the front end of your site. Default setting uses first/last name as display name if it exists', 'ultimate-member' ),
963
+ 'options' => array(
964
+ 'default' => __( 'Default WP Display Name', 'ultimate-member' ),
965
+ 'nickname' => __( 'Nickname', 'ultimate-member' ),
966
+ 'username' => __( 'Username', 'ultimate-member' ),
967
+ 'full_name' => __( 'First name & last name', 'ultimate-member' ),
968
+ 'sur_name' => __( 'Last name & first name', 'ultimate-member' ),
969
+ 'initial_name' => __( 'First name & first initial of last name', 'ultimate-member' ),
970
+ 'initial_name_f' => __( 'First initial of first name & last name', 'ultimate-member' ),
971
+ 'first_name' => __( 'First name only', 'ultimate-member' ),
972
+ 'field' => __( 'Custom field(s)', 'ultimate-member' ),
973
+ ),
974
+ 'placeholder' => __( 'Select...', 'ultimate-member' ),
975
+ ),
976
+ array(
977
+ 'id' => 'display_name_field',
978
+ 'type' => 'text',
979
+ 'label' => __( 'Display Name Custom Field(s)', 'ultimate-member' ),
980
+ 'tooltip' => __( 'Specify the custom field meta key or custom fields seperated by comma that you want to use to display users name on the frontend of your site', 'ultimate-member' ),
981
+ 'conditional' => array( 'display_name', '=', 'field' ),
982
+ ),
983
+ array(
984
+ 'id' => 'author_redirect',
985
+ 'type' => 'checkbox',
986
+ 'label' => __( 'Automatically redirect author page to their profile?', 'ultimate-member' ),
987
+ 'tooltip' => __( 'If enabled, author pages will automatically redirect to the user\'s profile page', 'ultimate-member' ),
988
+ ),
989
+ array(
990
+ 'id' => 'members_page',
991
+ 'type' => 'checkbox',
992
+ 'label' => __( 'Enable Members Directory', 'ultimate-member' ),
993
+ 'tooltip' => __( 'Control whether to enable or disable member directories on this site', 'ultimate-member' ),
994
+ ),
995
+ array(
996
+ 'id' => 'use_gravatars',
997
+ 'type' => 'checkbox',
998
+ 'label' => __( 'Use Gravatars?', 'ultimate-member' ),
999
+ 'tooltip' => __( 'Do you want to use gravatars instead of the default plugin profile photo (If the user did not upload a custom profile photo / avatar)', 'ultimate-member' ),
1000
+ ),
1001
+ array(
1002
+ 'id' => 'use_um_gravatar_default_builtin_image',
1003
+ 'type' => 'select',
1004
+ 'label' => __( 'Use Gravatar builtin image', 'ultimate-member' ),
1005
+ 'tooltip' => __( 'Gravatar has a number of built in options which you can also use as defaults', 'ultimate-member' ),
1006
+ 'options' => array(
1007
+ 'default' => __( 'Default', 'ultimate-member' ),
1008
+ '404' => __( '404 ( File Not Found response )', 'ultimate-member' ),
1009
+ 'mm' => __( 'Mystery Man', 'ultimate-member' ),
1010
+ 'identicon' => __( 'Identicon', 'ultimate-member' ),
1011
+ 'monsterid' => __( 'Monsterid', 'ultimate-member' ),
1012
+ 'wavatar' => __( 'Wavatar', 'ultimate-member' ),
1013
+ 'retro' => __( 'Retro', 'ultimate-member' ),
1014
+ 'blank' => __( 'Blank ( a transparent PNG image )', 'ultimate-member' ),
1015
+ ),
1016
+ 'conditional' => array( 'use_gravatars', '=', 1 ),
1017
+ 'size' => 'medium',
1018
+ ),
1019
+ array(
1020
+ 'id' => 'use_um_gravatar_default_image',
1021
+ 'type' => 'checkbox',
1022
+ 'label' => __( 'Use Default plugin avatar as Gravatar\'s Default avatar', 'ultimate-member' ),
1023
+ 'tooltip' => __( 'Do you want to use the plugin default avatar instead of the gravatar default photo (If the user did not upload a custom profile photo / avatar)', 'ultimate-member' ),
1024
+ 'conditional' => array( 'use_um_gravatar_default_builtin_image', '=', 'default' ),
1025
+ ),
1026
+ array(
1027
+ 'id' => 'reset_require_strongpass',
1028
+ 'type' => 'checkbox',
1029
+ 'label' => __( 'Require a strong password? (when user resets password only)', 'ultimate-member' ),
1030
+ 'tooltip' => __( 'Enable or disable a strong password rules on password reset and change procedure', 'ultimate-member' ),
1031
+ ),
1032
+ array(
1033
+ 'id' => 'profile_noindex',
1034
+ 'type' => 'select',
1035
+ 'size' => 'small',
1036
+ 'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ),
1037
+ 'tooltip' => __( 'Hides the profile page for robots. This setting can be overridden by individual role settings.', 'ultimate-member' ),
1038
+ 'options' => array(
1039
+ '0' => __( 'No', 'ultimate-member' ),
1040
+ '1' => __( 'Yes', 'ultimate-member' ),
1041
+ ),
1042
+ ),
1043
+ array(
1044
+ 'id' => 'activation_link_expiry_time',
1045
+ 'type' => 'number',
1046
+ 'label' => __( 'Activation link lifetime', 'ultimate-member' ),
1047
+ 'tooltip' => __( 'How long does an activation link live in seconds? Leave empty for endless links.', 'ultimate-member' ),
1048
+ 'size' => 'small',
1049
  ),
1050
  ),
1051
+ ),
1052
+ 'account' => array(
1053
+ 'title' => __( 'Account', 'ultimate-member' ),
1054
+ 'fields' => array(
1055
+ array(
1056
+ 'id' => 'account_tab_password',
1057
+ 'type' => 'checkbox',
1058
+ 'label' => __( 'Password Account Tab', 'ultimate-member' ),
1059
+ 'tooltip' => __( 'Enable/disable the Password account tab in account page', 'ultimate-member' ),
1060
+ ),
1061
+ array(
1062
+ 'id' => 'account_tab_privacy',
1063
+ 'type' => 'checkbox',
1064
+ 'label' => __( 'Privacy Account Tab', 'ultimate-member' ),
1065
+ 'tooltip' => __( 'Enable/disable the Privacy account tab in account page', 'ultimate-member' ),
1066
+ ),
1067
+ array(
1068
+ 'id' => 'account_tab_notifications',
1069
+ 'type' => 'checkbox',
1070
+ 'label' => __( 'Notifications Account Tab', 'ultimate-member' ),
1071
+ 'tooltip' => __( 'Enable/disable the Notifications account tab in account page', 'ultimate-member' ),
1072
+ ),
1073
+ array(
1074
+ 'id' => 'account_tab_delete',
1075
+ 'type' => 'checkbox',
1076
+ 'label' => __( 'Delete Account Tab', 'ultimate-member' ),
1077
+ 'tooltip' => __( 'Enable/disable the Delete account tab in account page', 'ultimate-member' ),
1078
+ ),
1079
+ array(
1080
+ 'id' => 'delete_account_text',
1081
+ 'type' => 'textarea', // bug with wp 4.4? should be editor
1082
+ 'label' => __( 'Account Deletion Custom Text', 'ultimate-member' ),
1083
+ 'tooltip' => __( 'This is custom text that will be displayed to users before they delete their accounts from your site when password is required.', 'ultimate-member' ),
1084
+ 'args' => array(
1085
+ 'textarea_rows' => 6,
1086
+ ),
1087
+ ),
1088
+ array(
1089
+ 'id' => 'delete_account_no_pass_required_text',
1090
+ 'type' => 'textarea',
1091
+ 'label' => __( 'Account Deletion without password Custom Text', 'ultimate-member' ),
1092
+ 'tooltip' => __( 'This is custom text that will be displayed to users before they delete their accounts from your site when password isn\'t required.', 'ultimate-member' ),
1093
+ 'args' => array(
1094
+ 'textarea_rows' => 6,
1095
+ ),
1096
+ ),
1097
+ array(
1098
+ 'id' => 'account_name',
1099
+ 'type' => 'checkbox',
1100
+ 'label' => __( 'Add a First & Last Name fields', 'ultimate-member' ),
1101
+ 'tooltip' => __( 'Whether to enable these fields on the user account page by default or hide them.', 'ultimate-member' ),
1102
+ ),
1103
+ array(
1104
+ 'id' => 'account_name_disable',
1105
+ 'type' => 'checkbox',
1106
+ 'label' => __( 'Disable First & Last Name fields', 'ultimate-member' ),
1107
+ 'tooltip' => __( 'Whether to allow users changing their first and last name in account page.', 'ultimate-member' ),
1108
+ 'conditional' => array( 'account_name', '=', '1' ),
1109
+ ),
1110
+ array(
1111
+ 'id' => 'account_name_require',
1112
+ 'type' => 'checkbox',
1113
+ 'label' => __( 'Require First & Last Name', 'ultimate-member' ),
1114
+ 'tooltip' => __( 'Require first and last name?', 'ultimate-member' ),
1115
+ 'conditional' => array( 'account_name', '=', '1' ),
1116
+ ),
1117
+ array(
1118
+ 'id' => 'account_email',
1119
+ 'type' => 'checkbox',
1120
+ 'label' => __( 'Allow users to change e-mail', 'ultimate-member' ),
1121
+ 'tooltip' => __( 'Whether to allow users changing their email in account page.', 'ultimate-member' ),
1122
+ ),
1123
+ array(
1124
+ 'id' => 'account_general_password',
1125
+ 'type' => 'checkbox',
1126
+ 'label' => __( 'Password is required?', 'ultimate-member' ),
1127
+ 'tooltip' => __( 'Password is required to save account data.', 'ultimate-member' ),
1128
+ ),
1129
+ array(
1130
+ 'id' => 'account_require_strongpass',
1131
+ 'type' => 'checkbox',
1132
+ 'label' => __( 'Require a strong password?', 'ultimate-member' ),
1133
+ 'tooltip' => __( 'Enable or disable a strong password rules on account page / change password tab', 'ultimate-member' ),
1134
+ ),
1135
+ array(
1136
+ 'id' => 'account_hide_in_directory',
1137
+ 'type' => 'checkbox',
1138
+ 'label' => __( 'Allow users to hide their profiles from directory', 'ultimate-member' ),
1139
+ 'tooltip' => __( 'Whether to allow users changing their profile visibility from member directory in account page.', 'ultimate-member' ),
1140
+ 'conditional' => array( 'account_tab_privacy', '=', '1' ),
1141
+ ),
1142
+ array(
1143
+ 'id' => 'account_hide_in_directory_default',
1144
+ 'type' => 'select',
1145
+ 'label' => __( 'Hide profiles from directory by default', 'ultimate-member' ),
1146
+ 'tooltip' => __( 'Set default value for the "Hide my profile from directory" option', 'ultimate-member' ),
1147
+ 'options' => array(
1148
+ 'No' => __( 'No', 'ultimate-member' ),
1149
+ 'Yes' => __( 'Yes', 'ultimate-member' ),
1150
+ ),
1151
+ 'size' => 'small',
1152
+ 'conditional' => array( 'account_hide_in_directory', '=', '1' ),
1153
+ ),
 
 
 
 
 
 
 
1154
  ),
1155
+ ),
1156
+ 'uploads' => array(
1157
+ 'title' => __( 'Uploads', 'ultimate-member' ),
1158
+ 'fields' => array(
1159
+ array(
1160
+ 'id' => 'profile_photo_max_size',
1161
+ 'type' => 'text',
1162
+ 'size' => 'small',
1163
+ 'label' => __( 'Profile Photo Maximum File Size (bytes)', 'ultimate-member' ),
1164
+ 'tooltip' => __( 'Sets a maximum size for the uploaded photo', 'ultimate-member' ),
1165
+ ),
1166
+ array(
1167
+ 'id' => 'cover_photo_max_size',
1168
+ 'type' => 'text',
1169
+ 'size' => 'small',
1170
+ 'label' => __( 'Cover Photo Maximum File Size (bytes)', 'ultimate-member' ),
1171
+ 'tooltip' => __( 'Sets a maximum size for the uploaded cover', 'ultimate-member' ),
1172
+ ),
1173
+ array(
1174
+ 'id' => 'photo_thumb_sizes',
1175
+ 'type' => 'multi_text',
1176
+ 'size' => 'small',
1177
+ 'label' => __( 'Profile Photo Thumbnail Sizes (px)', 'ultimate-member' ),
1178
+ 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each profile photo upload.', 'ultimate-member' ),
1179
+ 'validate' => 'numeric',
1180
+ 'add_text' => __( 'Add New Size', 'ultimate-member' ),
1181
+ 'show_default_number' => 1,
1182
+ ),
1183
+ array(
1184
+ 'id' => 'cover_thumb_sizes',
1185
+ 'type' => 'multi_text',
1186
+ 'size' => 'small',
1187
+ 'label' => __( 'Cover Photo Thumbnail Sizes (px)', 'ultimate-member' ),
1188
+ 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each cover photo upload.', 'ultimate-member' ),
1189
+ 'validate' => 'numeric',
1190
+ 'add_text' => __( 'Add New Size', 'ultimate-member' ),
1191
+ 'show_default_number' => 1,
1192
+ ),
1193
+ array(
1194
+ 'id' => 'image_orientation_by_exif',
1195
+ 'type' => 'checkbox',
1196
+ 'label' => __( 'Change image orientation', 'ultimate-member' ),
1197
+ 'tooltip' => __( 'Rotate image to and use orientation by the camera EXIF data.', 'ultimate-member' ),
1198
+ ),
1199
+ array(
1200
+ 'id' => 'image_compression',
1201
+ 'type' => 'text',
1202
+ 'size' => 'small',
1203
+ 'label' => __( 'Image Quality', 'ultimate-member' ),
1204
+ 'tooltip' => __( 'Quality is used to determine quality of image uploads, and ranges from 0 (worst quality, smaller file) to 100 (best quality, biggest file). The default range is 60.', 'ultimate-member' ),
1205
+ ),
1206
 
1207
+ array(
1208
+ 'id' => 'image_max_width',
1209
+ 'type' => 'text',
1210
+ 'size' => 'small',
1211
+ 'label' => __( 'Image Upload Maximum Width (px)', 'ultimate-member' ),
1212
+ 'tooltip' => __( 'Any image upload above this width will be resized to this limit automatically.', 'ultimate-member' ),
1213
+ ),
1214
 
1215
+ array(
1216
+ 'id' => 'cover_min_width',
1217
+ 'type' => 'text',
1218
+ 'size' => 'small',
1219
+ 'label' => __( 'Cover Photo Minimum Width (px)', 'ultimate-member' ),
1220
+ 'tooltip' => __( 'This will be the minimum width for cover photo uploads', 'ultimate-member' ),
1221
+ ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1222
  ),
1223
+ ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1224
  ),
1225
+ ),
1226
+ 'access' => array(
1227
+ 'title' => __( 'Access', 'ultimate-member' ),
1228
+ 'sections' => array(
1229
+ '' => array(
1230
+ 'title' => __( 'Restriction Content', 'ultimate-member' ),
1231
+ 'fields' => $access_fields,
1232
+ ),
1233
+ 'other' => array(
1234
+ 'title' => __( 'Other', 'ultimate-member' ),
1235
+ 'fields' => array(
1236
+ array(
1237
+ 'id' => 'enable_reset_password_limit',
1238
+ 'type' => 'checkbox',
1239
+ 'label' => __( 'Enable the Reset Password Limit?', 'ultimate-member' ),
1240
+ ),
1241
+ array(
1242
+ 'id' => 'reset_password_limit_number',
1243
+ 'type' => 'text',
1244
+ 'label' => __( 'Reset Password Limit', 'ultimate-member' ),
1245
+ 'tooltip' => __( 'Set the maximum reset password limit. If reached the maximum limit, user will be locked from using this.', 'ultimate-member' ),
1246
+ 'validate' => 'numeric',
1247
+ 'conditional' => array( 'enable_reset_password_limit', '=', 1 ),
1248
+ 'size' => 'small',
1249
+ ),
1250
+ array(
1251
+ 'id' => 'blocked_emails',
1252
+ 'type' => 'textarea',
1253
+ 'label' => __( 'Blocked Email Addresses', 'ultimate-member' ),
1254
+ 'tooltip' => __( 'This will block the specified e-mail addresses from being able to sign up or sign in to your site. To block an entire domain, use something like *@domain.com', 'ultimate-member' ),
1255
+ ),
1256
+ array(
1257
+ 'id' => 'blocked_words',
1258
+ 'type' => 'textarea',
1259
+ 'label' => __( 'Blacklist Words', 'ultimate-member' ),
1260
+ 'tooltip' => __( 'This option lets you specify blacklist of words to prevent anyone from signing up with such a word as their username', 'ultimate-member' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1261
  ),
1262
  ),
1263
+ ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1264
  ),
1265
+ ),
1266
+ 'email' => array(
1267
+ 'title' => __( 'Email', 'ultimate-member' ),
1268
+ 'fields' => array(
1269
+ array(
1270
+ 'id' => 'admin_email',
1271
+ 'type' => 'text',
1272
+ 'label' => __( 'Admin E-mail Address', 'ultimate-member' ),
1273
+ 'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
1274
+ ),
1275
+ array(
1276
+ 'id' => 'mail_from',
1277
+ 'type' => 'text',
1278
+ 'label' => __( 'Mail appears from', 'ultimate-member' ),
1279
+ 'tooltip' => __( 'e.g. Site Name', 'ultimate-member' ),
1280
+ ),
1281
+ array(
1282
+ 'id' => 'mail_from_addr',
1283
+ 'type' => 'text',
1284
+ 'label' => __( 'Mail appears from address', 'ultimate-member' ),
1285
+ 'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ),
1286
+ ),
1287
+ array(
1288
+ 'id' => 'email_html',
1289
+ 'type' => 'checkbox',
1290
+ 'label' => __( 'Use HTML for E-mails?', 'ultimate-member' ),
1291
+ 'tooltip' => __( 'If you plan use e-mails with HTML, please make sure that this option is enabled. Otherwise, HTML will be displayed as plain text.', 'ultimate-member' ),
1292
+ ),
1293
  ),
1294
+ ),
1295
+ 'appearance' => array(
1296
+ 'title' => __( 'Appearance', 'ultimate-member' ),
1297
+ 'sections' => array(
1298
+ '' => array(
1299
+ 'title' => __( 'Profile', 'ultimate-member' ),
1300
+ 'fields' => array(
1301
+ array(
1302
+ 'id' => 'profile_template',
1303
+ 'type' => 'select',
1304
+ 'label' => __( 'Profile Default Template', 'ultimate-member' ),
1305
+ 'tooltip' => __( 'This will be the default template to output profile', 'ultimate-member' ),
1306
+ 'default' => um_get_metadefault( 'profile_template' ),
1307
+ 'options' => UM()->shortcodes()->get_templates( 'profile' ),
1308
+ 'size' => 'small',
1309
+ ),
1310
+ array(
1311
+ 'id' => 'profile_max_width',
1312
+ 'type' => 'text',
1313
+ 'label' => __( 'Profile Maximum Width', 'ultimate-member' ),
1314
+ 'default' => um_get_metadefault( 'profile_max_width' ),
1315
+ 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
1316
+ 'size' => 'small',
1317
+ ),
1318
+ array(
1319
+ 'id' => 'profile_area_max_width',
1320
+ 'type' => 'text',
1321
+ 'label' => __( 'Profile Area Maximum Width', 'ultimate-member' ),
1322
+ 'default' => um_get_metadefault( 'profile_area_max_width' ),
1323
+ 'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ),
1324
+ 'size' => 'small',
1325
+ ),
1326
+ array(
1327
+ 'id' => 'profile_icons',
1328
+ 'type' => 'select',
1329
+ 'label' => __( 'Profile Field Icons', 'ultimate-member' ),
1330
+ 'tooltip' => __( 'This is applicable for edit mode only', 'ultimate-member' ),
1331
+ 'default' => um_get_metadefault( 'profile_icons' ),
1332
+ 'options' => array(
1333
+ 'field' => __( 'Show inside text field', 'ultimate-member' ),
1334
+ 'label' => __( 'Show with label', 'ultimate-member' ),
1335
+ 'off' => __( 'Turn off', 'ultimate-member' ),
1336
+ ),
1337
+ 'size' => 'small',
1338
+ ),
1339
+ array(
1340
+ 'id' => 'profile_primary_btn_word',
1341
+ 'type' => 'text',
1342
+ 'label' => __( 'Profile Primary Button Text', 'ultimate-member' ),
1343
+ 'default' => um_get_metadefault( 'profile_primary_btn_word' ),
1344
+ 'tooltip' => __( 'The text that is used for updating profile button', 'ultimate-member' ),
1345
+ 'size' => 'medium',
1346
+ ),
1347
+ array(
1348
+ 'id' => 'profile_secondary_btn',
1349
+ 'type' => 'checkbox',
1350
+ 'label' => __( 'Profile Secondary Button', 'ultimate-member' ),
1351
+ 'default' => um_get_metadefault( 'profile_secondary_btn' ),
1352
+ 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
1353
+ ),
1354
+ array(
1355
+ 'id' => 'profile_secondary_btn_word',
1356
+ 'type' => 'text',
1357
+ 'label' => __( 'Profile Secondary Button Text', 'ultimate-member' ),
1358
+ 'default' => um_get_metadefault( 'profile_secondary_btn_word' ),
1359
+ 'tooltip' => __( 'The text that is used for cancelling update profile button', 'ultimate-member' ),
1360
+ 'conditional' => array( 'profile_secondary_btn', '=', 1 ),
1361
+ 'size' => 'medium',
1362
+ ),
1363
+ array(
1364
+ 'id' => 'default_avatar',
1365
+ 'type' => 'media',
1366
+ 'label' => __( 'Default Profile Photo', 'ultimate-member' ),
1367
+ 'tooltip' => __( 'You can change the default profile picture globally here. Please make sure that the photo is 300x300px.', 'ultimate-member' ),
1368
+ 'upload_frame_title' => __( 'Select Default Profile Photo', 'ultimate-member' ),
1369
+ 'default' => array(
1370
+ 'url' => um_url . 'assets/img/default_avatar.jpg',
1371
+ ),
1372
+ ),
1373
+ array(
1374
+ 'id' => 'default_cover',
1375
+ 'type' => 'media',
1376
+ 'url' => true,
1377
+ 'preview' => false,
1378
+ 'label' => __( 'Default Cover Photo', 'ultimate-member' ),
1379
+ 'tooltip' => __( 'You can change the default cover photo globally here. Please make sure that the default cover is large enough and respects the ratio you are using for cover photos.', 'ultimate-member' ),
1380
+ 'upload_frame_title' => __( 'Select Default Cover Photo', 'ultimate-member' ),
1381
+ ),
1382
+ array(
1383
+ 'id' => 'disable_profile_photo_upload',
1384
+ 'type' => 'checkbox',
1385
+ 'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ),
1386
+ 'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ),
1387
+ 'default' => um_get_metadefault( 'disable_profile_photo_upload' ),
1388
+ ),
1389
+ array(
1390
+ 'id' => 'profile_photosize',
1391
+ 'type' => 'select',
1392
+ 'label' => __( 'Profile Photo Size', 'ultimate-member' ),
1393
+ 'default' => um_get_metadefault( 'profile_photosize' ),
1394
+ 'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ),
1395
+ 'tooltip' => __( 'The global default of profile photo size. This can be overridden by individual form settings', 'ultimate-member' ),
1396
+ 'size' => 'small',
1397
+ ),
1398
+ array(
1399
+ 'id' => 'profile_cover_enabled',
1400
+ 'type' => 'checkbox',
1401
+ 'label' => __( 'Profile Cover Photos', 'ultimate-member' ),
1402
+ 'default' => um_get_metadefault( 'profile_cover_enabled' ),
1403
+ 'tooltip' => __( 'Switch on/off the profile cover photos', 'ultimate-member' ),
1404
+ ),
1405
+ array(
1406
+ 'id' => 'profile_coversize',
1407
+ 'type' => 'select',
1408
+ 'label' => __( 'Profile Cover Size', 'ultimate-member' ),
1409
+ 'default' => um_get_metadefault( 'profile_coversize' ),
1410
+ 'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ),
1411
+ 'tooltip' => __( 'The global default width of cover photo size. This can be overridden by individual form settings', 'ultimate-member' ),
1412
+ 'conditional' => array( 'profile_cover_enabled', '=', 1 ),
1413
+ 'size' => 'small',
1414
+ ),
1415
+ array(
1416
+ 'id' => 'profile_cover_ratio',
1417
+ 'type' => 'select',
1418
+ 'label' => __( 'Profile Cover Ratio', 'ultimate-member' ),
1419
+ 'tooltip' => __( 'Choose global ratio for cover photos of profiles', 'ultimate-member' ),
1420
+ 'default' => um_get_metadefault( 'profile_cover_ratio' ),
1421
+ 'options' => array(
1422
+ '1.6:1' => '1.6:1',
1423
+ '2.7:1' => '2.7:1',
1424
+ '2.2:1' => '2.2:1',
1425
+ '3.2:1' => '3.2:1',
1426
+ ),
1427
+ 'conditional' => array( 'profile_cover_enabled', '=', 1 ),
1428
+ 'size' => 'small',
1429
+ ),
1430
+ array(
1431
+ 'id' => 'profile_show_metaicon',
1432
+ 'type' => 'checkbox',
1433
+ 'label' => __( 'Profile Header Meta Text Icon', 'ultimate-member' ),
1434
+ 'default' => 0,
1435
+ 'tooltip' => __( 'Display field icons for related user meta fields in header or not', 'ultimate-member' ),
1436
+ ),
1437
+ array(
1438
+ 'id' => 'profile_show_name',
1439
+ 'type' => 'checkbox',
1440
+ 'label' => __( 'Show display name in profile header', 'ultimate-member' ),
1441
+ 'default' => um_get_metadefault( 'profile_show_name' ),
1442
+ 'tooltip' => __( 'Switch on/off the user name on profile header', 'ultimate-member' ),
1443
+ ),
1444
+ array(
1445
+ 'id' => 'profile_show_social_links',
1446
+ 'type' => 'checkbox',
1447
+ 'label' => __( 'Show social links in profile header', 'ultimate-member' ),
1448
+ 'default' => um_get_metadefault( 'profile_show_social_links' ),
1449
+ 'tooltip' => __( 'Switch on/off the social links on profile header', 'ultimate-member' ),
1450
+ ),
1451
+ array(
1452
+ 'id' => 'profile_show_bio',
1453
+ 'type' => 'checkbox',
1454
+ 'label' => __( 'Show user description in header', 'ultimate-member' ),
1455
+ 'default' => um_get_metadefault( 'profile_show_bio' ),
1456
+ 'tooltip' => __( 'Switch on/off the user description on profile header', 'ultimate-member' ),
1457
+ ),
1458
+ array(
1459
+ 'id' => 'profile_show_html_bio',
1460
+ 'type' => 'checkbox',
1461
+ 'label' => __( 'Enable HTML support for user description', 'ultimate-member' ),
1462
+ 'tooltip' => __( 'Switch on/off to enable/disable support for html tags on user description.', 'ultimate-member' ),
1463
+ ),
1464
+ array(
1465
+ 'id' => 'profile_bio_maxchars',
1466
+ 'type' => 'text',
1467
+ 'label' => __( 'User description maximum chars', 'ultimate-member' ),
1468
+ 'default' => um_get_metadefault( 'profile_bio_maxchars' ),
1469
+ 'tooltip' => __( 'Maximum number of characters to allow in user description field in header.', 'ultimate-member' ),
1470
+ 'conditional' => array( 'profile_show_bio', '=', 1 ),
1471
+ 'size' => 'small',
1472
+ ),
1473
+ array(
1474
+ 'id' => 'profile_header_menu',
1475
+ 'type' => 'select',
1476
+ 'label' => __( 'Profile Header Menu Position', 'ultimate-member' ),
1477
+ 'default' => um_get_metadefault( 'profile_header_menu' ),
1478
+ 'tooltip' => __( 'For incompatible themes, please make the menu open from left instead of bottom by default.', 'ultimate-member' ),
1479
+ 'options' => array(
1480
+ 'bc' => __( 'Bottom of Icon', 'ultimate-member' ),
1481
+ 'lc' => __( 'Left of Icon (right for RTL)', 'ultimate-member' ),
1482
+ ),
1483
+ 'size' => 'small',
1484
+ ),
1485
+ array(
1486
+ 'id' => 'profile_empty_text',
1487
+ 'type' => 'checkbox',
1488
+ 'label' => __( 'Show a custom message if profile is empty', 'ultimate-member' ),
1489
+ 'default' => um_get_metadefault( 'profile_empty_text' ),
1490
+ 'tooltip' => __( 'Switch on/off the custom message that appears when the profile is empty', 'ultimate-member' ),
1491
+ ),
1492
+ array(
1493
+ 'id' => 'profile_empty_text_emo',
1494
+ 'type' => 'checkbox',
1495
+ 'label' => __( 'Show the emoticon', 'ultimate-member' ),
1496
+ 'default' => um_get_metadefault( 'profile_empty_text_emo' ),
1497
+ 'tooltip' => __( 'Switch on/off the emoticon (sad face) that appears above the message', 'ultimate-member' ),
1498
+ 'conditional' => array( 'profile_empty_text', '=', 1 ),
1499
+ ),
1500
  ),
1501
+ ),
1502
+ 'profile_menu' => array(
1503
+ 'title' => __( 'Profile Menu', 'ultimate-member' ),
1504
+ 'fields' => $appearances_profile_menu_fields,
1505
+ ),
1506
+ 'registration_form' => array(
1507
+ 'title' => __( 'Registration Form', 'ultimate-member' ),
1508
+ 'fields' => array(
1509
+ array(
1510
+ 'id' => 'register_template',
1511
+ 'type' => 'select',
1512
+ 'label' => __( 'Registration Default Template', 'ultimate-member' ),
1513
+ 'tooltip' => __( 'This will be the default template to output registration', 'ultimate-member' ),
1514
+ 'default' => um_get_metadefault( 'register_template' ),
1515
+ 'options' => UM()->shortcodes()->get_templates( 'register' ),
1516
+ 'size' => 'small',
1517
+ ),
1518
+ array(
1519
+ 'id' => 'register_max_width',
1520
+ 'type' => 'text',
1521
+ 'label' => __( 'Registration Maximum Width', 'ultimate-member' ),
1522
+ 'default' => um_get_metadefault( 'register_max_width' ),
1523
+ 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
1524
+ 'size' => 'small',
1525
+ ),
1526
+ array(
1527
+ 'id' => 'register_align',
1528
+ 'type' => 'select',
1529
+ 'label' => __( 'Registration Shortcode Alignment', 'ultimate-member' ),
1530
+ 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
1531
+ 'default' => um_get_metadefault( 'register_align' ),
1532
+ 'options' => array(
1533
+ 'center' => __( 'Centered', 'ultimate-member' ),
1534
+ 'left' => __( 'Left aligned', 'ultimate-member' ),
1535
+ 'right' => __( 'Right aligned', 'ultimate-member' ),
1536
+ ),
1537
+ 'size' => 'small',
1538
+ ),
1539
+ array(
1540
+ 'id' => 'register_icons',
1541
+ 'type' => 'select',
1542
+ 'label' => __( 'Registration Field Icons', 'ultimate-member' ),
1543
+ 'tooltip' => __( 'This controls the display of field icons in the registration form', 'ultimate-member' ),
1544
+ 'default' => um_get_metadefault( 'register_icons' ),
1545
+ 'options' => array(
1546
+ 'field' => __( 'Show inside text field', 'ultimate-member' ),
1547
+ 'label' => __( 'Show with label', 'ultimate-member' ),
1548
+ 'off' => __( 'Turn off', 'ultimate-member' ),
1549
+ ),
1550
+ 'size' => 'small',
1551
+ ),
1552
+ array(
1553
+ 'id' => 'register_primary_btn_word',
1554
+ 'type' => 'text',
1555
+ 'label' => __( 'Registration Primary Button Text', 'ultimate-member' ),
1556
+ 'default' => um_get_metadefault( 'register_primary_btn_word' ),
1557
+ 'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
1558
+ 'size' => 'medium',
1559
+ ),
1560
+ array(
1561
+ 'id' => 'register_secondary_btn',
1562
+ 'type' => 'checkbox',
1563
+ 'label' => __( 'Registration Secondary Button', 'ultimate-member' ),
1564
+ 'default' => 1,
1565
+ 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
1566
+ ),
1567
+ array(
1568
+ 'id' => 'register_secondary_btn_word',
1569
+ 'type' => 'text',
1570
+ 'label' => __( 'Registration Secondary Button Text', 'ultimate-member' ),
1571
+ 'default' => um_get_metadefault( 'register_secondary_btn_word' ),
1572
+ 'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
1573
+ 'conditional' => array( 'register_secondary_btn', '=', 1 ),
1574
+ 'size' => 'medium',
1575
+ ),
1576
+ array(
1577
+ 'id' => 'register_secondary_btn_url',
1578
+ 'type' => 'text',
1579
+ 'label' => __( 'Registration Secondary Button URL', 'ultimate-member' ),
1580
+ 'default' => um_get_metadefault( 'register_secondary_btn_url' ),
1581
+ 'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
1582
+ 'conditional' => array( 'register_secondary_btn', '=', 1 ),
1583
+ 'size' => 'medium',
1584
+ ),
1585
+ array(
1586
+ 'id' => 'register_role',
1587
+ 'type' => 'select',
1588
+ 'label' => __( 'Registration Default Role', 'ultimate-member' ),
1589
+ 'tooltip' => __( 'This will be the default role assigned to users registering thru registration form', 'ultimate-member' ),
1590
+ 'default' => um_get_metadefault( 'register_role' ),
1591
+ 'options' => UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ),
1592
+ 'size' => 'small',
1593
+ ),
1594
  ),
1595
+ ),
1596
+ 'login_form' => array(
1597
+ 'title' => __( 'Login Form', 'ultimate-member' ),
1598
+ 'fields' => array(
1599
+ array(
1600
+ 'id' => 'login_template',
1601
+ 'type' => 'select',
1602
+ 'label' => __( 'Login Default Template', 'ultimate-member' ),
1603
+ 'tooltip' => __( 'This will be the default template to output login', 'ultimate-member' ),
1604
+ 'default' => um_get_metadefault( 'login_template' ),
1605
+ 'options' => UM()->shortcodes()->get_templates( 'login' ),
1606
+ 'size' => 'small',
1607
+ ),
1608
+ array(
1609
+ 'id' => 'login_max_width',
1610
+ 'type' => 'text',
1611
+ 'label' => __( 'Login Maximum Width', 'ultimate-member' ),
1612
+ 'default' => um_get_metadefault( 'login_max_width' ),
1613
+ 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ),
1614
+ 'size' => 'small',
1615
+ ),
1616
+ array(
1617
+ 'id' => 'login_align',
1618
+ 'type' => 'select',
1619
+ 'label' => __( 'Login Shortcode Alignment', 'ultimate-member' ),
1620
+ 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
1621
+ 'default' => um_get_metadefault( 'login_align' ),
1622
+ 'options' => array(
1623
+ 'center' => __( 'Centered', 'ultimate-member' ),
1624
+ 'left' => __( 'Left aligned', 'ultimate-member' ),
1625
+ 'right' => __( 'Right aligned', 'ultimate-member' ),
1626
+ ),
1627
+ 'size' => 'small',
1628
+ ),
1629
+ array(
1630
+ 'id' => 'login_icons',
1631
+ 'type' => 'select',
1632
+ 'label' => __( 'Login Field Icons', 'ultimate-member' ),
1633
+ 'tooltip' => __( 'This controls the display of field icons in the login form', 'ultimate-member' ),
1634
+ 'default' => um_get_metadefault( 'login_icons' ),
1635
+ 'options' => array(
1636
+ 'field' => __( 'Show inside text field', 'ultimate-member' ),
1637
+ 'label' => __( 'Show with label', 'ultimate-member' ),
1638
+ 'off' => __( 'Turn off', 'ultimate-member' ),
1639
+ ),
1640
+ 'size' => 'small',
1641
+ ),
1642
+ array(
1643
+ 'id' => 'login_primary_btn_word',
1644
+ 'type' => 'text',
1645
+ 'label' => __( 'Login Primary Button Text', 'ultimate-member' ),
1646
+ 'default' => um_get_metadefault( 'login_primary_btn_word' ),
1647
+ 'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ),
1648
+ 'size' => 'medium',
1649
+ ),
1650
+ array(
1651
+ 'id' => 'login_secondary_btn',
1652
+ 'type' => 'checkbox',
1653
+ 'label' => __( 'Login Secondary Button', 'ultimate-member' ),
1654
+ 'default' => 1,
1655
+ 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ),
1656
+ ),
1657
+ array(
1658
+ 'id' => 'login_secondary_btn_word',
1659
+ 'type' => 'text',
1660
+ 'label' => __( 'Login Secondary Button Text', 'ultimate-member' ),
1661
+ 'default' => um_get_metadefault( 'login_secondary_btn_word' ),
1662
+ 'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ),
1663
+ 'conditional' => array( 'login_secondary_btn', '=', 1 ),
1664
+ 'size' => 'medium',
1665
+ ),
1666
+ array(
1667
+ 'id' => 'login_secondary_btn_url',
1668
+ 'type' => 'text',
1669
+ 'label' => __( 'Login Secondary Button URL', 'ultimate-member' ),
1670
+ 'default' => um_get_metadefault( 'login_secondary_btn_url' ),
1671
+ 'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ),
1672
+ 'conditional' => array( 'login_secondary_btn', '=', 1 ),
1673
+ 'size' => 'medium',
1674
+ ),
1675
+ array(
1676
+ 'id' => 'login_forgot_pass_link',
1677
+ 'type' => 'checkbox',
1678
+ 'label' => __( 'Login Forgot Password Link', 'ultimate-member' ),
1679
+ 'default' => 1,
1680
+ 'tooltip' => __( 'Switch on/off the forgot password link in login form', 'ultimate-member' ),
1681
+ ),
1682
+ array(
1683
+ 'id' => 'login_show_rememberme',
1684
+ 'type' => 'checkbox',
1685
+ 'label' => __( 'Show "Remember Me"', 'ultimate-member' ),
1686
+ 'default' => 1,
1687
+ 'tooltip' => __( 'Allow users to choose If they want to stay signed in even after closing the browser. If you do not show this option, the default will be to not remember login session.', 'ultimate-member' ),
1688
+ ),
1689
  ),
1690
+ ),
 
 
 
 
 
 
 
 
 
1691
  ),
1692
+ ),
1693
+ 'extensions' => array(
1694
+ 'title' => __( 'Extensions', 'ultimate-member' ),
1695
+ ),
1696
+ 'licenses' => array(
1697
+ 'title' => __( 'Licenses', 'ultimate-member' ),
1698
+ ),
1699
+ 'misc' => array(
1700
+ 'title' => __( 'Misc', 'ultimate-member' ),
1701
+ 'fields' => array(
1702
+ array(
1703
+ 'id' => 'form_asterisk',
1704
+ 'type' => 'checkbox',
1705
+ 'label' => __( 'Show an asterisk for required fields', 'ultimate-member' ),
1706
+ ),
1707
+ array(
1708
+ 'id' => 'profile_title',
1709
+ 'type' => 'text',
1710
+ 'label' => __( 'User Profile Title', 'ultimate-member' ),
1711
+ 'tooltip' => __( 'This is the title that is displayed on a specific user profile', 'ultimate-member' ),
1712
+ 'size' => 'medium',
1713
+ ),
1714
+ array(
1715
+ 'id' => 'profile_desc',
1716
+ 'type' => 'textarea',
1717
+ 'label' => __( 'User Profile Dynamic Meta Description', 'ultimate-member' ),
1718
+ 'tooltip' => __( 'This will be used in the meta description that is available for search-engines.', 'ultimate-member' ),
1719
+ 'args' => array(
1720
+ 'textarea_rows' => 6,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1721
  ),
1722
+ ),
1723
+ array(
1724
+ 'id' => 'um_profile_object_cache_stop',
1725
+ 'type' => 'checkbox',
1726
+ 'label' => __( 'Disable Cache User Profile', 'ultimate-member' ),
1727
+ 'tooltip' => __( 'Check this box if you would like to disable Ultimate Member user\'s cache.', 'ultimate-member' ),
1728
+ ),
1729
+ array(
1730
+ 'id' => 'enable_blocks',
1731
+ 'type' => 'checkbox',
1732
+ 'label' => __( 'Enable Gutenberg Blocks', 'ultimate-member' ),
1733
+ 'tooltip' => __( 'Check this box if you would like to use Ultimate Member blocks in Gutenberg editor. Important some themes have the conflicts with Gutenberg editor.', 'ultimate-member' ),
1734
+ ),
1735
+ array(
1736
+ 'id' => 'rest_api_version',
1737
+ 'type' => 'select',
1738
+ 'label' => __( 'REST API version', 'ultimate-member' ),
1739
+ 'tooltip' => __( 'This controls the REST API version, we recommend to use the last version', 'ultimate-member' ),
1740
+ 'options' => array(
1741
+ '1.0' => __( '1.0 version', 'ultimate-member' ),
1742
+ '2.0' => __( '2.0 version', 'ultimate-member' ),
1743
  ),
1744
+ ),
1745
+ $same_page_update,
1746
+ array(
1747
+ 'id' => 'uninstall_on_delete',
1748
+ 'type' => 'checkbox',
1749
+ 'label' => __( 'Remove Data on Uninstall?', 'ultimate-member' ),
1750
+ 'tooltip' => __( 'Check this box if you would like Ultimate Member to completely remove all of its data when the plugin/extensions are deleted.', 'ultimate-member' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1751
  ),
1752
  ),
1753
+ ),
1754
+ 'install_info' => array(
1755
+ 'title' => __( 'Install Info', 'ultimate-member' ),
1756
+ 'fields' => array(
1757
+ array(
1758
+ 'type' => 'install_info',
1759
+ ),
 
 
 
 
 
 
 
1760
  ),
1761
+ ),
1762
+ )
1763
+ );
1764
 
1765
  }
1766
 
1767
 
1768
  /**
1769
+ * @param array $settings
1770
  *
1771
+ * @return array
1772
  */
1773
+ public function sorting_licenses_options( $settings ) {
1774
  //sorting licenses
1775
  if ( empty( $settings['licenses']['fields'] ) ) {
1776
  return $settings;
1778
 
1779
  $licenses = $settings['licenses']['fields'];
1780
  @uasort( $licenses, function( $a, $b ) {
1781
+ return strnatcasecmp( $a['label'], $b['label'] );
1782
  } );
1783
  $settings['licenses']['fields'] = $licenses;
1784
 
1789
 
1790
  $extensions = $settings['extensions']['sections'];
1791
  @uasort( $extensions, function( $a, $b ) {
1792
+ return strnatcasecmp( $a['title'], $b['title'] );
1793
  } );
1794
 
1795
  $keys = array_keys( $extensions );
1796
+ if ( $keys[0] !== '' ) {
1797
+ $new_key = strtolower( str_replace( ' ', '_', $extensions['']['title'] ) );
1798
+ $temp = $extensions[''];
1799
+ $extensions[ $new_key ] = $temp;
1800
+ $extensions[''] = $extensions[ $keys[0] ];
1801
+ unset( $extensions[ $keys[0] ] );
1802
  @uasort( $extensions, function( $a, $b ) {
1803
+ return strnatcasecmp( $a['title'], $b['title'] );
1804
  } );
1805
  }
1806
 
2040
  $current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
2041
  foreach ( $menu_tabs as $name => $label ) {
2042
  $active = ( $current_tab == $name ) ? 'nav-tab-active' : '';
2043
+ $tabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $name ) ? '' : '&tab=' . $name ) ) ) . '" class="nav-tab ' . esc_attr( $active ) . '">' .
2044
+ $label .
2045
+ '</a>';
2046
  }
2047
 
2048
  break;
2097
  foreach ( $menu_subtabs as $name => $label ) {
2098
  $active = ( $current_subtab == $name ) ? 'current' : '';
2099
  $subtabs .= '<a href="' . esc_url( admin_url( 'admin.php?page=um_options' . ( empty( $current_tab ) ? '' : '&tab=' . $current_tab ) . ( empty( $name ) ? '' : '&section=' . $name ) ) ) . '" class="' . $active . '">'
2100
+ . $label .
2101
+ '</a> | ';
2102
  }
2103
 
2104
  return substr( $subtabs, 0, -3 ) . '</ul></div>';
2112
  */
2113
  function save_settings_handler() {
2114
 
2115
+ if ( isset( $_POST['um-settings-action'] ) && 'save' === sanitize_key( $_POST['um-settings-action'] ) && ! empty( $_POST['um_options'] ) ) {
2116
 
2117
  $nonce = ! empty( $_POST['__umnonce'] ) ? $_POST['__umnonce'] : '';
2118
 
2162
  */
2163
  $settings = apply_filters( 'um_change_settings_before_save', $_POST['um_options'] );
2164
 
2165
+ $settings = UM()->admin()->sanitize_options( $settings );
2166
+
2167
  foreach ( $settings as $key => $value ) {
2168
  UM()->options()->update( $key, $value );
2169
  }
2205
  }
2206
 
2207
 
2208
+ function set_default_if_empty( $settings ) {
2209
+ $tab = '';
2210
+ if ( ! empty( $_GET['tab'] ) ) {
2211
+ $tab = sanitize_key( $_GET['tab'] );
2212
+ }
2213
+
2214
+ $section = '';
2215
+ if ( ! empty( $_GET['section'] ) ) {
2216
+ $section = sanitize_key( $_GET['section'] );
2217
+ }
2218
+
2219
+
2220
+ if ( 'access' === $tab && empty( $section ) ) {
2221
+ if ( ! array_key_exists( 'access_exclude_uris', $settings ) ) {
2222
+ $settings['access_exclude_uris'] = array();
2223
+ }
2224
+ }
2225
+
2226
+ return $settings;
2227
+ }
2228
+
2229
+
2230
  /**
2231
  * Remove empty values from multi text fields
2232
  *
2276
  */
2277
  function check_permalinks_changes() {
2278
  if ( ! empty( $_POST['um_options']['permalink_base'] ) ) {
2279
+ if ( UM()->options()->get( 'permalink_base' ) !== $_POST['um_options']['permalink_base'] ) {
2280
  $this->need_change_permalinks = true;
2281
  }
2282
  }
2395
 
2396
  global $wpdb;
2397
 
2398
+ if ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) {
2399
 
2400
  $results = $wpdb->get_col(
2401
  "SELECT u.ID FROM {$wpdb->users} AS u
2421
  foreach ( $results as $user_id ) {
2422
  $md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
2423
  if ( ! empty( $md_data ) ) {
2424
+ $md_data['hide_in_members'] = ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) ? false : true;
2425
  update_user_meta( $user_id, 'um_member_directory_data', $md_data );
2426
  }
2427
  }
2441
  }
2442
 
2443
  foreach ( $_POST['um_options'] as $key => $value ) {
2444
+ $this->previous_licenses[ sanitize_key( $key ) ] = UM()->options()->get( $key );
2445
  }
2446
  }
2447
 
2455
  }
2456
 
2457
  foreach ( $_POST['um_options'] as $key => $value ) {
2458
+ $key = sanitize_key( $key );
2459
+ $value = sanitize_text_field( $value );
2460
+
2461
  $edd_action = '';
2462
  $license_key = '';
2463
  if ( empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) || ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) && $this->previous_licenses[ $key ] != $value ) ) {
3059
  Force UTF-8 Encoding: <?php if( UM()->options()->get( 'um_force_utf8_strings' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
3060
  JS/CSS Compression: <?php if ( defined('SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
3061
  <?php if( is_multisite() ): ?>
3062
+ Network Structure: <?php echo UM()->options()->get( 'network_permalink_structure' ). "\n"; ?>
3063
  <?php endif; ?>
3064
  Port Forwarding in URL: <?php if( UM()->options()->get( 'um_port_forwarding_url' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
3065
  Exclude CSS/JS on Home: <?php if( UM()->options()->get( 'js_css_exlcude_home' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
3124
  Enable Members Directory: <?php echo $this->info_value( UM()->options()->get('members_page'), 'yesno', true ); ?>
3125
  Use Gravatars: <?php echo $this->info_value( UM()->options()->get('use_gravatars'), 'yesno', true ); ?>
3126
  <?php if( UM()->options()->get('use_gravatars') ): ?>Gravatar builtin image: <?php echo UM()->options()->get('use_um_gravatar_default_builtin_image') . "\n"; ?>
3127
+ UM Avatar as blank Gravatar: <?php echo $this->info_value( UM()->options()->get('use_um_gravatar_default_image'), 'yesno', true ); ?><?php endif; ?>
3128
  Require a strong password: <?php echo $this->info_value( UM()->options()->get('reset_require_strongpass'), 'onoff', true ); ?>
3129
 
3130
 
3182
 
3183
  --- UM Total Users ---
3184
 
3185
+ <?php $result = count_users();
3186
+ echo 'All Users('.$result['total_users'].")\n";
3187
+ foreach( $result['avail_roles'] as $role => $count ) {
3188
+ echo $role."(".$count.")\n";
3189
+ } ?>
3190
 
3191
 
3192
  --- UM Roles ---
3193
 
3194
+ <?php foreach( UM()->roles()->get_roles() as $role_id => $role ) {
3195
+ echo $role." ({$role_id})\n";
3196
+ } ?>
3197
 
3198
 
3199
  --- UM Custom Templates ---
3200
 
3201
+ <?php // Show templates that have been copied to the theme's edd_templates dir
3202
+ $dir = get_stylesheet_directory() . '/ultimate-member/templates/*.php';
3203
+ if ( ! empty( $dir ) ) {
3204
+ $found = glob( $dir );
3205
+ if ( ! empty( $found ) ) {
3206
+ foreach ( glob( $dir ) as $file ) {
3207
+ echo "File: " . $file . "\n";
3208
+ }
3209
+ } else {
3210
+ echo 'N/A'."\n";
3211
+ }
3212
+ } ?>
3213
 
3214
 
3215
  --- UM Email HTML Templates ---
3216
 
3217
+ <?php $dir = get_stylesheet_directory() . '/ultimate-member/templates/emails/*.html';
3218
 
3219
+ if ( ! empty( $dir ) ) {
3220
+ $found = glob( $dir );
3221
+ if ( ! empty( $found ) ){
3222
+ foreach ( glob( $dir ) as $file ) {
3223
+ echo "File: ". $file . "\n";
3224
+ }
3225
+ } else {
3226
+ echo 'N/A'."\n";
3227
+ }
3228
+ } ?>
3229
 
3230
 
3231
  --- Web Server Configurations ---
3271
 
3272
  --- WordPress Active Plugins ---
3273
 
3274
+ <?php $plugins = get_plugins();
3275
+ $active_plugins = get_option( 'active_plugins', array() );
3276
 
3277
+ foreach ( $plugins as $plugin_path => $plugin ) {
3278
+ // If the plugin isn't active, don't show it.
3279
+ if ( ! in_array( $plugin_path, $active_plugins ) )
3280
+ continue;
3281
 
3282
+ echo $plugin['Name'] . ': ' . $plugin['Version'] ."\n";
3283
+ }
3284
 
3285
+ if ( is_multisite() ) { ?>
3286
 
3287
  --- WordPress Network Active Plugins ---
3288
 
3289
+ <?php $plugins = wp_get_active_network_plugins();
3290
+ $active_plugins = get_site_option( 'active_sitewide_plugins', array() );
3291
+
3292
+ foreach ( $plugins as $plugin_path ) {
3293
+ $plugin_base = plugin_basename( $plugin_path );
3294
+
3295
+ // If the plugin isn't active, don't show it.
3296
+ if ( ! array_key_exists( $plugin_base, $active_plugins ) )
3297
+ continue;
3298
+
3299
+ $plugin = get_plugin_data( $plugin_path );
3300
+
3301
+ echo $plugin['Name'] . ' :' . $plugin['Version'] . "\n";
3302
+ }
3303
+
3304
+ }
3305
+
3306
+ /**
3307
+ * UM hook
3308
+ *
3309
+ * @type action
3310
+ * @title um_install_info_after
3311
+ * @description After install info
3312
+ * @change_log
3313
+ * ["Since: 2.0"]
3314
+ * @usage add_action( 'um_install_info_after', 'function_name', 10 );
3315
+ * @example
3316
+ * <?php
3317
+ * add_action( 'um_install_info_after', 'my_install_info_after', 10 );
3318
+ * function my_install_info_after() {
3319
+ * // your code here
3320
+ * }
3321
+ * ?>
3322
+ */
3323
+ do_action( 'um_install_info_after' ); ?>
3324
 
3325
  ### End Install Info ###
3326
+ </textarea>
3327
+ <p class="submit">
3328
+ <input type="hidden" name="um-addon-hook" value="download_install_info" />
3329
+ <?php submit_button( 'Download Install Info File', 'primary', 'download_install_info', false ); ?>
3330
+ </p>
3331
+ </form>
3332
 
3333
+ <?php }
3334
+ }
3335
 
3336
 
3337
  /**
3338
  *
3339
  */
3340
  function um_download_install_info() {
 
3341
  if ( ! empty( $_POST['download_install_info'] ) ) {
3342
  nocache_headers();
3343
 
3344
  header( "Content-type: text/plain" );
3345
  header( 'Content-Disposition: attachment; filename="ultimatemember-install-info.txt"' );
3346
 
3347
+ echo wp_strip_all_tags( sanitize_textarea_field( $_POST['um-install-info'] ) );
3348
  exit;
3349
  }
3350
  }
3372
  /**
3373
  * Render settings section
3374
  *
3375
+ * @param array $section_fields
3376
+ * @param string $current_tab
3377
+ * @param string $current_subtab
3378
+ *
3379
  * @return string
3380
  */
3381
  function render_settings_section( $section_fields, $current_tab, $current_subtab ) {
3394
 
3395
 
3396
  /**
3397
+ * @param array $settings
3398
  *
3399
+ * @return array
3400
  */
3401
  function save_email_templates( $settings ) {
3402
 
3405
  }
3406
 
3407
  $template = $settings['um_email_template'];
3408
+ $content = wp_kses_post( stripslashes( $settings[ $template ] ) );
3409
 
3410
  $theme_template_path = UM()->mail()->get_template_file( 'theme', $template );
3411
 
3425
  return $settings;
3426
  }
3427
  }
3428
+ }
includes/admin/core/class-admin-users.php CHANGED
@@ -306,13 +306,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
306
  * @param $query
307
  * @return mixed
308
  */
309
- function sort_by_newest( $query ) {
310
  global $pagenow;
311
 
312
- if ( is_admin() && $pagenow == 'users.php' ) {
313
  if ( ! isset( $_REQUEST['orderby'] ) ) {
314
- $query->query_vars["order"] = 'desc';
315
- $query->query_orderby = " ORDER BY user_registered " . ( $query->query_vars["order"] == 'desc' ? 'desc ' : 'asc ' ); //set sort order
316
  }
317
  }
318
 
@@ -326,13 +326,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
326
  * @param $query
327
  * @return mixed
328
  */
329
- function filter_users_by_status( $query ) {
330
  global $wpdb, $pagenow;
331
- if ( is_admin() && $pagenow == 'users.php' && ! empty( $_REQUEST['um_status'] ) ) {
332
 
333
  $status = sanitize_key( $_REQUEST['um_status'] );
334
-
335
- if ( $status == 'needs-verification' ) {
336
  $query->query_where = str_replace('WHERE 1=1',
337
  "WHERE 1=1 AND {$wpdb->users}.ID IN (
338
  SELECT {$wpdb->usermeta}.user_id FROM $wpdb->usermeta
@@ -349,7 +349,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
349
  $query->query_where
350
  );
351
  }
352
-
353
  }
354
 
355
  return $query;
@@ -360,9 +359,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
360
  * Add status links to WP Users List Table
361
  *
362
  * @param $views
363
- * @return array|mixed|void
364
  */
365
- function add_status_links( $views ) {
366
  remove_filter( 'pre_user_query', array( &$this, 'filter_users_by_status' ) );
367
 
368
  $old_views = $views;
@@ -375,17 +374,17 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
375
  }
376
 
377
  $status = array(
378
- 'approved' => __( 'Approved', 'ultimate-member' ),
379
- 'awaiting_admin_review' => __( 'Pending review', 'ultimate-member' ),
380
- 'awaiting_email_confirmation' => __( 'Waiting e-mail confirmation', 'ultimate-member' ),
381
- 'inactive' => __( 'Inactive', 'ultimate-member' ),
382
- 'rejected' => __( 'Rejected', 'ultimate-member' )
383
  );
384
 
385
  UM()->query()->count_users_by_status( 'unassigned' );
386
 
387
  foreach ( $status as $k => $v ) {
388
- if ( isset( $_REQUEST['um_status'] ) && sanitize_key( $_REQUEST['um_status'] ) == $k ) {
389
  $current = 'class="current"';
390
  } else {
391
  $current = '';
@@ -429,11 +428,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
429
 
430
  // hide filters with not accessible roles
431
  if ( ! current_user_can( 'administrator' ) ) {
432
- $wp_roles = wp_roles();
433
  $can_view_roles = um_user( 'can_view_roles' );
434
  if ( ! empty( $can_view_roles ) ) {
435
  foreach ( $wp_roles->get_names() as $this_role => $name ) {
436
- if ( ! in_array( $this_role, $can_view_roles ) ) {
437
  unset( $views[ $this_role ] );
438
  }
439
  }
@@ -447,20 +446,20 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
447
  /**
448
  * Bulk user editing actions
449
  */
450
- function um_bulk_users_edit() {
451
  // bulk edit users
452
  if ( ! empty( $_REQUEST['users'] ) && ! empty( $_REQUEST['um_bulkedit'] ) && ! empty( $_REQUEST['um_bulk_action'] ) ) {
453
 
454
  $rolename = UM()->roles()->get_priority_user_role( get_current_user_id() );
455
- $role = get_role( $rolename );
456
 
457
- if ( ! current_user_can( 'edit_users' ) && ! $role->has_cap( 'edit_users' ) ) {
458
- wp_die( __( 'You do not have enough permissions to do that.', 'ultimate-member' ) );
459
  }
460
 
461
  check_admin_referer( 'bulk-users' );
462
 
463
- $users = array_map( 'absint', (array) $_REQUEST['users'] );
464
  $bulk_action = current( array_filter( $_REQUEST['um_bulk_action'] ) );
465
 
466
  foreach ( $users as $user_id ) {
@@ -552,4 +551,4 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
552
  }
553
 
554
  }
555
- }
306
  * @param $query
307
  * @return mixed
308
  */
309
+ public function sort_by_newest( $query ) {
310
  global $pagenow;
311
 
312
+ if ( is_admin() && 'users.php' === $pagenow ) {
313
  if ( ! isset( $_REQUEST['orderby'] ) ) {
314
+ $query->query_vars['order'] = 'desc';
315
+ $query->query_orderby = ' ORDER BY user_registered ' . ( 'desc' === $query->query_vars['order'] ? 'desc ' : 'asc ' ); //set sort order
316
  }
317
  }
318
 
326
  * @param $query
327
  * @return mixed
328
  */
329
+ public function filter_users_by_status( $query ) {
330
  global $wpdb, $pagenow;
331
+ if ( is_admin() && 'users.php' === $pagenow && ! empty( $_REQUEST['um_status'] ) ) {
332
 
333
  $status = sanitize_key( $_REQUEST['um_status'] );
334
+
335
+ if ( 'needs-verification' === $status ) {
336
  $query->query_where = str_replace('WHERE 1=1',
337
  "WHERE 1=1 AND {$wpdb->users}.ID IN (
338
  SELECT {$wpdb->usermeta}.user_id FROM $wpdb->usermeta
349
  $query->query_where
350
  );
351
  }
 
352
  }
353
 
354
  return $query;
359
  * Add status links to WP Users List Table
360
  *
361
  * @param $views
362
+ * @return array
363
  */
364
+ public function add_status_links( $views ) {
365
  remove_filter( 'pre_user_query', array( &$this, 'filter_users_by_status' ) );
366
 
367
  $old_views = $views;
374
  }
375
 
376
  $status = array(
377
+ 'approved' => __( 'Approved', 'ultimate-member' ),
378
+ 'awaiting_admin_review' => __( 'Pending review', 'ultimate-member' ),
379
+ 'awaiting_email_confirmation' => __( 'Waiting e-mail confirmation', 'ultimate-member' ),
380
+ 'inactive' => __( 'Inactive', 'ultimate-member' ),
381
+ 'rejected' => __( 'Rejected', 'ultimate-member' ),
382
  );
383
 
384
  UM()->query()->count_users_by_status( 'unassigned' );
385
 
386
  foreach ( $status as $k => $v ) {
387
+ if ( isset( $_REQUEST['um_status'] ) && sanitize_key( $_REQUEST['um_status'] ) === $k ) {
388
  $current = 'class="current"';
389
  } else {
390
  $current = '';
428
 
429
  // hide filters with not accessible roles
430
  if ( ! current_user_can( 'administrator' ) ) {
431
+ $wp_roles = wp_roles();
432
  $can_view_roles = um_user( 'can_view_roles' );
433
  if ( ! empty( $can_view_roles ) ) {
434
  foreach ( $wp_roles->get_names() as $this_role => $name ) {
435
+ if ( ! in_array( $this_role, $can_view_roles, true ) ) {
436
  unset( $views[ $this_role ] );
437
  }
438
  }
446
  /**
447
  * Bulk user editing actions
448
  */
449
+ public function um_bulk_users_edit() {
450
  // bulk edit users
451
  if ( ! empty( $_REQUEST['users'] ) && ! empty( $_REQUEST['um_bulkedit'] ) && ! empty( $_REQUEST['um_bulk_action'] ) ) {
452
 
453
  $rolename = UM()->roles()->get_priority_user_role( get_current_user_id() );
454
+ $role = get_role( $rolename );
455
 
456
+ if ( ! current_user_can( 'edit_users' ) && ! $role->has_cap( 'edit_users' ) ) {
457
+ wp_die( esc_html__( 'You do not have enough permissions to do that.', 'ultimate-member' ) );
458
  }
459
 
460
  check_admin_referer( 'bulk-users' );
461
 
462
+ $users = array_map( 'absint', (array) $_REQUEST['users'] );
463
  $bulk_action = current( array_filter( $_REQUEST['um_bulk_action'] ) );
464
 
465
  foreach ( $users as $user_id ) {
551
  }
552
 
553
  }
554
+ }
includes/admin/core/list-tables/roles-list-table.php CHANGED
@@ -1,11 +1,13 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit;
 
 
2
 
3
  global $wpdb;
4
 
5
  if ( isset( $_REQUEST['_wp_http_referer'] ) ) {
6
  $redirect = remove_query_arg( array( '_wp_http_referer' ), wp_unslash( $_REQUEST['_wp_http_referer'] ) );
7
  } else {
8
- $redirect = get_admin_url(). 'admin.php?page=um_roles';
9
  }
10
 
11
  global $wp_roles;
@@ -16,9 +18,9 @@ if ( isset( $_GET['action'] ) ) {
16
  case 'delete': {
17
  $role_keys = array();
18
  if ( isset( $_REQUEST['id'] ) ) {
19
- check_admin_referer( 'um_role_delete' . sanitize_key( $_REQUEST['id'] ) . get_current_user_id() );
20
  $role_keys = (array) sanitize_key( $_REQUEST['id'] );
21
- } elseif( isset( $_REQUEST['item'] ) ) {
22
  check_admin_referer( 'bulk-' . sanitize_key( __( 'Roles', 'ultimate-member' ) ) );
23
  $role_keys = array_map( 'sanitize_key', $_REQUEST['item'] );
24
  }
@@ -40,7 +42,7 @@ if ( isset( $_GET['action'] ) ) {
40
  delete_option( "um_role_{$role_key}_meta" );
41
  $um_roles = array_diff( $um_roles, array( $role_key ) );
42
 
43
- $roleID = 'um_' . $role_key;
44
  $um_custom_roles[] = $roleID;
45
 
46
  //check if role exist before removing it
@@ -51,11 +53,11 @@ if ( isset( $_GET['action'] ) ) {
51
 
52
  //set for users with deleted roles role "Subscriber"
53
  $args = array(
54
- 'blog_id' => get_current_blog_id(),
55
- 'role__in' => $um_custom_roles,
56
- 'number' => -1,
57
- 'count_total' => false,
58
- 'fields' => 'ids',
59
  );
60
  $users_to_subscriber = get_users( $args );
61
  if ( ! empty( $users_to_subscriber ) ) {
@@ -70,7 +72,12 @@ if ( isset( $_GET['action'] ) ) {
70
 
71
  //update user role if it's empty
72
  if ( empty( $object_user->roles ) ) {
73
- wp_update_user( array( 'ID' => $user_id, 'role' => 'subscriber' ) );
 
 
 
 
 
74
  }
75
  }
76
  }
@@ -85,7 +92,7 @@ if ( isset( $_GET['action'] ) ) {
85
  if ( isset( $_REQUEST['id'] ) ) {
86
  check_admin_referer( 'um_role_reset' . sanitize_key( $_REQUEST['id'] ) . get_current_user_id() );
87
  $role_keys = (array) sanitize_key( $_REQUEST['id'] );
88
- } elseif( isset( $_REQUEST['item'] ) ) {
89
  check_admin_referer( 'bulk-' . sanitize_key( __( 'Roles', 'ultimate-member' ) ) );
90
  $role_keys = array_map( 'sanitize_key', $_REQUEST['item'] );
91
  }
@@ -98,7 +105,7 @@ if ( isset( $_GET['action'] ) ) {
98
  $role_meta = get_option( "um_role_{$role_key}_meta" );
99
 
100
  if ( ! empty( $role_meta['_um_is_custom'] ) ) {
101
- unset( $role_keys[ array_search( $role_key, $role_keys ) ] );
102
  continue;
103
  }
104
 
@@ -113,14 +120,14 @@ if ( isset( $_GET['action'] ) ) {
113
 
114
  //remove extra query arg
115
  if ( ! empty( $_GET['_wp_http_referer'] ) ) {
116
- um_js_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce'), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
117
  }
118
 
119
  $order_by = 'name';
120
- $order = ( isset( $_GET['order'] ) && 'asc' == strtolower( sanitize_key( $_GET['order'] ) ) ) ? 'ASC' : 'DESC';
121
 
122
  if ( ! class_exists( 'WP_List_Table' ) ) {
123
- require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
124
  }
125
 
126
 
@@ -171,11 +178,11 @@ class UM_Roles_List_Table extends WP_List_Table {
171
  *
172
  * @param array $args
173
  */
174
- function __construct( $args = array() ){
175
  $args = wp_parse_args( $args, array(
176
- 'singular' => __( 'item', 'ultimate-member' ),
177
- 'plural' => __( 'items', 'ultimate-member' ),
178
- 'ajax' => false
179
  ) );
180
 
181
  $this->no_items_message = $args['plural'] . ' ' . __( 'not found.', 'ultimate-member' );
@@ -199,9 +206,9 @@ class UM_Roles_List_Table extends WP_List_Table {
199
  *
200
  */
201
  function prepare_items() {
202
- $columns = $this->get_columns();
203
- $hidden = array();
204
- $sortable = $this->get_sortable_columns();
205
  $this->_column_headers = array( $columns, $hidden, $sortable );
206
  }
207
 
@@ -236,11 +243,11 @@ class UM_Roles_List_Table extends WP_List_Table {
236
  */
237
  function set_sortable_columns( $args = array() ) {
238
  $return_args = array();
239
- foreach( $args as $k=>$val ) {
240
- if( is_numeric( $k ) ) {
241
- $return_args[ $val ] = array( $val, $val == $this->default_sorting_field );
242
- } else if( is_string( $k ) ) {
243
- $return_args[ $k ] = array( $val, $k == $this->default_sorting_field );
244
  } else {
245
  continue;
246
  }
@@ -336,21 +343,21 @@ class UM_Roles_List_Table extends WP_List_Table {
336
  function column_title( $item ) {
337
  $actions = array();
338
 
339
- $actions['edit'] = '<a href="admin.php?page=um_roles&tab=edit&id=' . $item['key'] . '">' . __( 'Edit', 'ultimate-member' ). '</a>';
340
 
341
  if ( ! empty( $item['_um_is_custom'] ) ) {
342
- $actions['delete'] = '<a href="admin.php?page=um_roles&action=delete&id=' . $item['key'] . '&_wpnonce=' . wp_create_nonce( 'um_role_delete' . $item['key'] . get_current_user_id() ) . '" onclick="return confirm( \'' . __( 'Are you sure you want to delete this role?', 'ultimate-member' ) . '\' );">' . __( 'Delete', 'ultimate-member' ). '</a>';
343
  } else {
344
  $role_meta = get_option( "um_role_{$item['key']}_meta" );
345
 
346
  if ( ! empty( $role_meta ) ) {
347
- $actions['reset'] = '<a href="admin.php?page=um_roles&action=reset&id=' . $item['key'] . '&_wpnonce=' . wp_create_nonce( 'um_role_reset' . $item['key'] . get_current_user_id() ) . '" onclick="return confirm( \'' . __( 'Are you sure you want to reset UM role meta?', 'ultimate-member' ) . '\' );">' . __( 'Reset UM Role meta', 'ultimate-member' ). '</a>';
348
  }
349
  }
350
 
351
 
352
 
353
- return sprintf('%1$s %2$s', '<strong><a class="row-title" href="admin.php?page=um_roles&tab=edit&id=' . $item['key'] . '">' . stripslashes( $item['name'] ) . '</a></strong>', $this->row_actions( $actions ) );
354
  }
355
 
356
 
@@ -487,7 +494,7 @@ $ListTable->um_set_pagination_args( array( 'total_items' => count( $roles ), 'pe
487
  </h2>
488
 
489
  <?php if ( ! empty( $_GET['msg'] ) ) {
490
- switch( sanitize_key( $_GET['msg'] ) ) {
491
  case 'd':
492
  echo '<div id="message" class="updated fade"><p>' . __( 'User Role <strong>Deleted</strong> Successfully.', 'ultimate-member' ) . '</p></div>';
493
  break;
@@ -498,4 +505,4 @@ $ListTable->um_set_pagination_args( array( 'total_items' => count( $roles ), 'pe
498
  <input type="hidden" name="page" value="um_roles" />
499
  <?php $ListTable->display(); ?>
500
  </form>
501
- </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
 
5
  global $wpdb;
6
 
7
  if ( isset( $_REQUEST['_wp_http_referer'] ) ) {
8
  $redirect = remove_query_arg( array( '_wp_http_referer' ), wp_unslash( $_REQUEST['_wp_http_referer'] ) );
9
  } else {
10
+ $redirect = get_admin_url() . 'admin.php?page=um_roles';
11
  }
12
 
13
  global $wp_roles;
18
  case 'delete': {
19
  $role_keys = array();
20
  if ( isset( $_REQUEST['id'] ) ) {
21
+ check_admin_referer( 'um_role_delete' . sanitize_key( $_REQUEST['id'] ) . get_current_user_id() );
22
  $role_keys = (array) sanitize_key( $_REQUEST['id'] );
23
+ } elseif ( isset( $_REQUEST['item'] ) ) {
24
  check_admin_referer( 'bulk-' . sanitize_key( __( 'Roles', 'ultimate-member' ) ) );
25
  $role_keys = array_map( 'sanitize_key', $_REQUEST['item'] );
26
  }
42
  delete_option( "um_role_{$role_key}_meta" );
43
  $um_roles = array_diff( $um_roles, array( $role_key ) );
44
 
45
+ $roleID = 'um_' . $role_key;
46
  $um_custom_roles[] = $roleID;
47
 
48
  //check if role exist before removing it
53
 
54
  //set for users with deleted roles role "Subscriber"
55
  $args = array(
56
+ 'blog_id' => get_current_blog_id(),
57
+ 'role__in' => $um_custom_roles,
58
+ 'number' => -1,
59
+ 'count_total' => false,
60
+ 'fields' => 'ids',
61
  );
62
  $users_to_subscriber = get_users( $args );
63
  if ( ! empty( $users_to_subscriber ) ) {
72
 
73
  //update user role if it's empty
74
  if ( empty( $object_user->roles ) ) {
75
+ wp_update_user(
76
+ array(
77
+ 'ID' => $user_id,
78
+ 'role' => 'subscriber',
79
+ )
80
+ );
81
  }
82
  }
83
  }
92
  if ( isset( $_REQUEST['id'] ) ) {
93
  check_admin_referer( 'um_role_reset' . sanitize_key( $_REQUEST['id'] ) . get_current_user_id() );
94
  $role_keys = (array) sanitize_key( $_REQUEST['id'] );
95
+ } elseif ( isset( $_REQUEST['item'] ) ) {
96
  check_admin_referer( 'bulk-' . sanitize_key( __( 'Roles', 'ultimate-member' ) ) );
97
  $role_keys = array_map( 'sanitize_key', $_REQUEST['item'] );
98
  }
105
  $role_meta = get_option( "um_role_{$role_key}_meta" );
106
 
107
  if ( ! empty( $role_meta['_um_is_custom'] ) ) {
108
+ unset( $role_keys[ array_search( $role_key, $role_keys, true ) ] );
109
  continue;
110
  }
111
 
120
 
121
  //remove extra query arg
122
  if ( ! empty( $_GET['_wp_http_referer'] ) ) {
123
+ um_js_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
124
  }
125
 
126
  $order_by = 'name';
127
+ $order = ( isset( $_GET['order'] ) && 'asc' === strtolower( sanitize_key( $_GET['order'] ) ) ) ? 'ASC' : 'DESC';
128
 
129
  if ( ! class_exists( 'WP_List_Table' ) ) {
130
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
131
  }
132
 
133
 
178
  *
179
  * @param array $args
180
  */
181
+ function __construct( $args = array() ) {
182
  $args = wp_parse_args( $args, array(
183
+ 'singular' => __( 'item', 'ultimate-member' ),
184
+ 'plural' => __( 'items', 'ultimate-member' ),
185
+ 'ajax' => false,
186
  ) );
187
 
188
  $this->no_items_message = $args['plural'] . ' ' . __( 'not found.', 'ultimate-member' );
206
  *
207
  */
208
  function prepare_items() {
209
+ $columns = $this->get_columns();
210
+ $hidden = array();
211
+ $sortable = $this->get_sortable_columns();
212
  $this->_column_headers = array( $columns, $hidden, $sortable );
213
  }
214
 
243
  */
244
  function set_sortable_columns( $args = array() ) {
245
  $return_args = array();
246
+ foreach ( $args as $k => $val ) {
247
+ if ( is_numeric( $k ) ) {
248
+ $return_args[ $val ] = array( $val, $val === $this->default_sorting_field );
249
+ } elseif ( is_string( $k ) ) {
250
+ $return_args[ $k ] = array( $val, $k === $this->default_sorting_field );
251
  } else {
252
  continue;
253
  }
343
  function column_title( $item ) {
344
  $actions = array();
345
 
346
+ $actions['edit'] = '<a href="admin.php?page=um_roles&tab=edit&id=' . esc_attr( $item['key'] ) . '">' . __( 'Edit', 'ultimate-member' ) . '</a>';
347
 
348
  if ( ! empty( $item['_um_is_custom'] ) ) {
349
+ $actions['delete'] = '<a href="admin.php?page=um_roles&action=delete&id=' . esc_attr( $item['key'] ) . '&_wpnonce=' . wp_create_nonce( 'um_role_delete' . $item['key'] . get_current_user_id() ) . '" onclick="return confirm( \'' . __( 'Are you sure you want to delete this role?', 'ultimate-member' ) . '\' );">' . __( 'Delete', 'ultimate-member' ) . '</a>';
350
  } else {
351
  $role_meta = get_option( "um_role_{$item['key']}_meta" );
352
 
353
  if ( ! empty( $role_meta ) ) {
354
+ $actions['reset'] = '<a href="admin.php?page=um_roles&action=reset&id=' . esc_attr( $item['key'] ) . '&_wpnonce=' . wp_create_nonce( 'um_role_reset' . $item['key'] . get_current_user_id() ) . '" onclick="return confirm( \'' . __( 'Are you sure you want to reset UM role meta?', 'ultimate-member' ) . '\' );">' . __( 'Reset UM Role meta', 'ultimate-member' ) . '</a>';
355
  }
356
  }
357
 
358
 
359
 
360
+ return sprintf('%1$s %2$s', '<strong><a class="row-title" href="admin.php?page=um_roles&tab=edit&id=' . esc_attr( $item['key'] ) . '">' . stripslashes( $item['name'] ) . '</a></strong>', $this->row_actions( $actions ) );
361
  }
362
 
363
 
494
  </h2>
495
 
496
  <?php if ( ! empty( $_GET['msg'] ) ) {
497
+ switch ( sanitize_key( $_GET['msg'] ) ) {
498
  case 'd':
499
  echo '<div id="message" class="updated fade"><p>' . __( 'User Role <strong>Deleted</strong> Successfully.', 'ultimate-member' ) . '</p></div>';
500
  break;
505
  <input type="hidden" name="page" value="um_roles" />
506
  <?php $ListTable->display(); ?>
507
  </form>
508
+ </div>
includes/admin/core/packages/2.0-beta1/functions.php CHANGED
@@ -32,7 +32,7 @@ function um_upgrade_get_users_per_role20beta1() {
32
  'meta_query' => array(
33
  array(
34
  'key' => 'role',
35
- 'value' => $_POST['key_in_meta']
36
  )
37
  ),
38
  'number' => '',
@@ -62,10 +62,10 @@ function um_upgrade_update_users_per_page20beta1() {
62
  'meta_query' => array(
63
  array(
64
  'key' => 'role',
65
- 'value' => $_POST['key_in_meta']
66
  )
67
  ),
68
- 'paged' => $_POST['page'],
69
  'number' => $users_per_page,
70
  );
71
  $all_users = get_users( $args );
@@ -74,17 +74,17 @@ function um_upgrade_update_users_per_page20beta1() {
74
  foreach ( $all_users as $k => $user ) {
75
  $user_object = get_userdata( $user->ID );
76
 
77
- if ( ! in_array( $_POST['role_key'], $all_wp_roles ) ) {
78
- $user_object->add_role( 'um_' . $_POST['role_key'] );
79
  } else {
80
- if ( ! in_array( $_POST['role_key'], (array) $user_object->roles ) ) {
81
- $user_object->add_role( $_POST['role_key'] );
82
  }
83
  }
84
  }
85
 
86
- $from = ( $_POST['page'] * $users_per_page ) - $users_per_page + 1;
87
- $to = $_POST['page'] * $users_per_page;
88
 
89
  wp_send_json_success( array( 'message' => sprintf( __( 'Users from %s to %s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
90
  } else {
@@ -184,7 +184,7 @@ function um_upgrade_update_forum_per_page20beta1() {
184
  $p_query = new WP_Query;
185
  $bb_forums = $p_query->query( array(
186
  'post_type' => 'forum',
187
- 'paged' => $_POST['page'],
188
  'posts_per_page' => $posts_per_page,
189
  'fields' => 'ids'
190
  ) );
@@ -212,8 +212,8 @@ function um_upgrade_update_forum_per_page20beta1() {
212
  }
213
  }
214
 
215
- $from = ( $_POST['page'] * $posts_per_page ) - $posts_per_page + 1;
216
- $to = $_POST['page'] * $posts_per_page;
217
 
218
  wp_send_json_success( array( 'message' => sprintf( __( 'Forums from %s to %s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
219
  } else {
@@ -250,7 +250,7 @@ function um_upgrade_update_products_per_page20beta1() {
250
  $p_query = new WP_Query;
251
  $wc_products = $p_query->query( array(
252
  'post_type' => 'product',
253
- 'paged' => $_POST['page'],
254
  'posts_per_page' => $posts_per_page,
255
  'fields' => 'ids'
256
  ) );
@@ -299,8 +299,8 @@ function um_upgrade_update_products_per_page20beta1() {
299
  }
300
  }
301
 
302
- $from = ( $_POST['page'] * $posts_per_page ) - $posts_per_page + 1;
303
- $to = $_POST['page'] * $posts_per_page;
304
 
305
  wp_send_json_success( array( 'message' => sprintf( __( 'Woocommerce Products from %s to %s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
306
  } else {
@@ -321,4 +321,4 @@ function um_upgrade_email_templates20beta1() {
321
  delete_option( 'um_roles_associations' );
322
 
323
  wp_send_json_success( array( 'message' => __( 'Email Templates was upgraded successfully', 'ultimate-member' ) ) );
324
- }
32
  'meta_query' => array(
33
  array(
34
  'key' => 'role',
35
+ 'value' => sanitize_key( $_POST['key_in_meta'] ),
36
  )
37
  ),
38
  'number' => '',
62
  'meta_query' => array(
63
  array(
64
  'key' => 'role',
65
+ 'value' => sanitize_key( $_POST['key_in_meta'] ),
66
  )
67
  ),
68
+ 'paged' => absint( $_POST['page'] ),
69
  'number' => $users_per_page,
70
  );
71
  $all_users = get_users( $args );
74
  foreach ( $all_users as $k => $user ) {
75
  $user_object = get_userdata( $user->ID );
76
 
77
+ if ( ! in_array( sanitize_key( $_POST['role_key'] ), $all_wp_roles ) ) {
78
+ $user_object->add_role( 'um_' . sanitize_key( $_POST['role_key'] ) );
79
  } else {
80
+ if ( ! in_array( sanitize_key( $_POST['role_key'] ), (array) $user_object->roles ) ) {
81
+ $user_object->add_role( sanitize_key( $_POST['role_key'] ) );
82
  }
83
  }
84
  }
85
 
86
+ $from = ( absint( $_POST['page'] ) * $users_per_page ) - $users_per_page + 1;
87
+ $to = absint( $_POST['page'] ) * $users_per_page;
88
 
89
  wp_send_json_success( array( 'message' => sprintf( __( 'Users from %s to %s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
90
  } else {
184
  $p_query = new WP_Query;
185
  $bb_forums = $p_query->query( array(
186
  'post_type' => 'forum',
187
+ 'paged' => absint( $_POST['page'] ),
188
  'posts_per_page' => $posts_per_page,
189
  'fields' => 'ids'
190
  ) );
212
  }
213
  }
214
 
215
+ $from = ( absint( $_POST['page'] ) * $posts_per_page ) - $posts_per_page + 1;
216
+ $to = absint( $_POST['page'] ) * $posts_per_page;
217
 
218
  wp_send_json_success( array( 'message' => sprintf( __( 'Forums from %s to %s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
219
  } else {
250
  $p_query = new WP_Query;
251
  $wc_products = $p_query->query( array(
252
  'post_type' => 'product',
253
+ 'paged' => absint( $_POST['page'] ),
254
  'posts_per_page' => $posts_per_page,
255
  'fields' => 'ids'
256
  ) );
299
  }
300
  }
301
 
302
+ $from = ( absint( $_POST['page'] ) * $posts_per_page ) - $posts_per_page + 1;
303
+ $to = absint( $_POST['page'] ) * $posts_per_page;
304
 
305
  wp_send_json_success( array( 'message' => sprintf( __( 'Woocommerce Products from %s to %s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
306
  } else {
321
  delete_option( 'um_roles_associations' );
322
 
323
  wp_send_json_success( array( 'message' => __( 'Email Templates was upgraded successfully', 'ultimate-member' ) ) );
324
+ }
includes/admin/core/packages/2.1.3-beta3/functions.php CHANGED
@@ -36,7 +36,7 @@ function um_upgrade_metadata_per_user213beta3() {
36
  ORDER BY u.ID
37
  LIMIT %d, %d
38
  ) as dt",
39
- ( $_POST['page'] - 1 ) * $per_page,
40
  $per_page
41
  ), ARRAY_A );
42
 
@@ -112,8 +112,8 @@ function um_upgrade_metadata_per_user213beta3() {
112
  }
113
  }
114
 
115
- $from = ( $_POST['page'] * $per_page ) - $per_page + 1;
116
- $to = $_POST['page'] * $per_page;
117
 
118
  wp_send_json_success( array( 'message' => sprintf( __( 'Metadata from %s to %s users were upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
119
  }
@@ -144,4 +144,4 @@ KEY meta_value_indx (um_value(191))
144
 
145
  update_option( 'um_last_version_upgrade', '2.1.3-beta3' );
146
  wp_send_json_success( array( 'message' => __( 'Usermeta table was upgraded successfully', 'ultimate-member' ) ) );
147
- }
36
  ORDER BY u.ID
37
  LIMIT %d, %d
38
  ) as dt",
39
+ ( absint( $_POST['page'] ) - 1 ) * $per_page,
40
  $per_page
41
  ), ARRAY_A );
42
 
112
  }
113
  }
114
 
115
+ $from = ( absint( $_POST['page'] ) * $per_page ) - $per_page + 1;
116
+ $to = absint( $_POST['page'] ) * $per_page;
117
 
118
  wp_send_json_success( array( 'message' => sprintf( __( 'Metadata from %s to %s users were upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
119
  }
144
 
145
  update_option( 'um_last_version_upgrade', '2.1.3-beta3' );
146
  wp_send_json_success( array( 'message' => __( 'Usermeta table was upgraded successfully', 'ultimate-member' ) ) );
147
+ }
includes/admin/templates/directory/appearance.php CHANGED
@@ -1,18 +1,23 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
2
-
 
3
 
4
  <div class="um-admin-metabox">
5
- <?php UM()->admin_forms( array(
6
- 'class' => 'um-member-directory-appearance um-top-label',
7
- 'prefix_id' => 'um_metadata',
8
- 'fields' => array(
9
- array(
10
- 'id' => '_um_directory_template',
11
- 'type' => 'select',
12
- 'label' => __( 'Template', 'ultimate-member' ),
13
- 'value' => UM()->query()->get_meta_value( '_um_directory_template', null, UM()->options()->get( 'directory_template' ) ),
14
- 'options' => UM()->shortcodes()->get_templates( 'members' ),
15
- )
 
 
 
16
  )
17
- ) )->render_form(); ?>
18
- </div>
 
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ } ?>
4
 
5
  <div class="um-admin-metabox">
6
+ <?php
7
+ UM()->admin_forms(
8
+ array(
9
+ 'class' => 'um-member-directory-appearance um-top-label',
10
+ 'prefix_id' => 'um_metadata',
11
+ 'fields' => array(
12
+ array(
13
+ 'id' => '_um_directory_template',
14
+ 'type' => 'select',
15
+ 'label' => __( 'Template', 'ultimate-member' ),
16
+ 'value' => UM()->query()->get_meta_value( '_um_directory_template', null, UM()->options()->get( 'directory_template' ) ),
17
+ 'options' => UM()->shortcodes()->get_templates( 'members' ),
18
+ ),
19
+ ),
20
  )
21
+ )->render_form();
22
+ ?>
23
+ </div>
includes/admin/templates/directory/general.php CHANGED
@@ -1,4 +1,6 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit;
 
 
2
 
3
  global $post_id;
4
 
@@ -7,117 +9,123 @@ $_um_roles_value = empty( $_um_roles_value ) ? array() : $_um_roles_value;
7
 
8
  $show_these_users = get_post_meta( get_the_ID(), '_um_show_these_users', true );
9
  if ( $show_these_users ) {
10
- $show_these_users = implode( "\n", str_replace( "\r", "", $show_these_users ) );
11
  }
12
 
13
  $exclude_these_users = get_post_meta( get_the_ID(), '_um_exclude_these_users', true );
14
  if ( $exclude_these_users ) {
15
- $exclude_these_users = implode( "\n", str_replace( "\r", "", $exclude_these_users ) );
16
  }
17
 
18
  $_um_view_types_value = get_post_meta( $post_id, '_um_view_types', true );
19
  $_um_view_types_value = empty( $_um_view_types_value ) ? array( 'grid', 'list' ) : $_um_view_types_value;
20
 
21
- $view_types_options = array_map( function( $item ) {
22
- return $item['title'];
23
- }, UM()->member_directory()->view_types );
 
 
 
24
 
25
  $conditional = array();
26
  foreach ( $view_types_options as $key => $value ) {
27
  $conditional[] = '_um_view_types_' . $key;
28
- } ?>
29
 
30
- <div class="um-admin-metabox">
31
 
32
- <?php $fields = array(
33
- array(
34
- 'id' => '_um_mode',
35
- 'type' => 'hidden',
36
- 'value' => 'directory',
37
- ),
38
- array(
39
- 'id' => '_um_view_types',
40
- 'type' => 'multi_checkbox',
41
- 'label' => __( 'View type(s)', 'ultimate-member' ),
42
- 'tooltip' => __( 'View type a specific parameter in the directory', 'ultimate-member' ),
43
- 'options' => $view_types_options,
44
- 'columns' => 3,
45
- 'value' => $_um_view_types_value,
46
- 'data' => array( 'fill__um_default_view' => 'checkbox_key' ),
47
- ),
48
- array(
49
- 'id' => '_um_default_view',
50
- 'type' => 'select',
51
- 'label' => __( 'Default view type', 'ultimate-member' ),
52
- 'tooltip' => __( 'Default directory view type', 'ultimate-member' ),
53
- 'options' => $view_types_options,
54
- 'value' => UM()->query()->get_meta_value( '_um_default_view', null, 'grid' ),
55
- 'conditional' => array( implode( '|', $conditional ), '~', 1 )
56
- ),
57
- array(
58
- 'id' => '_um_roles',
59
- 'type' => 'multi_checkbox',
60
- 'label' => __( 'User Roles to Display', 'ultimate-member' ),
61
- 'tooltip' => __( 'If you do not want to show all members, select only user roles to appear in this directory', 'ultimate-member' ),
62
- 'options' => UM()->roles()->get_roles(),
63
- 'columns' => 3,
64
- 'value' => $_um_roles_value,
65
- ),
66
- array(
67
- 'id' => '_um_has_profile_photo',
68
- 'type' => 'checkbox',
69
- 'label' => __( 'Only show members who have uploaded a profile photo', 'ultimate-member' ),
70
- 'tooltip' => __( 'If \'Use Gravatars\' as profile photo is enabled, this option is ignored', 'ultimate-member' ),
71
- 'value' => UM()->query()->get_meta_value( '_um_has_profile_photo' ),
72
- ),
73
- array(
74
- 'id' => '_um_has_cover_photo',
75
- 'type' => 'checkbox',
76
- 'label' => __( 'Only show members who have uploaded a cover photo', 'ultimate-member' ),
77
- 'value' => UM()->query()->get_meta_value( '_um_has_cover_photo' ),
78
- ),
79
- array(
80
- 'id' => '_um_show_these_users',
81
- 'type' => 'textarea',
82
- 'label' => __( 'Only show specific users (Enter one username per line)', 'ultimate-member' ),
83
- 'value' => $show_these_users,
84
- ),
85
- array(
86
- 'id' => '_um_exclude_these_users',
87
- 'type' => 'textarea',
88
- 'label' => __( 'Exclude specific users (Enter one username per line)', 'ultimate-member' ),
89
- 'value' => $exclude_these_users,
90
- ),
91
- );
92
 
93
- /**
94
- * UM hook
95
- *
96
- * @type filter
97
- * @title um_admin_extend_directory_options_general
98
- * @description Extend Directory options fields
99
- * @input_vars
100
- * [{"var":"$fields","type":"array","desc":"Directory options fields"}]
101
- * @change_log
102
- * ["Since: 2.0"]
103
- * @usage add_filter( 'um_admin_directory_sort_users_select', 'function_name', 10, 1 );
104
- * @example
105
- * <?php
106
- * add_filter( 'um_admin_directory_sort_users_select', 'my_directory_sort_users_select', 10, 1 );
107
- * function my_directory_sort_users_select( $sort_types ) {
108
- * // your code here
109
- * return $sort_types;
110
- * }
111
- * ?>
112
- */
113
- $fields = apply_filters( 'um_admin_extend_directory_options_general', $fields );
114
 
115
- UM()->admin_forms( array(
116
- 'class' => 'um-member-directory-general um-half-column',
117
- 'prefix_id' => 'um_metadata',
118
- 'fields' => $fields
119
- ) )->render_form(); ?>
 
 
 
 
 
120
 
121
  <div class="um-admin-clear"></div>
122
-
123
- </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
 
5
  global $post_id;
6
 
9
 
10
  $show_these_users = get_post_meta( get_the_ID(), '_um_show_these_users', true );
11
  if ( $show_these_users ) {
12
+ $show_these_users = implode( "\n", str_replace( "\r", '', $show_these_users ) );
13
  }
14
 
15
  $exclude_these_users = get_post_meta( get_the_ID(), '_um_exclude_these_users', true );
16
  if ( $exclude_these_users ) {
17
+ $exclude_these_users = implode( "\n", str_replace( "\r", '', $exclude_these_users ) );
18
  }
19
 
20
  $_um_view_types_value = get_post_meta( $post_id, '_um_view_types', true );
21
  $_um_view_types_value = empty( $_um_view_types_value ) ? array( 'grid', 'list' ) : $_um_view_types_value;
22
 
23
+ $view_types_options = array_map(
24
+ function( $item ) {
25
+ return $item['title'];
26
+ },
27
+ UM()->member_directory()->view_types
28
+ );
29
 
30
  $conditional = array();
31
  foreach ( $view_types_options as $key => $value ) {
32
  $conditional[] = '_um_view_types_' . $key;
33
+ }
34
 
 
35
 
36
+ $fields = array(
37
+ array(
38
+ 'id' => '_um_mode',
39
+ 'type' => 'hidden',
40
+ 'value' => 'directory',
41
+ ),
42
+ array(
43
+ 'id' => '_um_view_types',
44
+ 'type' => 'multi_checkbox',
45
+ 'label' => __( 'View type(s)', 'ultimate-member' ),
46
+ 'tooltip' => __( 'View type a specific parameter in the directory', 'ultimate-member' ),
47
+ 'options' => $view_types_options,
48
+ 'columns' => 3,
49
+ 'value' => $_um_view_types_value,
50
+ 'data' => array( 'fill__um_default_view' => 'checkbox_key' ),
51
+ ),
52
+ array(
53
+ 'id' => '_um_default_view',
54
+ 'type' => 'select',
55
+ 'label' => __( 'Default view type', 'ultimate-member' ),
56
+ 'tooltip' => __( 'Default directory view type', 'ultimate-member' ),
57
+ 'options' => $view_types_options,
58
+ 'value' => UM()->query()->get_meta_value( '_um_default_view', null, 'grid' ),
59
+ 'conditional' => array( implode( '|', $conditional ), '~', 1 ),
60
+ ),
61
+ array(
62
+ 'id' => '_um_roles',
63
+ 'type' => 'multi_checkbox',
64
+ 'label' => __( 'User Roles to Display', 'ultimate-member' ),
65
+ 'tooltip' => __( 'If you do not want to show all members, select only user roles to appear in this directory', 'ultimate-member' ),
66
+ 'options' => UM()->roles()->get_roles(),
67
+ 'columns' => 3,
68
+ 'value' => $_um_roles_value,
69
+ ),
70
+ array(
71
+ 'id' => '_um_has_profile_photo',
72
+ 'type' => 'checkbox',
73
+ 'label' => __( 'Only show members who have uploaded a profile photo', 'ultimate-member' ),
74
+ 'tooltip' => __( 'If \'Use Gravatars\' as profile photo is enabled, this option is ignored', 'ultimate-member' ),
75
+ 'value' => UM()->query()->get_meta_value( '_um_has_profile_photo' ),
76
+ ),
77
+ array(
78
+ 'id' => '_um_has_cover_photo',
79
+ 'type' => 'checkbox',
80
+ 'label' => __( 'Only show members who have uploaded a cover photo', 'ultimate-member' ),
81
+ 'value' => UM()->query()->get_meta_value( '_um_has_cover_photo' ),
82
+ ),
83
+ array(
84
+ 'id' => '_um_show_these_users',
85
+ 'type' => 'textarea',
86
+ 'label' => __( 'Only show specific users (Enter one username per line)', 'ultimate-member' ),
87
+ 'value' => $show_these_users,
88
+ ),
89
+ array(
90
+ 'id' => '_um_exclude_these_users',
91
+ 'type' => 'textarea',
92
+ 'label' => __( 'Exclude specific users (Enter one username per line)', 'ultimate-member' ),
93
+ 'value' => $exclude_these_users,
94
+ ),
95
+ );
96
 
97
+ /**
98
+ * UM hook
99
+ *
100
+ * @type filter
101
+ * @title um_admin_extend_directory_options_general
102
+ * @description Extend Directory options fields
103
+ * @input_vars
104
+ * [{"var":"$fields","type":"array","desc":"Directory options fields"}]
105
+ * @change_log
106
+ * ["Since: 2.0"]
107
+ * @usage add_filter( 'um_admin_directory_sort_users_select', 'function_name', 10, 1 );
108
+ * @example
109
+ * <?php
110
+ * add_filter( 'um_admin_directory_sort_users_select', 'my_directory_sort_users_select', 10, 1 );
111
+ * function my_directory_sort_users_select( $sort_types ) {
112
+ * // your code here
113
+ * return $sort_types;
114
+ * }
115
+ * ?>
116
+ */
117
+ $fields = apply_filters( 'um_admin_extend_directory_options_general', $fields ); ?>
118
 
119
+ <div class="um-admin-metabox">
120
+ <?php
121
+ UM()->admin_forms(
122
+ array(
123
+ 'class' => 'um-member-directory-general um-half-column',
124
+ 'prefix_id' => 'um_metadata',
125
+ 'fields' => $fields,
126
+ )
127
+ )->render_form();
128
+ ?>
129
 
130
  <div class="um-admin-clear"></div>
131
+ </div>
 
includes/admin/templates/directory/pagination.php CHANGED
@@ -1,68 +1,72 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
2
-
 
3
 
4
  <div class="um-admin-metabox">
5
- <?php UM()->admin_forms( array(
6
- 'class' => 'um-member-directory-pagination um-half-column',
7
- 'prefix_id' => 'um_metadata',
8
- 'fields' => array(
9
- array(
10
- 'id' => '_um_must_search',
11
- 'type' => 'checkbox',
12
- 'label' => __( 'Show results only after search/filtration', 'ultimate-member' ),
13
- 'tooltip' => __( 'If turned on, member results will only appear after search/filter is performed', 'ultimate-member' ),
14
- 'value' => UM()->query()->get_meta_value( '_um_must_search' ),
15
- 'conditional' => array( '_um_search||_um_filters', '=', 1 ),
16
- ),
17
- array(
18
- 'id' => '_um_max_users',
19
- 'type' => 'number',
20
- 'label' => __( 'Maximum number of profiles', 'ultimate-member' ),
21
- 'tooltip' => __( 'Use this setting to control the maximum number of profiles to appear in this directory. Leave blank to disable this limit', 'ultimate-member' ),
22
- 'value' => UM()->query()->get_meta_value( '_um_max_users', null, 'na' ),
23
- 'size' => 'small'
24
- ),
25
- array(
26
- 'id' => '_um_profiles_per_page',
27
- 'type' => 'number',
28
- 'label' => __( 'Number of profiles per page', 'ultimate-member' ),
29
- 'tooltip' => __( 'Number of profiles to appear on page for standard users', 'ultimate-member' ),
30
- 'value' => UM()->query()->get_meta_value( '_um_profiles_per_page', null, 12 ),
31
- 'size' => 'small'
32
- ),
33
- array(
34
- 'id' => '_um_profiles_per_page_mobile',
35
- 'type' => 'number',
36
- 'label' => __( 'Number of profiles per page (for Mobiles & Tablets)', 'ultimate-member' ),
37
- 'tooltip' => __( 'Number of profiles to appear on page for mobile users', 'ultimate-member' ),
38
- 'value' => UM()->query()->get_meta_value( '_um_profiles_per_page_mobile', null, 8 ),
39
- 'size' => 'small'
40
- ),
41
- array(
42
- 'id' => '_um_directory_header',
43
- 'type' => 'text',
44
- 'label' => __( 'Results Text', 'ultimate-member' ),
45
- 'tooltip' => __( 'Customize the search result text . e.g. Found 3,000 Members. Leave this blank to not show result text', 'ultimate-member' ),
46
- 'description' => __( 'You could use {total_users} placeholder for getting users count', 'ultimate-member' ),
47
- 'value' => UM()->query()->get_meta_value('_um_directory_header', null, 'na' ),
48
- ),
49
- array(
50
- 'id' => '_um_directory_header_single',
51
- 'type' => 'text',
52
- 'label' => __( 'Single Result Text', 'ultimate-member' ),
53
- 'tooltip' => __( 'Same as above but in case of 1 user found only', 'ultimate-member' ),
54
- 'description' => __( 'You could use {total_users} placeholder for getting users count', 'ultimate-member' ),
55
- 'value' => UM()->query()->get_meta_value('_um_directory_header_single', null, 'na' ),
56
- ),
57
- array(
58
- 'id' => '_um_directory_no_users',
59
- 'type' => 'text',
60
- 'label' => __( 'Custom text if no users were found', 'ultimate-member' ),
61
- 'tooltip' => __( 'This is the text that is displayed if no users are found during a search', 'ultimate-member' ),
62
- 'value' => UM()->query()->get_meta_value('_um_directory_no_users', null, 'na' ),
 
 
 
63
  ),
64
  )
65
- ) )->render_form(); ?>
66
-
67
  <div class="um-admin-clear"></div>
68
- </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ } ?>
4
 
5
  <div class="um-admin-metabox">
6
+ <?php
7
+ UM()->admin_forms(
8
+ array(
9
+ 'class' => 'um-member-directory-pagination um-half-column',
10
+ 'prefix_id' => 'um_metadata',
11
+ 'fields' => array(
12
+ array(
13
+ 'id' => '_um_must_search',
14
+ 'type' => 'checkbox',
15
+ 'label' => __( 'Show results only after search/filtration', 'ultimate-member' ),
16
+ 'tooltip' => __( 'If turned on, member results will only appear after search/filter is performed', 'ultimate-member' ),
17
+ 'value' => UM()->query()->get_meta_value( '_um_must_search' ),
18
+ 'conditional' => array( '_um_search||_um_filters', '=', 1 ),
19
+ ),
20
+ array(
21
+ 'id' => '_um_max_users',
22
+ 'type' => 'number',
23
+ 'label' => __( 'Maximum number of profiles', 'ultimate-member' ),
24
+ 'tooltip' => __( 'Use this setting to control the maximum number of profiles to appear in this directory. Leave blank to disable this limit', 'ultimate-member' ),
25
+ 'value' => UM()->query()->get_meta_value( '_um_max_users', null, 'na' ),
26
+ 'size' => 'small',
27
+ ),
28
+ array(
29
+ 'id' => '_um_profiles_per_page',
30
+ 'type' => 'number',
31
+ 'label' => __( 'Number of profiles per page', 'ultimate-member' ),
32
+ 'tooltip' => __( 'Number of profiles to appear on page for standard users', 'ultimate-member' ),
33
+ 'value' => UM()->query()->get_meta_value( '_um_profiles_per_page', null, 12 ),
34
+ 'size' => 'small',
35
+ ),
36
+ array(
37
+ 'id' => '_um_profiles_per_page_mobile',
38
+ 'type' => 'number',
39
+ 'label' => __( 'Number of profiles per page (for Mobiles & Tablets)', 'ultimate-member' ),
40
+ 'tooltip' => __( 'Number of profiles to appear on page for mobile users', 'ultimate-member' ),
41
+ 'value' => UM()->query()->get_meta_value( '_um_profiles_per_page_mobile', null, 8 ),
42
+ 'size' => 'small',
43
+ ),
44
+ array(
45
+ 'id' => '_um_directory_header',
46
+ 'type' => 'text',
47
+ 'label' => __( 'Results Text', 'ultimate-member' ),
48
+ 'tooltip' => __( 'Customize the search result text . e.g. Found 3,000 Members. Leave this blank to not show result text', 'ultimate-member' ),
49
+ 'description' => __( 'You could use {total_users} placeholder for getting users count', 'ultimate-member' ),
50
+ 'value' => UM()->query()->get_meta_value( '_um_directory_header', null, 'na' ),
51
+ ),
52
+ array(
53
+ 'id' => '_um_directory_header_single',
54
+ 'type' => 'text',
55
+ 'label' => __( 'Single Result Text', 'ultimate-member' ),
56
+ 'tooltip' => __( 'Same as above but in case of 1 user found only', 'ultimate-member' ),
57
+ 'description' => __( 'You could use {total_users} placeholder for getting users count', 'ultimate-member' ),
58
+ 'value' => UM()->query()->get_meta_value( '_um_directory_header_single', null, 'na' ),
59
+ ),
60
+ array(
61
+ 'id' => '_um_directory_no_users',
62
+ 'type' => 'text',
63
+ 'label' => __( 'Custom text if no users were found', 'ultimate-member' ),
64
+ 'tooltip' => __( 'This is the text that is displayed if no users are found during a search', 'ultimate-member' ),
65
+ 'value' => UM()->query()->get_meta_value( '_um_directory_no_users', null, 'na' ),
66
+ ),
67
  ),
68
  )
69
+ )->render_form();
70
+ ?>
71
  <div class="um-admin-clear"></div>
72
+ </div>
includes/admin/templates/directory/profile.php CHANGED
@@ -1,117 +1,120 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
 
 
2
 
 
 
 
 
3
 
4
- <div class="um-admin-metabox">
 
 
5
 
6
- <?php $user_fields = array();
7
- foreach ( UM()->builtin()->all_user_fields() as $key => $arr ) {
8
- $user_fields[ $key ] = isset( $arr['title'] ) ? $arr['title'] : '';
9
- }
10
 
11
- $post_id = get_the_ID();
12
- $_um_tagline_fields = get_post_meta( $post_id, '_um_tagline_fields', true );
13
- $_um_reveal_fields = get_post_meta( $post_id, '_um_reveal_fields', true );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
 
16
- $fields = array(
17
- array(
18
- 'id' => '_um_profile_photo',
19
- 'type' => 'checkbox',
20
- 'label' => __( 'Enable Profile Photo', 'ultimate-member' ),
21
- 'value' => UM()->query()->get_meta_value( '_um_profile_photo', null, 1 ),
22
- ),
23
- array(
24
- 'id' => '_um_cover_photos',
25
- 'type' => 'checkbox',
26
- 'label' => __( 'Enable Cover Photo', 'ultimate-member' ),
27
- 'tooltip' => __( 'If turned on, the users cover photo will appear in the directory', 'ultimate-member' ),
28
- 'value' => UM()->query()->get_meta_value( '_um_cover_photos', null, 1 ),
29
- ),
30
- array(
31
- 'id' => '_um_show_name',
32
- 'type' => 'checkbox',
33
- 'label' => __( 'Show display name', 'ultimate-member' ),
34
- 'value' => UM()->query()->get_meta_value( '_um_show_name', null, 1 ),
35
- ),
36
- array(
37
- 'id' => '_um_show_tagline',
38
- 'type' => 'checkbox',
39
- 'label' => __( 'Show tagline below profile name', 'ultimate-member' ),
40
- 'value' => UM()->query()->get_meta_value( '_um_show_tagline' ),
41
- ),
42
- array(
43
- 'id' => '_um_tagline_fields',
44
- 'type' => 'multi_selects',
45
- 'label' => __( 'Choose field(s) to display in tagline', 'ultimate-member' ),
46
- 'value' => $_um_tagline_fields,
47
- 'conditional' => array( '_um_show_tagline', '=', 1 ),
48
- 'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
49
- 'options' => $user_fields,
50
- 'show_default_number' => 1,
51
- 'sorting' => true,
52
- ),
53
- array(
54
- 'id' => '_um_show_userinfo',
55
- 'type' => 'checkbox',
56
- 'label' => __( 'Show extra user information below tagline?', 'ultimate-member' ),
57
- 'value' => UM()->query()->get_meta_value( '_um_show_userinfo' ),
58
- ),
59
- array(
60
- 'id' => '_um_reveal_fields',
61
- 'type' => 'multi_selects',
62
- 'label' => __( 'Choose field(s) to display in extra user information section', 'ultimate-member' ),
63
- 'value' => $_um_reveal_fields,
64
- 'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
65
- 'conditional' => array( '_um_show_userinfo', '=', 1 ),
66
- 'options' => $user_fields,
67
- 'show_default_number' => 1,
68
- 'sorting' => true,
69
- ),
70
- array(
71
- 'id' => '_um_show_social',
72
- 'type' => 'checkbox',
73
- 'label' => __( 'Show social connect icons in extra user information section', 'ultimate-member' ),
74
- 'value' => UM()->query()->get_meta_value( '_um_show_social' ),
75
- 'conditional' => array( '_um_show_userinfo', '=', 1 )
76
- ),
77
- array(
78
- 'id' => '_um_userinfo_animate',
79
- 'type' => 'checkbox',
80
- 'label' => __( 'Hide extra user information to the reveal section', 'ultimate-member' ),
81
- 'tooltip' => __( 'If not checked always shown', 'ultimate-member' ),
82
- 'value' => UM()->query()->get_meta_value( '_um_userinfo_animate' ),
83
- 'conditional' => array( '_um_show_userinfo', '=', 1 )
84
- ),
85
- );
86
-
87
-
88
- /**
89
- * UM hook
90
- *
91
- * @type filter
92
- * @title um_admin_extend_directory_options_general
93
- * @description Extend Directory options fields
94
- * @input_vars
95
- * [{"var":"$fields","type":"array","desc":"Directory options fields"}]
96
- * @change_log
97
- * ["Since: 2.0"]
98
- * @usage add_filter( 'um_admin_directory_sort_users_select', 'function_name', 10, 1 );
99
- * @example
100
- * <?php
101
- * add_filter( 'um_admin_directory_sort_users_select', 'my_directory_sort_users_select', 10, 1 );
102
- * function my_directory_sort_users_select( $sort_types ) {
103
- * // your code here
104
- * return $sort_types;
105
- * }
106
- * ?>
107
- */
108
- $fields = apply_filters( 'um_admin_extend_directory_options_profile', $fields );
109
-
110
- UM()->admin_forms( array(
111
- 'class' => 'um-member-directory-profile um-half-column',
112
- 'prefix_id' => 'um_metadata',
113
- 'fields' => $fields,
114
- ) )->render_form(); ?>
115
 
 
 
 
 
 
 
 
 
 
 
116
  <div class="um-admin-clear"></div>
117
- </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
 
5
+ $user_fields = array();
6
+ foreach ( UM()->builtin()->all_user_fields() as $key => $arr ) {
7
+ $user_fields[ $key ] = isset( $arr['title'] ) ? $arr['title'] : '';
8
+ }
9
 
10
+ $post_id = get_the_ID();
11
+ $_um_tagline_fields = get_post_meta( $post_id, '_um_tagline_fields', true );
12
+ $_um_reveal_fields = get_post_meta( $post_id, '_um_reveal_fields', true );
13
 
 
 
 
 
14
 
15
+ $fields = array(
16
+ array(
17
+ 'id' => '_um_profile_photo',
18
+ 'type' => 'checkbox',
19
+ 'label' => __( 'Enable Profile Photo', 'ultimate-member' ),
20
+ 'value' => UM()->query()->get_meta_value( '_um_profile_photo' ),
21
+ ),
22
+ array(
23
+ 'id' => '_um_cover_photos',
24
+ 'type' => 'checkbox',
25
+ 'label' => __( 'Enable Cover Photo', 'ultimate-member' ),
26
+ 'tooltip' => __( 'If turned on, the users cover photo will appear in the directory', 'ultimate-member' ),
27
+ 'value' => UM()->query()->get_meta_value( '_um_cover_photos' ),
28
+ ),
29
+ array(
30
+ 'id' => '_um_show_name',
31
+ 'type' => 'checkbox',
32
+ 'label' => __( 'Show display name', 'ultimate-member' ),
33
+ 'value' => UM()->query()->get_meta_value( '_um_show_name' ),
34
+ ),
35
+ array(
36
+ 'id' => '_um_show_tagline',
37
+ 'type' => 'checkbox',
38
+ 'label' => __( 'Show tagline below profile name', 'ultimate-member' ),
39
+ 'value' => UM()->query()->get_meta_value( '_um_show_tagline' ),
40
+ ),
41
+ array(
42
+ 'id' => '_um_tagline_fields',
43
+ 'type' => 'multi_selects',
44
+ 'label' => __( 'Choose field(s) to display in tagline', 'ultimate-member' ),
45
+ 'value' => $_um_tagline_fields,
46
+ 'conditional' => array( '_um_show_tagline', '=', 1 ),
47
+ 'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
48
+ 'options' => $user_fields,
49
+ 'show_default_number' => 1,
50
+ 'sorting' => true,
51
+ ),
52
+ array(
53
+ 'id' => '_um_show_userinfo',
54
+ 'type' => 'checkbox',
55
+ 'label' => __( 'Show extra user information below tagline?', 'ultimate-member' ),
56
+ 'value' => UM()->query()->get_meta_value( '_um_show_userinfo' ),
57
+ ),
58
+ array(
59
+ 'id' => '_um_reveal_fields',
60
+ 'type' => 'multi_selects',
61
+ 'label' => __( 'Choose field(s) to display in extra user information section', 'ultimate-member' ),
62
+ 'value' => $_um_reveal_fields,
63
+ 'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
64
+ 'conditional' => array( '_um_show_userinfo', '=', 1 ),
65
+ 'options' => $user_fields,
66
+ 'show_default_number' => 1,
67
+ 'sorting' => true,
68
+ ),
69
+ array(
70
+ 'id' => '_um_show_social',
71
+ 'type' => 'checkbox',
72
+ 'label' => __( 'Show social connect icons in extra user information section', 'ultimate-member' ),
73
+ 'value' => UM()->query()->get_meta_value( '_um_show_social' ),
74
+ 'conditional' => array( '_um_show_userinfo', '=', 1 ),
75
+ ),
76
+ array(
77
+ 'id' => '_um_userinfo_animate',
78
+ 'type' => 'checkbox',
79
+ 'label' => __( 'Hide extra user information to the reveal section', 'ultimate-member' ),
80
+ 'tooltip' => __( 'If not checked always shown', 'ultimate-member' ),
81
+ 'value' => UM()->query()->get_meta_value( '_um_userinfo_animate' ),
82
+ 'conditional' => array( '_um_show_userinfo', '=', 1 ),
83
+ ),
84
+ );
85
 
86
 
87
+ /**
88
+ * UM hook
89
+ *
90
+ * @type filter
91
+ * @title um_admin_extend_directory_options_general
92
+ * @description Extend Directory options fields
93
+ * @input_vars
94
+ * [{"var":"$fields","type":"array","desc":"Directory options fields"}]
95
+ * @change_log
96
+ * ["Since: 2.0"]
97
+ * @usage add_filter( 'um_admin_directory_sort_users_select', 'function_name', 10, 1 );
98
+ * @example
99
+ * <?php
100
+ * add_filter( 'um_admin_directory_sort_users_select', 'my_directory_sort_users_select', 10, 1 );
101
+ * function my_directory_sort_users_select( $sort_types ) {
102
+ * // your code here
103
+ * return $sort_types;
104
+ * }
105
+ * ?>
106
+ */
107
+ $fields = apply_filters( 'um_admin_extend_directory_options_profile', $fields ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
+ <div class="um-admin-metabox">
110
+ <?php
111
+ UM()->admin_forms(
112
+ array(
113
+ 'class' => 'um-member-directory-profile um-half-column',
114
+ 'prefix_id' => 'um_metadata',
115
+ 'fields' => $fields,
116
+ )
117
+ )->render_form();
118
+ ?>
119
  <div class="um-admin-clear"></div>
120
+ </div>
includes/admin/templates/directory/search.php CHANGED
@@ -1,97 +1,100 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit;
 
 
2
 
3
- global $post_id; ?>
4
 
 
 
5
 
6
- <div class="um-admin-metabox">
7
- <?php
8
 
9
- $_um_roles_search_value = get_post_meta( $post_id, '_um_roles_can_search', true );
10
- $_um_roles_search_value = empty( $_um_roles_search_value ) ? array() : $_um_roles_search_value;
11
 
12
- $_um_roles_filter_value = get_post_meta( $post_id, '_um_roles_can_filter', true );
13
- $_um_roles_filter_value = empty( $_um_roles_filter_value ) ? array() : $_um_roles_filter_value;
14
 
15
- $_um_search_fields = get_post_meta( $post_id, '_um_search_fields', true );
16
- $_um_search_filters = get_post_meta( $post_id, '_um_search_filters', true );
17
-
18
- UM()->admin_forms( array(
19
- 'class' => 'um-member-directory-search um-half-column',
20
- 'prefix_id' => 'um_metadata',
21
- 'fields' => array(
22
- array(
23
- 'id' => '_um_search',
24
- 'type' => 'checkbox',
25
- 'label' => __( 'Enable Search feature', 'ultimate-member' ),
26
- 'tooltip' => __( 'If turned on, users will be able to search members in this directory', 'ultimate-member' ),
27
- 'value' => UM()->query()->get_meta_value( '_um_search' ),
28
- ),
29
- array(
30
- 'id' => '_um_roles_can_search',
31
- 'type' => 'multi_checkbox',
32
- 'label' => __( 'User Roles that can use search', 'ultimate-member' ),
33
- 'tooltip' => __( 'If you want to allow specific user roles to be able to search only', 'ultimate-member' ),
34
- 'value' => $_um_roles_search_value,
35
- 'options' => UM()->roles()->get_roles(),
36
- 'columns' => 3,
37
- 'conditional' => array( '_um_search', '=', 1 )
38
- ),
39
- array(
40
- 'id' => '_um_filters',
41
- 'type' => 'checkbox',
42
- 'label' => __( 'Enable Filters feature', 'ultimate-member' ),
43
- 'tooltip' => __( 'If turned on, users will be able to filter members in this directory', 'ultimate-member' ),
44
- 'value' => UM()->query()->get_meta_value( '_um_filters' ),
45
- ),
46
- array(
47
- 'id' => '_um_roles_can_filter',
48
- 'type' => 'multi_checkbox',
49
- 'label' => __( 'User Roles that can use filters', 'ultimate-member' ),
50
- 'tooltip' => __( 'If you want to allow specific user roles to be able to filter only', 'ultimate-member' ),
51
- 'value' => $_um_roles_filter_value,
52
- 'options' => UM()->roles()->get_roles(),
53
- 'columns' => 3,
54
- 'conditional' => array( '_um_filters', '=', 1 )
55
- ),
56
- array(
57
- 'id' => '_um_search_fields',
58
- 'type' => 'multi_selects',
59
- 'label' => __( 'Choose filter(s) meta to enable', 'ultimate-member' ),
60
- 'value' => $_um_search_fields,
61
- 'conditional' => array( '_um_filters', '=', 1 ),
62
- 'options' => UM()->member_directory()->filter_fields,
63
- 'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
64
- 'show_default_number' => 1,
65
- 'sorting' => true,
66
- ),
67
- array(
68
- 'id' => '_um_filters_expanded',
69
- 'type' => 'checkbox',
70
- 'label' => __( 'Expand the filter bar by default', 'ultimate-member' ),
71
- 'tooltip' => __( 'If turned on, filters bar will be visible after a page loading', 'ultimate-member' ),
72
- 'value' => UM()->query()->get_meta_value( '_um_filters_expanded' ),
73
- 'conditional' => array( '_um_filters', '=', 1 )
74
- ),
75
- array(
76
- 'id' => '_um_filters_is_collapsible',
77
- 'type' => 'checkbox',
78
- 'label' => __( 'Can filter bar be collapsed', 'ultimate-member' ),
79
- 'tooltip' => __( 'If turned on, filters bar can be collapsed after a page loading', 'ultimate-member' ),
80
- 'value' => UM()->query()->get_meta_value( '_um_filters_is_collapsible' ),
81
- 'conditional' => array( '_um_filters_expanded', '=', 1 )
82
- ),
83
- array(
84
- 'id' => '_um_search_filters',
85
- 'type' => 'md_default_filters',
86
- 'label' => __( 'Admin filtering', 'ultimate-member' ),
87
- 'tooltip' => __( 'Limit which users appear in the member directory e.g only display users from USA', 'ultimate-member' ),
88
- 'value' => $_um_search_filters,
89
- 'options' => UM()->member_directory()->filter_fields,
90
- 'add_text' => __( 'Add New Filter', 'ultimate-member' ),
91
- 'show_default_number' => 0,
 
92
  ),
93
  )
94
- ) )->render_form(); ?>
95
-
96
  <div class="um-admin-clear"></div>
97
- </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
 
5
+ global $post_id;
6
 
7
+ $_um_roles_search_value = get_post_meta( $post_id, '_um_roles_can_search', true );
8
+ $_um_roles_search_value = empty( $_um_roles_search_value ) ? array() : $_um_roles_search_value;
9
 
10
+ $_um_roles_filter_value = get_post_meta( $post_id, '_um_roles_can_filter', true );
11
+ $_um_roles_filter_value = empty( $_um_roles_filter_value ) ? array() : $_um_roles_filter_value;
12
 
13
+ $_um_search_fields = get_post_meta( $post_id, '_um_search_fields', true );
14
+ $_um_search_filters = get_post_meta( $post_id, '_um_search_filters', true ); ?>
15
 
 
 
16
 
17
+ <div class="um-admin-metabox">
18
+ <?php
19
+ UM()->admin_forms(
20
+ array(
21
+ 'class' => 'um-member-directory-search um-half-column',
22
+ 'prefix_id' => 'um_metadata',
23
+ 'fields' => array(
24
+ array(
25
+ 'id' => '_um_search',
26
+ 'type' => 'checkbox',
27
+ 'label' => __( 'Enable Search feature', 'ultimate-member' ),
28
+ 'tooltip' => __( 'If turned on, users will be able to search members in this directory', 'ultimate-member' ),
29
+ 'value' => UM()->query()->get_meta_value( '_um_search' ),
30
+ ),
31
+ array(
32
+ 'id' => '_um_roles_can_search',
33
+ 'type' => 'multi_checkbox',
34
+ 'label' => __( 'User Roles that can use search', 'ultimate-member' ),
35
+ 'tooltip' => __( 'If you want to allow specific user roles to be able to search only', 'ultimate-member' ),
36
+ 'value' => $_um_roles_search_value,
37
+ 'options' => UM()->roles()->get_roles(),
38
+ 'columns' => 3,
39
+ 'conditional' => array( '_um_search', '=', 1 ),
40
+ ),
41
+ array(
42
+ 'id' => '_um_filters',
43
+ 'type' => 'checkbox',
44
+ 'label' => __( 'Enable Filters feature', 'ultimate-member' ),
45
+ 'tooltip' => __( 'If turned on, users will be able to filter members in this directory', 'ultimate-member' ),
46
+ 'value' => UM()->query()->get_meta_value( '_um_filters' ),
47
+ ),
48
+ array(
49
+ 'id' => '_um_roles_can_filter',
50
+ 'type' => 'multi_checkbox',
51
+ 'label' => __( 'User Roles that can use filters', 'ultimate-member' ),
52
+ 'tooltip' => __( 'If you want to allow specific user roles to be able to filter only', 'ultimate-member' ),
53
+ 'value' => $_um_roles_filter_value,
54
+ 'options' => UM()->roles()->get_roles(),
55
+ 'columns' => 3,
56
+ 'conditional' => array( '_um_filters', '=', 1 ),
57
+ ),
58
+ array(
59
+ 'id' => '_um_search_fields',
60
+ 'type' => 'multi_selects',
61
+ 'label' => __( 'Choose filter(s) meta to enable', 'ultimate-member' ),
62
+ 'value' => $_um_search_fields,
63
+ 'conditional' => array( '_um_filters', '=', 1 ),
64
+ 'options' => UM()->member_directory()->filter_fields,
65
+ 'add_text' => __( 'Add New Custom Field', 'ultimate-member' ),
66
+ 'show_default_number' => 0,
67
+ 'sorting' => true,
68
+ ),
69
+ array(
70
+ 'id' => '_um_filters_expanded',
71
+ 'type' => 'checkbox',
72
+ 'label' => __( 'Expand the filter bar by default', 'ultimate-member' ),
73
+ 'tooltip' => __( 'If turned on, filters bar will be visible after a page loading', 'ultimate-member' ),
74
+ 'value' => UM()->query()->get_meta_value( '_um_filters_expanded' ),
75
+ 'conditional' => array( '_um_filters', '=', 1 ),
76
+ ),
77
+ array(
78
+ 'id' => '_um_filters_is_collapsible',
79
+ 'type' => 'checkbox',
80
+ 'label' => __( 'Can filter bar be collapsed', 'ultimate-member' ),
81
+ 'tooltip' => __( 'If turned on, filters bar can be collapsed after a page loading', 'ultimate-member' ),
82
+ 'value' => UM()->query()->get_meta_value( '_um_filters_is_collapsible' ),
83
+ 'conditional' => array( '_um_filters_expanded', '=', 1 ),
84
+ ),
85
+ array(
86
+ 'id' => '_um_search_filters',
87
+ 'type' => 'md_default_filters',
88
+ 'label' => __( 'Admin filtering', 'ultimate-member' ),
89
+ 'tooltip' => __( 'Limit which users appear in the member directory e.g only display users from USA', 'ultimate-member' ),
90
+ 'value' => $_um_search_filters,
91
+ 'options' => UM()->member_directory()->filter_fields,
92
+ 'add_text' => __( 'Add New Filter', 'ultimate-member' ),
93
+ 'show_default_number' => 0,
94
+ ),
95
  ),
96
  )
97
+ )->render_form();
98
+ ?>
99
  <div class="um-admin-clear"></div>
100
+ </div>
includes/admin/templates/directory/shortcode.php CHANGED
@@ -1,4 +1,6 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
 
 
2
 
3
 
4
  <div class="um-admin-metabox">
@@ -24,4 +26,4 @@
24
 
25
  <p><?php echo UM()->shortcodes()->get_shortcode( get_the_ID() ); ?></p>
26
  <!-- <p>--><?php //echo UM()->shortcodes()->get_default_shortcode( get_the_ID() ); ?><!--</p>-->
27
- </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ } ?>
4
 
5
 
6
  <div class="um-admin-metabox">
26
 
27
  <p><?php echo UM()->shortcodes()->get_shortcode( get_the_ID() ); ?></p>
28
  <!-- <p>--><?php //echo UM()->shortcodes()->get_default_shortcode( get_the_ID() ); ?><!--</p>-->
29
+ </div>
includes/admin/templates/directory/sorting.php CHANGED
@@ -1,62 +1,65 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit;
 
 
2
 
3
  global $post_id;
4
 
5
-
6
  $_um_sorting_fields = get_post_meta( $post_id, '_um_sorting_fields', true );
7
- $_um_sorting_fields = empty( $_um_sorting_fields ) ? array() : $_um_sorting_fields; ?>
8
 
9
- <div class="um-admin-metabox">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
- <?php $fields = array(
12
- array(
13
- 'id' => '_um_sortby',
14
- 'type' => 'select',
15
- 'label' => __( 'Default sort users by', 'ultimate-member' ),
16
- 'tooltip' => __( 'Default sorting users by a specific parameter in the directory', 'ultimate-member' ),
17
- 'options' => UM()->member_directory()->default_sorting,
18
- 'value' => UM()->query()->get_meta_value( '_um_sortby' ),
19
- ),
20
- array(
21
- 'id' => '_um_sortby_custom',
22
- 'type' => 'text',
23
- 'label' => __( 'Meta key', 'ultimate-member' ),
24
- 'tooltip' => __( 'To sort by a custom field, enter the meta key of field here', 'ultimate-member' ),
25
- 'value' => UM()->query()->get_meta_value( '_um_sortby_custom', null, 'na' ),
26
- 'conditional' => array( '_um_sortby', '=', 'other' )
27
- ),
28
- array(
29
- 'id' => '_um_sortby_custom_label',
30
- 'type' => 'text',
31
- 'label' => __( 'Label of custom sort', 'ultimate-member' ),
32
- 'tooltip' => __( 'To sort by a custom field, enter the label of sorting here', 'ultimate-member' ),
33
- 'value' => UM()->query()->get_meta_value( '_um_sortby_custom_label', null, 'na' ),
34
- 'conditional' => array( '_um_sortby', '=', 'other' )
35
- ),
36
- array(
37
- 'id' => '_um_enable_sorting',
38
- 'type' => 'checkbox',
39
- 'label' => __( 'Enable custom sorting', 'ultimate-member' ),
40
- 'tooltip' => __( 'Whether to provide an ability to change the sorting on the directory page', 'ultimate-member' ),
41
- 'value' => UM()->query()->get_meta_value( '_um_enable_sorting' ),
42
- ),
43
  array(
44
- 'id' => '_um_sorting_fields',
45
- 'type' => 'md_sorting_fields',
46
- 'label' => __( 'Choose field(s) to enable in sorting', 'ultimate-member' ),
47
- 'value' => $_um_sorting_fields,
48
- 'options' => array_merge( UM()->member_directory()->sort_fields, array( 'other' => __( 'Other (Custom Field)', 'ultimate-member' ) ) ),
49
- 'add_text' => __( 'Add New Field', 'ultimate-member' ),
50
- 'show_default_number' => 1,
51
- 'conditional' => array( '_um_enable_sorting', '=', 1 ),
52
  )
53
- );
54
-
55
- UM()->admin_forms( array(
56
- 'class' => 'um-member-directory-sorting um-half-column',
57
- 'prefix_id' => 'um_metadata',
58
- 'fields' => $fields
59
- ) )->render_form(); ?>
60
-
61
  <div class="um-admin-clear"></div>
62
- </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
 
5
  global $post_id;
6
 
 
7
  $_um_sorting_fields = get_post_meta( $post_id, '_um_sorting_fields', true );
8
+ $_um_sorting_fields = empty( $_um_sorting_fields ) ? array() : $_um_sorting_fields;
9
 
10
+ $fields = array(
11
+ array(
12
+ 'id' => '_um_sortby',
13
+ 'type' => 'select',
14
+ 'label' => __( 'Default sort users by', 'ultimate-member' ),
15
+ 'tooltip' => __( 'Default sorting users by a specific parameter in the directory', 'ultimate-member' ),
16
+ 'options' => UM()->member_directory()->default_sorting,
17
+ 'value' => UM()->query()->get_meta_value( '_um_sortby' ),
18
+ ),
19
+ array(
20
+ 'id' => '_um_sortby_custom',
21
+ 'type' => 'text',
22
+ 'label' => __( 'Meta key', 'ultimate-member' ),
23
+ 'tooltip' => __( 'To sort by a custom field, enter the meta key of field here', 'ultimate-member' ),
24
+ 'value' => UM()->query()->get_meta_value( '_um_sortby_custom', null, 'na' ),
25
+ 'conditional' => array( '_um_sortby', '=', 'other' ),
26
+ ),
27
+ array(
28
+ 'id' => '_um_sortby_custom_label',
29
+ 'type' => 'text',
30
+ 'label' => __( 'Label of custom sort', 'ultimate-member' ),
31
+ 'tooltip' => __( 'To sort by a custom field, enter the label of sorting here', 'ultimate-member' ),
32
+ 'value' => UM()->query()->get_meta_value( '_um_sortby_custom_label', null, 'na' ),
33
+ 'conditional' => array( '_um_sortby', '=', 'other' ),
34
+ ),
35
+ array(
36
+ 'id' => '_um_enable_sorting',
37
+ 'type' => 'checkbox',
38
+ 'label' => __( 'Enable custom sorting', 'ultimate-member' ),
39
+ 'tooltip' => __( 'Whether to provide an ability to change the sorting on the directory page', 'ultimate-member' ),
40
+ 'value' => UM()->query()->get_meta_value( '_um_enable_sorting' ),
41
+ ),
42
+ array(
43
+ 'id' => '_um_sorting_fields',
44
+ 'type' => 'md_sorting_fields',
45
+ 'label' => __( 'Choose field(s) to enable in sorting', 'ultimate-member' ),
46
+ 'value' => $_um_sorting_fields,
47
+ 'options' => array_merge( UM()->member_directory()->sort_fields, array( 'other' => __( 'Other (Custom Field)', 'ultimate-member' ) ) ),
48
+ 'add_text' => __( 'Add New Field', 'ultimate-member' ),
49
+ 'show_default_number' => 0,
50
+ 'conditional' => array( '_um_enable_sorting', '=', 1 ),
51
+ ),
52
+ ); ?>
53
 
54
+ <div class="um-admin-metabox">
55
+ <?php
56
+ UM()->admin_forms(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  array(
58
+ 'class' => 'um-member-directory-sorting um-half-column',
59
+ 'prefix_id' => 'um_metadata',
60
+ 'fields' => $fields,
 
 
 
 
 
61
  )
62
+ )->render_form();
63
+ ?>
 
 
 
 
 
 
64
  <div class="um-admin-clear"></div>
65
+ </div>
includes/admin/templates/form/builder.php CHANGED
@@ -1,5 +1,6 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit;
2
-
 
3
 
4
  if ( empty( UM()->builder()->form_id ) ) {
5
  UM()->builder()->form_id = $this->form_id;
@@ -9,8 +10,10 @@ if ( empty( UM()->builder()->form_id ) ) {
9
 
10
  <div class="um-admin-drag-ctrls-demo um-admin-drag-ctrls">
11
 
12
- <a href="javascript:void(0);" class="active" data-modal="UM_preview_form" data-modal-size="smaller" data-dynamic-content="um_admin_preview_form"
13
- data-arg1="<?php esc_attr( the_ID() ); ?>" data-arg2=""><?php _e('Live Preview','ultimate-member'); ?></a>
 
 
14
 
15
  </div>
16
 
@@ -19,9 +22,7 @@ if ( empty( UM()->builder()->form_id ) ) {
19
  <div class="um-admin-drag">
20
 
21
  <div class="um-admin-drag-ajax" data-form_id="<?php echo esc_attr( UM()->builder()->form_id ); ?>">
22
-
23
  <?php UM()->builder()->show_builder(); ?>
24
-
25
  </div>
26
 
27
  <div class="um-admin-drag-addrow um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Master Row', 'ultimate-member' ); ?>"
@@ -31,4 +32,4 @@ if ( empty( UM()->builder()->form_id ) ) {
31
 
32
  </div>
33
 
34
- </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
 
5
  if ( empty( UM()->builder()->form_id ) ) {
6
  UM()->builder()->form_id = $this->form_id;
10
 
11
  <div class="um-admin-drag-ctrls-demo um-admin-drag-ctrls">
12
 
13
+ <a href="javascript:void(0);" class="active" data-modal="UM_preview_form" data-modal-size="smaller"
14
+ data-dynamic-content="um_admin_preview_form" data-arg1="<?php echo esc_attr( get_the_ID() ); ?>" data-arg2="">
15
+ <?php esc_html_e( 'Live Preview', 'ultimate-member' ); ?>
16
+ </a>
17
 
18
  </div>
19
 
22
  <div class="um-admin-drag">
23
 
24
  <div class="um-admin-drag-ajax" data-form_id="<?php echo esc_attr( UM()->builder()->form_id ); ?>">
 
25
  <?php UM()->builder()->show_builder(); ?>
 
26
  </div>
27
 
28
  <div class="um-admin-drag-addrow um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Master Row', 'ultimate-member' ); ?>"
32
 
33
  </div>
34
 
35
+ </div>
includes/admin/templates/form/login_customize.php CHANGED
@@ -1,102 +1,106 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
2
-
 
3
 
4
  <div class="um-admin-metabox">
5
- <?php UM()->admin_forms( array(
6
- 'class' => 'um-form-login-customize um-top-label',
7
- 'prefix_id' => 'form',
8
- 'fields' => array(
9
- array(
10
- 'id' => '_um_login_use_custom_settings',
11
- 'type' => 'select',
12
- 'label' => __( 'Apply custom settings to this form', 'ultimate-member' ),
13
- 'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling &amp; appearance', 'ultimate-member' ),
14
- 'value' => UM()->query()->get_meta_value( '_um_login_use_custom_settings', null, 0 ),
15
- 'options' => array(
16
- 0 => __( 'No', 'ultimate-member' ),
17
- 1 => __( 'Yes', 'ultimate-member' ),
 
 
 
18
  ),
19
- ),
20
- array(
21
- 'id' => '_um_login_template',
22
- 'type' => 'select',
23
- 'label' => __( 'Template', 'ultimate-member' ),
24
- 'value' => UM()->query()->get_meta_value( '_um_login_template', null, UM()->options()->get( 'login_template' ) ),
25
- 'options' => UM()->shortcodes()->get_templates( 'login' ),
26
- 'conditional' => array( '_um_login_use_custom_settings', '=', 1 )
27
- ),
28
- array(
29
- 'id' => '_um_login_max_width',
30
- 'type' => 'text',
31
- 'label' => __( 'Max. Width (px)', 'ultimate-member' ),
32
- 'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ),
33
- 'value' => UM()->query()->get_meta_value('_um_login_max_width', null, UM()->options()->get( 'login_max_width' ) ),
34
- 'conditional' => array( '_um_login_use_custom_settings', '=', 1 )
35
- ),
36
- array(
37
- 'id' => '_um_login_icons',
38
- 'type' => 'select',
39
- 'label' => __( 'Field Icons', 'ultimate-member' ),
40
- 'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ),
41
- 'value' => UM()->query()->get_meta_value( '_um_login_icons', null, UM()->options()->get( 'login_icons' ) ) ,
42
- 'options' => array(
43
- 'field' => __( 'Show inside text field', 'ultimate-member' ),
44
- 'label' => __( 'Show with label', 'ultimate-member' ),
45
- 'off' => __( 'Turn off', 'ultimate-member' )
46
  ),
47
- 'conditional' => array( '_um_login_use_custom_settings', '=', 1 )
48
- ),
49
- array(
50
- 'id' => '_um_login_primary_btn_word',
51
- 'type' => 'text',
52
- 'label' => __( 'Primary Button Text', 'ultimate-member' ),
53
- 'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
54
- 'value' => UM()->query()->get_meta_value( '_um_login_primary_btn_word', null, UM()->options()->get( 'login_primary_btn_word' ) ),
55
- 'conditional' => array( '_um_login_use_custom_settings', '=', 1 )
56
- ),
57
- array(
58
- 'id' => '_um_login_secondary_btn',
59
- 'type' => 'select',
60
- 'label' => __( 'Show Secondary Button', 'ultimate-member' ),
61
- 'value' => UM()->query()->get_meta_value( '_um_login_secondary_btn', null, UM()->options()->get( 'login_secondary_btn' ) ),
62
- 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
63
- 'options' => array(
64
- 0 => __( 'No', 'ultimate-member' ),
65
- 1 => __( 'Yes', 'ultimate-member' ),
66
- ),
67
- ),
68
- array(
69
- 'id' => '_um_login_secondary_btn_word',
70
- 'type' => 'text',
71
- 'label' => __( 'Secondary Button Text', 'ultimate-member' ),
72
- 'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
73
- 'value' => UM()->query()->get_meta_value( '_um_login_secondary_btn_word', null, UM()->options()->get( 'login_secondary_btn_word' ) ),
74
- 'conditional' => array( '_um_login_secondary_btn', '=', 1 )
75
- ),
76
- array(
77
- 'id' => '_um_login_forgot_pass_link',
78
- 'type' => 'select',
79
- 'label' => __( 'Show Forgot Password Link?', 'ultimate-member' ),
80
- 'value' => UM()->query()->get_meta_value( '_um_login_forgot_pass_link', null, UM()->options()->get('login_forgot_pass_link') ),
81
- 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
82
- 'options' => array(
83
- 0 => __( 'No', 'ultimate-member' ),
84
- 1 => __( 'Yes', 'ultimate-member' ),
85
  ),
86
- ),
87
- array(
88
- 'id' => '_um_login_show_rememberme',
89
- 'type' => 'select',
90
- 'label' => __( 'Show "Remember Me"?', 'ultimate-member' ),
91
- 'value' => UM()->query()->get_meta_value( '_um_login_show_rememberme', null, UM()->options()->get('login_show_rememberme') ),
92
- 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
93
- 'options' => array(
94
- 0 => __( 'No', 'ultimate-member' ),
95
- 1 => __( 'Yes', 'ultimate-member' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  ),
97
  ),
98
  )
99
- ) )->render_form(); ?>
100
-
101
  <div class="um-admin-clear"></div>
102
- </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ } ?>
4
 
5
  <div class="um-admin-metabox">
6
+ <?php
7
+ UM()->admin_forms(
8
+ array(
9
+ 'class' => 'um-form-login-customize um-top-label',
10
+ 'prefix_id' => 'form',
11
+ 'fields' => array(
12
+ array(
13
+ 'id' => '_um_login_use_custom_settings',
14
+ 'type' => 'select',
15
+ 'label' => __( 'Apply custom settings to this form', 'ultimate-member' ),
16
+ 'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling &amp; appearance', 'ultimate-member' ),
17
+ 'value' => UM()->query()->get_meta_value( '_um_login_use_custom_settings', null, 0 ),
18
+ 'options' => array(
19
+ 0 => __( 'No', 'ultimate-member' ),
20
+ 1 => __( 'Yes', 'ultimate-member' ),
21
+ ),
22
  ),
23
+ array(
24
+ 'id' => '_um_login_template',
25
+ 'type' => 'select',
26
+ 'label' => __( 'Template', 'ultimate-member' ),
27
+ 'value' => UM()->query()->get_meta_value( '_um_login_template', null, UM()->options()->get( 'login_template' ) ),
28
+ 'options' => UM()->shortcodes()->get_templates( 'login' ),
29
+ 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  ),
31
+ array(
32
+ 'id' => '_um_login_max_width',
33
+ 'type' => 'text',
34
+ 'label' => __( 'Max. Width (px)', 'ultimate-member' ),
35
+ 'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ),
36
+ 'value' => UM()->query()->get_meta_value( '_um_login_max_width', null, UM()->options()->get( 'login_max_width' ) ),
37
+ 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  ),
39
+ array(
40
+ 'id' => '_um_login_icons',
41
+ 'type' => 'select',
42
+ 'label' => __( 'Field Icons', 'ultimate-member' ),
43
+ 'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ),
44
+ 'value' => UM()->query()->get_meta_value( '_um_login_icons', null, UM()->options()->get( 'login_icons' ) ),
45
+ 'options' => array(
46
+ 'field' => __( 'Show inside text field', 'ultimate-member' ),
47
+ 'label' => __( 'Show with label', 'ultimate-member' ),
48
+ 'off' => __( 'Turn off', 'ultimate-member' ),
49
+ ),
50
+ 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
51
+ ),
52
+ array(
53
+ 'id' => '_um_login_primary_btn_word',
54
+ 'type' => 'text',
55
+ 'label' => __( 'Primary Button Text', 'ultimate-member' ),
56
+ 'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
57
+ 'value' => UM()->query()->get_meta_value( '_um_login_primary_btn_word', null, UM()->options()->get( 'login_primary_btn_word' ) ),
58
+ 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
59
+ ),
60
+ array(
61
+ 'id' => '_um_login_secondary_btn',
62
+ 'type' => 'select',
63
+ 'label' => __( 'Show Secondary Button', 'ultimate-member' ),
64
+ 'value' => UM()->query()->get_meta_value( '_um_login_secondary_btn', null, UM()->options()->get( 'login_secondary_btn' ) ),
65
+ 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
66
+ 'options' => array(
67
+ 0 => __( 'No', 'ultimate-member' ),
68
+ 1 => __( 'Yes', 'ultimate-member' ),
69
+ ),
70
+ ),
71
+ array(
72
+ 'id' => '_um_login_secondary_btn_word',
73
+ 'type' => 'text',
74
+ 'label' => __( 'Secondary Button Text', 'ultimate-member' ),
75
+ 'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
76
+ 'value' => UM()->query()->get_meta_value( '_um_login_secondary_btn_word', null, UM()->options()->get( 'login_secondary_btn_word' ) ),
77
+ 'conditional' => array( '_um_login_secondary_btn', '=', 1 ),
78
+ ),
79
+ array(
80
+ 'id' => '_um_login_forgot_pass_link',
81
+ 'type' => 'select',
82
+ 'label' => __( 'Show Forgot Password Link?', 'ultimate-member' ),
83
+ 'value' => UM()->query()->get_meta_value( '_um_login_forgot_pass_link', null, UM()->options()->get( 'login_forgot_pass_link' ) ),
84
+ 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
85
+ 'options' => array(
86
+ 0 => __( 'No', 'ultimate-member' ),
87
+ 1 => __( 'Yes', 'ultimate-member' ),
88
+ ),
89
+ ),
90
+ array(
91
+ 'id' => '_um_login_show_rememberme',
92
+ 'type' => 'select',
93
+ 'label' => __( 'Show "Remember Me"?', 'ultimate-member' ),
94
+ 'value' => UM()->query()->get_meta_value( '_um_login_show_rememberme', null, UM()->options()->get( 'login_show_rememberme' ) ),
95
+ 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ),
96
+ 'options' => array(
97
+ 0 => __( 'No', 'ultimate-member' ),
98
+ 1 => __( 'Yes', 'ultimate-member' ),
99
+ ),
100
  ),
101
  ),
102
  )
103
+ )->render_form();
104
+ ?>
105
  <div class="um-admin-clear"></div>
106
+ </div>
includes/admin/templates/form/login_settings.php CHANGED
@@ -1,34 +1,38 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
2
-
 
3
 
4
  <div class="um-admin-metabox">
5
- <?php UM()->admin_forms( array(
6
- 'class' => 'um-form-login-settings um-top-label',
7
- 'prefix_id' => 'form',
8
- 'fields' => array(
9
- array(
10
- 'id' => '_um_login_after_login',
11
- 'type' => 'select',
12
- 'label' => __( 'Redirection after Login', 'ultimate-member' ),
13
- 'tooltip' => __( 'Change this If you want to override role redirection settings after login only.', 'ultimate-member' ),
14
- 'value' => UM()->query()->get_meta_value( '_um_login_after_login', null, 0 ),
15
- 'options' => array(
16
- '0' => __( 'Default', 'ultimate-member' ),
17
- 'redirect_profile' => __( 'Redirect to profile', 'ultimate-member' ),
18
- 'redirect_url' => __( 'Redirect to URL', 'ultimate-member' ),
19
- 'refresh' => __( 'Refresh active page', 'ultimate-member' ),
20
- 'redirect_admin' => __( 'Redirect to WordPress Admin', 'ultimate-member' ),
 
 
 
 
 
 
 
 
 
 
21
  ),
22
  ),
23
- array(
24
- 'id' => '_um_login_redirect_url',
25
- 'type' => 'text',
26
- 'label' => __( 'Set Custom Redirect URL', 'ultimate-member' ),
27
- 'value' => UM()->query()->get_meta_value('_um_login_redirect_url', null, 'na' ),
28
- 'conditional' => array( '_um_login_after_login', '=', 'redirect_url' )
29
- )
30
  )
31
- ) )->render_form(); ?>
32
-
33
  <div class="um-admin-clear"></div>
34
- </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ } ?>
4
 
5
  <div class="um-admin-metabox">
6
+ <?php
7
+ UM()->admin_forms(
8
+ array(
9
+ 'class' => 'um-form-login-settings um-top-label',
10
+ 'prefix_id' => 'form',
11
+ 'fields' => array(
12
+ array(
13
+ 'id' => '_um_login_after_login',
14
+ 'type' => 'select',
15
+ 'label' => __( 'Redirection after Login', 'ultimate-member' ),
16
+ 'tooltip' => __( 'Change this If you want to override role redirection settings after login only.', 'ultimate-member' ),
17
+ 'value' => UM()->query()->get_meta_value( '_um_login_after_login', null, 0 ),
18
+ 'options' => array(
19
+ '0' => __( 'Default', 'ultimate-member' ),
20
+ 'redirect_profile' => __( 'Redirect to profile', 'ultimate-member' ),
21
+ 'redirect_url' => __( 'Redirect to URL', 'ultimate-member' ),
22
+ 'refresh' => __( 'Refresh active page', 'ultimate-member' ),
23
+ 'redirect_admin' => __( 'Redirect to WordPress Admin', 'ultimate-member' ),
24
+ ),
25
+ ),
26
+ array(
27
+ 'id' => '_um_login_redirect_url',
28
+ 'type' => 'text',
29
+ 'label' => __( 'Set Custom Redirect URL', 'ultimate-member' ),
30
+ 'value' => UM()->query()->get_meta_value( '_um_login_redirect_url', null, 'na' ),
31
+ 'conditional' => array( '_um_login_after_login', '=', 'redirect_url' ),
32
  ),
33
  ),
 
 
 
 
 
 
 
34
  )
35
+ )->render_form();
36
+ ?>
37
  <div class="um-admin-clear"></div>
38
+ </div>
includes/admin/templates/form/mode.php CHANGED
@@ -1,21 +1,29 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit;
2
-
 
3
 
4
  $is_core = get_post_meta( get_the_ID(), '_um_core', true ); ?>
5
 
6
- <div class="um-admin-boxed-links um-admin-ajaxlink <?php if ( $is_core ) echo 'is-core-form'; ?>">
7
 
8
  <?php if ( $is_core ) { ?>
9
- <p><?php _e( '<strong>Note:</strong> Form type cannot be changed for the default forms.', 'ultimate-member' ); ?></p>
 
 
10
  <?php } ?>
11
 
12
- <a href="javascript:void(0);" data-role="register"><?php _e( 'Registration Form', 'ultimate-member' ); ?></a>
 
 
13
 
14
- <a href="javascript:void(0);" data-role="profile"><?php _e('Profile Form', 'ultimate-member' ); ?></a>
 
 
15
 
16
- <a href="javascript:void(0);" data-role="login"><?php _e( 'Login Form', 'ultimate-member' ); ?></a>
 
 
17
 
18
  <input type="hidden" name="form[_um_mode]" id="form__um_mode" value="<?php echo esc_attr( UM()->query()->get_meta_value( '_um_mode', null, 'register' ) ); ?>" />
19
-
20
  </div>
21
- <div class="um-admin-clear"></div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
 
5
  $is_core = get_post_meta( get_the_ID(), '_um_core', true ); ?>
6
 
7
+ <div class="um-admin-boxed-links um-admin-ajaxlink<?php echo $is_core ? ' is-core-form' : ''; ?>">
8
 
9
  <?php if ( $is_core ) { ?>
10
+ <p>
11
+ <strong><?php esc_html_e( 'Note: ', 'ultimate-member' ); ?></strong><?php esc_html_e( 'Form type cannot be changed for the default forms.', 'ultimate-member' ); ?>
12
+ </p>
13
  <?php } ?>
14
 
15
+ <a href="javascript:void(0);" data-role="register">
16
+ <?php esc_html_e( 'Registration Form', 'ultimate-member' ); ?>
17
+ </a>
18
 
19
+ <a href="javascript:void(0);" data-role="profile">
20
+ <?php esc_html_e( 'Profile Form', 'ultimate-member' ); ?>
21
+ </a>
22
 
23
+ <a href="javascript:void(0);" data-role="login">
24
+ <?php esc_html_e( 'Login Form', 'ultimate-member' ); ?>
25
+ </a>
26
 
27
  <input type="hidden" name="form[_um_mode]" id="form__um_mode" value="<?php echo esc_attr( UM()->query()->get_meta_value( '_um_mode', null, 'register' ) ); ?>" />
 
28
  </div>
29
+ <div class="um-admin-clear"></div>
includes/admin/templates/form/profile_customize.php CHANGED
@@ -1,208 +1,211 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
 
 
2
 
3
-
4
- <div class="um-admin-metabox">
5
-
6
- <?php $profile_role_array = array();
7
- foreach ( UM()->roles()->get_roles() as $key => $value ) {
8
- $_um_profile_role = UM()->query()->get_meta_value( '_um_profile_role', $key );
9
- if ( ! empty( $_um_profile_role ) ) {
10
- $profile_role_array[] = $_um_profile_role;
11
- }
12
  }
 
13
 
14
- UM()->admin_forms( array(
15
- 'class' => 'um-form-profile-customize um-top-label',
16
- 'prefix_id' => 'form',
17
- 'fields' => array(
18
- array(
19
- 'id' => '_um_profile_use_custom_settings',
20
- 'type' => 'select',
21
- 'label' => __( 'Apply custom settings to this form', 'ultimate-member' ),
22
- 'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling &amp; appearance', 'ultimate-member' ),
23
- 'value' => UM()->query()->get_meta_value( '_um_profile_use_custom_settings', null, 0 ),
24
- 'options' => array(
25
- 0 => __( 'No', 'ultimate-member' ),
26
- 1 => __( 'Yes', 'ultimate-member' ),
 
 
 
 
 
27
  ),
28
- ),
29
- array(
30
- 'id' => '_um_profile_role',
31
- 'type' => 'select',
32
- 'multi' => true,
33
- 'label' => __( 'Make this profile form role-specific', 'ultimate-member' ),
34
- 'tooltip' => __( 'Please note if you make a profile form specific to a role then you must make sure that every other role is assigned a profile form', 'ultimate-member' ),
35
- 'value' => $profile_role_array,
36
- 'options' => UM()->roles()->get_roles(),
37
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
38
- ),
39
- array(
40
- 'id' => '_um_profile_template',
41
- 'type' => 'select',
42
- 'label' => __( 'Template', 'ultimate-member' ),
43
- 'value' => UM()->query()->get_meta_value( '_um_profile_template', null, UM()->options()->get( 'profile_template' ) ),
44
- 'options' => UM()->shortcodes()->get_templates( 'profile' ),
45
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
46
- ),
47
- array(
48
- 'id' => '_um_profile_max_width',
49
- 'type' => 'text',
50
- 'label' => __( 'Max. Width (px)', 'ultimate-member' ),
51
- 'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ),
52
- 'value' => UM()->query()->get_meta_value('_um_profile_max_width', null, UM()->options()->get( 'profile_max_width' ) ),
53
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
54
- ),
55
- array(
56
- 'id' => '_um_profile_area_max_width',
57
- 'type' => 'text',
58
- 'label' => __( 'Profile Area Max. Width (px)', 'ultimate-member' ),
59
- 'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ),
60
- 'value' => UM()->query()->get_meta_value('_um_profile_area_max_width', null, UM()->options()->get( 'profile_area_max_width' ) ),
61
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
62
- ),
63
- array(
64
- 'id' => '_um_profile_icons',
65
- 'type' => 'select',
66
- 'label' => __( 'Field Icons', 'ultimate-member' ),
67
- 'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ),
68
- 'value' => UM()->query()->get_meta_value( '_um_profile_icons', null, UM()->options()->get( 'profile_icons' ) ) ,
69
- 'options' => array(
70
- 'field' => __( 'Show inside text field', 'ultimate-member' ),
71
- 'label' => __( 'Show with label', 'ultimate-member' ),
72
- 'off' => __( 'Turn off', 'ultimate-member' )
73
- ),
74
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
75
- ),
76
- array(
77
- 'id' => '_um_profile_primary_btn_word',
78
- 'type' => 'text',
79
- 'label' => __( 'Primary Button Text', 'ultimate-member' ),
80
- 'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
81
- 'value' => UM()->query()->get_meta_value( '_um_profile_primary_btn_word', null, UM()->options()->get( 'profile_primary_btn_word' ) ),
82
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
83
- ),
84
- array(
85
- 'id' => '_um_profile_secondary_btn',
86
- 'type' => 'select',
87
- 'label' => __( 'Show Secondary Button', 'ultimate-member' ),
88
- 'value' => UM()->query()->get_meta_value( '_um_profile_secondary_btn', null, UM()->options()->get( 'profile_secondary_btn' ) ),
89
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
90
- 'options' => array(
91
- 0 => __( 'No', 'ultimate-member' ),
92
- 1 => __( 'Yes', 'ultimate-member' ),
93
  ),
94
- ),
95
- array(
96
- 'id' => '_um_profile_secondary_btn_word',
97
- 'type' => 'text',
98
- 'label' => __( 'Secondary Button Text', 'ultimate-member' ),
99
- 'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
100
- 'value' => UM()->query()->get_meta_value( '_um_profile_secondary_btn_word', null, UM()->options()->get( 'profile_secondary_btn_word' ) ),
101
- 'conditional' => array( '_um_profile_secondary_btn', '=', 1 )
102
- ),
103
- array(
104
- 'id' => '_um_profile_cover_enabled',
105
- 'type' => 'select',
106
- 'label' => __( 'Enable Cover Photos', 'ultimate-member' ),
107
- 'value' => UM()->query()->get_meta_value( '_um_profile_cover_enabled', null, 1 ),
108
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
109
- 'options' => array(
110
- 0 => __( 'No', 'ultimate-member' ),
111
- 1 => __( 'Yes', 'ultimate-member' ),
112
  ),
113
- ),
114
- array(
115
- 'id' => '_um_profile_coversize',
116
- 'type' => 'select',
117
- 'label' => __( 'Cover Photo Size', 'ultimate-member' ),
118
- 'tooltip' => __( 'Set the profile photo size in pixels here', 'ultimate-member' ),
119
- 'value' => UM()->query()->get_meta_value( '_um_profile_coversize', null, UM()->options()->get( 'profile_coversize' ) ),
120
- 'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ),
121
- 'conditional' => array( '_um_profile_cover_enabled', '=', 1 )
122
- ),
123
- array(
124
- 'id' => '_um_profile_cover_ratio',
125
- 'type' => 'select',
126
- 'label' => __( 'Cover photo ratio', 'ultimate-member' ),
127
- 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
128
- 'value' => UM()->query()->get_meta_value( '_um_profile_cover_ratio', null, UM()->options()->get( 'profile_cover_ratio' ) ),
129
- 'options' => array(
130
- '1.6:1' => '1.6:1',
131
- '2.7:1' => '2.7:1',
132
- '2.2:1' => '2.2:1',
133
- '3.2:1' => '3.2:1'
134
- ),
135
- 'conditional' => array( '_um_profile_cover_enabled', '=', 1 )
136
- ),
137
- array(
138
- 'id' => '_um_profile_disable_photo_upload',
139
- 'type' => 'select',
140
- 'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ),
141
- 'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ),
142
- 'value' => UM()->query()->get_meta_value( '_um_profile_disable_photo_upload', null, UM()->options()->get( 'disable_profile_photo_upload' ) ),
143
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
144
- 'options' => array(
145
- 0 => __( 'No', 'ultimate-member' ),
146
- 1 => __( 'Yes', 'ultimate-member' ),
147
  ),
148
- ),
149
- array(
150
- 'id' => '_um_profile_photosize',
151
- 'type' => 'select',
152
- 'label' => __( 'Profile Photo Size', 'ultimate-member' ),
153
- 'tooltip' => __( 'Set the profile photo size in pixels here', 'ultimate-member' ),
154
- 'value' => UM()->query()->get_meta_value( '_um_profile_photosize', null, UM()->options()->get( 'profile_photosize' ) ),
155
- 'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ),
156
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
157
- ),
158
- array(
159
- 'id' => '_um_profile_photo_required',
160
- 'type' => 'select',
161
- 'label' => __( 'Make Profile Photo Required', 'ultimate-member' ),
162
- 'tooltip' => __( 'Require user to update a profile photo when updating their profile', 'ultimate-member' ),
163
- 'value' => UM()->query()->get_meta_value( '_um_profile_photo_required' ),
164
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
165
- 'options' => array(
166
- 0 => __( 'No', 'ultimate-member' ),
167
- 1 => __( 'Yes', 'ultimate-member' ),
168
  ),
169
- ),
170
- array(
171
- 'id' => '_um_profile_show_name',
172
- 'type' => 'select',
173
- 'label' => __( 'Show display name in profile header?', 'ultimate-member' ),
174
- 'value' => UM()->query()->get_meta_value( '_um_profile_show_name', null, 1 ),
175
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
176
- 'options' => array(
177
- 0 => __( 'No', 'ultimate-member' ),
178
- 1 => __( 'Yes', 'ultimate-member' ),
 
 
179
  ),
180
- ),
181
- array(
182
- 'id' => '_um_profile_show_social_links',
183
- 'type' => 'select',
184
- 'label' => __( 'Show social links in profile header?', 'ultimate-member' ),
185
- 'value' => UM()->query()->get_meta_value( '_um_profile_show_social_links', null, UM()->options()->get( 'profile_show_social_links' ) ),
186
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
187
- 'options' => array(
188
- 0 => __( 'No', 'ultimate-member' ),
189
- 1 => __( 'Yes', 'ultimate-member' ),
190
  ),
191
- ),
192
- array(
193
- 'id' => '_um_profile_show_bio',
194
- 'type' => 'select',
195
- 'label' => __( 'Show user description in profile header?', 'ultimate-member' ),
196
- 'value' => UM()->query()->get_meta_value( '_um_profile_show_bio', null, 1 ),
197
- 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
198
- 'options' => array(
199
- 0 => __( 'No', 'ultimate-member' ),
200
- 1 => __( 'Yes', 'ultimate-member' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  ),
202
  ),
203
-
204
  )
205
- ) )->render_form(); ?>
206
-
207
  <div class="um-admin-clear"></div>
208
- </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
 
5
+ $profile_role_array = array();
6
+ foreach ( UM()->roles()->get_roles() as $key => $value ) {
7
+ $_um_profile_role = UM()->query()->get_meta_value( '_um_profile_role', $key );
8
+ if ( ! empty( $_um_profile_role ) ) {
9
+ $profile_role_array[] = $_um_profile_role;
 
 
 
 
10
  }
11
+ } ?>
12
 
13
+
14
+ <div class="um-admin-metabox">
15
+ <?php
16
+ UM()->admin_forms(
17
+ array(
18
+ 'class' => 'um-form-profile-customize um-top-label',
19
+ 'prefix_id' => 'form',
20
+ 'fields' => array(
21
+ array(
22
+ 'id' => '_um_profile_use_custom_settings',
23
+ 'type' => 'select',
24
+ 'label' => __( 'Apply custom settings to this form', 'ultimate-member' ),
25
+ 'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling &amp; appearance', 'ultimate-member' ),
26
+ 'value' => UM()->query()->get_meta_value( '_um_profile_use_custom_settings', null, 0 ),
27
+ 'options' => array(
28
+ 0 => __( 'No', 'ultimate-member' ),
29
+ 1 => __( 'Yes', 'ultimate-member' ),
30
+ ),
31
  ),
32
+ array(
33
+ 'id' => '_um_profile_role',
34
+ 'type' => 'select',
35
+ 'multi' => true,
36
+ 'label' => __( 'Make this profile form role-specific', 'ultimate-member' ),
37
+ 'tooltip' => __( 'Please note if you make a profile form specific to a role then you must make sure that every other role is assigned a profile form', 'ultimate-member' ),
38
+ 'value' => $profile_role_array,
39
+ 'options' => UM()->roles()->get_roles(),
40
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  ),
42
+ array(
43
+ 'id' => '_um_profile_template',
44
+ 'type' => 'select',
45
+ 'label' => __( 'Template', 'ultimate-member' ),
46
+ 'value' => UM()->query()->get_meta_value( '_um_profile_template', null, UM()->options()->get( 'profile_template' ) ),
47
+ 'options' => UM()->shortcodes()->get_templates( 'profile' ),
48
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
 
 
 
 
 
 
 
 
 
 
 
49
  ),
50
+ array(
51
+ 'id' => '_um_profile_max_width',
52
+ 'type' => 'text',
53
+ 'label' => __( 'Max. Width (px)', 'ultimate-member' ),
54
+ 'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ),
55
+ 'value' => UM()->query()->get_meta_value( '_um_profile_max_width', null, UM()->options()->get( 'profile_max_width' ) ),
56
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  ),
58
+ array(
59
+ 'id' => '_um_profile_area_max_width',
60
+ 'type' => 'text',
61
+ 'label' => __( 'Profile Area Max. Width (px)', 'ultimate-member' ),
62
+ 'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ),
63
+ 'value' => UM()->query()->get_meta_value( '_um_profile_area_max_width', null, UM()->options()->get( 'profile_area_max_width' ) ),
64
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  ),
66
+ array(
67
+ 'id' => '_um_profile_icons',
68
+ 'type' => 'select',
69
+ 'label' => __( 'Field Icons', 'ultimate-member' ),
70
+ 'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ),
71
+ 'value' => UM()->query()->get_meta_value( '_um_profile_icons', null, UM()->options()->get( 'profile_icons' ) ),
72
+ 'options' => array(
73
+ 'field' => __( 'Show inside text field', 'ultimate-member' ),
74
+ 'label' => __( 'Show with label', 'ultimate-member' ),
75
+ 'off' => __( 'Turn off', 'ultimate-member' ),
76
+ ),
77
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
78
  ),
79
+ array(
80
+ 'id' => '_um_profile_primary_btn_word',
81
+ 'type' => 'text',
82
+ 'label' => __( 'Primary Button Text', 'ultimate-member' ),
83
+ 'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
84
+ 'value' => UM()->query()->get_meta_value( '_um_profile_primary_btn_word', null, UM()->options()->get( 'profile_primary_btn_word' ) ),
85
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
 
 
 
86
  ),
87
+ array(
88
+ 'id' => '_um_profile_secondary_btn',
89
+ 'type' => 'select',
90
+ 'label' => __( 'Show Secondary Button', 'ultimate-member' ),
91
+ 'value' => UM()->query()->get_meta_value( '_um_profile_secondary_btn', null, UM()->options()->get( 'profile_secondary_btn' ) ),
92
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
93
+ 'options' => array(
94
+ 0 => __( 'No', 'ultimate-member' ),
95
+ 1 => __( 'Yes', 'ultimate-member' ),
96
+ ),
97
+ ),
98
+ array(
99
+ 'id' => '_um_profile_secondary_btn_word',
100
+ 'type' => 'text',
101
+ 'label' => __( 'Secondary Button Text', 'ultimate-member' ),
102
+ 'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
103
+ 'value' => UM()->query()->get_meta_value( '_um_profile_secondary_btn_word', null, UM()->options()->get( 'profile_secondary_btn_word' ) ),
104
+ 'conditional' => array( '_um_profile_secondary_btn', '=', 1 ),
105
+ ),
106
+ array(
107
+ 'id' => '_um_profile_cover_enabled',
108
+ 'type' => 'select',
109
+ 'label' => __( 'Enable Cover Photos', 'ultimate-member' ),
110
+ 'value' => UM()->query()->get_meta_value( '_um_profile_cover_enabled', null, 1 ),
111
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
112
+ 'options' => array(
113
+ 0 => __( 'No', 'ultimate-member' ),
114
+ 1 => __( 'Yes', 'ultimate-member' ),
115
+ ),
116
+ ),
117
+ array(
118
+ 'id' => '_um_profile_coversize',
119
+ 'type' => 'select',
120
+ 'label' => __( 'Cover Photo Size', 'ultimate-member' ),
121
+ 'tooltip' => __( 'Set the profile photo size in pixels here', 'ultimate-member' ),
122
+ 'value' => UM()->query()->get_meta_value( '_um_profile_coversize', null, UM()->options()->get( 'profile_coversize' ) ),
123
+ 'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ),
124
+ 'conditional' => array( '_um_profile_cover_enabled', '=', 1 ),
125
+ ),
126
+ array(
127
+ 'id' => '_um_profile_cover_ratio',
128
+ 'type' => 'select',
129
+ 'label' => __( 'Cover photo ratio', 'ultimate-member' ),
130
+ 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
131
+ 'value' => UM()->query()->get_meta_value( '_um_profile_cover_ratio', null, UM()->options()->get( 'profile_cover_ratio' ) ),
132
+ 'options' => array(
133
+ '1.6:1' => '1.6:1',
134
+ '2.7:1' => '2.7:1',
135
+ '2.2:1' => '2.2:1',
136
+ '3.2:1' => '3.2:1',
137
+ ),
138
+ 'conditional' => array( '_um_profile_cover_enabled', '=', 1 ),
139
+ ),
140
+ array(
141
+ 'id' => '_um_profile_disable_photo_upload',
142
+ 'type' => 'select',
143
+ 'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ),
144
+ 'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ),
145
+ 'value' => UM()->query()->get_meta_value( '_um_profile_disable_photo_upload', null, UM()->options()->get( 'disable_profile_photo_upload' ) ),
146
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
147
+ 'options' => array(
148
+ 0 => __( 'No', 'ultimate-member' ),
149
+ 1 => __( 'Yes', 'ultimate-member' ),
150
+ ),
151
+ ),
152
+ array(
153
+ 'id' => '_um_profile_photosize',
154
+ 'type' => 'select',
155
+ 'label' => __( 'Profile Photo Size', 'ultimate-member' ),
156
+ 'tooltip' => __( 'Set the profile photo size in pixels here', 'ultimate-member' ),
157
+ 'value' => UM()->query()->get_meta_value( '_um_profile_photosize', null, UM()->options()->get( 'profile_photosize' ) ),
158
+ 'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ),
159
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
160
+ ),
161
+ array(
162
+ 'id' => '_um_profile_photo_required',
163
+ 'type' => 'select',
164
+ 'label' => __( 'Make Profile Photo Required', 'ultimate-member' ),
165
+ 'tooltip' => __( 'Require user to update a profile photo when updating their profile', 'ultimate-member' ),
166
+ 'value' => UM()->query()->get_meta_value( '_um_profile_photo_required' ),
167
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
168
+ 'options' => array(
169
+ 0 => __( 'No', 'ultimate-member' ),
170
+ 1 => __( 'Yes', 'ultimate-member' ),
171
+ ),
172
+ ),
173
+ array(
174
+ 'id' => '_um_profile_show_name',
175
+ 'type' => 'select',
176
+ 'label' => __( 'Show display name in profile header?', 'ultimate-member' ),
177
+ 'value' => UM()->query()->get_meta_value( '_um_profile_show_name', null, 1 ),
178
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
179
+ 'options' => array(
180
+ 0 => __( 'No', 'ultimate-member' ),
181
+ 1 => __( 'Yes', 'ultimate-member' ),
182
+ ),
183
+ ),
184
+ array(
185
+ 'id' => '_um_profile_show_social_links',
186
+ 'type' => 'select',
187
+ 'label' => __( 'Show social links in profile header?', 'ultimate-member' ),
188
+ 'value' => UM()->query()->get_meta_value( '_um_profile_show_social_links', null, UM()->options()->get( 'profile_show_social_links' ) ),
189
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
190
+ 'options' => array(
191
+ 0 => __( 'No', 'ultimate-member' ),
192
+ 1 => __( 'Yes', 'ultimate-member' ),
193
+ ),
194
+ ),
195
+ array(
196
+ 'id' => '_um_profile_show_bio',
197
+ 'type' => 'select',
198
+ 'label' => __( 'Show user description in profile header?', 'ultimate-member' ),
199
+ 'value' => UM()->query()->get_meta_value( '_um_profile_show_bio', null, 1 ),
200
+ 'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
201
+ 'options' => array(
202
+ 0 => __( 'No', 'ultimate-member' ),
203
+ 1 => __( 'Yes', 'ultimate-member' ),
204
+ ),
205
  ),
206
  ),
 
207
  )
208
+ )->render_form();
209
+ ?>
210
  <div class="um-admin-clear"></div>
211
+ </div>
includes/admin/templates/form/profile_settings.php CHANGED
@@ -1,32 +1,37 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
 
 
2
 
 
 
 
 
3
 
4
- <div class="um-admin-metabox">
5
- <?php $user_fields = array();
6
- foreach ( UM()->builtin()->all_user_fields() as $key => $arr ) {
7
- $user_fields[ $key ] = isset( $arr['title'] ) ? $arr['title'] : '';
8
- }
9
 
10
- $post_id = get_the_ID();
11
- $_um_search_fields = get_post_meta( $post_id, '_um_profile_metafields', true );
12
- $_um_search_fields = empty( $_um_search_fields ) ? array() : $_um_search_fields;
13
 
14
- UM()->admin_forms( array(
15
- 'class' => 'um-form-profile-settings um-top-label',
16
- 'prefix_id' => 'form',
17
- 'fields' => array(
18
- array(
19
- 'id' => '_um_profile_metafields',
20
- 'type' => 'multi_selects',
21
- 'label' => __( 'Field(s) to show in user meta', 'ultimate-member' ),
22
- 'tooltip' => __( 'Fields selected here will appear in the profile header area below the user\'s display name', 'ultimate-member' ),
23
- 'value' => $_um_search_fields,
24
- 'options' => $user_fields,
25
- 'add_text' => __( 'Add New Field', 'ultimate-member' ),
26
- 'show_default_number' => 0,
27
- )
 
 
 
 
28
  )
29
- ) )->render_form(); ?>
30
-
31
  <div class="um-admin-clear"></div>
32
- </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
 
5
+ $user_fields = array();
6
+ foreach ( UM()->builtin()->all_user_fields() as $key => $arr ) {
7
+ $user_fields[ $key ] = isset( $arr['title'] ) ? $arr['title'] : '';
8
+ }
9
 
10
+ $post_id = get_the_ID();
11
+ $_um_search_fields = get_post_meta( $post_id, '_um_profile_metafields', true );
12
+ $_um_search_fields = empty( $_um_search_fields ) ? array() : $_um_search_fields; ?>
 
 
13
 
 
 
 
14
 
15
+ <div class="um-admin-metabox">
16
+ <?php
17
+ UM()->admin_forms(
18
+ array(
19
+ 'class' => 'um-form-profile-settings um-top-label',
20
+ 'prefix_id' => 'form',
21
+ 'fields' => array(
22
+ array(
23
+ 'id' => '_um_profile_metafields',
24
+ 'type' => 'multi_selects',
25
+ 'label' => __( 'Field(s) to show in user meta', 'ultimate-member' ),
26
+ 'tooltip' => __( 'Fields selected here will appear in the profile header area below the user\'s display name', 'ultimate-member' ),
27
+ 'value' => $_um_search_fields,
28
+ 'options' => $user_fields,
29
+ 'add_text' => __( 'Add New Field', 'ultimate-member' ),
30
+ 'show_default_number' => 0,
31
+ ),
32
+ ),
33
  )
34
+ )->render_form();
35
+ ?>
36
  <div class="um-admin-clear"></div>
37
+ </div>
includes/admin/templates/form/register_customize.php CHANGED
@@ -1,95 +1,99 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
 
 
2
 
3
-
4
- <div class="um-admin-metabox">
5
-
6
- <?php foreach ( UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ) as $key => $value ) {
7
- $_um_register_role = UM()->query()->get_meta_value( '_um_register_role', $key );
8
- if ( ! empty( $_um_register_role ) )
9
- $register_role = $_um_register_role;
10
  }
 
11
 
12
- UM()->admin_forms( array(
13
- 'class' => 'um-form-register-customize um-top-label',
14
- 'prefix_id' => 'form',
15
- 'fields' => array(
16
- array(
17
- 'id' => '_um_register_use_custom_settings',
18
- 'type' => 'select',
19
- 'label' => __( 'Apply custom settings to this form', 'ultimate-member' ),
20
- 'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling &amp; appearance', 'ultimate-member' ),
21
- 'value' => UM()->query()->get_meta_value( '_um_register_use_custom_settings', null, 0 ),
22
- 'options' => array(
23
- 0 => __( 'No', 'ultimate-member' ),
24
- 1 => __( 'Yes', 'ultimate-member' ),
 
 
 
 
25
  ),
26
- ),
27
- array(
28
- 'id' => '_um_register_role',
29
- 'type' => 'select',
30
- 'label' => __( 'Assign role to form', 'ultimate-member' ),
31
- 'value' => ! empty( $register_role ) ? $register_role : 0,
32
- 'options' => UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ),
33
- 'conditional' => array( '_um_register_use_custom_settings', '=', 1 )
34
- ),
35
- array(
36
- 'id' => '_um_register_template',
37
- 'type' => 'select',
38
- 'label' => __( 'Template', 'ultimate-member' ),
39
- 'value' => UM()->query()->get_meta_value( '_um_register_template', null, UM()->options()->get( 'register_template' ) ),
40
- 'options' => UM()->shortcodes()->get_templates( 'register' ),
41
- 'conditional' => array( '_um_register_use_custom_settings', '=', 1 )
42
- ),
43
- array(
44
- 'id' => '_um_register_max_width',
45
- 'type' => 'text',
46
- 'label' => __( 'Max. Width (px)', 'ultimate-member' ),
47
- 'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ),
48
- 'value' => UM()->query()->get_meta_value('_um_register_max_width', null, UM()->options()->get( 'register_max_width' ) ),
49
- 'conditional' => array( '_um_register_use_custom_settings', '=', 1 )
50
- ),
51
- array(
52
- 'id' => '_um_register_icons',
53
- 'type' => 'select',
54
- 'label' => __( 'Field Icons', 'ultimate-member' ),
55
- 'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ),
56
- 'value' => UM()->query()->get_meta_value( '_um_register_icons', null, UM()->options()->get( 'register_icons' ) ) ,
57
- 'options' => array(
58
- 'field' => __( 'Show inside text field', 'ultimate-member' ),
59
- 'label' => __( 'Show with label', 'ultimate-member' ),
60
- 'off' => __( 'Turn off', 'ultimate-member' )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  ),
62
- 'conditional' => array( '_um_register_use_custom_settings', '=', 1 )
63
- ),
64
- array(
65
- 'id' => '_um_register_primary_btn_word',
66
- 'type' => 'text',
67
- 'label' => __( 'Primary Button Text', 'ultimate-member' ),
68
- 'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
69
- 'value' => UM()->query()->get_meta_value( '_um_register_primary_btn_word', null, UM()->options()->get( 'register_primary_btn_word' ) ),
70
- 'conditional' => array( '_um_register_use_custom_settings', '=', 1 )
71
- ),
72
- array(
73
- 'id' => '_um_register_secondary_btn',
74
- 'type' => 'select',
75
- 'label' => __( 'Show Secondary Button', 'ultimate-member' ),
76
- 'value' => UM()->query()->get_meta_value( '_um_register_secondary_btn', null, UM()->options()->get( 'register_secondary_btn' ) ),
77
- 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ),
78
- 'options' => array(
79
- 0 => __( 'No', 'ultimate-member' ),
80
- 1 => __( 'Yes', 'ultimate-member' ),
81
- ),
82
  ),
83
- array(
84
- 'id' => '_um_register_secondary_btn_word',
85
- 'type' => 'text',
86
- 'label' => __( 'Secondary Button Text', 'ultimate-member' ),
87
- 'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
88
- 'value' => UM()->query()->get_meta_value( '_um_register_secondary_btn_word', null, UM()->options()->get( 'register_secondary_btn_word' ) ),
89
- 'conditional' => array( '_um_register_secondary_btn', '=', 1 )
90
- )
91
  )
92
- ) )->render_form(); ?>
93
-
94
  <div class="um-admin-clear"></div>
95
- </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
 
5
+ foreach ( UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ) as $key => $value ) {
6
+ $_um_register_role = UM()->query()->get_meta_value( '_um_register_role', $key );
7
+ if ( ! empty( $_um_register_role ) ) {
8
+ $register_role = $_um_register_role;
 
 
 
9
  }
10
+ } ?>
11
 
12
+ <div class="um-admin-metabox">
13
+ <?php
14
+ UM()->admin_forms(
15
+ array(
16
+ 'class' => 'um-form-register-customize um-top-label',
17
+ 'prefix_id' => 'form',
18
+ 'fields' => array(
19
+ array(
20
+ 'id' => '_um_register_use_custom_settings',
21
+ 'type' => 'select',
22
+ 'label' => __( 'Apply custom settings to this form', 'ultimate-member' ),
23
+ 'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling &amp; appearance', 'ultimate-member' ),
24
+ 'value' => UM()->query()->get_meta_value( '_um_register_use_custom_settings', null, 0 ),
25
+ 'options' => array(
26
+ 0 => __( 'No', 'ultimate-member' ),
27
+ 1 => __( 'Yes', 'ultimate-member' ),
28
+ ),
29
  ),
30
+ array(
31
+ 'id' => '_um_register_role',
32
+ 'type' => 'select',
33
+ 'label' => __( 'Assign role to form', 'ultimate-member' ),
34
+ 'value' => ! empty( $register_role ) ? $register_role : 0,
35
+ 'options' => UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ),
36
+ 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ),
37
+ ),
38
+ array(
39
+ 'id' => '_um_register_template',
40
+ 'type' => 'select',
41
+ 'label' => __( 'Template', 'ultimate-member' ),
42
+ 'value' => UM()->query()->get_meta_value( '_um_register_template', null, UM()->options()->get( 'register_template' ) ),
43
+ 'options' => UM()->shortcodes()->get_templates( 'register' ),
44
+ 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ),
45
+ ),
46
+ array(
47
+ 'id' => '_um_register_max_width',
48
+ 'type' => 'text',
49
+ 'label' => __( 'Max. Width (px)', 'ultimate-member' ),
50
+ 'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ),
51
+ 'value' => UM()->query()->get_meta_value( '_um_register_max_width', null, UM()->options()->get( 'register_max_width' ) ),
52
+ 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ),
53
+ ),
54
+ array(
55
+ 'id' => '_um_register_icons',
56
+ 'type' => 'select',
57
+ 'label' => __( 'Field Icons', 'ultimate-member' ),
58
+ 'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ),
59
+ 'value' => UM()->query()->get_meta_value( '_um_register_icons', null, UM()->options()->get( 'register_icons' ) ),
60
+ 'options' => array(
61
+ 'field' => __( 'Show inside text field', 'ultimate-member' ),
62
+ 'label' => __( 'Show with label', 'ultimate-member' ),
63
+ 'off' => __( 'Turn off', 'ultimate-member' ),
64
+ ),
65
+ 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ),
66
+ ),
67
+ array(
68
+ 'id' => '_um_register_primary_btn_word',
69
+ 'type' => 'text',
70
+ 'label' => __( 'Primary Button Text', 'ultimate-member' ),
71
+ 'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
72
+ 'value' => UM()->query()->get_meta_value( '_um_register_primary_btn_word', null, UM()->options()->get( 'register_primary_btn_word' ) ),
73
+ 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ),
74
+ ),
75
+ array(
76
+ 'id' => '_um_register_secondary_btn',
77
+ 'type' => 'select',
78
+ 'label' => __( 'Show Secondary Button', 'ultimate-member' ),
79
+ 'value' => UM()->query()->get_meta_value( '_um_register_secondary_btn', null, UM()->options()->get( 'register_secondary_btn' ) ),
80
+ 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ),
81
+ 'options' => array(
82
+ 0 => __( 'No', 'ultimate-member' ),
83
+ 1 => __( 'Yes', 'ultimate-member' ),
84
+ ),
85
+ ),
86
+ array(
87
+ 'id' => '_um_register_secondary_btn_word',
88
+ 'type' => 'text',
89
+ 'label' => __( 'Secondary Button Text', 'ultimate-member' ),
90
+ 'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
91
+ 'value' => UM()->query()->get_meta_value( '_um_register_secondary_btn_word', null, UM()->options()->get( 'register_secondary_btn_word' ) ),
92
+ 'conditional' => array( '_um_register_secondary_btn', '=', 1 ),
93
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  ),
 
 
 
 
 
 
 
 
95
  )
96
+ )->render_form();
97
+ ?>
98
  <div class="um-admin-clear"></div>
99
+ </div>
includes/admin/templates/form/register_gdpr.php CHANGED
@@ -1,74 +1,76 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
 
 
2
 
 
 
 
3
 
4
- <div class="um-admin-metabox">
 
 
 
5
 
 
6
  <?php
7
- $options = array(
8
- '' => __( 'Select page', 'ultimate-member' )
9
- );
10
-
11
- $pages = get_pages();
12
- foreach ( $pages as $page ) {
13
- $options[$page->ID] = $page->post_title;
14
- }
15
-
16
- UM()->admin_forms( array(
17
- 'class' => 'um-form-register-gdpr um-top-label',
18
- 'prefix_id' => 'form',
19
- 'fields' => array(
20
- array(
21
- 'id' => '_um_register_use_gdpr',
22
- 'type' => 'select',
23
- 'label' => __( 'Enable on this form', 'ultimate-member' ),
24
- 'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr', null, '' ),
25
- 'options' => array(
26
- '0' => __( 'No', 'ultimate-member' ),
27
- '1' => __( 'Yes', 'ultimate-member' )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  ),
29
  ),
30
- array(
31
- 'id' => '_um_register_use_gdpr_content_id',
32
- 'type' => 'select',
33
- 'label' => __( 'Content', 'ultimate-member' ),
34
- 'value' => UM()->query()->get_meta_value('_um_register_use_gdpr_content_id', null, '' ),
35
- 'options' => $options,
36
- 'conditional' => array( '_um_register_use_gdpr', '=', '1' )
37
- ),
38
- array(
39
- 'id' => '_um_register_use_gdpr_toggle_show',
40
- 'type' => 'text',
41
- 'label' => __( 'Toggle Show text', 'ultimate-member' ),
42
- 'placeholder' => __( 'Show privacy policy', 'ultimate-member' ),
43
- 'value' => UM()->query()->get_meta_value('_um_register_use_gdpr_toggle_show', null, __( 'Show privacy policy', 'ultimate-member' ) ),
44
- 'conditional' => array( '_um_register_use_gdpr', '=', '1' )
45
- ),
46
- array(
47
- 'id' => '_um_register_use_gdpr_toggle_hide',
48
- 'type' => 'text',
49
- 'label' => __( 'Toggle Hide text', 'ultimate-member' ),
50
- 'placeholder' => __( 'Hide privacy policy', 'ultimate-member' ),
51
- 'value' => UM()->query()->get_meta_value('_um_register_use_gdpr_toggle_hide', null, __( 'Hide privacy policy', 'ultimate-member' ) ),
52
- 'conditional' => array( '_um_register_use_gdpr', '=', '1' )
53
- ),
54
- array(
55
- 'id' => '_um_register_use_gdpr_agreement',
56
- 'type' => 'text',
57
- 'label' => __( 'Checkbox agreement description', 'ultimate-member' ),
58
- 'placeholder' => __( 'Please confirm that you agree to our privacy policy', 'ultimate-member' ),
59
- 'value' => UM()->query()->get_meta_value('_um_register_use_gdpr_agreement', null, __( 'Please confirm that you agree to our privacy policy', 'ultimate-member' ) ),
60
- 'conditional' => array( '_um_register_use_gdpr', '=', '1' )
61
- ),
62
- array(
63
- 'id' => '_um_register_use_gdpr_error_text',
64
- 'type' => 'text',
65
- 'label' => __( 'Error Text', 'ultimate-member' ),
66
- 'placeholder' => __( 'Please confirm your acceptance of our privacy policy', 'ultimate-member' ),
67
- 'value' => UM()->query()->get_meta_value('_um_register_use_gdpr_error_text', null, __( 'Please confirm your acceptance of our privacy policy', 'ultimate-member' ) ),
68
- 'conditional' => array( '_um_register_use_gdpr', '=', '1' )
69
- )
70
  )
71
- ) )->render_form(); ?>
72
-
73
  <div class="um-admin-clear"></div>
74
- </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
 
5
+ $options = array(
6
+ '' => __( 'Select page', 'ultimate-member' ),
7
+ );
8
 
9
+ $pages = get_pages();
10
+ foreach ( $pages as $page ) {
11
+ $options[ $page->ID ] = $page->post_title;
12
+ } ?>
13
 
14
+ <div class="um-admin-metabox">
15
  <?php
16
+ UM()->admin_forms(
17
+ array(
18
+ 'class' => 'um-form-register-gdpr um-top-label',
19
+ 'prefix_id' => 'form',
20
+ 'fields' => array(
21
+ array(
22
+ 'id' => '_um_register_use_gdpr',
23
+ 'type' => 'select',
24
+ 'label' => __( 'Enable on this form', 'ultimate-member' ),
25
+ 'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr', null, '' ),
26
+ 'options' => array(
27
+ '0' => __( 'No', 'ultimate-member' ),
28
+ '1' => __( 'Yes', 'ultimate-member' ),
29
+ ),
30
+ ),
31
+ array(
32
+ 'id' => '_um_register_use_gdpr_content_id',
33
+ 'type' => 'select',
34
+ 'label' => __( 'Content', 'ultimate-member' ),
35
+ 'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr_content_id', null, '' ),
36
+ 'options' => $options,
37
+ 'conditional' => array( '_um_register_use_gdpr', '=', '1' ),
38
+ ),
39
+ array(
40
+ 'id' => '_um_register_use_gdpr_toggle_show',
41
+ 'type' => 'text',
42
+ 'label' => __( 'Toggle Show text', 'ultimate-member' ),
43
+ 'placeholder' => __( 'Show privacy policy', 'ultimate-member' ),
44
+ 'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr_toggle_show', null, __( 'Show privacy policy', 'ultimate-member' ) ),
45
+ 'conditional' => array( '_um_register_use_gdpr', '=', '1' ),
46
+ ),
47
+ array(
48
+ 'id' => '_um_register_use_gdpr_toggle_hide',
49
+ 'type' => 'text',
50
+ 'label' => __( 'Toggle Hide text', 'ultimate-member' ),
51
+ 'placeholder' => __( 'Hide privacy policy', 'ultimate-member' ),
52
+ 'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr_toggle_hide', null, __( 'Hide privacy policy', 'ultimate-member' ) ),
53
+ 'conditional' => array( '_um_register_use_gdpr', '=', '1' ),
54
+ ),
55
+ array(
56
+ 'id' => '_um_register_use_gdpr_agreement',
57
+ 'type' => 'text',
58
+ 'label' => __( 'Checkbox agreement description', 'ultimate-member' ),
59
+ 'placeholder' => __( 'Please confirm that you agree to our privacy policy', 'ultimate-member' ),
60
+ 'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr_agreement', null, __( 'Please confirm that you agree to our privacy policy', 'ultimate-member' ) ),
61
+ 'conditional' => array( '_um_register_use_gdpr', '=', '1' ),
62
+ ),
63
+ array(
64
+ 'id' => '_um_register_use_gdpr_error_text',
65
+ 'type' => 'text',
66
+ 'label' => __( 'Error Text', 'ultimate-member' ),
67
+ 'placeholder' => __( 'Please confirm your acceptance of our privacy policy', 'ultimate-member' ),
68
+ 'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr_error_text', null, __( 'Please confirm your acceptance of our privacy policy', 'ultimate-member' ) ),
69
+ 'conditional' => array( '_um_register_use_gdpr', '=', '1' ),
70
  ),
71
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  )
73
+ )->render_form();
74
+ ?>
75
  <div class="um-admin-clear"></div>
76
+ </div>
includes/admin/templates/role/publish.php CHANGED
@@ -1,27 +1,33 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit;
 
 
2
 
3
  $role = $object['data']; ?>
4
 
5
  <div class="um-admin-metabox">
6
- <?php UM()->admin_forms( array(
7
- 'class' => 'um-role-publish um-top-label',
8
- 'prefix_id' => 'role',
9
- 'fields' => array(
10
- array(
11
- 'id' => '_um_priority',
12
- 'type' => 'text',
13
- 'label' => __( 'Role Priority', 'ultimate-member' ),
14
- 'tooltip' => __( 'The higher the number, the higher the priority', 'ultimate-member' ),
15
- 'value' => ! empty( $role['_um_priority'] ) ? $role['_um_priority'] : '',
 
 
 
16
  ),
17
  )
18
- ) )->render_form(); ?>
 
19
  </div>
20
 
21
  <div class="submitbox" id="submitpost">
22
  <div id="major-publishing-actions">
23
- <input type="submit" value="<?php echo ! empty( $_GET['id'] ) ? esc_attr__( 'Update Role', 'ultimate-member' ) : esc_attr__( 'Create Role', 'ultimate-member' ) ?>" class="button-primary" id="create_role" name="create_role">
24
  <input type="button" class="cancel_popup button" value="<?php esc_attr_e( 'Cancel', 'ultimate-member' ) ?>" onclick="window.location = '<?php echo add_query_arg( array( 'page' => 'um_roles' ), admin_url( 'admin.php' ) ) ?>';" />
25
  <div class="clear"></div>
26
  </div>
27
- </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
 
5
  $role = $object['data']; ?>
6
 
7
  <div class="um-admin-metabox">
8
+ <?php
9
+ UM()->admin_forms(
10
+ array(
11
+ 'class' => 'um-role-publish um-top-label',
12
+ 'prefix_id' => 'role',
13
+ 'fields' => array(
14
+ array(
15
+ 'id' => '_um_priority',
16
+ 'type' => 'text',
17
+ 'label' => __( 'Role Priority', 'ultimate-member' ),
18
+ 'tooltip' => __( 'The higher the number, the higher the priority', 'ultimate-member' ),
19
+ 'value' => ! empty( $role['_um_priority'] ) ? $role['_um_priority'] : '',
20
+ ),
21
  ),
22
  )
23
+ )->render_form();
24
+ ?>
25
  </div>
26
 
27
  <div class="submitbox" id="submitpost">
28
  <div id="major-publishing-actions">
29
+ <input type="submit" value="<?php echo ! empty( $_GET['id'] ) ? esc_attr__( 'Update Role', 'ultimate-member' ) : esc_attr__( 'Create Role', 'ultimate-member' ) ?>" class="button-primary" id="create_role" name="create_role" />
30
  <input type="button" class="cancel_popup button" value="<?php esc_attr_e( 'Cancel', 'ultimate-member' ) ?>" onclick="window.location = '<?php echo add_query_arg( array( 'page' => 'um_roles' ), admin_url( 'admin.php' ) ) ?>';" />
31
  <div class="clear"></div>
32
  </div>
33
+ </div>
includes/admin/templates/role/role-edit.php CHANGED
@@ -1,4 +1,6 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit;
 
 
2
 
3
  wp_enqueue_script( 'postbox' );
4
  wp_enqueue_media();
@@ -42,7 +44,7 @@ do_action( 'um_roles_add_meta_boxes', 'um_role_meta' );
42
  */
43
  do_action( 'um_roles_add_meta_boxes_um_role_meta' );
44
 
45
- $data = array();
46
  $option = array();
47
  global $wp_roles;
48
 
@@ -60,11 +62,11 @@ if ( ! empty( $_GET['id'] ) ) {
60
 
61
  if ( ! empty( $_POST['role'] ) ) {
62
 
63
- $id = '';
64
  $redirect = '';
65
- $error = '';
66
 
67
- if ( 'add' == sanitize_key( $_GET['tab'] ) ) {
68
  if ( ! wp_verify_nonce( $_POST['um_nonce'], 'um-add-role' ) ) {
69
  $error = __( 'Security Issue', 'ultimate-member' ) . '<br />';
70
  }
@@ -76,155 +78,9 @@ if ( ! empty( $_POST['role'] ) ) {
76
 
77
  if ( empty( $error ) ) {
78
 
79
- $data = $_POST['role'];
80
-
81
- $all_roles = array_keys( UM()->roles()->get_roles() );
82
-
83
- if ( array_key_exists( '_um_priority', $data ) ) {
84
- $data['_um_priority'] = (int) $data['_um_priority'];
85
- }
86
-
87
- if ( array_key_exists( '_um_can_access_wpadmin', $data ) ) {
88
- $data['_um_can_access_wpadmin'] = (bool) $data['_um_can_access_wpadmin'];
89
- }
90
-
91
- if ( array_key_exists( '_um_can_not_see_adminbar', $data ) ) {
92
- $data['_um_can_not_see_adminbar'] = (bool) $data['_um_can_not_see_adminbar'];
93
- }
94
-
95
- if ( array_key_exists( '_um_can_edit_everyone', $data ) ) {
96
- $data['_um_can_edit_everyone'] = (bool) $data['_um_can_edit_everyone'];
97
- }
98
 
99
- if ( array_key_exists( '_um_can_edit_roles', $data ) && ! empty( $data['_um_can_edit_roles'] ) ) {
100
- $data['_um_can_edit_roles'] = array_filter( $data['_um_can_edit_roles'], function( $v, $k ) use ( $all_roles ) {
101
- return in_array( $v, $all_roles );
102
- }, ARRAY_FILTER_USE_BOTH );
103
- }
104
-
105
- if ( array_key_exists( '_um_can_delete_everyone', $data ) ) {
106
- $data['_um_can_delete_everyone'] = (bool) $data['_um_can_delete_everyone'];
107
- }
108
-
109
- if ( array_key_exists( '_um_can_delete_roles', $data ) && ! empty( $data['_um_can_delete_roles'] ) ) {
110
- $data['_um_can_delete_roles'] = array_filter( $data['_um_can_delete_roles'], function( $v, $k ) use ( $all_roles ) {
111
- return in_array( $v, $all_roles );
112
- }, ARRAY_FILTER_USE_BOTH );
113
- }
114
-
115
- if ( array_key_exists( '_um_can_edit_profile', $data ) ) {
116
- $data['_um_can_edit_profile'] = (bool) $data['_um_can_edit_profile'];
117
- }
118
-
119
- if ( array_key_exists( '_um_can_delete_profile', $data ) ) {
120
- $data['_um_can_delete_profile'] = (bool) $data['_um_can_delete_profile'];
121
- }
122
-
123
- if ( array_key_exists( '_um_can_view_all', $data ) ) {
124
- $data['_um_can_view_all'] = (bool) $data['_um_can_view_all'];
125
- }
126
-
127
- if ( array_key_exists( '_um_can_view_roles', $data ) && ! empty( $data['_um_can_view_roles'] ) ) {
128
- $data['_um_can_view_roles'] = array_filter( $data['_um_can_view_roles'], function( $v, $k ) use ( $all_roles ) {
129
- return in_array( $v, $all_roles );
130
- }, ARRAY_FILTER_USE_BOTH );
131
- }
132
-
133
- if ( array_key_exists( '_um_can_make_private_profile', $data ) ) {
134
- $data['_um_can_make_private_profile'] = (bool) $data['_um_can_make_private_profile'];
135
- }
136
-
137
- if ( array_key_exists( '_um_can_access_private_profile', $data ) ) {
138
- $data['_um_can_access_private_profile'] = (bool) $data['_um_can_access_private_profile'];
139
- }
140
-
141
- if ( array_key_exists( '_um_profile_noindex', $data ) ) {
142
- $data['_um_profile_noindex'] = $data['_um_profile_noindex'] !== '' ? (bool) $data['_um_profile_noindex'] : $data['_um_profile_noindex'];
143
- }
144
-
145
- if ( array_key_exists( '_um_default_homepage', $data ) ) {
146
- $data['_um_default_homepage'] = (bool) $data['_um_default_homepage'];
147
- }
148
-
149
- if ( array_key_exists( '_um_redirect_homepage', $data ) ) {
150
- $data['_um_redirect_homepage'] = esc_url_raw( $data['_um_redirect_homepage'] );
151
- }
152
-
153
- if ( array_key_exists( '_um_status', $data ) ) {
154
- $data['_um_status'] = ! in_array( sanitize_key( $data['_um_status'] ), [ 'approved', 'checkmail', 'pending' ] ) ? 'approved' : sanitize_key( $data['_um_status'] );
155
- }
156
-
157
- if ( array_key_exists( '_um_auto_approve_act', $data ) ) {
158
- $data['_um_auto_approve_act'] = ! in_array( sanitize_key( $data['_um_auto_approve_act'] ), [ 'redirect_profile', 'redirect_url' ] ) ? 'redirect_profile' : sanitize_key( $data['_um_auto_approve_act'] );
159
- }
160
-
161
- if ( array_key_exists( '_um_auto_approve_url', $data ) ) {
162
- $data['_um_auto_approve_url'] = esc_url_raw( $data['_um_auto_approve_url'] );
163
- }
164
-
165
- if ( array_key_exists( '_um_login_email_activate', $data ) ) {
166
- $data['_um_login_email_activate'] = (bool) $data['_um_login_email_activate'];
167
- }
168
-
169
- if ( array_key_exists( '_um_checkmail_action', $data ) ) {
170
- $data['_um_checkmail_action'] = ! in_array( sanitize_key( $data['_um_checkmail_action'] ), [ 'show_message', 'redirect_url' ] ) ? 'show_message' : sanitize_key( $data['_um_checkmail_action'] );
171
- }
172
-
173
- if ( array_key_exists( '_um_checkmail_message', $data ) ) {
174
- $data['_um_checkmail_message'] = sanitize_textarea_field( $data['_um_checkmail_message'] );
175
- }
176
-
177
- if ( array_key_exists( '_um_checkmail_url', $data ) ) {
178
- $data['_um_checkmail_url'] = esc_url_raw( $data['_um_checkmail_url'] );
179
- }
180
-
181
- if ( array_key_exists( '_um_url_email_activate', $data ) ) {
182
- $data['_um_url_email_activate'] = esc_url_raw( $data['_um_url_email_activate'] );
183
- }
184
-
185
- if ( array_key_exists( '_um_pending_action', $data ) ) {
186
- $data['_um_pending_action'] = ! in_array( sanitize_key( $data['_um_pending_action'] ), [ 'show_message', 'redirect_url' ] ) ? 'show_message' : sanitize_key( $data['_um_pending_action'] );
187
- }
188
-
189
- if ( array_key_exists( '_um_pending_message', $data ) ) {
190
- $data['_um_pending_message'] = sanitize_textarea_field( $data['_um_pending_message'] );
191
- }
192
-
193
- if ( array_key_exists( '_um_pending_url', $data ) ) {
194
- $data['_um_pending_url'] = esc_url_raw( $data['_um_pending_url'] );
195
- }
196
-
197
- if ( array_key_exists( '_um_after_login', $data ) ) {
198
- $data['_um_after_login'] = ! in_array( sanitize_key( $data['_um_after_login'] ), [ 'redirect_profile', 'redirect_url', 'refresh', 'redirect_admin' ] ) ? 'redirect_profile' : sanitize_key( $data['_um_after_login'] );
199
- }
200
-
201
- if ( array_key_exists( '_um_login_redirect_url', $data ) ) {
202
- $data['_um_login_redirect_url'] = esc_url_raw( $data['_um_login_redirect_url'] );
203
- }
204
-
205
- if ( array_key_exists( '_um_after_logout', $data ) ) {
206
- $data['_um_after_logout'] = ! in_array( sanitize_key( $data['_um_after_logout'] ), [ 'redirect_home', 'redirect_url' ] ) ? 'redirect_home' : sanitize_key( $data['_um_after_logout'] );
207
- }
208
-
209
- if ( array_key_exists( '_um_logout_redirect_url', $data ) ) {
210
- $data['_um_logout_redirect_url'] = esc_url_raw( $data['_um_logout_redirect_url'] );
211
- }
212
-
213
- if ( array_key_exists( '_um_after_delete', $data ) ) {
214
- $data['_um_after_delete'] = ! in_array( sanitize_key( $data['_um_after_delete'] ), [ 'redirect_home', 'redirect_url' ] ) ? 'redirect_home' : sanitize_key( $data['_um_after_delete'] );
215
- }
216
-
217
- if ( array_key_exists( '_um_delete_redirect_url', $data ) ) {
218
- $data['_um_delete_redirect_url'] = esc_url_raw( $data['_um_delete_redirect_url'] );
219
- }
220
-
221
- if ( array_key_exists( 'wp_capabilities', $data ) && ! empty( $data['wp_capabilities'] ) ) {
222
- $data['wp_capabilities'] = array_map( 'boolval', array_filter( $data['wp_capabilities'] ) );
223
- }
224
-
225
- $data = apply_filters( 'um_save_role_meta_sanitize', $data );
226
-
227
- if ( 'add' == sanitize_key( $_GET['tab'] ) ) {
228
 
229
  $data['name'] = trim( esc_html( strip_tags( $data['name'] ) ) );
230
 
@@ -237,11 +93,11 @@ if ( ! empty( $_POST['role'] ) ) {
237
  } else {
238
  $auto_increment = UM()->options()->get( 'custom_roles_increment' );
239
  $auto_increment = ! empty( $auto_increment ) ? $auto_increment : 1;
240
- $id = 'custom_role_' . $auto_increment;
241
  }
242
 
243
  $redirect = add_query_arg( array( 'page'=>'um_roles', 'tab'=>'edit', 'id'=>$id, 'msg'=>'a' ), admin_url( 'admin.php' ) );
244
- } elseif ( 'edit' == sanitize_key( $_GET['tab'] ) && ! empty( $_GET['id'] ) ) {
245
  $id = sanitize_key( $_GET['id'] );
246
 
247
  $pre_role_meta = get_option( "um_role_{$id}_meta", array() );
@@ -254,16 +110,16 @@ if ( ! empty( $_POST['role'] ) ) {
254
 
255
 
256
  $all_roles = array_keys( get_editable_roles() );
257
- if ( 'add' == sanitize_key( $_GET['tab'] ) ) {
258
- if ( in_array( 'um_' . $id, $all_roles ) || in_array( $id, $all_roles ) ) {
259
  $error .= __( 'Role already exists!', 'ultimate-member' ) . '<br />';
260
  }
261
  }
262
 
263
- if ( '' == $error ) {
264
 
265
- if ( 'add' == sanitize_key( $_GET['tab'] ) ) {
266
- $roles = get_option( 'um_roles', array() );
267
  $roles[] = $id;
268
 
269
  update_option( 'um_roles', $roles );
@@ -297,14 +153,30 @@ $screen_id = $current_screen->id; ?>
297
 
298
  <div class="wrap">
299
  <h2>
300
- <?php echo ( 'add' == sanitize_key( $_GET['tab'] ) ) ? __( 'Add New Role', 'ultimate-member' ) : __( 'Edit Role', 'ultimate-member' ) ?>
301
- <?php if ( 'edit' == sanitize_key( $_GET['tab'] ) ) { ?>
302
- <a class="add-new-h2" href="<?php echo esc_url( add_query_arg( array( 'page' => 'um_roles', 'tab' => 'add' ), admin_url( 'admin.php' ) ) ) ?>"><?php _e( 'Add New', 'ultimate-member' ) ?></a>
303
- <?php } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
  </h2>
305
 
306
- <?php if ( ! empty( $_GET['msg'] ) ) {
307
- switch( sanitize_key( $_GET['msg'] ) ) {
 
308
  case 'a':
309
  echo '<div id="message" class="updated fade"><p>' . __( 'User Role <strong>Added</strong> Successfully.', 'ultimate-member' ) . '</p></div>';
310
  break;
@@ -316,13 +188,13 @@ $screen_id = $current_screen->id; ?>
316
 
317
  if ( ! empty( $error ) ) { ?>
318
  <div id="message" class="error fade">
319
- <p><?php echo $error ?></p>
320
  </div>
321
  <?php } ?>
322
 
323
  <form id="um_edit_role" action="" method="post">
324
  <input type="hidden" name="role[id]" value="<?php echo isset( $_GET['id'] ) ? esc_attr( sanitize_key( $_GET['id'] ) ) : '' ?>" />
325
- <?php if ( 'add' == sanitize_key( $_GET['tab'] ) ) { ?>
326
  <input type="hidden" name="role[_um_is_custom]" value="1" />
327
  <input type="hidden" name="um_nonce" value="<?php echo esc_attr( wp_create_nonce( 'um-add-role' ) ) ?>" />
328
  <?php } else { ?>
@@ -335,7 +207,7 @@ $screen_id = $current_screen->id; ?>
335
  <div id="post-body-content">
336
  <div id="titlediv">
337
  <div id="titlewrap">
338
- <?php if ( 'add' == sanitize_key( $_GET['tab'] ) ) { ?>
339
  <label for="title" class="screen-reader-text"><?php _e( 'Title', 'ultimate-member' ) ?></label>
340
  <input type="text" name="role[name]" placeholder="<?php esc_attr_e( 'Enter Title Here', 'ultimate-member' ) ?>" id="title" value="<?php echo isset( $data['name'] ) ? $data['name'] : '' ?>" />
341
  <?php } else { ?>
@@ -345,11 +217,18 @@ $screen_id = $current_screen->id; ?>
345
  </div>
346
  </div>
347
 
 
 
 
 
 
 
 
348
  <div id="postbox-container-1" class="postbox-container">
349
- <?php do_meta_boxes( 'um_role_meta', 'side', array( 'data' => $data, 'option' => $option ) ); ?>
350
  </div>
351
  <div id="postbox-container-2" class="postbox-container">
352
- <?php do_meta_boxes( 'um_role_meta', 'normal', array( 'data' => $data, 'option' => $option ) ); ?>
353
  </div>
354
  </div>
355
  </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
 
5
  wp_enqueue_script( 'postbox' );
6
  wp_enqueue_media();
44
  */
45
  do_action( 'um_roles_add_meta_boxes_um_role_meta' );
46
 
47
+ $data = array();
48
  $option = array();
49
  global $wp_roles;
50
 
62
 
63
  if ( ! empty( $_POST['role'] ) ) {
64
 
65
+ $id = '';
66
  $redirect = '';
67
+ $error = '';
68
 
69
+ if ( 'add' === sanitize_key( $_GET['tab'] ) ) {
70
  if ( ! wp_verify_nonce( $_POST['um_nonce'], 'um-add-role' ) ) {
71
  $error = __( 'Security Issue', 'ultimate-member' ) . '<br />';
72
  }
78
 
79
  if ( empty( $error ) ) {
80
 
81
+ $data = UM()->admin()->sanitize_role_meta( $_POST['role'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
83
+ if ( 'add' === sanitize_key( $_GET['tab'] ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
 
85
  $data['name'] = trim( esc_html( strip_tags( $data['name'] ) ) );
86
 
93
  } else {
94
  $auto_increment = UM()->options()->get( 'custom_roles_increment' );
95
  $auto_increment = ! empty( $auto_increment ) ? $auto_increment : 1;
96
+ $id = 'custom_role_' . $auto_increment;
97
  }
98
 
99
  $redirect = add_query_arg( array( 'page'=>'um_roles', 'tab'=>'edit', 'id'=>$id, 'msg'=>'a' ), admin_url( 'admin.php' ) );
100
+ } elseif ( 'edit' === sanitize_key( $_GET['tab'] ) && ! empty( $_GET['id'] ) ) {
101
  $id = sanitize_key( $_GET['id'] );
102
 
103
  $pre_role_meta = get_option( "um_role_{$id}_meta", array() );
110
 
111
 
112
  $all_roles = array_keys( get_editable_roles() );
113
+ if ( 'add' === sanitize_key( $_GET['tab'] ) ) {
114
+ if ( in_array( 'um_' . $id, $all_roles, true ) || in_array( $id, $all_roles, true ) ) {
115
  $error .= __( 'Role already exists!', 'ultimate-member' ) . '<br />';
116
  }
117
  }
118
 
119
+ if ( '' === $error ) {
120
 
121
+ if ( 'add' === sanitize_key( $_GET['tab'] ) ) {
122
+ $roles = get_option( 'um_roles', array() );
123
  $roles[] = $id;
124
 
125
  update_option( 'um_roles', $roles );
153
 
154
  <div class="wrap">
155
  <h2>
156
+ <?php
157
+ if ( 'add' === sanitize_key( $_GET['tab'] ) ) {
158
+ esc_html_e( 'Add New Role', 'ultimate-member' );
159
+ } elseif ( 'edit' === sanitize_key( $_GET['tab'] ) ) {
160
+ esc_html_e( 'Edit Role', 'ultimate-member' );
161
+ $add_new_link = add_query_arg(
162
+ array(
163
+ 'page' => 'um_roles',
164
+ 'tab' => 'add',
165
+ ),
166
+ admin_url( 'admin.php' )
167
+ );
168
+ ?>
169
+ <a class="add-new-h2" href="<?php echo esc_url( $add_new_link ); ?>">
170
+ <?php esc_html_e( 'Add New', 'ultimate-member' ); ?>
171
+ </a>
172
+ <?php
173
+ }
174
+ ?>
175
  </h2>
176
 
177
+ <?php
178
+ if ( ! empty( $_GET['msg'] ) ) {
179
+ switch ( sanitize_key( $_GET['msg'] ) ) {
180
  case 'a':
181
  echo '<div id="message" class="updated fade"><p>' . __( 'User Role <strong>Added</strong> Successfully.', 'ultimate-member' ) . '</p></div>';
182
  break;
188
 
189
  if ( ! empty( $error ) ) { ?>
190
  <div id="message" class="error fade">
191
+ <p><?php echo $error; ?></p>
192
  </div>
193
  <?php } ?>
194
 
195
  <form id="um_edit_role" action="" method="post">
196
  <input type="hidden" name="role[id]" value="<?php echo isset( $_GET['id'] ) ? esc_attr( sanitize_key( $_GET['id'] ) ) : '' ?>" />
197
+ <?php if ( 'add' === sanitize_key( $_GET['tab'] ) ) { ?>
198
  <input type="hidden" name="role[_um_is_custom]" value="1" />
199
  <input type="hidden" name="um_nonce" value="<?php echo esc_attr( wp_create_nonce( 'um-add-role' ) ) ?>" />
200
  <?php } else { ?>
207
  <div id="post-body-content">
208
  <div id="titlediv">
209
  <div id="titlewrap">
210
+ <?php if ( 'add' === sanitize_key( $_GET['tab'] ) ) { ?>
211
  <label for="title" class="screen-reader-text"><?php _e( 'Title', 'ultimate-member' ) ?></label>
212
  <input type="text" name="role[name]" placeholder="<?php esc_attr_e( 'Enter Title Here', 'ultimate-member' ) ?>" id="title" value="<?php echo isset( $data['name'] ) ? $data['name'] : '' ?>" />
213
  <?php } else { ?>
217
  </div>
218
  </div>
219
 
220
+ <?php
221
+ $object = array(
222
+ 'data' => $data,
223
+ 'option' => $option,
224
+ );
225
+ ?>
226
+
227
  <div id="postbox-container-1" class="postbox-container">
228
+ <?php do_meta_boxes( 'um_role_meta', 'side', $object ); ?>
229
  </div>
230
  <div id="postbox-container-2" class="postbox-container">
231
+ <?php do_meta_boxes( 'um_role_meta', 'normal', $object ); ?>
232
  </div>
233
  </div>
234
  </div>
includes/admin/templates/role/wp-capabilities.php CHANGED
@@ -51,7 +51,8 @@
51
  </span>
52
 
53
 
54
- <?php $role = $object['data'];
 
55
  $role_capabilities = ! empty( $role['wp_capabilities'] ) ? array_keys( $role['wp_capabilities'] ) : array( 'read' );
56
 
57
  if ( ! empty( $_GET['id'] ) ) {
@@ -89,4 +90,4 @@
89
  )
90
  )
91
  ) )->render_form(); ?>
92
- </div>
51
  </span>
52
 
53
 
54
+ <?php
55
+ $role = $object['data'];
56
  $role_capabilities = ! empty( $role['wp_capabilities'] ) ? array_keys( $role['wp_capabilities'] ) : array( 'read' );
57
 
58
  if ( ! empty( $_GET['id'] ) ) {
90
  )
91
  )
92
  ) )->render_form(); ?>
93
+ </div>
includes/class-functions.php CHANGED
@@ -48,7 +48,7 @@ if ( ! class_exists( 'UM_Functions' ) ) {
48
  * @param bool $action
49
  */
50
  function check_ajax_nonce( $action = false ) {
51
- $nonce = isset( $_REQUEST['nonce'] ) ? $_REQUEST['nonce'] : '';
52
  $action = empty( $action ) ? 'um-frontend-nonce' : $action;
53
 
54
  if ( ! wp_verify_nonce( $nonce, $action ) ) {
@@ -392,4 +392,4 @@ if ( ! class_exists( 'UM_Functions' ) ) {
392
  }
393
 
394
  }
395
- }
48
  * @param bool $action
49
  */
50
  function check_ajax_nonce( $action = false ) {
51
+ $nonce = isset( $_REQUEST['nonce'] ) ? sanitize_text_field( $_REQUEST['nonce'] ) : '';
52
  $action = empty( $action ) ? 'um-frontend-nonce' : $action;
53
 
54
  if ( ! wp_verify_nonce( $nonce, $action ) ) {
392
  }
393
 
394
  }
395
+ }
includes/core/class-access.php CHANGED
@@ -51,6 +51,13 @@ if ( ! class_exists( 'um\core\Access' ) ) {
51
  $this->redirect_handler = false;
52
  $this->allow_access = false;
53
 
 
 
 
 
 
 
 
54
  //there is posts (Posts/Page/CPT) filtration if site is accessible
55
  //there also will be redirects if they need
56
  //protect posts types
@@ -63,6 +70,10 @@ if ( ! class_exists( 'um\core\Access' ) ) {
63
  // turn on/off content replacement on the filter 'the_content'
64
  add_action( 'get_header', array( &$this, 'replace_post_content_on' ), 12 );
65
  add_action( 'get_footer', array( &$this, 'replace_post_content_off' ), 8 );
 
 
 
 
66
 
67
  //filter attachment
68
  add_filter( 'wp_get_attachment_url', array( &$this, 'filter_attachment' ), 99, 2 );
@@ -504,9 +515,10 @@ if ( ! class_exists( 'um\core\Access' ) ) {
504
  * }
505
  * ?>
506
  */
507
- $enable_referer = apply_filters( "um_access_enable_referer", false );
508
- if ( ! $enable_referer )
509
  return $url;
 
510
 
511
  $url = add_query_arg( 'um_ref', $referer, $url );
512
  return $url;
@@ -541,10 +553,14 @@ if ( ! class_exists( 'um\core\Access' ) ) {
541
  * return false if post is not private
542
  * Restrict content new logic
543
  *
544
- * @param $post
545
  * @return bool|array
546
  */
547
  function get_post_privacy_settings( $post ) {
 
 
 
 
548
  $exclude = false;
549
 
550
  //if logged in administrator all pages are visible
@@ -699,7 +715,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
699
  foreach ( $posts as $post ) {
700
 
701
  //Woocommerce AJAX fixes....remove filtration on wc-ajax which goes to Front Page
702
- if ( ! empty( $_GET['wc-ajax'] ) && defined('WC_DOING_AJAX') && WC_DOING_AJAX /*&& $query->is_front_page()*/ ) {
703
  $filtered_posts[] = $post;
704
  continue;
705
  }
@@ -1013,6 +1029,120 @@ if ( ! class_exists( 'um\core\Access' ) ) {
1013
  }
1014
 
1015
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1016
  /**
1017
  * @param string $single_template
1018
  *
@@ -1203,7 +1333,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
1203
  $restricted = false;
1204
  } elseif ( '1' == $restriction[ '_um_accessible' ] ) {
1205
  //if post for not logged in users and user is not logged in
1206
- if ( !is_user_logged_in() ) {
1207
  $restricted = false;
1208
  } else {
1209
 
@@ -1464,4 +1594,4 @@ if ( ! class_exists( 'um\core\Access' ) ) {
1464
  }
1465
 
1466
  }
1467
- }
51
  $this->redirect_handler = false;
52
  $this->allow_access = false;
53
 
54
+ add_action( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99, 1 );
55
+ add_action( 'pre_get_comments', array( &$this, 'exclude_posts_comments' ), 99, 1 );
56
+ add_filter( 'get_next_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 );
57
+ add_filter( 'get_previous_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 );
58
+ add_filter( 'widget_posts_args', array( &$this, 'exclude_restricted_posts_widget' ), 99, 1 );
59
+ add_filter( 'comment_feed_where', array( &$this, 'exclude_posts_comments_feed' ), 99, 2 );
60
+
61
  //there is posts (Posts/Page/CPT) filtration if site is accessible
62
  //there also will be redirects if they need
63
  //protect posts types
70
  // turn on/off content replacement on the filter 'the_content'
71
  add_action( 'get_header', array( &$this, 'replace_post_content_on' ), 12 );
72
  add_action( 'get_footer', array( &$this, 'replace_post_content_off' ), 8 );
73
+ // turn on/off content replacement on the filter 'the_content' with the theme "Avada"
74
+ add_action( 'avada_before_body_content', array( &$this, 'replace_post_content_off' ), 8 );
75
+ add_action( 'avada_before_main_container', array( &$this, 'replace_post_content_on' ), 12 );
76
+ add_action( 'avada_after_main_content', array( &$this, 'replace_post_content_off' ), 8 );
77
 
78
  //filter attachment
79
  add_filter( 'wp_get_attachment_url', array( &$this, 'filter_attachment' ), 99, 2 );
515
  * }
516
  * ?>
517
  */
518
+ $enable_referer = apply_filters( 'um_access_enable_referer', false );
519
+ if ( ! $enable_referer ) {
520
  return $url;
521
+ }
522
 
523
  $url = add_query_arg( 'um_ref', $referer, $url );
524
  return $url;
553
  * return false if post is not private
554
  * Restrict content new logic
555
  *
556
+ * @param \WP_Post|int $post Post ID or object
557
  * @return bool|array
558
  */
559
  function get_post_privacy_settings( $post ) {
560
+ if ( is_numeric( $post ) ) {
561
+ $post = get_post( $post );
562
+ }
563
+
564
  $exclude = false;
565
 
566
  //if logged in administrator all pages are visible
715
  foreach ( $posts as $post ) {
716
 
717
  //Woocommerce AJAX fixes....remove filtration on wc-ajax which goes to Front Page
718
+ if ( ! empty( $_GET['wc-ajax'] ) && defined( 'WC_DOING_AJAX' ) && WC_DOING_AJAX ) {
719
  $filtered_posts[] = $post;
720
  continue;
721
  }
1029
  }
1030
 
1031
 
1032
+ /**
1033
+ * Exclude posts from query
1034
+ *
1035
+ * @param \WP_Query $query
1036
+ */
1037
+ function exclude_posts( $query ) {
1038
+ if ( $query->is_main_query() ) {
1039
+ $exclude_posts = $this->exclude_posts_array();
1040
+ if ( ! empty( $exclude_posts ) ) {
1041
+ $post__not_in = $query->get( 'post__not_in', array() );
1042
+ $query->set( 'post__not_in', array_merge( $post__not_in, $exclude_posts ) );
1043
+ }
1044
+ }
1045
+ }
1046
+
1047
+
1048
+ /**
1049
+ * Exclude comments from restricted posts in widgets
1050
+ *
1051
+ * @param \WP_Comment_Query $query
1052
+ *
1053
+ */
1054
+ function exclude_posts_comments( $query ) {
1055
+ $exclude_posts = $this->exclude_posts_array( false );
1056
+ if ( ! empty( $exclude_posts ) ) {
1057
+ $query->query_vars['post__not_in'] = $exclude_posts;
1058
+ }
1059
+ }
1060
+
1061
+
1062
+ /**
1063
+ * Exclude comments from comments feed
1064
+ *
1065
+ * @param string $where
1066
+ * @param \WP_Query $query
1067
+ *
1068
+ * @return string
1069
+ */
1070
+ function exclude_posts_comments_feed( $where, $query ) {
1071
+ $exclude_posts = $this->exclude_posts_array( false );
1072
+ if ( ! empty( $exclude_posts ) ) {
1073
+ $exclude_string = implode( ',', $exclude_posts );
1074
+ $where .= ' AND comment_post_ID NOT IN ( ' . $exclude_string . ' )';
1075
+ }
1076
+
1077
+ return $where;
1078
+ }
1079
+
1080
+
1081
+ /**
1082
+ * get array with restricted posts
1083
+ *
1084
+ * @param bool $in_query
1085
+ *
1086
+ * @return array
1087
+ */
1088
+ function exclude_posts_array( $in_query = true ) {
1089
+ global $wpdb;
1090
+
1091
+ $exclude_posts = array();
1092
+ $posts = $wpdb->get_col("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = 'um_content_restriction'");
1093
+ foreach ( $posts as $post ) {
1094
+ $content_restriction = $this->get_post_privacy_settings( $post );
1095
+
1096
+ if ( false === $in_query || ! empty( $content_restriction['_um_access_hide_from_queries'] ) ) {
1097
+ if ( $this->is_restricted( $post ) ) {
1098
+ array_push( $exclude_posts, $post );
1099
+ }
1100
+ }
1101
+ }
1102
+
1103
+ return $exclude_posts;
1104
+ }
1105
+
1106
+
1107
+ /**
1108
+ * Exclude posts from next, previous navigation
1109
+ *
1110
+ * @param string $where
1111
+ * @param bool $in_same_term
1112
+ * @param array $excluded_terms
1113
+ * @param string $taxonomy.
1114
+ * @param \WP_Post $post
1115
+ *
1116
+ * @return string
1117
+ */
1118
+ function exclude_navigation_posts( $where, $in_same_term, $excluded_terms, $taxonomy, $post ) {
1119
+ $exclude_posts = $this->exclude_posts_array();
1120
+ if ( ! empty( $exclude_posts ) ) {
1121
+ $exclude_string = implode( ',', $exclude_posts );
1122
+ $where .= ' AND ID NOT IN ( ' . $exclude_string . ' )';
1123
+ }
1124
+
1125
+ return $where;
1126
+ }
1127
+
1128
+
1129
+ /**
1130
+ * Exclude restricted posts in widgets
1131
+ *
1132
+ * @param array $array
1133
+ *
1134
+ * @return array
1135
+ */
1136
+ function exclude_restricted_posts_widget( $array ) {
1137
+ $exclude_posts = $this->exclude_posts_array();
1138
+ if ( ! empty( $exclude_posts ) ) {
1139
+ $array['post__not_in'] = $exclude_posts;
1140
+ }
1141
+
1142
+ return $array;
1143
+ }
1144
+
1145
+
1146
  /**
1147
  * @param string $single_template
1148
  *
1333
  $restricted = false;
1334
  } elseif ( '1' == $restriction[ '_um_accessible' ] ) {
1335
  //if post for not logged in users and user is not logged in
1336
+ if ( ! is_user_logged_in() ) {
1337
  $restricted = false;
1338
  } else {
1339
 
1594
  }
1595
 
1596
  }
1597
+ }
includes/core/class-account.php CHANGED
@@ -397,6 +397,8 @@ if ( ! class_exists( 'um\core\Account' ) ) {
397
  $this->current_tab = UM()->form()->post_form['_um_account_tab'];
398
  }
399
 
 
 
400
  if ( ! isset( UM()->form()->errors ) ) {
401
  /**
402
  * UM hook
@@ -971,4 +973,4 @@ if ( ! class_exists( 'um\core\Account' ) ) {
971
  return $is_required;
972
  }
973
  }
974
- }
397
  $this->current_tab = UM()->form()->post_form['_um_account_tab'];
398
  }
399
 
400
+ $this->current_tab = sanitize_key( $this->current_tab );
401
+
402
  if ( ! isset( UM()->form()->errors ) ) {
403
  /**
404
  * UM hook
973
  return $is_required;
974
  }
975
  }
976
+ }
includes/core/class-builtin.php CHANGED
@@ -1,1890 +1,1915 @@
1
- <?php
2
- namespace um\core;
3
-
4
- // Exit if accessed directly
5
- if ( ! defined( 'ABSPATH' ) ) exit;
6
-
7
- if ( ! class_exists( 'um\core\Builtin' ) ) {
8
-
9
-
10
- /**
11
- * Class Builtin
12
- * @package um\core
13
- */
14
- class Builtin {
15
-
16
-
17
- /**
18
- * @var array
19
- */
20
- public $predefined_fields = array();
21
-
22
-
23
- /**
24
- * @var array
25
- */
26
- var $all_user_fields = array();
27
-
28
-
29
- /**
30
- * @var array
31
- */
32
- var $core_fields = array();
33
-
34
-
35
- /**
36
- * Builtin constructor.
37
- */
38
- function __construct() {
39
- add_action( 'init', array(&$this, 'set_core_fields'), 1);
40
- add_action( 'init', array(&$this, 'set_predefined_fields'), 1);
41
- add_action( 'init', array(&$this, 'set_custom_fields'), 1);
42
- $this->saved_fields = get_option( 'um_fields' );
43
- }
44
-
45
-
46
- /**
47
- * @return array
48
- */
49
- function get_all_user_fields() {
50
- return apply_filters( 'um_builtin_all_user_fields', $this->all_user_fields );
51
- }
52
-
53
-
54
- /**
55
- * Regular or multi-select/options
56
- *
57
- * @param $field
58
- * @param $attrs
59
- *
60
- * @return bool
61
- */
62
- function is_dropdown_field( $field, $attrs ) {
63
-
64
- if ( isset( $attrs['options'] ) )
65
- return true;
66
-
67
- $fields = $this->all_user_fields;
68
-
69
- if ( isset( $fields[$field]['options'] ) || ! empty( $fields[$field]['custom_dropdown_options_source'] ) )
70
- return true;
71
-
72
- return false;
73
- }
74
-
75
-
76
- /**
77
- * Get a field
78
- *
79
- * @param $field
80
- *
81
- * @return mixed|string
82
- */
83
- function get_a_field( $field ) {
84
- $fields = $this->all_user_fields;
85
- if ( isset( $fields[ $field ] ) ) {
86
- return $fields[ $field ];
87
- }
88
- return '';
89
- }
90
-
91
-
92
- /**
93
- * Get specific fields
94
- *
95
- * @param $fields
96
- *
97
- * @return array
98
- */
99
- function get_specific_fields( $fields ) {
100
- $fields = explode( ',', $fields );
101
- $array = array();
102
- foreach ( $fields as $field ) {
103
- if ( isset( $this->predefined_fields[ $field ] ) ) {
104
- $array[ $field ] = $this->predefined_fields[ $field ];
105
- }
106
- }
107
- return $array;
108
- }
109
-
110
-
111
- /**
112
- * Get specific field
113
- *
114
- * @param $fields
115
- *
116
- * @return array|mixed
117
- */
118
- function get_specific_field( $fields ) {
119
- $fields = explode( ',', $fields );
120
- $array = array();
121
- foreach ( $fields as $field ) {
122
- if ( isset( $this->predefined_fields[ $field ] ) ) {
123
- $array = $this->predefined_fields[ $field ];
124
- } elseif ( isset( $this->saved_fields[ $field ] ) ) {
125
- $array = $this->saved_fields[ $field ];
126
- }
127
- }
128
- return $array;
129
- }
130
-
131
-
132
- /**
133
- * Checks for a unique field error
134
- *
135
- * @param $key
136
- *
137
- * @return int|string|void
138
- */
139
- function unique_field_err( $key ) {
140
- if ( empty( $key ) ) return __('Please provide a meta key','ultimate-member');
141
- if ( isset( $this->core_fields[ $key ] ) ) return __('Your meta key is a reserved core field and cannot be used','ultimate-member');
142
- if ( isset( $this->predefined_fields[ $key ] ) ) return __('Your meta key is a predefined reserved key and cannot be used','ultimate-member');
143
- if ( isset( $this->saved_fields[ $key ] ) ) return __('Your meta key already exists in your fields list','ultimate-member');
144
- if ( ! UM()->validation()->safe_string( $key ) ) return __('Your meta key contains illegal characters. Please correct it.','ultimate-member');
145
- return 0;
146
- }
147
-
148
-
149
- /**
150
- * Check date range errors (start date)
151
- *
152
- * @param $date
153
- *
154
- * @return int|string|void
155
- */
156
- function date_range_start_err( $date ) {
157
- if ( empty( $date ) ) return __('Please provide a date range beginning','ultimate-member');
158
- if ( ! UM()->validation()->validate_date( $date ) ) return __('Please enter a valid start date in the date range','ultimate-member');
159
- return 0;
160
- }
161
-
162
-
163
- /**
164
- * Check date range errors (end date)
165
- *
166
- * @param $date
167
- * @param $start_date
168
- *
169
- * @return int|string|void
170
- */
171
- function date_range_end_err( $date, $start_date ) {
172
- if ( empty( $date ) ) return __('Please provide a date range end','ultimate-member');
173
- if ( ! UM()->validation()->validate_date( $date ) ) return __('Please enter a valid end date in the date range','ultimate-member');
174
- if ( strtotime( $date ) <= strtotime( $start_date ) ) return __('The end of date range must be greater than the start of date range','ultimate-member');
175
- return 0;
176
- }
177
-
178
-
179
- /**
180
- * Get a core field attrs
181
- *
182
- * @param $type
183
- *
184
- * @return array|mixed
185
- */
186
- function get_core_field_attrs( $type ) {
187
- return ( isset( $this->core_fields[ $type ] ) ) ? $this->core_fields[ $type ] : array('');
188
- }
189
-
190
-
191
- /**
192
- * Core Fields
193
- */
194
- function set_core_fields() {
195
-
196
- $this->core_fields = array(
197
-
198
- 'row' => array(
199
- 'name' => 'Row',
200
- 'in_fields' => false,
201
- 'form_only' => true,
202
- 'conditional_support' => 0,
203
- 'icon' => 'um-faicon-pencil',
204
- 'col1' => array('_id','_background','_text_color','_padding','_margin','_border','_borderradius','_borderstyle','_bordercolor'),
205
- 'col2' => array('_heading','_heading_text','_heading_background_color','_heading_text_color','_icon','_icon_color','_css_class'),
206
- ),
207
-
208
- 'text' => array(
209
- 'name' => 'Text Box',
210
- 'col1' => array('_title','_metakey','_help','_default','_min_chars','_visibility'),
211
- 'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate','_max_chars'),
212
- 'col3' => array('_required','_editable','_icon'),
213
- 'validate' => array(
214
- '_title' => array(
215
- 'mode' => 'required',
216
- 'error' => __('You must provide a title','ultimate-member')
217
- ),
218
- '_metakey' => array(
219
- 'mode' => 'unique',
220
- ),
221
- )
222
- ),
223
-
224
- 'number' => array(
225
- 'name' => __('Number','ultimate-member'),
226
- 'col1' => array('_title','_metakey','_help','_default','_min','_visibility'),
227
- 'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate','_max'),
228
- 'col3' => array('_required','_editable','_icon'),
229
- 'validate' => array(
230
- '_title' => array(
231
- 'mode' => 'required',
232
- 'error' => __('You must provide a title','ultimate-member')
233
- ),
234
- '_metakey' => array(
235
- 'mode' => 'unique',
236
- ),
237
- )
238
- ),
239
-
240
- 'textarea' => array(
241
- 'name' => 'Textarea',
242
- 'col1' => array('_title','_metakey','_help','_height','_max_chars','_max_words','_visibility'),
243
- 'col2' => array('_label','_placeholder','_public','_roles','_default','_html'),
244
- 'col3' => array('_required','_editable','_icon'),
245
- 'validate' => array(
246
- '_title' => array(
247
- 'mode' => 'required',
248
- 'error' => __('You must provide a title','ultimate-member')
249
- ),
250
- '_metakey' => array(
251
- 'mode' => 'unique',
252
- ),
253
- )
254
- ),
255
-
256
- 'select' => array(
257
- 'name' => 'Dropdown',
258
- 'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
259
- 'col2' => array('_label','_placeholder','_public','_roles','_custom_dropdown_options_source','_parent_dropdown_relationship'),
260
- 'col3' => array('_required','_editable','_icon'),
261
- 'validate' => array(
262
- '_title' => array(
263
- 'mode' => 'required',
264
- 'error' => __('You must provide a title','ultimate-member')
265
- ),
266
- '_metakey' => array(
267
- 'mode' => 'unique',
268
- ),
269
- '_options' => array(
270
- 'mode' => 'required',
271
- 'error' => __('You have not added any choices yet.','ultimate-member')
272
- ),
273
- )
274
- ),
275
-
276
- 'multiselect' => array(
277
- 'name' => 'Multi-Select',
278
- 'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
279
- 'col2' => array('_label','_placeholder','_public','_roles','_min_selections','_max_selections','_custom_dropdown_options_source'),
280
- 'col3' => array('_required','_editable','_icon'),
281
- 'validate' => array(
282
- '_title' => array(
283
- 'mode' => 'required',
284
- 'error' => __('You must provide a title','ultimate-member')
285
- ),
286
- '_metakey' => array(
287
- 'mode' => 'unique',
288
- ),
289
- '_options' => array(
290
- 'mode' => 'required',
291
- 'error' => __('You have not added any choices yet.','ultimate-member')
292
- ),
293
- )
294
- ),
295
-
296
- 'radio' => array(
297
- 'name' => 'Radio',
298
- 'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
299
- 'col2' => array('_label','_public','_roles'),
300
- 'col3' => array('_required','_editable','_icon'),
301
- 'validate' => array(
302
- '_title' => array(
303
- 'mode' => 'required',
304
- 'error' => __('You must provide a title','ultimate-member')
305
- ),
306
- '_metakey' => array(
307
- 'mode' => 'unique',
308
- ),
309
- '_options' => array(
310
- 'mode' => 'required',
311
- 'error' => __('You have not added any choices yet.','ultimate-member')
312
- ),
313
- )
314
- ),
315
-
316
- 'checkbox' => array(
317
- 'name' => 'Checkbox',
318
- 'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
319
- 'col2' => array('_label','_public','_roles','_max_selections'),
320
- 'col3' => array('_required','_editable','_icon'),
321
- 'validate' => array(
322
- '_title' => array(
323
- 'mode' => 'required',
324
- 'error' => __('You must provide a title','ultimate-member')
325
- ),
326
- '_metakey' => array(
327
- 'mode' => 'unique',
328
- ),
329
- '_options' => array(
330
- 'mode' => 'required',
331
- 'error' => __('You have not added any choices yet.','ultimate-member')
332
- ),
333
- )
334
- ),
335
-
336
- 'url' => array(
337
- 'name' => 'URL',
338
- 'col1' => array('_title','_metakey','_help','_default','_url_text','_visibility'),
339
- 'col2' => array('_label','_placeholder','_url_target','_url_rel','_public','_roles','_validate','_custom_validate'),
340
- 'col3' => array('_required','_editable','_icon'),
341
- 'validate' => array(
342
- '_title' => array(
343
- 'mode' => 'required',
344
- 'error' => __('You must provide a title','ultimate-member')
345
- ),
346
- '_metakey' => array(
347
- 'mode' => 'unique',
348
- ),
349
- )
350
- ),
351
-
352
- 'password' => array(
353
- 'name' => 'Password',
354
- 'col1' => array('_title','_metakey','_help','_min_chars','_max_chars','_visibility'),
355
- 'col2' => array('_label','_placeholder','_public','_roles','_force_good_pass','_force_confirm_pass'),
356
- 'col3' => array('_required','_editable','_icon'),
357
- 'validate' => array(
358
- '_title' => array(
359
- 'mode' => 'required',
360
- 'error' => __('You must provide a title','ultimate-member')
361
- ),
362
- '_metakey' => array(
363
- 'mode' => 'unique',
364
- ),
365
- )
366
- ),
367
-
368
- 'image' => array(
369
- 'name' => 'Image Upload',
370
- 'col1' => array('_title','_metakey','_help','_allowed_types','_max_size','_crop','_visibility'),
371
- 'col2' => array('_label','_public','_roles','_upload_text','_upload_help_text','_button_text'),
372
- 'col3' => array('_required','_editable','_icon'),
373
- 'validate' => array(
374
- '_title' => array(
375
- 'mode' => 'required',
376
- 'error' => __('You must provide a title','ultimate-member')
377
- ),
378
- '_metakey' => array(
379
- 'mode' => 'unique',
380
- ),
381
- '_max_size' => array(
382
- 'mode' => 'numeric',
383
- 'error' => __('Please enter a valid size','ultimate-member')
384
- ),
385
- )
386
- ),
387
-
388
- 'file' => array(
389
- 'name' => 'File Upload',
390
- 'col1' => array('_title','_metakey','_help','_allowed_types','_max_size','_visibility'),
391
- 'col2' => array('_label','_public','_roles','_upload_text','_upload_help_text','_button_text'),
392
- 'col3' => array('_required','_editable','_icon'),
393
- 'validate' => array(
394
- '_title' => array(
395
- 'mode' => 'required',
396
- 'error' => __('You must provide a title','ultimate-member')
397
- ),
398
- '_metakey' => array(
399
- 'mode' => 'unique',
400
- ),
401
- '_max_size' => array(
402
- 'mode' => 'numeric',
403
- 'error' => __( 'Please enter a valid size', 'ultimate-member' )
404
- ),
405
- )
406
- ),
407
-
408
- 'date' => array(
409
- 'name' => 'Date Picker',
410
- 'col1' => array( '_title', '_metakey', '_help', '_default', '_range', '_years', '_years_x', '_range_start', '_range_end', '_visibility' ),
411
- 'col2' => array( '_label', '_placeholder', '_public', '_roles', '_format', '_format_custom', '_pretty_format', '_disabled_weekdays' ),
412
- 'col3' => array( '_required', '_editable', '_icon' ),
413
- 'validate' => array(
414
- '_title' => array(
415
- 'mode' => 'required',
416
- 'error' => __( 'You must provide a title', 'ultimate-member' )
417
- ),
418
- '_metakey' => array(
419
- 'mode' => 'unique',
420
- ),
421
- '_years' => array(
422
- 'mode' => 'numeric',
423
- 'error' => __( 'Number of years is not valid', 'ultimate-member' )
424
- ),
425
- '_range_start' => array(
426
- 'mode' => 'range-start',
427
- ),
428
- '_range_end' => array(
429
- 'mode' => 'range-end',
430
- ),
431
- )
432
- ),
433
-
434
- 'time' => array(
435
- 'name' => 'Time Picker',
436
- 'col1' => array('_title','_metakey','_help','_format','_visibility'),
437
- 'col2' => array('_label','_placeholder','_default','_public','_roles','_intervals'),
438
- 'col3' => array('_required','_editable','_icon'),
439
- 'validate' => array(
440
- '_title' => array(
441
- 'mode' => 'required',
442
- 'error' => __( 'You must provide a title', 'ultimate-member' )
443
- ),
444
- '_metakey' => array(
445
- 'mode' => 'unique',
446
- ),
447
- )
448
- ),
449
-
450
- 'rating' => array(
451
- 'name' => 'Rating',
452
- 'col1' => array('_title','_metakey','_help','_visibility'),
453
- 'col2' => array('_label','_public','_roles','_number','_default'),
454
- 'col3' => array('_required','_editable','_icon'),
455
- 'validate' => array(
456
- '_title' => array(
457
- 'mode' => 'required',
458
- 'error' => __('You must provide a title','ultimate-member')
459
- ),
460
- '_metakey' => array(
461
- 'mode' => 'unique',
462
- ),
463
- )
464
- ),
465
-
466
- 'block' => array(
467
- 'name' => 'Content Block',
468
- 'col1' => array('_title','_visibility'),
469
- 'col2' => array('_public','_roles'),
470
- 'col_full' => array('_content'),
471
- 'mce_content' => true,
472
- 'validate' => array(
473
- '_title' => array(
474
- 'mode' => 'required',
475
- 'error' => __('You must provide a title','ultimate-member')
476
- ),
477
- )
478
- ),
479
-
480
- 'shortcode' => array(
481
- 'name' => 'Shortcode',
482
- 'col1' => array('_title','_visibility'),
483
- 'col2' => array('_public','_roles'),
484
- 'col_full' => array('_content'),
485
- 'validate' => array(
486
- '_title' => array(
487
- 'mode' => 'required',
488
- 'error' => __('You must provide a title','ultimate-member')
489
- ),
490
- '_content' => array(
491
- 'mode' => 'required',
492
- 'error' => __('You must add a shortcode to the content area','ultimate-member')
493
- ),
494
- )
495
- ),
496
-
497
- 'spacing' => array(
498
- 'name' => 'Spacing',
499
- 'col1' => array('_title','_visibility'),
500
- 'col2' => array('_spacing'),
501
- 'form_only' => true,
502
- 'validate' => array(
503
- '_title' => array(
504
- 'mode' => 'required',
505
- 'error' => __('You must provide a title','ultimate-member')
506
- ),
507
- )
508
- ),
509
-
510
- 'divider' => array(
511
- 'name' => 'Divider',
512
- 'col1' => array('_title','_width','_divider_text','_visibility'),
513
- 'col2' => array('_style','_color','_public','_roles'),
514
- 'form_only' => true,
515
- 'validate' => array(
516
- '_title' => array(
517
- 'mode' => 'required',
518
- 'error' => __('You must provide a title','ultimate-member')
519
- ),
520
- )
521
- ),
522
-
523
- 'googlemap' => array(
524
- 'name' => 'Google Map',
525
- 'col1' => array('_title','_metakey','_help','_visibility'),
526
- 'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
527
- 'col3' => array('_required','_editable','_icon'),
528
- 'validate' => array(
529
- '_title' => array(
530
- 'mode' => 'required',
531
- 'error' => __('You must provide a title','ultimate-member')
532
- ),
533
- '_metakey' => array(
534
- 'mode' => 'unique',
535
- ),
536
- )
537
- ),
538
-
539
- 'youtube_video' => array(
540
- 'name' => 'YouTube Video',
541
- 'col1' => array('_title','_metakey','_help','_visibility'),
542
- 'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
543
- 'col3' => array('_required','_editable','_icon'),
544
- 'validate' => array(
545
- '_title' => array(
546
- 'mode' => 'required',
547
- 'error' => __('You must provide a title','ultimate-member')
548
- ),
549
- '_metakey' => array(
550
- 'mode' => 'unique',
551
- ),
552
- )
553
- ),
554
-
555
- 'vimeo_video' => array(
556
- 'name' => 'Vimeo Video',
557
- 'col1' => array('_title','_metakey','_help','_visibility'),
558
- 'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
559
- 'col3' => array('_required','_editable','_icon'),
560
- 'validate' => array(
561
- '_title' => array(
562
- 'mode' => 'required',
563
- 'error' => __('You must provide a title','ultimate-member')
564
- ),
565
- '_metakey' => array(
566
- 'mode' => 'unique',
567
- ),
568
- )
569
- ),
570
-
571
- 'soundcloud_track' => array(
572
- 'name' => 'SoundCloud Track',
573
- 'col1' => array('_title','_metakey','_help','_visibility'),
574
- 'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
575
- 'col3' => array('_required','_editable','_icon'),
576
- 'validate' => array(
577
- '_title' => array(
578
- 'mode' => 'required',
579
- 'error' => __('You must provide a title','ultimate-member')
580
- ),
581
- '_metakey' => array(
582
- 'mode' => 'unique',
583
- ),
584
- )
585
- ),
586
-
587
- /*'group' => array(
588
- 'name' => 'Field Group',
589
- 'col1' => array('_title','_max_entries'),
590
- 'col2' => array('_label','_public','_roles'),
591
- 'form_only' => true,
592
- 'validate' => array(
593
- '_title' => array(
594
- 'mode' => 'required',
595
- 'error' => 'You must provide a title'
596
- ),
597
- '_label' => array(
598
- 'mode' => 'required',
599
- 'error' => 'You must provide a label'
600
- ),
601
- )
602
- ),*/
603
-
604
- );
605
-
606
- /**
607
- * UM hook
608
- *
609
- * @type filter
610
- * @title um_core_fields_hook
611
- * @description UM Core Fields
612
- * @input_vars
613
- * [{"var":"$core_fields","type":"array","desc":"Core Fields"}]
614
- * @change_log
615
- * ["Since: 2.0"]
616
- * @usage add_filter( 'um_core_fields_hook', 'function_name', 10, 1 );
617
- * @example
618
- * <?php
619
- * add_filter( 'um_core_fields_hook', 'my_core_fields', 10, 1 );
620
- * function my_core_fields( $core_fields ) {
621
- * // your code here
622
- * return $core_fields;
623
- * }
624
- * ?>
625
- */
626
- $this->core_fields = apply_filters( 'um_core_fields_hook', $this->core_fields );
627
- }
628
-
629
-
630
- /**
631
- * Predefined Fields
632
- */
633
- function set_predefined_fields() {
634
-
635
- global $wp_roles;
636
- $role_keys = get_option( 'um_roles', array() );
637
- if ( ! empty( $role_keys ) && is_array( $role_keys ) ) {
638
- $role_keys = array_map( function( $item ) {
639
- return 'um_' . $item;
640
- }, $role_keys );
641
- } else {
642
- $role_keys = array();
643
- }
644
-
645
- $exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
646
-
647
- $um_roles = UM()->roles()->get_roles( false, $exclude_roles );
648
-
649
- /**
650
- * UM hook
651
- *
652
- * @type filter
653
- * @title um_profile_privacy_options
654
- * @description Profile Privacy Options
655
- * @input_vars
656
- * [{"var":"$privacy_options","type":"array","desc":"Privacy Options"}]
657
- * @change_log
658
- * ["Since: 2.0"]
659
- * @usage add_filter( 'um_profile_privacy_options', 'function_name', 10, 1 );
660
- * @example
661
- * <?php
662
- * add_filter( 'um_profile_privacy_options', 'my_profile_privacy_options', 10, 1 );
663
- * function my_profile_privacy_options( $privacy_options ) {
664
- * // your code here
665
- * return $privacy_options;
666
- * }
667
- * ?>
668
- */
669
- $profile_privacy = apply_filters( 'um_profile_privacy_options', array(
670
- 'Everyone' => __( 'Everyone', 'ultimate-member' ),
671
- 'Only me' => __( 'Only me', 'ultimate-member' )
672
- ) );
673
-
674
- /*
675
- * it's important create key for array equals value of 'metakey'.
676
- *
677
- */
678
-
679
- $this->predefined_fields = array(
680
-
681
- 'user_login' => array(
682
- 'title' => __('Username','ultimate-member'),
683
- 'metakey' => 'user_login',
684
- 'type' => 'text',
685
- 'label' => __('Username','ultimate-member'),
686
- 'required' => 1,
687
- 'public' => 1,
688
- 'editable' => 0,
689
- 'validate' => 'unique_username',
690
- 'min_chars' => 3,
691
- 'max_chars' => 24
692
- ),
693
-
694
- 'username' => array(
695
- 'title' => __('Username or E-mail','ultimate-member'),
696
- 'metakey' => 'username',
697
- 'type' => 'text',
698
- 'label' => __('Username or E-mail','ultimate-member'),
699
- 'required' => 1,
700
- 'public' => 1,
701
- 'editable' => 0,
702
- 'validate' => 'unique_username_or_email',
703
- ),
704
-
705
- 'user_password' => array(
706
- 'title' => __('Password','ultimate-member'),
707
- 'metakey' => 'user_password',
708
- 'type' => 'password',
709
- 'label' => __('Password','ultimate-member'),
710
- 'required' => 1,
711
- 'public' => 1,
712
- 'editable' => 1,
713
- 'min_chars' => 8,
714
- 'max_chars' => 30,
715
- 'force_good_pass' => 1,
716
- 'force_confirm_pass' => 1,
717
- ),
718
-
719
- 'first_name' => array(
720
- 'title' => __('First Name','ultimate-member'),
721
- 'metakey' => 'first_name',
722
- 'type' => 'text',
723
- 'label' => __('First Name','ultimate-member'),
724
- 'required' => 0,
725
- 'public' => 1,
726
- 'editable' => 1,
727
- ),
728
-
729
- 'last_name' => array(
730
- 'title' => __('Last Name','ultimate-member'),
731
- 'metakey' => 'last_name',
732
- 'type' => 'text',
733
- 'label' => __('Last Name','ultimate-member'),
734
- 'required' => 0,
735
- 'public' => 1,
736
- 'editable' => 1,
737
- ),
738
-
739
- 'nickname' => array(
740
- 'title' => __('Nickname','ultimate-member'),
741
- 'metakey' => 'nickname',
742
- 'type' => 'text',
743
- 'label' => __('Nickname','ultimate-member'),
744
- 'required' => 0,
745
- 'public' => 1,
746
- 'editable' => 1,
747
- ),
748
-
749
- 'user_url' => array(
750
- 'title' => __('Website URL','ultimate-member'),
751
- 'metakey' => 'user_url',
752
- 'type' => 'url',
753
- 'label' => __('Website URL','ultimate-member'),
754
- 'required' => 1,
755
- 'public' => 1,
756
- 'editable' => 1,
757
- 'validate' => 'url'
758
- ),
759
-
760
- 'user_registered' => array(
761
- 'title' => __('Registration Date','ultimate-member'),
762
- 'metakey' => 'user_registered',
763
- 'type' => 'text',
764
- 'label' => __('Registration Date','ultimate-member'),
765
- 'required' => 0,
766
- 'public' => 1,
767
- 'editable' => 1,
768
- 'edit_forbidden' => 1,
769
- ),
770
-
771
- '_um_last_login' => array(
772
- 'title' => __('Last Login','ultimate-member'),
773
- 'metakey' => '_um_last_login',
774
- 'type' => 'text',
775
- 'label' => __('Last Login','ultimate-member'),
776
- 'required' => 0,
777
- 'public' => 1,
778
- 'editable' => 1,
779
- 'edit_forbidden' => 1,
780
- ),
781
-
782
- 'user_email' => array(
783
- 'title' => __('E-mail Address','ultimate-member'),
784
- 'metakey' => 'user_email',
785
- 'type' => 'text',
786
- 'label' => __('E-mail Address','ultimate-member'),
787
- 'required' => 0,
788
- 'public' => 1,
789
- 'validate' => 'unique_email',
790
- 'autocomplete' => 'off'
791
- ),
792
-
793
- 'secondary_user_email' => array(
794
- 'title' => __('Secondary E-mail Address','ultimate-member'),
795
- 'metakey' => 'secondary_user_email',
796
- 'type' => 'text',
797
- 'label' => __('Secondary E-mail Address','ultimate-member'),
798
- 'required' => 0,
799
- 'public' => 1,
800
- 'editable' => 1,
801
- 'validate' => 'unique_email',
802
- 'autocomplete' => 'off'
803
- ),
804
-
805
- 'description' => array(
806
- 'title' => __('Biography','ultimate-member'),
807
- 'metakey' => 'description',
808
- 'type' => 'textarea',
809
- 'label' => __('Biography','ultimate-member'),
810
- 'html' => 0,
811
- 'required' => 0,
812
- 'public' => 1,
813
- 'editable' => 1,
814
- 'max_words' => 40,
815
- 'placeholder' => __('Enter a bit about yourself...','ultimate-member'),
816
- ),
817
-
818
- 'birth_date' => array(
819
- 'title' => __('Birth Date','ultimate-member'),
820
- 'metakey' => 'birth_date',
821
- 'type' => 'date',
822
- 'label' => __('Birth Date','ultimate-member'),
823
- 'required' => 0,
824
- 'public' => 1,
825
- 'editable' => 1,
826
- 'pretty_format' => 1,
827
- 'years' => 115,
828
- 'years_x' => 'past',
829
- 'icon' => 'um-faicon-calendar'
830
- ),
831
-
832
- 'gender' => array(
833
- 'title' => __('Gender','ultimate-member'),
834
- 'metakey' => 'gender',
835
- 'type' => 'radio',
836
- 'label' => __('Gender','ultimate-member'),
837
- 'required' => 0,
838
- 'public' => 1,
839
- 'editable' => 1,
840
- 'options' => array( __('Male','ultimate-member'), __('Female','ultimate-member') )
841
- ),
842
-
843
- 'country' => array(
844
- 'title' => __('Country','ultimate-member'),
845
- 'metakey' => 'country',
846
- 'type' => 'select',
847
- 'label' => __('Country','ultimate-member'),
848
- 'placeholder' => __('Choose a Country','ultimate-member'),
849
- 'required' => 0,
850
- 'public' => 1,
851
- 'editable' => 1,
852
- 'options' => $this->get('countries')
853
- ),
854
-
855
- 'facebook' => array(
856
- 'title' => __('Facebook','ultimate-member'),
857
- 'metakey' => 'facebook',
858
- 'type' => 'url',
859
- 'label' => __('Facebook','ultimate-member'),
860
- 'required' => 0,
861
- 'public' => 1,
862
- 'editable' => 1,
863
- 'url_target' => '_blank',
864
- 'url_rel' => 'nofollow',
865
- 'icon' => 'um-faicon-facebook',
866
- 'validate' => 'facebook_url',
867
- 'url_text' => 'Facebook',
868
- 'advanced' => 'social',
869
- 'color' => '#3B5999',
870
- 'match' => 'https://facebook.com/',
871
- ),
872
-
873
- 'twitter' => array(
874
- 'title' => __('Twitter','ultimate-member'),
875
- 'metakey' => 'twitter',
876
- 'type' => 'url',
877
- 'label' => __('Twitter','ultimate-member'),
878
- 'required' => 0,
879
- 'public' => 1,
880
- 'editable' => 1,
881
- 'url_target' => '_blank',
882
- 'url_rel' => 'nofollow',
883
- 'icon' => 'um-faicon-twitter',
884
- 'validate' => 'twitter_url',
885
- 'url_text' => 'Twitter',
886
- 'advanced' => 'social',
887
- 'color' => '#4099FF',
888
- 'match' => 'https://twitter.com/',
889
- ),
890
-
891
- 'linkedin' => array(
892
- 'title' => __('LinkedIn','ultimate-member'),
893
- 'metakey' => 'linkedin',
894
- 'type' => 'url',
895
- 'label' => __('LinkedIn','ultimate-member'),
896
- 'required' => 0,
897
- 'public' => 1,
898
- 'editable' => 1,
899
- 'url_target' => '_blank',
900
- 'url_rel' => 'nofollow',
901
- 'icon' => 'um-faicon-linkedin',
902
- 'validate' => 'linkedin_url',
903
- 'url_text' => 'LinkedIn',
904
- 'advanced' => 'social',
905
- 'color' => '#0976b4',
906
- 'match' => 'https://linkedin.com/in/',
907
- ),
908
-
909
- 'googleplus' => array(
910
- 'title' => __('Google+','ultimate-member'),
911
- 'metakey' => 'googleplus',
912
- 'type' => 'url',
913
- 'label' => __('Google+','ultimate-member'),
914
- 'required' => 0,
915
- 'public' => 1,
916
- 'editable' => 1,
917
- 'url_target' => '_blank',
918
- 'url_rel' => 'nofollow',
919
- 'icon' => 'um-faicon-google-plus',
920
- 'validate' => 'google_url',
921
- 'url_text' => 'Google+',
922
- 'advanced' => 'social',
923
- 'color' => '#dd4b39',
924
- 'match' => 'https://google.com/+',
925
- ),
926
-
927
- 'instagram' => array(
928
- 'title' => __('Instagram','ultimate-member'),
929
- 'metakey' => 'instagram',
930
- 'type' => 'url',
931
- 'label' => __('Instagram','ultimate-member'),
932
- 'required' => 0,
933
- 'public' => 1,
934
- 'editable' => 1,
935
- 'url_target' => '_blank',
936
- 'url_rel' => 'nofollow',
937
- 'icon' => 'um-faicon-instagram',
938
- 'validate' => 'instagram_url',
939
- 'url_text' => 'Instagram',
940
- 'advanced' => 'social',
941
- 'color' => 'radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%,#d6249f 60%,#285AEB 90%)',
942
- 'match' => 'https://instagram.com/',
943
- ),
944
-
945
- 'skype' => array(
946
- 'title' => __('Skype ID','ultimate-member'),
947
- 'metakey' => 'skype',
948
- 'type' => 'url',
949
- 'label' => __('Skype ID','ultimate-member'),
950
- 'required' => 0,
951
- 'public' => 1,
952
- 'editable' => 1,
953
- 'url_target' => '_blank',
954
- 'url_rel' => 'nofollow',
955
- 'icon' => 'um-faicon-skype',
956
- 'validate' => 'skype',
957
- 'url_text' => 'Skype',
958
- ),
959
-
960
- 'youtube' => array(
961
- 'title' => __('YouTube','ultimate-member'),
962
- 'metakey' => 'youtube',
963
- 'type' => 'url',
964
- 'label' => __('YouTube','ultimate-member'),
965
- 'required' => 0,
966
- 'public' => 1,
967
- 'editable' => 1,
968
- 'url_target' => '_blank',
969
- 'url_rel' => 'nofollow',
970
- 'icon' => 'um-faicon-youtube',
971
- 'validate' => 'youtube_url',
972
- 'url_text' => 'YouTube',
973
- 'advanced' => 'social',
974
- 'color' => '#e52d27',
975
- 'match' => 'https://youtube.com/',
976
- ),
977
-
978
- 'soundcloud' => array(
979
- 'title' => __('SoundCloud','ultimate-member'),
980
- 'metakey' => 'soundcloud',
981
- 'type' => 'url',
982
- 'label' => __('SoundCloud','ultimate-member'),
983
- 'required' => 0,
984
- 'public' => 1,
985
- 'editable' => 1,
986
- 'url_target' => '_blank',
987
- 'url_rel' => 'nofollow',
988
- 'icon' => 'um-faicon-soundcloud',
989
- 'validate' => 'soundcloud_url',
990
- 'url_text' => 'SoundCloud',
991
- 'advanced' => 'social',
992
- 'color' => '#f50',
993
- 'match' => 'https://soundcloud.com/',
994
- ),
995
-
996
- 'vkontakte' => array(
997
- 'title' => __('VKontakte','ultimate-member'),
998
- 'metakey' => 'vkontakte',
999
- 'type' => 'url',
1000
- 'label' => __('VKontakte','ultimate-member'),
1001
- 'required' => 0,
1002
- 'public' => 1,
1003
- 'editable' => 1,
1004
- 'url_target' => '_blank',
1005
- 'url_rel' => 'nofollow',
1006
- 'icon' => 'um-faicon-vk',
1007
- 'validate' => 'vk_url',
1008
- 'url_text' => 'VKontakte',
1009
- 'advanced' => 'social',
1010
- 'color' => '#2B587A',
1011
- 'match' => 'https://vk.com/',
1012
- ),
1013
-
1014
- 'role_select' => array(
1015
- 'title' => __('Roles (Dropdown)','ultimate-member'),
1016
- 'metakey' => 'role_select',
1017
- 'type' => 'select',
1018
- 'label' => __('Account Type','ultimate-member'),
1019
- 'placeholder' => 'Choose account type',
1020
- 'required' => 0,
1021
- 'public' => 1,
1022
- 'editable' => 1,
1023
- 'options' => $um_roles,
1024
- ),
1025
-
1026
- 'role_radio' => array(
1027
- 'title' => __('Roles (Radio)','ultimate-member'),
1028
- 'metakey' => 'role_radio',
1029
- 'type' => 'radio',
1030
- 'label' => __('Account Type','ultimate-member'),
1031
- 'required' => 0,
1032
- 'public' => 1,
1033
- 'editable' => 1,
1034
- 'options' => $um_roles,
1035
- ),
1036
-
1037
- 'languages' => array(
1038
- 'title' => __('Languages','ultimate-member'),
1039
- 'metakey' => 'languages',
1040
- 'type' => 'multiselect',
1041
- 'label' => __('Languages Spoken','ultimate-member'),
1042
- 'placeholder' => __('Select languages','ultimate-member'),
1043
- 'required' => 0,
1044
- 'public' => 1,
1045
- 'editable' => 1,
1046
- 'options' => $this->get('languages'),
1047
- ),
1048
-
1049
- 'phone_number' => array(
1050
- 'title' => __('Phone Number','ultimate-member'),
1051
- 'metakey' => 'phone_number',
1052
- 'type' => 'text',
1053
- 'label' => __('Phone Number','ultimate-member'),
1054
- 'required' => 0,
1055
- 'public' => 1,
1056
- 'editable' => 1,
1057
- 'validate' => 'phone_number',
1058
- 'icon' => 'um-faicon-phone',
1059
- ),
1060
-
1061
- 'mobile_number' => array(
1062
- 'title' => __('Mobile Number','ultimate-member'),
1063
- 'metakey' => 'mobile_number',
1064
- 'type' => 'text',
1065
- 'label' => __('Mobile Number','ultimate-member'),
1066
- 'required' => 0,
1067
- 'public' => 1,
1068
- 'editable' => 1,
1069
- 'validate' => 'phone_number',
1070
- 'icon' => 'um-faicon-mobile',
1071
- ),
1072
-
1073
- // private use ( not public list )
1074
-
1075
- 'profile_photo' => array(
1076
- 'title' => __('Profile Photo','ultimate-member'),
1077
- 'metakey' => 'profile_photo',
1078
- 'type' => 'image',
1079
- 'label' => __('Change your profile photo','ultimate-member'),
1080
- 'upload_text' => __('Upload your photo here','ultimate-member'),
1081
- 'icon' => 'um-faicon-camera',
1082
- 'crop' => 1,
1083
- 'max_size' => ( UM()->options()->get('profile_photo_max_size') ) ? UM()->options()->get('profile_photo_max_size') : 999999999,
1084
- 'min_width' => str_replace('px','',UM()->options()->get('profile_photosize')),
1085
- 'min_height' => str_replace('px','',UM()->options()->get('profile_photosize')),
1086
- 'private_use' => true,
1087
- ),
1088
-
1089
- 'cover_photo' => array(
1090
- 'title' => __('Cover Photo','ultimate-member'),
1091
- 'metakey' => 'cover_photo',
1092
- 'type' => 'image',
1093
- 'label' => __('Change your cover photo','ultimate-member'),
1094
- 'upload_text' => __('Upload profile cover here','ultimate-member'),
1095
- 'icon' => 'um-faicon-picture-o',
1096
- 'crop' => 2,
1097
- 'max_size' => ( UM()->options()->get('cover_photo_max_size') ) ? UM()->options()->get('cover_photo_max_size') : 999999999,
1098
- 'modal_size' => 'large',
1099
- 'ratio' => str_replace(':1','',UM()->options()->get('profile_cover_ratio')),
1100
- 'min_width' => UM()->options()->get('cover_min_width'),
1101
- 'private_use' => true,
1102
- ),
1103
-
1104
- 'username_b' => array(
1105
- 'title' => __('Username or E-mail','ultimate-member'),
1106
- 'metakey' => 'username_b',
1107
- 'type' => 'text',
1108
- 'placeholder' => __('Enter your username or email','ultimate-member'),
1109
- 'required' => 1,
1110
- 'public' => 1,
1111
- 'editable' => 0,
1112
- 'private_use' => true,
1113
- ),
1114
-
1115
- // account page use ( not public )
1116
-
1117
- 'profile_privacy' => array(
1118
- 'title' => __( 'Profile Privacy', 'ultimate-member' ),
1119
- 'metakey' => 'profile_privacy',
1120
- 'type' => 'select',
1121
- 'label' => __( 'Profile Privacy', 'ultimate-member' ),
1122
- 'help' => __( 'Who can see your public profile?', 'ultimate-member' ),
1123
- 'required' => 0,
1124
- 'public' => 1,
1125
- 'editable' => 1,
1126
- 'default' => 'Everyone',
1127
- 'options' => $profile_privacy,
1128
- 'allowclear' => 0,
1129
- 'account_only' => true,
1130
- 'required_perm' => 'can_make_private_profile',
1131
- ),
1132
-
1133
- 'profile_noindex' => array(
1134
- 'title' => __( 'Avoid indexing my profile by search engines', 'ultimate-member' ),
1135
- 'metakey' => 'profile_noindex',
1136
- 'type' => 'select',
1137
- 'label' => __( 'Avoid indexing my profile by search engines', 'ultimate-member' ),
1138
- 'help' => __( 'Hide my profile for robots?', 'ultimate-member' ),
1139
- 'required' => 0,
1140
- 'public' => 1,
1141
- 'editable' => 1,
1142
- 'default' => UM()->roles()->um_user_can( 'profile_noindex' ) ? '1' : '0',
1143
- 'options' => array(
1144
- '0' => __( 'No', 'ultimate-member' ),
1145
- '1' => __( 'Yes', 'ultimate-member' ),
1146
- ),
1147
- 'allowclear' => 0,
1148
- 'account_only' => true,
1149
- 'required_perm' => 'can_make_private_profile',
1150
- ),
1151
-
1152
- 'hide_in_members' => array(
1153
- 'title' => __( 'Hide my profile from directory', 'ultimate-member' ),
1154
- 'metakey' => 'hide_in_members',
1155
- 'type' => 'radio',
1156
- 'label' => __( 'Hide my profile from directory', 'ultimate-member' ),
1157
- 'help' => __( 'Here you can hide yourself from appearing in public directory', 'ultimate-member' ),
1158
- 'required' => 0,
1159
- 'public' => 1,
1160
- 'editable' => 1,
1161
- 'default' => UM()->member_directory()->get_hide_in_members_default() ? 'Yes' : 'No',
1162
- 'options' => array(
1163
- 'No' => __( 'No', 'ultimate-member' ),
1164
- 'Yes' => __( 'Yes', 'ultimate-member' ),
1165
- ),
1166
- 'account_only' => true,
1167
- 'required_opt' => array( 'members_page', 1 ),
1168
- ),
1169
-
1170
- 'delete_account' => array(
1171
- 'title' => __( 'Delete Account', 'ultimate-member' ),
1172
- 'metakey' => 'delete_account',
1173
- 'type' => 'radio',
1174
- 'label' => __( 'Delete Account', 'ultimate-member'),
1175
- 'help' => __( 'If you confirm, everything related to your profile will be deleted permanently from the site', 'ultimate-member' ),
1176
- 'required' => 0,
1177
- 'public' => 1,
1178
- 'editable' => 1,
1179
- 'default' => __( 'No', 'ultimate-member' ),
1180
- 'options' => array(
1181
- __( 'Yes', 'ultimate-member' ),
1182
- __( 'No', 'ultimate-member' )
1183
- ),
1184
- 'account_only' => true,
1185
- ),
1186
-
1187
- 'single_user_password' => array(
1188
- 'title' => __( 'Password', 'ultimate-member' ),
1189
- 'metakey' => 'single_user_password',
1190
- 'type' => 'password',
1191
- 'label' => __( 'Password', 'ultimate-member' ),
1192
- 'required' => 1,
1193
- 'public' => 1,
1194
- 'editable' => 1,
1195
- 'account_only' => true,
1196
- ),
1197
-
1198
- );
1199
-
1200
- /**
1201
- * UM hook
1202
- *
1203
- * @type filter
1204
- * @title um_predefined_fields_hook
1205
- * @description Extend Predefined Fields
1206
- * @input_vars
1207
- * [{"var":"$predefined_fields","type":"array","desc":"Predefined Fields"}]
1208
- * @change_log
1209
- * ["Since: 2.0"]
1210
- * @usage add_filter( 'um_predefined_fields_hook', 'function_name', 10, 1 );
1211
- * @example
1212
- * <?php
1213
- * add_filter( 'um_predefined_fields_hook', 'my_predefined_fields', 10, 1 );
1214
- * function my_predefined_fields( $predefined_fields ) {
1215
- * // your code here
1216
- * return $predefined_fields;
1217
- * }
1218
- * ?>
1219
- */
1220
- $this->predefined_fields = apply_filters( 'um_predefined_fields_hook', $this->predefined_fields );
1221
- }
1222
-
1223
-
1224
- /**
1225
- * Custom Fields
1226
- */
1227
- function set_custom_fields() {
1228
-
1229
- if ( is_array( $this->saved_fields ) ) {
1230
-
1231
- $this->custom_fields = $this->saved_fields;
1232
-
1233
- } else {
1234
-
1235
- $this->custom_fields = '';
1236
-
1237
- }
1238
-
1239
- $custom = $this->custom_fields;
1240
- $predefined = $this->predefined_fields;
1241
-
1242
- if ( is_array( $custom ) ){
1243
- $this->all_user_fields = array_merge( $predefined, $custom );
1244
- } else {
1245
- $this->all_user_fields = $predefined;
1246
- }
1247
-
1248
- }
1249
-
1250
-
1251
- /**
1252
- * Get all fields without metakeys
1253
- *
1254
- * @since 2.0.56
1255
- *
1256
- * @return array
1257
- */
1258
- function get_fields_without_metakey() {
1259
- $fields_without_metakey = array(
1260
- 'block',
1261
- 'shortcode',
1262
- 'spacing',
1263
- 'divider',
1264
- 'group'
1265
- );
1266
-
1267
-
1268
- /**
1269
- * UM hook
1270
- *
1271
- * @type filter
1272
- * @title um_fields_without_metakey
1273
- * @description Field Types without meta key
1274
- * @input_vars
1275
- * [{"var":"$types","type":"array","desc":"Field Types"}]
1276
- * @change_log
1277
- * ["Since: 2.0"]
1278
- * @usage add_filter( 'um_fields_without_metakey', 'function_name', 10, 1 );
1279
- * @example
1280
- * <?php
1281
- * add_filter( 'um_fields_without_metakey', 'my_fields_without_metakey', 10, 1 );
1282
- * function my_fields_without_metakey( $types ) {
1283
- * // your code here
1284
- * return $types;
1285
- * }
1286
- * ?>
1287
- */
1288
- return apply_filters( 'um_fields_without_metakey', $fields_without_metakey );
1289
- }
1290
-
1291
-
1292
- /**
1293
- * May be used to show a dropdown, or source for user meta
1294
- *
1295
- * @param null $exclude_types
1296
- * @param bool $show_all
1297
- *
1298
- * @return array
1299
- */
1300
- function all_user_fields( $exclude_types = null, $show_all = false ) {
1301
-
1302
- $fields_without_metakey = $this->get_fields_without_metakey();
1303
- $fields_without_metakey = apply_filters( 'um_all_user_fields_without_metakey', $fields_without_metakey );
1304
-
1305
- if ( ! $show_all ) {
1306
- $this->fields_dropdown = array( 'image', 'file', 'password', 'rating' );
1307
- $this->fields_dropdown = array_merge( $this->fields_dropdown, $fields_without_metakey );
1308
- } else {
1309
- $this->fields_dropdown = $fields_without_metakey;
1310
- }
1311
-
1312
- $custom = $this->custom_fields;
1313
- $predefined = $this->predefined_fields;
1314
-
1315
- if ( $exclude_types ) {
1316
- $exclude_types = explode( ',', $exclude_types );
1317
- }
1318
-
1319
- $all = array( 0 => '' );
1320
-
1321
- if ( is_array( $custom ) ) {
1322
- $all = $all + array_merge( $predefined, $custom );
1323
- } else {
1324
- $all = $all + $predefined;
1325
- }
1326
-
1327
- foreach ( $all as $k => $arr ) {
1328
-
1329
- if ( $k == 0 ) {
1330
- unset( $all[ $k ] );
1331
- }
1332
-
1333
- if ( isset( $arr['title'] ) ) {
1334
- $all[ $k ]['title'] = stripslashes( $arr['title'] );
1335
- }
1336
-
1337
- if ( $exclude_types && isset( $arr['type'] ) && in_array( $arr['type'], $exclude_types ) ) {
1338
- unset( $all[ $k ] );
1339
- }
1340
- if ( isset( $arr['account_only'] ) || isset( $arr['private_use'] ) ) {
1341
- if ( ! $show_all ) {
1342
- unset( $all[ $k ] );
1343
- }
1344
- }
1345
- if ( isset( $arr['type'] ) && in_array( $arr['type'], $this->fields_dropdown ) ) {
1346
- unset( $all[ $k ] );
1347
- }
1348
- }
1349
-
1350
- $all = UM()->fields()->array_sort_by_column( $all, 'title' );
1351
-
1352
- return $all;
1353
- }
1354
-
1355
-
1356
- /**
1357
- * Possible validation types for fields
1358
- *
1359
- * @return mixed
1360
- */
1361
- function validation_types() {
1362
-
1363
- $array[0] = __('None','ultimate-member');
1364
- $array['alphabetic'] = __('Alphabetic value only','ultimate-member');
1365
- $array['alpha_numeric'] = __('Alpha-numeric value','ultimate-member');
1366
- $array['english'] = __('English letters only','ultimate-member');
1367
- $array['facebook_url'] = __('Facebook URL','ultimate-member');
1368
- $array['google_url'] = __('Google+ URL','ultimate-member');
1369
- $array['instagram_url'] = __('Instagram URL','ultimate-member');
1370
- $array['linkedin_url'] = __('LinkedIn URL','ultimate-member');
1371
- $array['vk_url'] = __('VKontakte URL','ultimate-member');
1372
- $array['lowercase'] = __('Lowercase only','ultimate-member');
1373
- $array['numeric'] = __('Numeric value only','ultimate-member');
1374
- $array['phone_number'] = __('Phone Number','ultimate-member');
1375
- $array['skype'] = __('Skype ID','ultimate-member');
1376
- $array['soundcloud'] = __('SoundCloud Profile','ultimate-member');
1377
- $array['twitter_url'] = __('Twitter URL','ultimate-member');
1378
- $array['is_email'] = __('E-mail( Not Unique )','ultimate-member');
1379
- $array['unique_email'] = __('Unique E-mail','ultimate-member');
1380
- $array['unique_value'] = __('Unique Metakey value','ultimate-member');
1381
- $array['unique_username'] = __('Unique Username','ultimate-member');
1382
- $array['unique_username_or_email'] = __('Unique Username/E-mail','ultimate-member');
1383
- $array['url'] = __('Website URL','ultimate-member');
1384
- $array['youtube_url'] = __('YouTube Profile','ultimate-member');
1385
- $array['custom'] = __('Custom Validation','ultimate-member');
1386
-
1387
- /**
1388
- * UM hook
1389
- *
1390
- * @type filter
1391
- * @title um_admin_field_validation_hook
1392
- * @description Extend validation types
1393
- * @input_vars
1394
- * [{"var":"$types","type":"array","desc":"Validation Types"}]
1395
- * @change_log
1396
- * ["Since: 2.0"]
1397
- * @usage add_filter( 'um_admin_field_validation_hook', 'function_name', 10, 1 );
1398
- * @example
1399
- * <?php
1400
- * add_filter( 'um_admin_field_validation_hook', 'my_admin_field_validation', 10, 1 );
1401
- * function my_admin_field_validation( $types ) {
1402
- * // your code here
1403
- * return $types;
1404
- * }
1405
- * ?>
1406
- */
1407
- $array = apply_filters( 'um_admin_field_validation_hook', $array );
1408
- return $array;
1409
- }
1410
-
1411
-
1412
- /**
1413
- * Get predefined options
1414
- *
1415
- * @param $data
1416
- *
1417
- * @return array|mixed|void
1418
- */
1419
- function get( $data ) {
1420
- switch ( $data ) {
1421
-
1422
- case 'languages':
1423
- $array = array(
1424
- "aa" => __("Afar",'ultimate-member'),
1425
- "ab" => __("Abkhazian",'ultimate-member'),
1426
- "ae" => __("Avestan",'ultimate-member'),
1427
- "af" => __("Afrikaans",'ultimate-member'),
1428
- "ak" => __("Akan",'ultimate-member'),
1429
- "am" => __("Amharic",'ultimate-member'),
1430
- "an" => __("Aragonese",'ultimate-member'),
1431
- "ar" => __("Arabic",'ultimate-member'),
1432
- "as" => __("Assamese",'ultimate-member'),
1433
- "av" => __("Avaric",'ultimate-member'),
1434
- "ay" => __("Aymara",'ultimate-member'),
1435
- "az" => __("Azerbaijani",'ultimate-member'),
1436
- "ba" => __("Bashkir",'ultimate-member'),
1437
- "be" => __("Belarusian",'ultimate-member'),
1438
- "bg" => __("Bulgarian",'ultimate-member'),
1439
- "bh" => __("Bihari",'ultimate-member'),
1440
- "bi" => __("Bislama",'ultimate-member'),
1441
- "bm" => __("Bambara",'ultimate-member'),
1442
- "bn" => __("Bengali",'ultimate-member'),
1443
- "bo" => __("Tibetan",'ultimate-member'),
1444
- "br" => __("Breton",'ultimate-member'),
1445
- "bs" => __("Bosnian",'ultimate-member'),
1446
- "ca" => __("Catalan",'ultimate-member'),
1447
- "ce" => __("Chechen",'ultimate-member'),
1448
- "ch" => __("Chamorro",'ultimate-member'),
1449
- "co" => __("Corsican",'ultimate-member'),
1450
- "cr" => __("Cree",'ultimate-member'),
1451
- "cs" => __("Czech",'ultimate-member'),
1452
- "cu" => __("Church Slavic",'ultimate-member'),
1453
- "cv" => __("Chuvash",'ultimate-member'),
1454
- "cy" => __("Welsh",'ultimate-member'),
1455
- "da" => __("Danish",'ultimate-member'),
1456
- "de" => __("German",'ultimate-member'),
1457
- "dv" => __("Divehi",'ultimate-member'),
1458
- "dz" => __("Dzongkha",'ultimate-member'),
1459
- "ee" => __("Ewe",'ultimate-member'),
1460
- "el" => __("Greek",'ultimate-member'),
1461
- "en" => __("English",'ultimate-member'),
1462
- "eo" => __("Esperanto",'ultimate-member'),
1463
- "es" => __("Spanish",'ultimate-member'),
1464
- "et" => __("Estonian",'ultimate-member'),
1465
- "eu" => __("Basque",'ultimate-member'),
1466
- "fa" => __("Persian",'ultimate-member'),
1467
- "ff" => __("Fulah",'ultimate-member'),
1468
- "fi" => __("Finnish",'ultimate-member'),
1469
- "fj" => __("Fijian",'ultimate-member'),
1470
- "fo" => __("Faroese",'ultimate-member'),
1471
- "fr" => __("French",'ultimate-member'),
1472
- "fy" => __("Western Frisian",'ultimate-member'),
1473
- "ga" => __("Irish",'ultimate-member'),
1474
- "gd" => __("Scottish Gaelic",'ultimate-member'),
1475
- "gl" => __("Galician",'ultimate-member'),
1476
- "gn" => __("Guarani",'ultimate-member'),
1477
- "gu" => __("Gujarati",'ultimate-member'),
1478
- "gv" => __("Manx",'ultimate-member'),
1479
- "ha" => __("Hausa",'ultimate-member'),
1480
- "he" => __("Hebrew",'ultimate-member'),
1481
- "hi" => __("Hindi",'ultimate-member'),
1482
- "ho" => __("Hiri Motu",'ultimate-member'),
1483
- "hr" => __("Croatian",'ultimate-member'),
1484
- "ht" => __("Haitian",'ultimate-member'),
1485
- "hu" => __("Hungarian",'ultimate-member'),
1486
- "hy" => __("Armenian",'ultimate-member'),
1487
- "hz" => __("Herero",'ultimate-member'),
1488
- "ia" => __("Interlingua (International Auxiliary Language Association)",'ultimate-member'),
1489
- "id" => __("Indonesian",'ultimate-member'),
1490
- "ie" => __("Interlingue",'ultimate-member'),
1491
- "ig" => __("Igbo",'ultimate-member'),
1492
- "ii" => __("Sichuan Yi",'ultimate-member'),
1493
- "ik" => __("Inupiaq",'ultimate-member'),
1494
- "io" => __("Ido",'ultimate-member'),
1495
- "is" => __("Icelandic",'ultimate-member'),
1496
- "it" => __("Italian",'ultimate-member'),
1497
- "iu" => __("Inuktitut",'ultimate-member'),
1498
- "ja" => __("Japanese",'ultimate-member'),
1499
- "jv" => __("Javanese",'ultimate-member'),
1500
- "ka" => __("Georgian",'ultimate-member'),
1501
- "kg" => __("Kongo",'ultimate-member'),
1502
- "ki" => __("Kikuyu",'ultimate-member'),
1503
- "kj" => __("Kwanyama",'ultimate-member'),
1504
- "kk" => __("Kazakh",'ultimate-member'),
1505
- "kl" => __("Kalaallisut",'ultimate-member'),
1506
- "km" => __("Khmer",'ultimate-member'),
1507
- "kn" => __("Kannada",'ultimate-member'),
1508
- "ko" => __("Korean",'ultimate-member'),
1509
- "kr" => __("Kanuri",'ultimate-member'),
1510
- "ks" => __("Kashmiri",'ultimate-member'),
1511
- "ku" => __("Kurdish",'ultimate-member'),
1512
- "kv" => __("Komi",'ultimate-member'),
1513
- "kw" => __("Cornish",'ultimate-member'),
1514
- "ky" => __("Kirghiz",'ultimate-member'),
1515
- "la" => __("Latin",'ultimate-member'),
1516
- "lb" => __("Luxembourgish",'ultimate-member'),
1517
- "lg" => __("Ganda",'ultimate-member'),
1518
- "li" => __("Limburgish",'ultimate-member'),
1519
- "ln" => __("Lingala",'ultimate-member'),
1520
- "lo" => __("Lao",'ultimate-member'),
1521
- "lt" => __("Lithuanian",'ultimate-member'),
1522
- "lu" => __("Luba-Katanga",'ultimate-member'),
1523
- "lv" => __("Latvian",'ultimate-member'),
1524
- "mg" => __("Malagasy",'ultimate-member'),
1525
- "mh" => __("Marshallese",'ultimate-member'),
1526
- "mi" => __("Maori",'ultimate-member'),
1527
- "mk" => __("Macedonian",'ultimate-member'),
1528
- "ml" => __("Malayalam",'ultimate-member'),
1529
- "mn" => __("Mongolian",'ultimate-member'),
1530
- "mr" => __("Marathi",'ultimate-member'),
1531
- "ms" => __("Malay",'ultimate-member'),
1532
- "mt" => __("Maltese",'ultimate-member'),
1533
- "my" => __("Burmese",'ultimate-member'),
1534
- "na" => __("Nauru",'ultimate-member'),
1535
- "nb" => __("Norwegian Bokmal",'ultimate-member'),
1536
- "nd" => __("North Ndebele",'ultimate-member'),
1537
- "ne" => __("Nepali",'ultimate-member'),
1538
- "ng" => __("Ndonga",'ultimate-member'),
1539
- "nl" => __("Dutch",'ultimate-member'),
1540
- "nn" => __("Norwegian Nynorsk",'ultimate-member'),
1541
- "no" => __("Norwegian",'ultimate-member'),
1542
- "nr" => __("South Ndebele",'ultimate-member'),
1543
- "nv" => __("Navajo",'ultimate-member'),
1544
- "ny" => __("Chichewa",'ultimate-member'),
1545
- "oc" => __("Occitan",'ultimate-member'),
1546
- "oj" => __("Ojibwa",'ultimate-member'),
1547
- "om" => __("Oromo",'ultimate-member'),
1548
- "or" => __("Oriya",'ultimate-member'),
1549
- "os" => __("Ossetian",'ultimate-member'),
1550
- "pa" => __("Panjabi",'ultimate-member'),
1551
- "pi" => __("Pali",'ultimate-member'),
1552
- "pl" => __("Polish",'ultimate-member'),
1553
- "ps" => __("Pashto",'ultimate-member'),
1554
- "pt" => __("Portuguese",'ultimate-member'),
1555
- "qu" => __("Quechua",'ultimate-member'),
1556
- "rm" => __("Raeto-Romance",'ultimate-member'),
1557
- "rn" => __("Kirundi",'ultimate-member'),
1558
- "ro" => __("Romanian",'ultimate-member'),
1559
- "ru" => __("Russian",'ultimate-member'),
1560
- "rw" => __("Kinyarwanda",'ultimate-member'),
1561
- "sa" => __("Sanskrit",'ultimate-member'),
1562
- "sc" => __("Sardinian",'ultimate-member'),
1563
- "sd" => __("Sindhi",'ultimate-member'),
1564
- "se" => __("Northern Sami",'ultimate-member'),
1565
- "sg" => __("Sango",'ultimate-member'),
1566
- "si" => __("Sinhala",'ultimate-member'),
1567
- "sk" => __("Slovak",'ultimate-member'),
1568
- "sl" => __("Slovenian",'ultimate-member'),
1569
- "sm" => __("Samoan",'ultimate-member'),
1570
- "sn" => __("Shona",'ultimate-member'),
1571
- "so" => __("Somali",'ultimate-member'),
1572
- "sq" => __("Albanian",'ultimate-member'),
1573
- "sr" => __("Serbian",'ultimate-member'),
1574
- "ss" => __("Swati",'ultimate-member'),
1575
- "st" => __("Southern Sotho",'ultimate-member'),
1576
- "su" => __("Sundanese",'ultimate-member'),
1577
- "sv" => __("Swedish",'ultimate-member'),
1578
- "sw" => __("Swahili",'ultimate-member'),
1579
- "ta" => __("Tamil",'ultimate-member'),
1580
- "te" => __("Telugu",'ultimate-member'),
1581
- "tg" => __("Tajik",'ultimate-member'),
1582
- "th" => __("Thai",'ultimate-member'),
1583
- "ti" => __("Tigrinya",'ultimate-member'),
1584
- "tk" => __("Turkmen",'ultimate-member'),
1585
- "tl" => __("Tagalog",'ultimate-member'),
1586
- "tn" => __("Tswana",'ultimate-member'),
1587
- "to" => __("Tonga",'ultimate-member'),
1588
- "tr" => __("Turkish",'ultimate-member'),
1589
- "ts" => __("Tsonga",'ultimate-member'),
1590
- "tt" => __("Tatar",'ultimate-member'),
1591
- "tw" => __("Twi",'ultimate-member'),
1592
- "ty" => __("Tahitian",'ultimate-member'),
1593
- "ug" => __("Uighur",'ultimate-member'),
1594
- "uk" => __("Ukrainian",'ultimate-member'),
1595
- "ur" => __("Urdu",'ultimate-member'),
1596
- "uz" => __("Uzbek",'ultimate-member'),
1597
- "ve" => __("Venda",'ultimate-member'),
1598
- "vi" => __("Vietnamese",'ultimate-member'),
1599
- "vo" => __("Volapuk",'ultimate-member'),
1600
- "wa" => __("Walloon",'ultimate-member'),
1601
- "wo" => __("Wolof",'ultimate-member'),
1602
- "xh" => __("Xhosa",'ultimate-member'),
1603
- "yi" => __("Yiddish",'ultimate-member'),
1604
- "yo" => __("Yoruba",'ultimate-member'),
1605
- "za" => __("Zhuang",'ultimate-member'),
1606
- "zh" => __("Chinese",'ultimate-member'),
1607
- "zu" => __("Zulu",'ultimate-member')
1608
- );
1609
- break;
1610
-
1611
- case 'countries':
1612
- $array = array (
1613
- 'AF' => __('Afghanistan','ultimate-member'),
1614
- 'AX' => __('Åland Islands','ultimate-member'),
1615
- 'AL' => __('Albania','ultimate-member'),
1616
- 'DZ' => __('Algeria','ultimate-member'),
1617
- 'AS' => __('American Samoa','ultimate-member'),
1618
- 'AD' => __('Andorra','ultimate-member'),
1619
- 'AO' => __('Angola','ultimate-member'),
1620
- 'AI' => __('Anguilla','ultimate-member'),
1621
- 'AQ' => __('Antarctica','ultimate-member'),
1622
- 'AG' => __('Antigua and Barbuda','ultimate-member'),
1623
- 'AR' => __('Argentina','ultimate-member'),
1624
- 'AM' => __('Armenia','ultimate-member'),
1625
- 'AW' => __('Aruba','ultimate-member'),
1626
- 'AU' => __('Australia','ultimate-member'),
1627
- 'AT' => __('Austria','ultimate-member'),
1628
- 'AZ' => __('Azerbaijan','ultimate-member'),
1629
- 'BS' => __('Bahamas','ultimate-member'),
1630
- 'BH' => __('Bahrain','ultimate-member'),
1631
- 'BD' => __('Bangladesh','ultimate-member'),
1632
- 'BB' => __('Barbados','ultimate-member'),
1633
- 'BY' => __('Belarus','ultimate-member'),
1634
- 'BE' => __('Belgium','ultimate-member'),
1635
- 'BZ' => __('Belize','ultimate-member'),
1636
- 'BJ' => __('Benin','ultimate-member'),
1637
- 'BM' => __('Bermuda','ultimate-member'),
1638
- 'BT' => __('Bhutan','ultimate-member'),
1639
- 'BO' => __('Bolivia, Plurinational State of','ultimate-member'),
1640
- 'BA' => __('Bosnia and Herzegovina','ultimate-member'),
1641
- 'BW' => __('Botswana','ultimate-member'),
1642
- 'BV' => __('Bouvet Island','ultimate-member'),
1643
- 'BR' => __('Brazil','ultimate-member'),
1644
- 'IO' => __('British Indian Ocean Territory','ultimate-member'),
1645
- 'BN' => __('Brunei Darussalam','ultimate-member'),
1646
- 'BG' => __('Bulgaria','ultimate-member'),
1647
- 'BF' => __('Burkina Faso','ultimate-member'),
1648
- 'BI' => __('Burundi','ultimate-member'),
1649
- 'KH' => __('Cambodia','ultimate-member'),
1650
- 'CM' => __('Cameroon','ultimate-member'),
1651
- 'CA' => __('Canada','ultimate-member'),
1652
- 'CV' => __('Cape Verde','ultimate-member'),
1653
- 'KY' => __('Cayman Islands','ultimate-member'),
1654
- 'CF' => __('Central African Republic','ultimate-member'),
1655
- 'TD' => __('Chad','ultimate-member'),
1656
- 'CL' => __('Chile','ultimate-member'),
1657
- 'CN' => __('China','ultimate-member'),
1658
- 'CX' => __('Christmas Island','ultimate-member'),
1659
- 'CC' => __('Cocos (Keeling) Islands','ultimate-member'),
1660
- 'CO' => __('Colombia','ultimate-member'),
1661
- 'KM' => __('Comoros','ultimate-member'),
1662
- 'CG' => __('Congo','ultimate-member'),
1663
- 'CD' => __('Congo, the Democratic Republic of the','ultimate-member'),
1664
- 'CK' => __('Cook Islands','ultimate-member'),
1665
- 'CR' => __('Costa Rica','ultimate-member'),
1666
- 'CI' => __("Côte d'Ivoire",'ultimate-member'),
1667
- 'HR' => __('Croatia','ultimate-member'),
1668
- 'CU' => __('Cuba','ultimate-member'),
1669
- 'CY' => __('Cyprus','ultimate-member'),
1670
- 'CZ' => __('Czech Republic','ultimate-member'),
1671
- 'DK' => __('Denmark','ultimate-member'),
1672
- 'DJ' => __('Djibouti','ultimate-member'),
1673
- 'DM' => __('Dominica','ultimate-member'),
1674
- 'DO' => __('Dominican Republic','ultimate-member'),
1675
- 'EC' => __('Ecuador','ultimate-member'),
1676
- 'EG' => __('Egypt','ultimate-member'),
1677
- 'SV' => __('El Salvador','ultimate-member'),
1678
- 'GQ' => __('Equatorial Guinea','ultimate-member'),
1679
- 'ER' => __('Eritrea','ultimate-member'),
1680
- 'EE' => __('Estonia','ultimate-member'),
1681
- 'ET' => __('Ethiopia','ultimate-member'),
1682
- 'FK' => __('Falkland Islands (Malvinas)','ultimate-member'),
1683
- 'FO' => __('Faroe Islands','ultimate-member'),
1684
- 'FJ' => __('Fiji','ultimate-member'),
1685
- 'FI' => __('Finland','ultimate-member'),
1686
- 'FR' => __('France','ultimate-member'),
1687
- 'GF' => __('French Guiana','ultimate-member'),
1688
- 'PF' => __('French Polynesia','ultimate-member'),
1689
- 'TF' => __('French Southern Territories','ultimate-member'),
1690
- 'GA' => __('Gabon','ultimate-member'),
1691
- 'GM' => __('Gambia','ultimate-member'),
1692
- 'GE' => __('Georgia','ultimate-member'),
1693
- 'DE' => __('Germany','ultimate-member'),
1694
- 'GH' => __('Ghana','ultimate-member'),
1695
- 'GI' => __('Gibraltar','ultimate-member'),
1696
- 'GR' => __('Greece','ultimate-member'),
1697
- 'GL' => __('Greenland','ultimate-member'),
1698
- 'GD' => __('Grenada','ultimate-member'),
1699
- 'GP' => __('Guadeloupe','ultimate-member'),
1700
- 'GU' => __('Guam','ultimate-member'),
1701
- 'GT' => __('Guatemala','ultimate-member'),
1702
- 'GG' => __('Guernsey','ultimate-member'),
1703
- 'GN' => __('Guinea','ultimate-member'),
1704
- 'GW' => __('Guinea-Bissau','ultimate-member'),
1705
- 'GY' => __('Guyana','ultimate-member'),
1706
- 'HT' => __('Haiti','ultimate-member'),
1707
- 'HM' => __('Heard Island and McDonald Islands','ultimate-member'),
1708
- 'VA' => __('Holy See (Vatican City State)','ultimate-member'),
1709
- 'HN' => __('Honduras','ultimate-member'),
1710
- 'HK' => __('Hong Kong','ultimate-member'),
1711
- 'HU' => __('Hungary','ultimate-member'),
1712
- 'IS' => __('Iceland','ultimate-member'),
1713
- 'IN' => __('India','ultimate-member'),
1714
- 'ID' => __('Indonesia','ultimate-member'),
1715
- 'IR' => __('Iran, Islamic Republic of','ultimate-member'),
1716
- 'IQ' => __('Iraq','ultimate-member'),
1717
- 'IE' => __('Ireland','ultimate-member'),
1718
- 'IM' => __('Isle of Man','ultimate-member'),
1719
- 'IL' => __('Israel','ultimate-member'),
1720
- 'IT' => __('Italy','ultimate-member'),
1721
- 'JM' => __('Jamaica','ultimate-member'),
1722
- 'JP' => __('Japan','ultimate-member'),
1723
- 'JE' => __('Jersey','ultimate-member'),
1724
- 'JO' => __('Jordan','ultimate-member'),
1725
- 'KZ' => __('Kazakhstan','ultimate-member'),
1726
- 'KE' => __('Kenya','ultimate-member'),
1727
- 'KI' => __('Kiribati','ultimate-member'),
1728
- 'KP' => __("Korea, Democratic People's Republic of",'ultimate-member'),
1729
- 'KR' => __('Korea, Republic of','ultimate-member'),
1730
- 'KW' => __('Kuwait','ultimate-member'),
1731
- 'KG' => __('Kyrgyzstan','ultimate-member'),
1732
- 'LA' => __("Lao People's Democratic Republic",'ultimate-member'),
1733
- 'LV' => __('Latvia','ultimate-member'),
1734
- 'LB' => __('Lebanon','ultimate-member'),
1735
- 'LS' => __('Lesotho','ultimate-member'),
1736
- 'LR' => __('Liberia','ultimate-member'),
1737
- 'LY' => __('Libyan Arab Jamahiriya','ultimate-member'),
1738
- 'LI' => __('Liechtenstein','ultimate-member'),
1739
- 'LT' => __('Lithuania','ultimate-member'),
1740
- 'LU' => __('Luxembourg','ultimate-member'),
1741
- 'MO' => __('Macao','ultimate-member'),
1742
- 'MK' => __('Macedonia, the former Yugoslav Republic of','ultimate-member'),
1743
- 'MG' => __('Madagascar','ultimate-member'),
1744
- 'MW' => __('Malawi','ultimate-member'),
1745
- 'MY' => __('Malaysia','ultimate-member'),
1746
- 'MV' => __('Maldives','ultimate-member'),
1747
- 'ML' => __('Mali','ultimate-member'),
1748
- 'MT' => __('Malta','ultimate-member'),
1749
- 'MH' => __('Marshall Islands','ultimate-member'),
1750
- 'MQ' => __('Martinique','ultimate-member'),
1751
- 'MR' => __('Mauritania','ultimate-member'),
1752
- 'MU' => __('Mauritius','ultimate-member'),
1753
- 'YT' => __('Mayotte','ultimate-member'),
1754
- 'MX' => __('Mexico','ultimate-member'),
1755
- 'FM' => __('Micronesia, Federated States of','ultimate-member'),
1756
- 'MD' => __('Moldova, Republic of','ultimate-member'),
1757
- 'MC' => __('Monaco','ultimate-member'),
1758
- 'MN' => __('Mongolia','ultimate-member'),
1759
- 'ME' => __('Montenegro','ultimate-member'),
1760
- 'MS' => __('Montserrat','ultimate-member'),
1761
- 'MA' => __('Morocco','ultimate-member'),
1762
- 'MZ' => __('Mozambique','ultimate-member'),
1763
- 'MM' => __('Myanmar','ultimate-member'),
1764
- 'NA' => __('Namibia','ultimate-member'),
1765
- 'NR' => __('Nauru','ultimate-member'),
1766
- 'NP' => __('Nepal','ultimate-member'),
1767
- 'NL' => __('Netherlands','ultimate-member'),
1768
- 'AN' => __('Netherlands Antilles','ultimate-member'),
1769
- 'NC' => __('New Caledonia','ultimate-member'),
1770
- 'NZ' => __('New Zealand','ultimate-member'),
1771
- 'NI' => __('Nicaragua','ultimate-member'),
1772
- 'NE' => __('Niger','ultimate-member'),
1773
- 'NG' => __('Nigeria','ultimate-member'),
1774
- 'NU' => __('Niue','ultimate-member'),
1775
- 'NF' => __('Norfolk Island','ultimate-member'),
1776
- 'MP' => __('Northern Mariana Islands','ultimate-member'),
1777
- 'NO' => __('Norway','ultimate-member'),
1778
- 'OM' => __('Oman','ultimate-member'),
1779
- 'PK' => __('Pakistan','ultimate-member'),
1780
- 'PW' => __('Palau','ultimate-member'),
1781
- 'PS' => __('Palestine','ultimate-member'),
1782
- 'PA' => __('Panama','ultimate-member'),
1783
- 'PG' => __('Papua New Guinea','ultimate-member'),
1784
- 'PY' => __('Paraguay','ultimate-member'),
1785
- 'PE' => __('Peru','ultimate-member'),
1786
- 'PH' => __('Philippines','ultimate-member'),
1787
- 'PN' => __('Pitcairn','ultimate-member'),
1788
- 'PL' => __('Poland','ultimate-member'),
1789
- 'PT' => __('Portugal','ultimate-member'),
1790
- 'PR' => __('Puerto Rico','ultimate-member'),
1791
- 'QA' => __('Qatar','ultimate-member'),
1792
- 'RE' => __('Réunion','ultimate-member'),
1793
- 'RO' => __('Romania','ultimate-member'),
1794
- 'RU' => __('Russian Federation','ultimate-member'),
1795
- 'RW' => __('Rwanda','ultimate-member'),
1796
- 'BL' => __('Saint Barthélemy','ultimate-member'),
1797
- 'SH' => __('Saint Helena','ultimate-member'),
1798
- 'KN' => __('Saint Kitts and Nevis','ultimate-member'),
1799
- 'LC' => __('Saint Lucia','ultimate-member'),
1800
- 'MF' => __('Saint Martin (French part)','ultimate-member'),
1801
- 'PM' => __('Saint Pierre and Miquelon','ultimate-member'),
1802
- 'VC' => __('Saint Vincent and the Grenadines','ultimate-member'),
1803
- 'WS' => __('Samoa','ultimate-member'),
1804
- 'SM' => __('San Marino','ultimate-member'),
1805
- 'ST' => __('Sao Tome and Principe','ultimate-member'),
1806
- 'SA' => __('Saudi Arabia','ultimate-member'),
1807
- 'SN' => __('Senegal','ultimate-member'),
1808
- 'RS' => __('Serbia','ultimate-member'),
1809
- 'SC' => __('Seychelles','ultimate-member'),
1810
- 'SL' => __('Sierra Leone','ultimate-member'),
1811
- 'SG' => __('Singapore','ultimate-member'),
1812
- 'SK' => __('Slovakia','ultimate-member'),
1813
- 'SI' => __('Slovenia','ultimate-member'),
1814
- 'SB' => __('Solomon Islands','ultimate-member'),
1815
- 'SO' => __('Somalia','ultimate-member'),
1816
- 'ZA' => __('South Africa','ultimate-member'),
1817
- 'GS' => __('South Georgia and the South Sandwich Islands','ultimate-member'),
1818
- 'SS' => __('South Sudan','ultimate-member'),
1819
- 'ES' => __('Spain','ultimate-member'),
1820
- 'LK' => __('Sri Lanka','ultimate-member'),
1821
- 'SD' => __('Sudan','ultimate-member'),
1822
- 'SR' => __('Suriname','ultimate-member'),
1823
- 'SJ' => __('Svalbard and Jan Mayen','ultimate-member'),
1824
- 'SZ' => __('Swaziland','ultimate-member'),
1825
- 'SE' => __('Sweden','ultimate-member'),
1826
- 'CH' => __('Switzerland','ultimate-member'),
1827
- 'SY' => __('Syrian Arab Republic','ultimate-member'),
1828
- 'TW' => __('Taiwan, Province of China','ultimate-member'),
1829
- 'TJ' => __('Tajikistan','ultimate-member'),
1830
- 'TZ' => __('Tanzania, United Republic of','ultimate-member'),
1831
- 'TH' => __('Thailand','ultimate-member'),
1832
- 'TL' => __('Timor-Leste','ultimate-member'),
1833
- 'TG' => __('Togo','ultimate-member'),
1834
- 'TK' => __('Tokelau','ultimate-member'),
1835
- 'TO' => __('Tonga','ultimate-member'),
1836
- 'TT' => __('Trinidad and Tobago','ultimate-member'),
1837
- 'TN' => __('Tunisia','ultimate-member'),
1838
- 'TR' => __('Turkey','ultimate-member'),
1839
- 'TM' => __('Turkmenistan','ultimate-member'),
1840
- 'TC' => __('Turks and Caicos Islands','ultimate-member'),
1841
- 'TV' => __('Tuvalu','ultimate-member'),
1842
- 'UG' => __('Uganda','ultimate-member'),
1843
- 'UA' => __('Ukraine','ultimate-member'),
1844
- 'AE' => __('United Arab Emirates','ultimate-member'),
1845
- 'GB' => __('United Kingdom','ultimate-member'),
1846
- 'US' => __('United States','ultimate-member'),
1847
- 'UM' => __('United States Minor Outlying Islands','ultimate-member'),
1848
- 'UY' => __('Uruguay','ultimate-member'),
1849
- 'UZ' => __('Uzbekistan','ultimate-member'),
1850
- 'VU' => __('Vanuatu','ultimate-member'),
1851
- 'VE' => __('Venezuela, Bolivarian Republic of','ultimate-member'),
1852
- 'VN' => __('Viet Nam','ultimate-member'),
1853
- 'VG' => __('Virgin Islands, British','ultimate-member'),
1854
- 'VI' => __('Virgin Islands, U.S.','ultimate-member'),
1855
- 'WF' => __('Wallis and Futuna','ultimate-member'),
1856
- 'EH' => __('Western Sahara','ultimate-member'),
1857
- 'YE' => __('Yemen','ultimate-member'),
1858
- 'ZM' => __('Zambia','ultimate-member'),
1859
- 'ZW' => __('Zimbabwe','ultimate-member'),
1860
- );
1861
- break;
1862
-
1863
- }
1864
-
1865
- /**
1866
- * UM hook
1867
- *
1868
- * @type filter
1869
- * @title um_{$data}_predefined_field_options
1870
- * @description Extend Predefined Fields options. Where $data - field key.
1871
- * @input_vars
1872
- * [{"var":"$options","type":"array","desc":"Field's Options"}]
1873
- * @change_log
1874
- * ["Since: 2.0"]
1875
- * @usage add_filter( 'um_{$data}_predefined_field_options', 'function_name', 10, 1 );
1876
- * @example
1877
- * <?php
1878
- * add_filter( 'um_{$data}_predefined_field_options', 'my_predefined_field', 10, 1 );
1879
- * function my_predefined_field( $options ) {
1880
- * // your code here
1881
- * return $options;
1882
- * }
1883
- * ?>
1884
- */
1885
- $array = apply_filters( "um_{$data}_predefined_field_options", $array );
1886
- return $array;
1887
- }
1888
-
1889
- }
1890
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace um\core;
3
+
4
+ // Exit if accessed directly
5
+ if ( ! defined( 'ABSPATH' ) ) exit;
6
+
7
+ if ( ! class_exists( 'um\core\Builtin' ) ) {
8
+
9
+
10
+ /**
11
+ * Class Builtin
12
+ * @package um\core
13
+ */
14
+ class Builtin {
15
+
16
+
17
+ /**
18
+ * @var array
19
+ */
20
+ public $predefined_fields = array();
21
+
22
+
23
+ /**
24
+ * @var array
25
+ */
26
+ var $all_user_fields = array();
27
+
28
+
29
+ /**
30
+ * @var array
31
+ */
32
+ var $core_fields = array();
33
+
34
+
35
+ /**
36
+ * Builtin constructor.
37
+ */
38
+ function __construct() {
39
+ add_action( 'init', array( &$this, 'set_core_fields' ), 1 );
40
+ add_action( 'init', array( &$this, 'set_predefined_fields' ), 1 );
41
+ add_action( 'init', array( &$this, 'set_custom_fields' ), 1 );
42
+ $this->saved_fields = get_option( 'um_fields' );
43
+ }
44
+
45
+
46
+ /**
47
+ * @return array
48
+ */
49
+ function get_all_user_fields() {
50
+ return apply_filters( 'um_builtin_all_user_fields', $this->all_user_fields );
51
+ }
52
+
53
+
54
+ /**
55
+ * Regular or multi-select/options
56
+ *
57
+ * @param $field
58
+ * @param $attrs
59
+ *
60
+ * @return bool
61
+ */
62
+ function is_dropdown_field( $field, $attrs ) {
63
+
64
+ if ( isset( $attrs['options'] ) ) {
65
+ return true;
66
+ }
67
+
68
+ $fields = $this->all_user_fields;
69
+
70
+ if ( isset( $fields[$field]['options'] ) || ! empty( $fields[$field]['custom_dropdown_options_source'] ) ) {
71
+ return true;
72
+ }
73
+
74
+ return false;
75
+ }
76
+
77
+
78
+ /**
79
+ * Get a field
80
+ *
81
+ * @param $field
82
+ *
83
+ * @return mixed|string
84
+ */
85
+ function get_a_field( $field ) {
86
+ $fields = $this->all_user_fields;
87
+ if ( isset( $fields[ $field ] ) ) {
88
+ return $fields[ $field ];
89
+ }
90
+ return '';
91
+ }
92
+
93
+
94
+ /**
95
+ * Get specific fields
96
+ *
97
+ * @param $fields
98
+ *
99
+ * @return array
100
+ */
101
+ function get_specific_fields( $fields ) {
102
+ $fields = explode( ',', $fields );
103
+ $array = array();
104
+ foreach ( $fields as $field ) {
105
+ if ( isset( $this->predefined_fields[ $field ] ) ) {
106
+ $array[ $field ] = $this->predefined_fields[ $field ];
107
+ }
108
+ }
109
+ return $array;
110
+ }
111
+
112
+
113
+ /**
114
+ * Get specific field
115
+ *
116
+ * @param $fields
117
+ *
118
+ * @return array|mixed
119
+ */
120
+ function get_specific_field( $fields ) {
121
+ $fields = explode( ',', $fields );
122
+ $array = array();
123
+ foreach ( $fields as $field ) {
124
+ if ( isset( $this->predefined_fields[ $field ] ) ) {
125
+ $array = $this->predefined_fields[ $field ];
126
+ } elseif ( isset( $this->saved_fields[ $field ] ) ) {
127
+ $array = $this->saved_fields[ $field ];
128
+ }
129
+ }
130
+ return $array;
131
+ }
132
+
133
+
134
+ /**
135
+ * Checks for a unique field error
136
+ *
137
+ * @param $key
138
+ *
139
+ * @return int|string
140
+ */
141
+ function unique_field_err( $key ) {
142
+ if ( empty( $key ) ) {
143
+ return __( 'Please provide a meta key', 'ultimate-member' );
144
+ }
145
+ if ( isset( $this->core_fields[ $key ] ) ) {
146
+ return __( 'Your meta key is a reserved core field and cannot be used', 'ultimate-member' );
147
+ }
148
+ if ( isset( $this->predefined_fields[ $key ] ) ) {
149
+ return __( 'Your meta key is a predefined reserved key and cannot be used', 'ultimate-member' );
150
+ }
151
+ if ( isset( $this->saved_fields[ $key ] ) ) {
152
+ return __( 'Your meta key already exists in your fields list', 'ultimate-member' );
153
+ }
154
+ if ( ! UM()->validation()->safe_string( $key ) ) {
155
+ return __( 'Your meta key contains illegal characters. Please correct it.', 'ultimate-member' );
156
+ }
157
+
158
+ return 0;
159
+ }
160
+
161
+
162
+ /**
163
+ * Check date range errors (start date)
164
+ *
165
+ * @param $date
166
+ *
167
+ * @return int|string
168
+ */
169
+ function date_range_start_err( $date ) {
170
+ if ( empty( $date ) ) {
171
+ return __( 'Please provide a date range beginning', 'ultimate-member' );
172
+ }
173
+ if ( ! UM()->validation()->validate_date( $date ) ) {
174
+ return __( 'Please enter a valid start date in the date range', 'ultimate-member' );
175
+ }
176
+
177
+ return 0;
178
+ }
179
+
180
+
181
+ /**
182
+ * Check date range errors (end date)
183
+ *
184
+ * @param $date
185
+ * @param $start_date
186
+ *
187
+ * @return int|string
188
+ */
189
+ function date_range_end_err( $date, $start_date ) {
190
+ if ( empty( $date ) ) {
191
+ return __( 'Please provide a date range end', 'ultimate-member' );
192
+ }
193
+ if ( ! UM()->validation()->validate_date( $date ) ) {
194
+ return __( 'Please enter a valid end date in the date range', 'ultimate-member' );
195
+ }
196
+ if ( strtotime( $date ) <= strtotime( $start_date ) ) {
197
+ return __( 'The end of date range must be greater than the start of date range', 'ultimate-member' );
198
+ }
199
+ return 0;
200
+ }
201
+
202
+
203
+ /**
204
+ * Get a core field attrs
205
+ *
206
+ * @param $type
207
+ *
208
+ * @return array|mixed
209
+ */
210
+ function get_core_field_attrs( $type ) {
211
+ return ( isset( $this->core_fields[ $type ] ) ) ? $this->core_fields[ $type ] : array('');
212
+ }
213
+
214
+
215
+ /**
216
+ * Core Fields
217
+ */
218
+ function set_core_fields() {
219
+
220
+ $this->core_fields = array(
221
+
222
+ 'row' => array(
223
+ 'name' => 'Row',
224
+ 'in_fields' => false,
225
+ 'form_only' => true,
226
+ 'conditional_support' => 0,
227
+ 'icon' => 'um-faicon-pencil',
228
+ 'col1' => array('_id','_background','_text_color','_padding','_margin','_border','_borderradius','_borderstyle','_bordercolor'),
229
+ 'col2' => array('_heading','_heading_text','_heading_background_color','_heading_text_color','_icon','_icon_color','_css_class'),
230
+ ),
231
+
232
+ 'text' => array(
233
+ 'name' => 'Text Box',
234
+ 'col1' => array('_title','_metakey','_help','_default','_min_chars','_visibility'),
235
+ 'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate','_max_chars'),
236
+ 'col3' => array('_required','_editable','_icon'),
237
+ 'validate' => array(
238
+ '_title' => array(
239
+ 'mode' => 'required',
240
+ 'error' => __('You must provide a title','ultimate-member')
241
+ ),
242
+ '_metakey' => array(
243
+ 'mode' => 'unique',
244
+ ),
245
+ )
246
+ ),
247
+
248
+ 'number' => array(
249
+ 'name' => __('Number','ultimate-member'),
250
+ 'col1' => array('_title','_metakey','_help','_default','_min','_visibility'),
251
+ 'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate','_max'),
252
+ 'col3' => array('_required','_editable','_icon'),
253
+ 'validate' => array(
254
+ '_title' => array(
255
+ 'mode' => 'required',
256
+ 'error' => __('You must provide a title','ultimate-member')
257
+ ),
258
+ '_metakey' => array(
259
+ 'mode' => 'unique',
260
+ ),
261
+ )
262
+ ),
263
+
264
+ 'textarea' => array(
265
+ 'name' => 'Textarea',
266
+ 'col1' => array('_title','_metakey','_help','_height','_max_chars','_max_words','_visibility'),
267
+ 'col2' => array('_label','_placeholder','_public','_roles','_default','_html'),
268
+ 'col3' => array('_required','_editable','_icon'),
269
+ 'validate' => array(
270
+ '_title' => array(
271
+ 'mode' => 'required',
272
+ 'error' => __('You must provide a title','ultimate-member')
273
+ ),
274
+ '_metakey' => array(
275
+ 'mode' => 'unique',
276
+ ),
277
+ )
278
+ ),
279
+
280
+ 'select' => array(
281
+ 'name' => 'Dropdown',
282
+ 'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
283
+ 'col2' => array('_label','_placeholder','_public','_roles','_custom_dropdown_options_source','_parent_dropdown_relationship'),
284
+ 'col3' => array('_required','_editable','_icon'),
285
+ 'validate' => array(
286
+ '_title' => array(
287
+ 'mode' => 'required',
288
+ 'error' => __('You must provide a title','ultimate-member')
289
+ ),
290
+ '_metakey' => array(
291
+ 'mode' => 'unique',
292
+ ),
293
+ '_options' => array(
294
+ 'mode' => 'required',
295
+ 'error' => __('You have not added any choices yet.','ultimate-member')
296
+ ),
297
+ )
298
+ ),
299
+
300
+ 'multiselect' => array(
301
+ 'name' => 'Multi-Select',
302
+ 'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
303
+ 'col2' => array('_label','_placeholder','_public','_roles','_min_selections','_max_selections','_custom_dropdown_options_source'),
304
+ 'col3' => array('_required','_editable','_icon'),
305
+ 'validate' => array(
306
+ '_title' => array(
307
+ 'mode' => 'required',
308
+ 'error' => __('You must provide a title','ultimate-member')
309
+ ),
310
+ '_metakey' => array(
311
+ 'mode' => 'unique',
312
+ ),
313
+ '_options' => array(
314
+ 'mode' => 'required',
315
+ 'error' => __('You have not added any choices yet.','ultimate-member')
316
+ ),
317
+ )
318
+ ),
319
+
320
+ 'radio' => array(
321
+ 'name' => 'Radio',
322
+ 'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
323
+ 'col2' => array('_label','_public','_roles'),
324
+ 'col3' => array('_required','_editable','_icon'),
325
+ 'validate' => array(
326
+ '_title' => array(
327
+ 'mode' => 'required',
328
+ 'error' => __('You must provide a title','ultimate-member')
329
+ ),
330
+ '_metakey' => array(
331
+ 'mode' => 'unique',
332
+ ),
333
+ '_options' => array(
334
+ 'mode' => 'required',
335
+ 'error' => __('You have not added any choices yet.','ultimate-member')
336
+ ),
337
+ )
338
+ ),
339
+
340
+ 'checkbox' => array(
341
+ 'name' => 'Checkbox',
342
+ 'col1' => array('_title','_metakey','_help','_default','_options','_visibility'),
343
+ 'col2' => array('_label','_public','_roles','_max_selections'),
344
+ 'col3' => array('_required','_editable','_icon'),
345
+ 'validate' => array(
346
+ '_title' => array(
347
+ 'mode' => 'required',
348
+ 'error' => __('You must provide a title','ultimate-member')
349
+ ),
350
+ '_metakey' => array(
351
+ 'mode' => 'unique',
352
+ ),
353
+ '_options' => array(
354
+ 'mode' => 'required',
355
+ 'error' => __('You have not added any choices yet.','ultimate-member')
356
+ ),
357
+ )
358
+ ),
359
+
360
+ 'url' => array(
361
+ 'name' => 'URL',
362
+ 'col1' => array('_title','_metakey','_help','_default','_url_text','_visibility'),
363
+ 'col2' => array('_label','_placeholder','_url_target','_url_rel','_public','_roles','_validate','_custom_validate'),
364
+ 'col3' => array('_required','_editable','_icon'),
365
+ 'validate' => array(
366
+ '_title' => array(
367
+ 'mode' => 'required',
368
+ 'error' => __('You must provide a title','ultimate-member')
369
+ ),
370
+ '_metakey' => array(
371
+ 'mode' => 'unique',
372
+ ),
373
+ )
374
+ ),
375
+
376
+ 'password' => array(
377
+ 'name' => 'Password',
378
+ 'col1' => array('_title','_metakey','_help','_min_chars','_max_chars','_visibility'),
379
+ 'col2' => array('_label','_placeholder','_public','_roles','_force_good_pass','_force_confirm_pass','_label_confirm_pass'),
380
+ 'col3' => array('_required','_editable','_icon'),
381
+ 'validate' => array(
382
+ '_title' => array(
383
+ 'mode' => 'required',
384
+ 'error' => __('You must provide a title','ultimate-member')
385
+ ),
386
+ '_metakey' => array(
387
+ 'mode' => 'unique',
388
+ ),
389
+ )
390
+ ),
391
+
392
+ 'image' => array(
393
+ 'name' => 'Image Upload',
394
+ 'col1' => array('_title','_metakey','_help','_allowed_types','_max_size','_crop','_visibility'),
395
+ 'col2' => array('_label','_public','_roles','_upload_text','_upload_help_text','_button_text'),
396
+ 'col3' => array('_required','_editable','_icon'),
397
+ 'validate' => array(
398
+ '_title' => array(
399
+ 'mode' => 'required',
400
+ 'error' => __('You must provide a title','ultimate-member')
401
+ ),
402
+ '_metakey' => array(
403
+ 'mode' => 'unique',
404
+ ),
405
+ '_max_size' => array(
406
+ 'mode' => 'numeric',
407
+ 'error' => __('Please enter a valid size','ultimate-member')
408
+ ),
409
+ )
410
+ ),
411
+
412
+ 'file' => array(
413
+ 'name' => 'File Upload',
414
+ 'col1' => array('_title','_metakey','_help','_allowed_types','_max_size','_visibility'),
415
+ 'col2' => array('_label','_public','_roles','_upload_text','_upload_help_text','_button_text'),
416
+ 'col3' => array('_required','_editable','_icon'),
417
+ 'validate' => array(
418
+ '_title' => array(
419
+ 'mode' => 'required',
420
+ 'error' => __('You must provide a title','ultimate-member')
421
+ ),
422
+ '_metakey' => array(
423
+ 'mode' => 'unique',
424
+ ),
425
+ '_max_size' => array(
426
+ 'mode' => 'numeric',
427
+ 'error' => __( 'Please enter a valid size', 'ultimate-member' )
428
+ ),
429
+ )
430
+ ),
431
+
432
+ 'date' => array(
433
+ 'name' => 'Date Picker',
434
+ 'col1' => array( '_title', '_metakey', '_help', '_default', '_range', '_years', '_years_x', '_range_start', '_range_end', '_visibility' ),
435
+ 'col2' => array( '_label', '_placeholder', '_public', '_roles', '_format', '_format_custom', '_pretty_format', '_disabled_weekdays' ),
436
+ 'col3' => array( '_required', '_editable', '_icon' ),
437
+ 'validate' => array(
438
+ '_title' => array(
439
+ 'mode' => 'required',
440
+ 'error' => __( 'You must provide a title', 'ultimate-member' )
441
+ ),
442
+ '_metakey' => array(
443
+ 'mode' => 'unique',
444
+ ),
445
+ '_years' => array(
446
+ 'mode' => 'numeric',
447
+ 'error' => __( 'Number of years is not valid', 'ultimate-member' )
448
+ ),
449
+ '_range_start' => array(
450
+ 'mode' => 'range-start',
451
+ ),
452
+ '_range_end' => array(
453
+ 'mode' => 'range-end',
454
+ ),
455
+ )
456
+ ),
457
+
458
+ 'time' => array(
459
+ 'name' => 'Time Picker',
460
+ 'col1' => array('_title','_metakey','_help','_format','_visibility'),
461
+ 'col2' => array('_label','_placeholder','_default','_public','_roles','_intervals'),
462
+ 'col3' => array('_required','_editable','_icon'),
463
+ 'validate' => array(
464
+ '_title' => array(
465
+ 'mode' => 'required',
466
+ 'error' => __( 'You must provide a title', 'ultimate-member' )
467
+ ),
468
+ '_metakey' => array(
469
+ 'mode' => 'unique',
470
+ ),
471
+ )
472
+ ),
473
+
474
+ 'rating' => array(
475
+ 'name' => 'Rating',
476
+ 'col1' => array('_title','_metakey','_help','_visibility'),
477
+ 'col2' => array('_label','_public','_roles','_number','_default'),
478
+ 'col3' => array('_required','_editable','_icon'),
479
+ 'validate' => array(
480
+ '_title' => array(
481
+ 'mode' => 'required',
482
+ 'error' => __('You must provide a title','ultimate-member')
483
+ ),
484
+ '_metakey' => array(
485
+ 'mode' => 'unique',
486
+ ),
487
+ )
488
+ ),
489
+
490
+ 'block' => array(
491
+ 'name' => 'Content Block',
492
+ 'col1' => array('_title','_visibility'),
493
+ 'col2' => array('_public','_roles'),
494
+ 'col_full' => array('_content'),
495
+ 'mce_content' => true,
496
+ 'validate' => array(
497
+ '_title' => array(
498
+ 'mode' => 'required',
499
+ 'error' => __('You must provide a title','ultimate-member')
500
+ ),
501
+ )
502
+ ),
503
+
504
+ 'shortcode' => array(
505
+ 'name' => 'Shortcode',
506
+ 'col1' => array('_title','_visibility'),
507
+ 'col2' => array('_public','_roles'),
508
+ 'col_full' => array('_content'),
509
+ 'validate' => array(
510
+ '_title' => array(
511
+ 'mode' => 'required',
512
+ 'error' => __('You must provide a title','ultimate-member')
513
+ ),
514
+ '_content' => array(
515
+ 'mode' => 'required',
516
+ 'error' => __('You must add a shortcode to the content area','ultimate-member')
517
+ ),
518
+ )
519
+ ),
520
+
521
+ 'spacing' => array(
522
+ 'name' => 'Spacing',
523
+ 'col1' => array('_title','_visibility'),
524
+ 'col2' => array('_spacing'),
525
+ 'form_only' => true,
526
+ 'validate' => array(
527
+ '_title' => array(
528
+ 'mode' => 'required',
529
+ 'error' => __('You must provide a title','ultimate-member')
530
+ ),
531
+ )
532
+ ),
533
+
534
+ 'divider' => array(
535
+ 'name' => 'Divider',
536
+ 'col1' => array('_title','_width','_divider_text','_visibility'),
537
+ 'col2' => array('_style','_color','_public','_roles'),
538
+ 'form_only' => true,
539
+ 'validate' => array(
540
+ '_title' => array(
541
+ 'mode' => 'required',
542
+ 'error' => __('You must provide a title','ultimate-member')
543
+ ),
544
+ )
545
+ ),
546
+
547
+ 'googlemap' => array(
548
+ 'name' => 'Google Map',
549
+ 'col1' => array('_title','_metakey','_help','_visibility'),
550
+ 'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
551
+ 'col3' => array('_required','_editable','_icon'),
552
+ 'validate' => array(
553
+ '_title' => array(
554
+ 'mode' => 'required',
555
+ 'error' => __('You must provide a title','ultimate-member')
556
+ ),
557
+ '_metakey' => array(
558
+ 'mode' => 'unique',
559
+ ),
560
+ )
561
+ ),
562
+
563
+ 'youtube_video' => array(
564
+ 'name' => 'YouTube Video',
565
+ 'col1' => array('_title','_metakey','_help','_visibility'),
566
+ 'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
567
+ 'col3' => array('_required','_editable','_icon'),
568
+ 'validate' => array(
569
+ '_title' => array(
570
+ 'mode' => 'required',
571
+ 'error' => __('You must provide a title','ultimate-member')
572
+ ),
573
+ '_metakey' => array(
574
+ 'mode' => 'unique',
575
+ ),
576
+ )
577
+ ),
578
+
579
+ 'vimeo_video' => array(
580
+ 'name' => 'Vimeo Video',
581
+ 'col1' => array('_title','_metakey','_help','_visibility'),
582
+ 'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
583
+ 'col3' => array('_required','_editable','_icon'),
584
+ 'validate' => array(
585
+ '_title' => array(
586
+ 'mode' => 'required',
587
+ 'error' => __('You must provide a title','ultimate-member')
588
+ ),
589
+ '_metakey' => array(
590
+ 'mode' => 'unique',
591
+ ),
592
+ )
593
+ ),
594
+
595
+ 'soundcloud_track' => array(
596
+ 'name' => 'SoundCloud Track',
597
+ 'col1' => array('_title','_metakey','_help','_visibility'),
598
+ 'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate'),
599
+ 'col3' => array('_required','_editable','_icon'),
600
+ 'validate' => array(
601
+ '_title' => array(
602
+ 'mode' => 'required',
603
+ 'error' => __('You must provide a title','ultimate-member')
604
+ ),
605
+ '_metakey' => array(
606
+ 'mode' => 'unique',
607
+ ),
608
+ )
609
+ ),
610
+
611
+ /*'group' => array(
612
+ 'name' => 'Field Group',
613
+ 'col1' => array('_title','_max_entries'),
614
+ 'col2' => array('_label','_public','_roles'),
615
+ 'form_only' => true,
616
+ 'validate' => array(
617
+ '_title' => array(
618
+ 'mode' => 'required',
619
+ 'error' => 'You must provide a title'
620
+ ),
621
+ '_label' => array(
622
+ 'mode' => 'required',
623
+ 'error' => 'You must provide a label'
624
+ ),
625
+ )
626
+ ),*/
627
+
628
+ );
629
+
630
+ /**
631
+ * UM hook
632
+ *
633
+ * @type filter
634
+ * @title um_core_fields_hook
635
+ * @description UM Core Fields
636
+ * @input_vars
637
+ * [{"var":"$core_fields","type":"array","desc":"Core Fields"}]
638
+ * @change_log
639
+ * ["Since: 2.0"]
640
+ * @usage add_filter( 'um_core_fields_hook', 'function_name', 10, 1 );
641
+ * @example
642
+ * <?php
643
+ * add_filter( 'um_core_fields_hook', 'my_core_fields', 10, 1 );
644
+ * function my_core_fields( $core_fields ) {
645
+ * // your code here
646
+ * return $core_fields;
647
+ * }
648
+ * ?>
649
+ */
650
+ $this->core_fields = apply_filters( 'um_core_fields_hook', $this->core_fields );
651
+ }
652
+
653
+
654
+ /**
655
+ * Predefined Fields
656
+ */
657
+ function set_predefined_fields() {
658
+
659
+ global $wp_roles;
660
+ $role_keys = get_option( 'um_roles', array() );
661
+ if ( ! empty( $role_keys ) && is_array( $role_keys ) ) {
662
+ $role_keys = array_map( function( $item ) {
663
+ return 'um_' . $item;
664
+ }, $role_keys );
665
+ } else {
666
+ $role_keys = array();
667
+ }
668
+
669
+ $exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
670
+
671
+ $um_roles = UM()->roles()->get_roles( false, $exclude_roles );
672
+
673
+ /**
674
+ * UM hook
675
+ *
676
+ * @type filter
677
+ * @title um_profile_privacy_options
678
+ * @description Profile Privacy Options
679
+ * @input_vars
680
+ * [{"var":"$privacy_options","type":"array","desc":"Privacy Options"}]
681
+ * @change_log
682
+ * ["Since: 2.0"]
683
+ * @usage add_filter( 'um_profile_privacy_options', 'function_name', 10, 1 );
684
+ * @example
685
+ * <?php
686
+ * add_filter( 'um_profile_privacy_options', 'my_profile_privacy_options', 10, 1 );
687
+ * function my_profile_privacy_options( $privacy_options ) {
688
+ * // your code here
689
+ * return $privacy_options;
690
+ * }
691
+ * ?>
692
+ */
693
+ $profile_privacy = apply_filters( 'um_profile_privacy_options', array(
694
+ 'Everyone' => __( 'Everyone', 'ultimate-member' ),
695
+ 'Only me' => __( 'Only me', 'ultimate-member' )
696
+ ) );
697
+
698
+ /*
699
+ * it's important create key for array equals value of 'metakey'.
700
+ *
701
+ */
702
+
703
+ $this->predefined_fields = array(
704
+
705
+ 'user_login' => array(
706
+ 'title' => __('Username','ultimate-member'),
707
+ 'metakey' => 'user_login',
708
+ 'type' => 'text',
709
+ 'label' => __('Username','ultimate-member'),
710
+ 'required' => 1,
711
+ 'public' => 1,
712
+ 'editable' => 0,
713
+ 'validate' => 'unique_username',
714
+ 'min_chars' => 3,
715
+ 'max_chars' => 24
716
+ ),
717
+
718
+ 'username' => array(
719
+ 'title' => __('Username or E-mail','ultimate-member'),
720
+ 'metakey' => 'username',
721
+ 'type' => 'text',
722
+ 'label' => __('Username or E-mail','ultimate-member'),
723
+ 'required' => 1,
724
+ 'public' => 1,
725
+ 'editable' => 0,
726
+ 'validate' => 'unique_username_or_email',
727
+ ),
728
+
729
+ 'user_password' => array(
730
+ 'title' => __('Password','ultimate-member'),
731
+ 'metakey' => 'user_password',
732
+ 'type' => 'password',
733
+ 'label' => __('Password','ultimate-member'),
734
+ 'required' => 1,
735
+ 'public' => 1,
736
+ 'editable' => 1,
737
+ 'min_chars' => 8,
738
+ 'max_chars' => 30,
739
+ 'force_good_pass' => 1,
740
+ 'force_confirm_pass' => 1,
741
+ 'label_confirm_pass' => __('Confirm Password','ultimate-member')
742
+ ),
743
+
744
+ 'first_name' => array(
745
+ 'title' => __('First Name','ultimate-member'),
746
+ 'metakey' => 'first_name',
747
+ 'type' => 'text',
748
+ 'label' => __('First Name','ultimate-member'),
749
+ 'required' => 0,
750
+ 'public' => 1,
751
+ 'editable' => 1,
752
+ ),
753
+
754
+ 'last_name' => array(
755
+ 'title' => __('Last Name','ultimate-member'),
756
+ 'metakey' => 'last_name',
757
+ 'type' => 'text',
758
+ 'label' => __('Last Name','ultimate-member'),
759
+ 'required' => 0,
760
+ 'public' => 1,
761
+ 'editable' => 1,
762
+ ),
763
+
764
+ 'nickname' => array(
765
+ 'title' => __('Nickname','ultimate-member'),
766
+ 'metakey' => 'nickname',
767
+ 'type' => 'text',
768
+ 'label' => __('Nickname','ultimate-member'),
769
+ 'required' => 0,
770
+ 'public' => 1,
771
+ 'editable' => 1,
772
+ ),
773
+
774
+ 'user_url' => array(
775
+ 'title' => __('Website URL','ultimate-member'),
776
+ 'metakey' => 'user_url',
777
+ 'type' => 'url',
778
+ 'label' => __('Website URL','ultimate-member'),
779
+ 'required' => 1,
780
+ 'public' => 1,
781
+ 'editable' => 1,
782
+ 'validate' => 'url'
783
+ ),
784
+
785
+ 'user_registered' => array(
786
+ 'title' => __('Registration Date','ultimate-member'),
787
+ 'metakey' => 'user_registered',
788
+ 'type' => 'text',
789
+ 'label' => __('Registration Date','ultimate-member'),
790
+ 'required' => 0,
791
+ 'public' => 1,
792
+ 'editable' => 1,
793
+ 'edit_forbidden' => 1,
794
+ ),
795
+
796
+ '_um_last_login' => array(
797
+ 'title' => __('Last Login','ultimate-member'),
798
+ 'metakey' => '_um_last_login',
799
+ 'type' => 'text',
800
+ 'label' => __('Last Login','ultimate-member'),
801
+ 'required' => 0,
802
+ 'public' => 1,
803
+ 'editable' => 1,
804
+ 'edit_forbidden' => 1,
805
+ ),
806
+
807
+ 'user_email' => array(
808
+ 'title' => __('E-mail Address','ultimate-member'),
809
+ 'metakey' => 'user_email',
810
+ 'type' => 'text',
811
+ 'label' => __('E-mail Address','ultimate-member'),
812
+ 'required' => 0,
813
+ 'public' => 1,
814
+ 'validate' => 'unique_email',
815
+ 'autocomplete' => 'off'
816
+ ),
817
+
818
+ 'secondary_user_email' => array(
819
+ 'title' => __('Secondary E-mail Address','ultimate-member'),
820
+ 'metakey' => 'secondary_user_email',
821
+ 'type' => 'text',
822
+ 'label' => __('Secondary E-mail Address','ultimate-member'),
823
+ 'required' => 0,
824
+ 'public' => 1,
825
+ 'editable' => 1,
826
+ 'validate' => 'unique_email',
827
+ 'autocomplete' => 'off'
828
+ ),
829
+
830
+ 'description' => array(
831
+ 'title' => __('Biography','ultimate-member'),
832
+ 'metakey' => 'description',
833
+ 'type' => 'textarea',
834
+ 'label' => __('Biography','ultimate-member'),
835
+ 'html' => 0,
836
+ 'required' => 0,
837
+ 'public' => 1,
838
+ 'editable' => 1,
839
+ 'max_words' => 40,
840
+ 'placeholder' => __('Enter a bit about yourself...','ultimate-member'),
841
+ ),
842
+
843
+ 'birth_date' => array(
844
+ 'title' => __('Birth Date','ultimate-member'),
845
+ 'metakey' => 'birth_date',
846
+ 'type' => 'date',
847
+ 'label' => __('Birth Date','ultimate-member'),
848
+ 'required' => 0,
849
+ 'public' => 1,
850
+ 'editable' => 1,
851
+ 'pretty_format' => 1,
852
+ 'years' => 115,
853
+ 'years_x' => 'past',
854
+ 'icon' => 'um-faicon-calendar'
855
+ ),
856
+
857
+ 'gender' => array(
858
+ 'title' => __('Gender','ultimate-member'),
859
+ 'metakey' => 'gender',
860
+ 'type' => 'radio',
861
+ 'label' => __('Gender','ultimate-member'),
862
+ 'required' => 0,
863
+ 'public' => 1,
864
+ 'editable' => 1,
865
+ 'options' => array( __('Male','ultimate-member'), __('Female','ultimate-member') )
866
+ ),
867
+
868
+ 'country' => array(
869
+ 'title' => __('Country','ultimate-member'),
870
+ 'metakey' => 'country',
871
+ 'type' => 'select',
872
+ 'label' => __('Country','ultimate-member'),
873
+ 'placeholder' => __('Choose a Country','ultimate-member'),
874
+ 'required' => 0,
875
+ 'public' => 1,
876
+ 'editable' => 1,
877
+ 'options' => $this->get('countries')
878
+ ),
879
+
880
+ 'facebook' => array(
881
+ 'title' => __('Facebook','ultimate-member'),
882
+ 'metakey' => 'facebook',
883
+ 'type' => 'url',
884
+ 'label' => __('Facebook','ultimate-member'),
885
+ 'required' => 0,
886
+ 'public' => 1,
887
+ 'editable' => 1,
888
+ 'url_target' => '_blank',
889
+ 'url_rel' => 'nofollow',
890
+ 'icon' => 'um-faicon-facebook',
891
+ 'validate' => 'facebook_url',
892
+ 'url_text' => 'Facebook',
893
+ 'advanced' => 'social',
894
+ 'color' => '#3B5999',
895
+ 'match' => 'https://facebook.com/',
896
+ ),
897
+
898
+ 'twitter' => array(
899
+ 'title' => __('Twitter','ultimate-member'),
900
+ 'metakey' => 'twitter',
901
+ 'type' => 'url',
902
+ 'label' => __('Twitter','ultimate-member'),
903
+ 'required' => 0,
904
+ 'public' => 1,
905
+ 'editable' => 1,
906
+ 'url_target' => '_blank',
907
+ 'url_rel' => 'nofollow',
908
+ 'icon' => 'um-faicon-twitter',
909
+ 'validate' => 'twitter_url',
910
+ 'url_text' => 'Twitter',
911
+ 'advanced' => 'social',
912
+ 'color' => '#4099FF',
913
+ 'match' => 'https://twitter.com/',
914
+ ),
915
+
916
+ 'linkedin' => array(
917
+ 'title' => __('LinkedIn','ultimate-member'),
918
+ 'metakey' => 'linkedin',
919
+ 'type' => 'url',
920
+ 'label' => __('LinkedIn','ultimate-member'),
921
+ 'required' => 0,
922
+ 'public' => 1,
923
+ 'editable' => 1,
924
+ 'url_target' => '_blank',
925
+ 'url_rel' => 'nofollow',
926
+ 'icon' => 'um-faicon-linkedin',
927
+ 'validate' => 'linkedin_url',
928
+ 'url_text' => 'LinkedIn',
929
+ 'advanced' => 'social',
930
+ 'color' => '#0976b4',
931
+ 'match' => 'https://linkedin.com/in/',
932
+ ),
933
+
934
+ 'googleplus' => array(
935
+ 'title' => __('Google+','ultimate-member'),
936
+ 'metakey' => 'googleplus',
937
+ 'type' => 'url',
938
+ 'label' => __('Google+','ultimate-member'),
939
+ 'required' => 0,
940
+ 'public' => 1,
941
+ 'editable' => 1,
942
+ 'url_target' => '_blank',
943
+ 'url_rel' => 'nofollow',
944
+ 'icon' => 'um-faicon-google-plus',
945
+ 'validate' => 'google_url',
946
+ 'url_text' => 'Google+',
947
+ 'advanced' => 'social',
948
+ 'color' => '#dd4b39',
949
+ 'match' => 'https://google.com/+',
950
+ ),
951
+
952
+ 'instagram' => array(
953
+ 'title' => __('Instagram','ultimate-member'),
954
+ 'metakey' => 'instagram',
955
+ 'type' => 'url',
956
+ 'label' => __('Instagram','ultimate-member'),
957
+ 'required' => 0,
958
+ 'public' => 1,
959
+ 'editable' => 1,
960
+ 'url_target' => '_blank',
961
+ 'url_rel' => 'nofollow',
962
+ 'icon' => 'um-faicon-instagram',
963
+ 'validate' => 'instagram_url',
964
+ 'url_text' => 'Instagram',
965
+ 'advanced' => 'social',
966
+ 'color' => 'radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%,#d6249f 60%,#285AEB 90%)',
967
+ 'match' => 'https://instagram.com/',
968
+ ),
969
+
970
+ 'skype' => array(
971
+ 'title' => __('Skype ID','ultimate-member'),
972
+ 'metakey' => 'skype',
973
+ 'type' => 'url',
974
+ 'label' => __('Skype ID','ultimate-member'),
975
+ 'required' => 0,
976
+ 'public' => 1,
977
+ 'editable' => 1,
978
+ 'url_target' => '_blank',
979
+ 'url_rel' => 'nofollow',
980
+ 'icon' => 'um-faicon-skype',
981
+ 'validate' => 'skype',
982
+ 'url_text' => 'Skype',
983
+ ),
984
+
985
+ 'youtube' => array(
986
+ 'title' => __('YouTube','ultimate-member'),
987
+ 'metakey' => 'youtube',
988
+ 'type' => 'url',
989
+ 'label' => __('YouTube','ultimate-member'),
990
+ 'required' => 0,
991
+ 'public' => 1,
992
+ 'editable' => 1,
993
+ 'url_target' => '_blank',
994
+ 'url_rel' => 'nofollow',
995
+ 'icon' => 'um-faicon-youtube',
996
+ 'validate' => 'youtube_url',
997
+ 'url_text' => 'YouTube',
998
+ 'advanced' => 'social',
999
+ 'color' => '#e52d27',
1000
+ 'match' => 'https://youtube.com/',
1001
+ ),
1002
+
1003
+ 'soundcloud' => array(
1004
+ 'title' => __('SoundCloud','ultimate-member'),
1005
+ 'metakey' => 'soundcloud',
1006
+ 'type' => 'url',
1007
+ 'label' => __('SoundCloud','ultimate-member'),
1008
+ 'required' => 0,
1009
+ 'public' => 1,
1010
+ 'editable' => 1,
1011
+ 'url_target' => '_blank',
1012
+ 'url_rel' => 'nofollow',
1013
+ 'icon' => 'um-faicon-soundcloud',
1014
+ 'validate' => 'soundcloud_url',
1015
+ 'url_text' => 'SoundCloud',
1016
+ 'advanced' => 'social',
1017
+ 'color' => '#f50',
1018
+ 'match' => 'https://soundcloud.com/',
1019
+ ),
1020
+
1021
+ 'vkontakte' => array(
1022
+ 'title' => __('VKontakte','ultimate-member'),
1023
+ 'metakey' => 'vkontakte',
1024
+ 'type' => 'url',
1025
+ 'label' => __('VKontakte','ultimate-member'),
1026
+ 'required' => 0,
1027
+ 'public' => 1,
1028
+ 'editable' => 1,
1029
+ 'url_target' => '_blank',
1030
+ 'url_rel' => 'nofollow',
1031
+ 'icon' => 'um-faicon-vk',
1032
+ 'validate' => 'vk_url',
1033
+ 'url_text' => 'VKontakte',
1034
+ 'advanced' => 'social',
1035
+ 'color' => '#2B587A',
1036
+ 'match' => 'https://vk.com/',
1037
+ ),
1038
+
1039
+ 'role_select' => array(
1040
+ 'title' => __('Roles (Dropdown)','ultimate-member'),
1041
+ 'metakey' => 'role_select',
1042
+ 'type' => 'select',
1043
+ 'label' => __('Account Type','ultimate-member'),
1044
+ 'placeholder' => 'Choose account type',
1045
+ 'required' => 0,
1046
+ 'public' => 1,
1047
+ 'editable' => 1,
1048
+ 'options' => $um_roles,
1049
+ ),
1050
+
1051
+ 'role_radio' => array(
1052
+ 'title' => __('Roles (Radio)','ultimate-member'),
1053
+ 'metakey' => 'role_radio',
1054
+ 'type' => 'radio',
1055
+ 'label' => __('Account Type','ultimate-member'),
1056
+ 'required' => 0,
1057
+ 'public' => 1,
1058
+ 'editable' => 1,
1059
+ 'options' => $um_roles,
1060
+ ),
1061
+
1062
+ 'languages' => array(
1063
+ 'title' => __('Languages','ultimate-member'),
1064
+ 'metakey' => 'languages',
1065
+ 'type' => 'multiselect',
1066
+ 'label' => __('Languages Spoken','ultimate-member'),
1067
+ 'placeholder' => __('Select languages','ultimate-member'),
1068
+ 'required' => 0,
1069
+ 'public' => 1,
1070
+ 'editable' => 1,
1071
+ 'options' => $this->get('languages'),
1072
+ ),
1073
+
1074
+ 'phone_number' => array(
1075
+ 'title' => __('Phone Number','ultimate-member'),
1076
+ 'metakey' => 'phone_number',
1077
+ 'type' => 'text',
1078
+ 'label' => __('Phone Number','ultimate-member'),
1079
+ 'required' => 0,
1080
+ 'public' => 1,
1081
+ 'editable' => 1,
1082
+ 'validate' => 'phone_number',
1083
+ 'icon' => 'um-faicon-phone',
1084
+ ),
1085
+
1086
+ 'mobile_number' => array(
1087
+ 'title' => __('Mobile Number','ultimate-member'),
1088
+ 'metakey' => 'mobile_number',
1089
+ 'type' => 'text',
1090
+ 'label' => __('Mobile Number','ultimate-member'),
1091
+ 'required' => 0,
1092
+ 'public' => 1,
1093
+ 'editable' => 1,
1094
+ 'validate' => 'phone_number',
1095
+ 'icon' => 'um-faicon-mobile',
1096
+ ),
1097
+
1098
+ // private use ( not public list )
1099
+
1100
+ 'profile_photo' => array(
1101
+ 'title' => __('Profile Photo','ultimate-member'),
1102
+ 'metakey' => 'profile_photo',
1103
+ 'type' => 'image',
1104
+ 'label' => __('Change your profile photo','ultimate-member'),
1105
+ 'upload_text' => __('Upload your photo here','ultimate-member'),
1106
+ 'icon' => 'um-faicon-camera',
1107
+ 'crop' => 1,
1108
+ 'max_size' => ( UM()->options()->get('profile_photo_max_size') ) ? UM()->options()->get('profile_photo_max_size') : 999999999,
1109
+ 'min_width' => str_replace('px','',UM()->options()->get('profile_photosize')),
1110
+ 'min_height' => str_replace('px','',UM()->options()->get('profile_photosize')),
1111
+ 'private_use' => true,
1112
+ ),
1113
+
1114
+ 'cover_photo' => array(
1115
+ 'title' => __('Cover Photo','ultimate-member'),
1116
+ 'metakey' => 'cover_photo',
1117
+ 'type' => 'image',
1118
+ 'label' => __('Change your cover photo','ultimate-member'),
1119
+ 'upload_text' => __('Upload profile cover here','ultimate-member'),
1120
+ 'icon' => 'um-faicon-picture-o',
1121
+ 'crop' => 2,
1122
+ 'max_size' => ( UM()->options()->get('cover_photo_max_size') ) ? UM()->options()->get('cover_photo_max_size') : 999999999,
1123
+ 'modal_size' => 'large',
1124
+ 'ratio' => str_replace(':1','',UM()->options()->get('profile_cover_ratio')),
1125
+ 'min_width' => UM()->options()->get('cover_min_width'),
1126
+ 'private_use' => true,
1127
+ ),
1128
+
1129
+ 'username_b' => array(
1130
+ 'title' => __('Username or E-mail','ultimate-member'),
1131
+ 'metakey' => 'username_b',
1132
+ 'type' => 'text',
1133
+ 'placeholder' => __('Enter your username or email','ultimate-member'),
1134
+ 'required' => 1,
1135
+ 'public' => 1,
1136
+ 'editable' => 0,
1137
+ 'private_use' => true,
1138
+ ),
1139
+
1140
+ // account page use ( not public )
1141
+
1142
+ 'profile_privacy' => array(
1143
+ 'title' => __( 'Profile Privacy', 'ultimate-member' ),
1144
+ 'metakey' => 'profile_privacy',
1145
+ 'type' => 'select',
1146
+ 'label' => __( 'Profile Privacy', 'ultimate-member' ),
1147
+ 'help' => __( 'Who can see your public profile?', 'ultimate-member' ),
1148
+ 'required' => 0,
1149
+ 'public' => 1,
1150
+ 'editable' => 1,
1151
+ 'default' => 'Everyone',
1152
+ 'options' => $profile_privacy,
1153
+ 'allowclear' => 0,
1154
+ 'account_only' => true,
1155
+ 'required_perm' => 'can_make_private_profile',
1156
+ ),
1157
+
1158
+ 'profile_noindex' => array(
1159
+ 'title' => __( 'Avoid indexing my profile by search engines', 'ultimate-member' ),
1160
+ 'metakey' => 'profile_noindex',
1161
+ 'type' => 'select',
1162
+ 'label' => __( 'Avoid indexing my profile by search engines', 'ultimate-member' ),
1163
+ 'help' => __( 'Hide my profile for robots?', 'ultimate-member' ),
1164
+ 'required' => 0,
1165
+ 'public' => 1,
1166
+ 'editable' => 1,
1167
+ 'default' => UM()->roles()->um_user_can( 'profile_noindex' ) ? '1' : '0',
1168
+ 'options' => array(
1169
+ '0' => __( 'No', 'ultimate-member' ),
1170
+ '1' => __( 'Yes', 'ultimate-member' ),
1171
+ ),
1172
+ 'allowclear' => 0,
1173
+ 'account_only' => true,
1174
+ 'required_perm' => 'can_make_private_profile',
1175
+ ),
1176
+
1177
+ 'hide_in_members' => array(
1178
+ 'title' => __( 'Hide my profile from directory', 'ultimate-member' ),
1179
+ 'metakey' => 'hide_in_members',
1180
+ 'type' => 'radio',
1181
+ 'label' => __( 'Hide my profile from directory', 'ultimate-member' ),
1182
+ 'help' => __( 'Here you can hide yourself from appearing in public directory', 'ultimate-member' ),
1183
+ 'required' => 0,
1184
+ 'public' => 1,
1185
+ 'editable' => 1,
1186
+ 'default' => UM()->member_directory()->get_hide_in_members_default() ? 'Yes' : 'No',
1187
+ 'options' => array(
1188
+ 'No' => __( 'No', 'ultimate-member' ),
1189
+ 'Yes' => __( 'Yes', 'ultimate-member' ),
1190
+ ),
1191
+ 'account_only' => true,
1192
+ 'required_opt' => array( 'members_page', 1 ),
1193
+ ),
1194
+
1195
+ 'delete_account' => array(
1196
+ 'title' => __( 'Delete Account', 'ultimate-member' ),
1197
+ 'metakey' => 'delete_account',
1198
+ 'type' => 'radio',
1199
+ 'label' => __( 'Delete Account', 'ultimate-member'),
1200
+ 'help' => __( 'If you confirm, everything related to your profile will be deleted permanently from the site', 'ultimate-member' ),
1201
+ 'required' => 0,
1202
+ 'public' => 1,
1203
+ 'editable' => 1,
1204
+ 'default' => __( 'No', 'ultimate-member' ),
1205
+ 'options' => array(
1206
+ __( 'Yes', 'ultimate-member' ),
1207
+ __( 'No', 'ultimate-member' )
1208
+ ),
1209
+ 'account_only' => true,
1210
+ ),
1211
+
1212
+ 'single_user_password' => array(
1213
+ 'title' => __( 'Password', 'ultimate-member' ),
1214
+ 'metakey' => 'single_user_password',
1215
+ 'type' => 'password',
1216
+ 'label' => __( 'Password', 'ultimate-member' ),
1217
+ 'required' => 1,
1218
+ 'public' => 1,
1219
+ 'editable' => 1,
1220
+ 'account_only' => true,
1221
+ ),
1222
+
1223
+ );
1224
+
1225
+ /**
1226
+ * UM hook
1227
+ *
1228
+ * @type filter
1229
+ * @title um_predefined_fields_hook
1230
+ * @description Extend Predefined Fields
1231
+ * @input_vars
1232
+ * [{"var":"$predefined_fields","type":"array","desc":"Predefined Fields"}]
1233
+ * @change_log
1234
+ * ["Since: 2.0"]
1235
+ * @usage add_filter( 'um_predefined_fields_hook', 'function_name', 10, 1 );
1236
+ * @example
1237
+ * <?php
1238
+ * add_filter( 'um_predefined_fields_hook', 'my_predefined_fields', 10, 1 );
1239
+ * function my_predefined_fields( $predefined_fields ) {
1240
+ * // your code here
1241
+ * return $predefined_fields;
1242
+ * }
1243
+ * ?>
1244
+ */
1245
+ $this->predefined_fields = apply_filters( 'um_predefined_fields_hook', $this->predefined_fields );
1246
+ }
1247
+
1248
+
1249
+ /**
1250
+ * Custom Fields
1251
+ */
1252
+ function set_custom_fields() {
1253
+
1254
+ if ( is_array( $this->saved_fields ) ) {
1255
+
1256
+ $this->custom_fields = $this->saved_fields;
1257
+
1258
+ } else {
1259
+
1260
+ $this->custom_fields = '';
1261
+
1262
+ }
1263
+
1264
+ $custom = $this->custom_fields;
1265
+ $predefined = $this->predefined_fields;
1266
+
1267
+ if ( is_array( $custom ) ){
1268
+ $this->all_user_fields = array_merge( $predefined, $custom );
1269
+ } else {
1270
+ $this->all_user_fields = $predefined;
1271
+ }
1272
+
1273
+ }
1274
+
1275
+
1276
+ /**
1277
+ * Get all fields without metakeys
1278
+ *
1279
+ * @since 2.0.56
1280
+ *
1281
+ * @return array
1282
+ */
1283
+ function get_fields_without_metakey() {
1284
+ $fields_without_metakey = array(
1285
+ 'block',
1286
+ 'shortcode',
1287
+ 'spacing',
1288
+ 'divider',
1289
+ 'group'
1290
+ );
1291
+
1292
+
1293
+ /**
1294
+ * UM hook
1295
+ *
1296
+ * @type filter
1297
+ * @title um_fields_without_metakey
1298
+ * @description Field Types without meta key
1299
+ * @input_vars
1300
+ * [{"var":"$types","type":"array","desc":"Field Types"}]
1301
+ * @change_log
1302
+ * ["Since: 2.0"]
1303
+ * @usage add_filter( 'um_fields_without_metakey', 'function_name', 10, 1 );
1304
+ * @example
1305
+ * <?php
1306
+ * add_filter( 'um_fields_without_metakey', 'my_fields_without_metakey', 10, 1 );
1307
+ * function my_fields_without_metakey( $types ) {
1308
+ * // your code here
1309
+ * return $types;
1310
+ * }
1311
+ * ?>
1312
+ */
1313
+ return apply_filters( 'um_fields_without_metakey', $fields_without_metakey );
1314
+ }
1315
+
1316
+
1317
+ /**
1318
+ * May be used to show a dropdown, or source for user meta
1319
+ *
1320
+ * @param null $exclude_types
1321
+ * @param bool $show_all
1322
+ *
1323
+ * @return array
1324
+ */
1325
+ function all_user_fields( $exclude_types = null, $show_all = false ) {
1326
+
1327
+ $fields_without_metakey = $this->get_fields_without_metakey();
1328
+ $fields_without_metakey = apply_filters( 'um_all_user_fields_without_metakey', $fields_without_metakey );
1329
+
1330
+ if ( ! $show_all ) {
1331
+ $this->fields_dropdown = array( 'image', 'file', 'password', 'rating' );
1332
+ $this->fields_dropdown = array_merge( $this->fields_dropdown, $fields_without_metakey );
1333
+ } else {
1334
+ $this->fields_dropdown = $fields_without_metakey;
1335
+ }
1336
+
1337
+ $custom = $this->custom_fields;
1338
+ $predefined = $this->predefined_fields;
1339
+
1340
+ if ( $exclude_types ) {
1341
+ $exclude_types = explode( ',', $exclude_types );
1342
+ }
1343
+
1344
+ $all = array( 0 => '' );
1345
+
1346
+ if ( is_array( $custom ) ) {
1347
+ $all = $all + array_merge( $predefined, $custom );
1348
+ } else {
1349
+ $all = $all + $predefined;
1350
+ }
1351
+
1352
+ foreach ( $all as $k => $arr ) {
1353
+
1354
+ if ( $k == 0 ) {
1355
+ unset( $all[ $k ] );
1356
+ }
1357
+
1358
+ if ( isset( $arr['title'] ) ) {
1359
+ $all[ $k ]['title'] = stripslashes( $arr['title'] );
1360
+ }
1361
+
1362
+ if ( $exclude_types && isset( $arr['type'] ) && in_array( $arr['type'], $exclude_types ) ) {
1363
+ unset( $all[ $k ] );
1364
+ }
1365
+ if ( isset( $arr['account_only'] ) || isset( $arr['private_use'] ) ) {
1366
+ if ( ! $show_all ) {
1367
+ unset( $all[ $k ] );
1368
+ }
1369
+ }
1370
+ if ( isset( $arr['type'] ) && in_array( $arr['type'], $this->fields_dropdown ) ) {
1371
+ unset( $all[ $k ] );
1372
+ }
1373
+ }
1374
+
1375
+ $all = UM()->fields()->array_sort_by_column( $all, 'title' );
1376
+
1377
+ return $all;
1378
+ }
1379
+
1380
+
1381
+ /**
1382
+ * Possible validation types for fields
1383
+ *
1384
+ * @return mixed
1385
+ */
1386
+ function validation_types() {
1387
+
1388
+ $array[0] = __('None','ultimate-member');
1389
+ $array['alphabetic'] = __('Alphabetic value only','ultimate-member');
1390
+ $array['alpha_numeric'] = __('Alpha-numeric value','ultimate-member');
1391
+ $array['english'] = __('English letters only','ultimate-member');
1392
+ $array['facebook_url'] = __('Facebook URL','ultimate-member');
1393
+ $array['google_url'] = __('Google+ URL','ultimate-member');
1394
+ $array['instagram_url'] = __('Instagram URL','ultimate-member');
1395
+ $array['linkedin_url'] = __('LinkedIn URL','ultimate-member');
1396
+ $array['vk_url'] = __('VKontakte URL','ultimate-member');
1397
+ $array['lowercase'] = __('Lowercase only','ultimate-member');
1398
+ $array['numeric'] = __('Numeric value only','ultimate-member');
1399
+ $array['phone_number'] = __('Phone Number','ultimate-member');
1400
+ $array['skype'] = __('Skype ID','ultimate-member');
1401
+ $array['soundcloud'] = __('SoundCloud Profile','ultimate-member');
1402
+ $array['twitter_url'] = __('Twitter URL','ultimate-member');
1403
+ $array['is_email'] = __('E-mail( Not Unique )','ultimate-member');
1404
+ $array['unique_email'] = __('Unique E-mail','ultimate-member');
1405
+ $array['unique_value'] = __('Unique Metakey value','ultimate-member');
1406
+ $array['unique_username'] = __('Unique Username','ultimate-member');
1407
+ $array['unique_username_or_email'] = __('Unique Username/E-mail','ultimate-member');
1408
+ $array['url'] = __('Website URL','ultimate-member');
1409
+ $array['youtube_url'] = __('YouTube Profile','ultimate-member');
1410
+ $array['custom'] = __('Custom Validation','ultimate-member');
1411
+
1412
+ /**
1413
+ * UM hook
1414
+ *
1415
+ * @type filter
1416
+ * @title um_admin_field_validation_hook
1417
+ * @description Extend validation types
1418
+ * @input_vars
1419
+ * [{"var":"$types","type":"array","desc":"Validation Types"}]
1420
+ * @change_log
1421
+ * ["Since: 2.0"]
1422
+ * @usage add_filter( 'um_admin_field_validation_hook', 'function_name', 10, 1 );
1423
+ * @example
1424
+ * <?php
1425
+ * add_filter( 'um_admin_field_validation_hook', 'my_admin_field_validation', 10, 1 );
1426
+ * function my_admin_field_validation( $types ) {
1427
+ * // your code here
1428
+ * return $types;
1429
+ * }
1430
+ * ?>
1431
+ */
1432
+ $array = apply_filters( 'um_admin_field_validation_hook', $array );
1433
+ return $array;
1434
+ }
1435
+
1436
+
1437
+ /**
1438
+ * Get predefined options
1439
+ *
1440
+ * @param $data
1441
+ *
1442
+ * @return array|mixed|void
1443
+ */
1444
+ function get( $data ) {
1445
+ switch ( $data ) {
1446
+
1447
+ case 'languages':
1448
+ $array = array(
1449
+ "aa" => __("Afar",'ultimate-member'),
1450
+ "ab" => __("Abkhazian",'ultimate-member'),
1451
+ "ae" => __("Avestan",'ultimate-member'),
1452
+ "af" => __("Afrikaans",'ultimate-member'),
1453
+ "ak" => __("Akan",'ultimate-member'),
1454
+ "am" => __("Amharic",'ultimate-member'),
1455
+ "an" => __("Aragonese",'ultimate-member'),
1456
+ "ar" => __("Arabic",'ultimate-member'),
1457
+ "as" => __("Assamese",'ultimate-member'),
1458
+ "av" => __("Avaric",'ultimate-member'),
1459
+ "ay" => __("Aymara",'ultimate-member'),
1460
+ "az" => __("Azerbaijani",'ultimate-member'),
1461
+ "ba" => __("Bashkir",'ultimate-member'),
1462
+ "be" => __("Belarusian",'ultimate-member'),
1463
+ "bg" => __("Bulgarian",'ultimate-member'),
1464
+ "bh" => __("Bihari",'ultimate-member'),
1465
+ "bi" => __("Bislama",'ultimate-member'),
1466
+ "bm" => __("Bambara",'ultimate-member'),
1467
+ "bn" => __("Bengali",'ultimate-member'),
1468
+ "bo" => __("Tibetan",'ultimate-member'),
1469
+ "br" => __("Breton",'ultimate-member'),
1470
+ "bs" => __("Bosnian",'ultimate-member'),
1471
+ "ca" => __("Catalan",'ultimate-member'),
1472
+ "ce" => __("Chechen",'ultimate-member'),
1473
+ "ch" => __("Chamorro",'ultimate-member'),
1474
+ "co" => __("Corsican",'ultimate-member'),
1475
+ "cr" => __("Cree",'ultimate-member'),
1476
+ "cs" => __("Czech",'ultimate-member'),
1477
+ "cu" => __("Church Slavic",'ultimate-member'),
1478
+ "cv" => __("Chuvash",'ultimate-member'),
1479
+ "cy" => __("Welsh",'ultimate-member'),
1480
+ "da" => __("Danish",'ultimate-member'),
1481
+ "de" => __("German",'ultimate-member'),
1482
+ "dv" => __("Divehi",'ultimate-member'),
1483
+ "dz" => __("Dzongkha",'ultimate-member'),
1484
+ "ee" => __("Ewe",'ultimate-member'),
1485
+ "el" => __("Greek",'ultimate-member'),
1486
+ "en" => __("English",'ultimate-member'),
1487
+ "eo" => __("Esperanto",'ultimate-member'),
1488
+ "es" => __("Spanish",'ultimate-member'),
1489
+ "et" => __("Estonian",'ultimate-member'),
1490
+ "eu" => __("Basque",'ultimate-member'),
1491
+ "fa" => __("Persian",'ultimate-member'),
1492
+ "ff" => __("Fulah",'ultimate-member'),
1493
+ "fi" => __("Finnish",'ultimate-member'),
1494
+ "fj" => __("Fijian",'ultimate-member'),
1495
+ "fo" => __("Faroese",'ultimate-member'),
1496
+ "fr" => __("French",'ultimate-member'),
1497
+ "fy" => __("Western Frisian",'ultimate-member'),
1498
+ "ga" => __("Irish",'ultimate-member'),
1499
+ "gd" => __("Scottish Gaelic",'ultimate-member'),
1500
+ "gl" => __("Galician",'ultimate-member'),
1501
+ "gn" => __("Guarani",'ultimate-member'),
1502
+ "gu" => __("Gujarati",'ultimate-member'),
1503
+ "gv" => __("Manx",'ultimate-member'),
1504
+ "ha" => __("Hausa",'ultimate-member'),
1505
+ "he" => __("Hebrew",'ultimate-member'),
1506
+ "hi" => __("Hindi",'ultimate-member'),
1507
+ "ho" => __("Hiri Motu",'ultimate-member'),
1508
+ "hr" => __("Croatian",'ultimate-member'),
1509
+ "ht" => __("Haitian",'ultimate-member'),
1510
+ "hu" => __("Hungarian",'ultimate-member'),
1511
+ "hy" => __("Armenian",'ultimate-member'),
1512
+ "hz" => __("Herero",'ultimate-member'),
1513
+ "ia" => __("Interlingua (International Auxiliary Language Association)",'ultimate-member'),
1514
+ "id" => __("Indonesian",'ultimate-member'),
1515
+ "ie" => __("Interlingue",'ultimate-member'),
1516
+ "ig" => __("Igbo",'ultimate-member'),
1517
+ "ii" => __("Sichuan Yi",'ultimate-member'),
1518
+ "ik" => __("Inupiaq",'ultimate-member'),
1519
+ "io" => __("Ido",'ultimate-member'),
1520
+ "is" => __("Icelandic",'ultimate-member'),
1521
+ "it" => __("Italian",'ultimate-member'),
1522
+ "iu" => __("Inuktitut",'ultimate-member'),
1523
+ "ja" => __("Japanese",'ultimate-member'),
1524
+ "jv" => __("Javanese",'ultimate-member'),
1525
+ "ka" => __("Georgian",'ultimate-member'),
1526
+ "kg" => __("Kongo",'ultimate-member'),
1527
+ "ki" => __("Kikuyu",'ultimate-member'),
1528
+ "kj" => __("Kwanyama",'ultimate-member'),
1529
+ "kk" => __("Kazakh",'ultimate-member'),
1530
+ "kl" => __("Kalaallisut",'ultimate-member'),
1531
+ "km" => __("Khmer",'ultimate-member'),
1532
+ "kn" => __("Kannada",'ultimate-member'),
1533
+ "ko" => __("Korean",'ultimate-member'),
1534
+ "kr" => __("Kanuri",'ultimate-member'),
1535
+ "ks" => __("Kashmiri",'ultimate-member'),
1536
+ "ku" => __("Kurdish",'ultimate-member'),
1537
+ "kv" => __("Komi",'ultimate-member'),
1538
+ "kw" => __("Cornish",'ultimate-member'),
1539
+ "ky" => __("Kirghiz",'ultimate-member'),
1540
+ "la" => __("Latin",'ultimate-member'),
1541
+ "lb" => __("Luxembourgish",'ultimate-member'),
1542
+ "lg" => __("Ganda",'ultimate-member'),
1543
+ "li" => __("Limburgish",'ultimate-member'),
1544
+ "ln" => __("Lingala",'ultimate-member'),
1545
+ "lo" => __("Lao",'ultimate-member'),
1546
+ "lt" => __("Lithuanian",'ultimate-member'),
1547
+ "lu" => __("Luba-Katanga",'ultimate-member'),
1548
+ "lv" => __("Latvian",'ultimate-member'),
1549
+ "mg" => __("Malagasy",'ultimate-member'),
1550
+ "mh" => __("Marshallese",'ultimate-member'),
1551
+ "mi" => __("Maori",'ultimate-member'),
1552
+ "mk" => __("Macedonian",'ultimate-member'),
1553
+ "ml" => __("Malayalam",'ultimate-member'),
1554
+ "mn" => __("Mongolian",'ultimate-member'),
1555
+ "mr" => __("Marathi",'ultimate-member'),
1556
+ "ms" => __("Malay",'ultimate-member'),
1557
+ "mt" => __("Maltese",'ultimate-member'),
1558
+ "my" => __("Burmese",'ultimate-member'),
1559
+ "na" => __("Nauru",'ultimate-member'),
1560
+ "nb" => __("Norwegian Bokmal",'ultimate-member'),
1561
+ "nd" => __("North Ndebele",'ultimate-member'),
1562
+ "ne" => __("Nepali",'ultimate-member'),
1563
+ "ng" => __("Ndonga",'ultimate-member'),
1564
+ "nl" => __("Dutch",'ultimate-member'),
1565
+ "nn" => __("Norwegian Nynorsk",'ultimate-member'),
1566
+ "no" => __("Norwegian",'ultimate-member'),
1567
+ "nr" => __("South Ndebele",'ultimate-member'),
1568
+ "nv" => __("Navajo",'ultimate-member'),
1569
+ "ny" => __("Chichewa",'ultimate-member'),
1570
+ "oc" => __("Occitan",'ultimate-member'),
1571
+ "oj" => __("Ojibwa",'ultimate-member'),
1572
+ "om" => __("Oromo",'ultimate-member'),
1573
+ "or" => __("Oriya",'ultimate-member'),
1574
+ "os" => __("Ossetian",'ultimate-member'),
1575
+ "pa" => __("Panjabi",'ultimate-member'),
1576
+ "pi" => __("Pali",'ultimate-member'),
1577
+ "pl" => __("Polish",'ultimate-member'),
1578
+ "ps" => __("Pashto",'ultimate-member'),
1579
+ "pt" => __("Portuguese",'ultimate-member'),
1580
+ "qu" => __("Quechua",'ultimate-member'),
1581
+ "rm" => __("Raeto-Romance",'ultimate-member'),
1582
+ "rn" => __("Kirundi",'ultimate-member'),
1583
+ "ro" => __("Romanian",'ultimate-member'),
1584
+ "ru" => __("Russian",'ultimate-member'),
1585
+ "rw" => __("Kinyarwanda",'ultimate-member'),
1586
+ "sa" => __("Sanskrit",'ultimate-member'),
1587
+ "sc" => __("Sardinian",'ultimate-member'),
1588
+ "sd" => __("Sindhi",'ultimate-member'),
1589
+ "se" => __("Northern Sami",'ultimate-member'),
1590
+ "sg" => __("Sango",'ultimate-member'),
1591
+ "si" => __("Sinhala",'ultimate-member'),
1592
+ "sk" => __("Slovak",'ultimate-member'),
1593
+ "sl" => __("Slovenian",'ultimate-member'),
1594
+ "sm" => __("Samoan",'ultimate-member'),
1595
+ "sn" => __("Shona",'ultimate-member'),
1596
+ "so" => __("Somali",'ultimate-member'),
1597
+ "sq" => __("Albanian",'ultimate-member'),
1598
+ "sr" => __("Serbian",'ultimate-member'),
1599
+ "ss" => __("Swati",'ultimate-member'),
1600
+ "st" => __("Southern Sotho",'ultimate-member'),
1601
+ "su" => __("Sundanese",'ultimate-member'),
1602
+ "sv" => __("Swedish",'ultimate-member'),
1603
+ "sw" => __("Swahili",'ultimate-member'),
1604
+ "ta" => __("Tamil",'ultimate-member'),
1605
+ "te" => __("Telugu",'ultimate-member'),
1606
+ "tg" => __("Tajik",'ultimate-member'),
1607
+ "th" => __("Thai",'ultimate-member'),
1608
+ "ti" => __("Tigrinya",'ultimate-member'),
1609
+ "tk" => __("Turkmen",'ultimate-member'),
1610
+ "tl" => __("Tagalog",'ultimate-member'),
1611
+ "tn" => __("Tswana",'ultimate-member'),
1612
+ "to" => __("Tonga",'ultimate-member'),
1613
+ "tr" => __("Turkish",'ultimate-member'),
1614
+ "ts" => __("Tsonga",'ultimate-member'),
1615
+ "tt" => __("Tatar",'ultimate-member'),
1616
+ "tw" => __("Twi",'ultimate-member'),
1617
+ "ty" => __("Tahitian",'ultimate-member'),
1618
+ "ug" => __("Uighur",'ultimate-member'),
1619
+ "uk" => __("Ukrainian",'ultimate-member'),
1620
+ "ur" => __("Urdu",'ultimate-member'),
1621
+ "uz" => __("Uzbek",'ultimate-member'),
1622
+ "ve" => __("Venda",'ultimate-member'),
1623
+ "vi" => __("Vietnamese",'ultimate-member'),
1624
+ "vo" => __("Volapuk",'ultimate-member'),
1625
+ "wa" => __("Walloon",'ultimate-member'),
1626
+ "wo" => __("Wolof",'ultimate-member'),
1627
+ "xh" => __("Xhosa",'ultimate-member'),
1628
+ "yi" => __("Yiddish",'ultimate-member'),
1629
+ "yo" => __("Yoruba",'ultimate-member'),
1630
+ "za" => __("Zhuang",'ultimate-member'),
1631
+ "zh" => __("Chinese",'ultimate-member'),
1632
+ "zu" => __("Zulu",'ultimate-member')
1633
+ );
1634
+ break;
1635
+
1636
+ case 'countries':
1637
+ $array = array (
1638
+ 'AF' => __('Afghanistan','ultimate-member'),
1639
+ 'AX' => __('Åland Islands','ultimate-member'),
1640
+ 'AL' => __('Albania','ultimate-member'),
1641
+ 'DZ' => __('Algeria','ultimate-member'),
1642
+ 'AS' => __('American Samoa','ultimate-member'),
1643
+ 'AD' => __('Andorra','ultimate-member'),
1644
+ 'AO' => __('Angola','ultimate-member'),
1645
+ 'AI' => __('Anguilla','ultimate-member'),
1646
+ 'AQ' => __('Antarctica','ultimate-member'),
1647
+ 'AG' => __('Antigua and Barbuda','ultimate-member'),
1648
+ 'AR' => __('Argentina','ultimate-member'),
1649
+ 'AM' => __('Armenia','ultimate-member'),
1650
+ 'AW' => __('Aruba','ultimate-member'),
1651
+ 'AU' => __('Australia','ultimate-member'),
1652
+ 'AT' => __('Austria','ultimate-member'),
1653
+ 'AZ' => __('Azerbaijan','ultimate-member'),
1654
+ 'BS' => __('Bahamas','ultimate-member'),
1655
+ 'BH' => __('Bahrain','ultimate-member'),
1656
+ 'BD' => __('Bangladesh','ultimate-member'),
1657
+ 'BB' => __('Barbados','ultimate-member'),
1658
+ 'BY' => __('Belarus','ultimate-member'),
1659
+ 'BE' => __('Belgium','ultimate-member'),
1660
+ 'BZ' => __('Belize','ultimate-member'),
1661
+ 'BJ' => __('Benin','ultimate-member'),
1662
+ 'BM' => __('Bermuda','ultimate-member'),
1663
+ 'BT' => __('Bhutan','ultimate-member'),
1664
+ 'BO' => __('Bolivia, Plurinational State of','ultimate-member'),
1665
+ 'BA' => __('Bosnia and Herzegovina','ultimate-member'),
1666
+ 'BW' => __('Botswana','ultimate-member'),
1667
+ 'BV' => __('Bouvet Island','ultimate-member'),
1668
+ 'BR' => __('Brazil','ultimate-member'),
1669
+ 'IO' => __('British Indian Ocean Territory','ultimate-member'),
1670
+ 'BN' => __('Brunei Darussalam','ultimate-member'),
1671
+ 'BG' => __('Bulgaria','ultimate-member'),
1672
+ 'BF' => __('Burkina Faso','ultimate-member'),
1673
+ 'BI' => __('Burundi','ultimate-member'),
1674
+ 'KH' => __('Cambodia','ultimate-member'),
1675
+ 'CM' => __('Cameroon','ultimate-member'),
1676
+ 'CA' => __('Canada','ultimate-member'),
1677
+ 'CV' => __('Cape Verde','ultimate-member'),
1678
+ 'KY' => __('Cayman Islands','ultimate-member'),
1679
+ 'CF' => __('Central African Republic','ultimate-member'),
1680
+ 'TD' => __('Chad','ultimate-member'),
1681
+ 'CL' => __('Chile','ultimate-member'),
1682
+ 'CN' => __('China','ultimate-member'),
1683
+ 'CX' => __('Christmas Island','ultimate-member'),
1684
+ 'CC' => __('Cocos (Keeling) Islands','ultimate-member'),
1685
+ 'CO' => __('Colombia','ultimate-member'),
1686
+ 'KM' => __('Comoros','ultimate-member'),
1687
+ 'CG' => __('Congo','ultimate-member'),
1688
+ 'CD' => __('Congo, the Democratic Republic of the','ultimate-member'),
1689
+ 'CK' => __('Cook Islands','ultimate-member'),
1690
+ 'CR' => __('Costa Rica','ultimate-member'),
1691
+ 'CI' => __("Côte d'Ivoire",'ultimate-member'),
1692
+ 'HR' => __('Croatia','ultimate-member'),
1693
+ 'CU' => __('Cuba','ultimate-member'),
1694
+ 'CY' => __('Cyprus','ultimate-member'),
1695
+ 'CZ' => __('Czech Republic','ultimate-member'),
1696
+ 'DK' => __('Denmark','ultimate-member'),
1697
+ 'DJ' => __('Djibouti','ultimate-member'),
1698
+ 'DM' => __('Dominica','ultimate-member'),
1699
+ 'DO' => __('Dominican Republic','ultimate-member'),
1700
+ 'EC' => __('Ecuador','ultimate-member'),
1701
+ 'EG' => __('Egypt','ultimate-member'),
1702
+ 'SV' => __('El Salvador','ultimate-member'),
1703
+ 'GQ' => __('Equatorial Guinea','ultimate-member'),
1704
+ 'ER' => __('Eritrea','ultimate-member'),
1705
+ 'EE' => __('Estonia','ultimate-member'),
1706
+ 'ET' => __('Ethiopia','ultimate-member'),
1707
+ 'FK' => __('Falkland Islands (Malvinas)','ultimate-member'),
1708
+ 'FO' => __('Faroe Islands','ultimate-member'),
1709
+ 'FJ' => __('Fiji','ultimate-member'),
1710
+ 'FI' => __('Finland','ultimate-member'),
1711
+ 'FR' => __('France','ultimate-member'),
1712
+ 'GF' => __('French Guiana','ultimate-member'),
1713
+ 'PF' => __('French Polynesia','ultimate-member'),
1714
+ 'TF' => __('French Southern Territories','ultimate-member'),
1715
+ 'GA' => __('Gabon','ultimate-member'),
1716
+ 'GM' => __('Gambia','ultimate-member'),
1717
+ 'GE' => __('Georgia','ultimate-member'),
1718
+ 'DE' => __('Germany','ultimate-member'),
1719
+ 'GH' => __('Ghana','ultimate-member'),
1720
+ 'GI' => __('Gibraltar','ultimate-member'),
1721
+ 'GR' => __('Greece','ultimate-member'),
1722
+ 'GL' => __('Greenland','ultimate-member'),
1723
+ 'GD' => __('Grenada','ultimate-member'),
1724
+ 'GP' => __('Guadeloupe','ultimate-member'),
1725
+ 'GU' => __('Guam','ultimate-member'),
1726
+ 'GT' => __('Guatemala','ultimate-member'),
1727
+ 'GG' => __('Guernsey','ultimate-member'),
1728
+ 'GN' => __('Guinea','ultimate-member'),
1729
+ 'GW' => __('Guinea-Bissau','ultimate-member'),
1730
+ 'GY' => __('Guyana','ultimate-member'),
1731
+ 'HT' => __('Haiti','ultimate-member'),
1732
+ 'HM' => __('Heard Island and McDonald Islands','ultimate-member'),
1733
+ 'VA' => __('Holy See (Vatican City State)','ultimate-member'),
1734
+ 'HN' => __('Honduras','ultimate-member'),
1735
+ 'HK' => __('Hong Kong','ultimate-member'),
1736
+ 'HU' => __('Hungary','ultimate-member'),
1737
+ 'IS' => __('Iceland','ultimate-member'),
1738
+ 'IN' => __('India','ultimate-member'),
1739
+ 'ID' => __('Indonesia','ultimate-member'),
1740
+ 'IR' => __('Iran, Islamic Republic of','ultimate-member'),
1741
+ 'IQ' => __('Iraq','ultimate-member'),
1742
+ 'IE' => __('Ireland','ultimate-member'),
1743
+ 'IM' => __('Isle of Man','ultimate-member'),
1744
+ 'IL' => __('Israel','ultimate-member'),
1745
+ 'IT' => __('Italy','ultimate-member'),
1746
+ 'JM' => __('Jamaica','ultimate-member'),
1747
+ 'JP' => __('Japan','ultimate-member'),
1748
+ 'JE' => __('Jersey','ultimate-member'),
1749
+ 'JO' => __('Jordan','ultimate-member'),
1750
+ 'KZ' => __('Kazakhstan','ultimate-member'),
1751
+ 'KE' => __('Kenya','ultimate-member'),
1752
+ 'KI' => __('Kiribati','ultimate-member'),
1753
+ 'KP' => __("Korea, Democratic People's Republic of",'ultimate-member'),
1754
+ 'KR' => __('Korea, Republic of','ultimate-member'),
1755
+ 'KW' => __('Kuwait','ultimate-member'),
1756
+ 'KG' => __('Kyrgyzstan','ultimate-member'),
1757
+ 'LA' => __("Lao People's Democratic Republic",'ultimate-member'),
1758
+ 'LV' => __('Latvia','ultimate-member'),
1759
+ 'LB' => __('Lebanon','ultimate-member'),
1760
+ 'LS' => __('Lesotho','ultimate-member'),
1761
+ 'LR' => __('Liberia','ultimate-member'),
1762
+ 'LY' => __('Libyan Arab Jamahiriya','ultimate-member'),
1763
+ 'LI' => __('Liechtenstein','ultimate-member'),
1764
+ 'LT' => __('Lithuania','ultimate-member'),
1765
+ 'LU' => __('Luxembourg','ultimate-member'),
1766
+ 'MO' => __('Macao','ultimate-member'),
1767
+ 'MK' => __('Macedonia, the former Yugoslav Republic of','ultimate-member'),
1768
+ 'MG' => __('Madagascar','ultimate-member'),
1769
+ 'MW' => __('Malawi','ultimate-member'),
1770
+ 'MY' => __('Malaysia','ultimate-member'),
1771
+ 'MV' => __('Maldives','ultimate-member'),
1772
+ 'ML' => __('Mali','ultimate-member'),
1773
+ 'MT' => __('Malta','ultimate-member'),
1774
+ 'MH' => __('Marshall Islands','ultimate-member'),
1775
+ 'MQ' => __('Martinique','ultimate-member'),
1776
+ 'MR' => __('Mauritania','ultimate-member'),
1777
+ 'MU' => __('Mauritius','ultimate-member'),
1778
+ 'YT' => __('Mayotte','ultimate-member'),
1779
+ 'MX' => __('Mexico','ultimate-member'),
1780
+ 'FM' => __('Micronesia, Federated States of','ultimate-member'),
1781
+ 'MD' => __('Moldova, Republic of','ultimate-member'),
1782
+ 'MC' => __('Monaco','ultimate-member'),
1783
+ 'MN' => __('Mongolia','ultimate-member'),
1784
+ 'ME' => __('Montenegro','ultimate-member'),
1785
+ 'MS' => __('Montserrat','ultimate-member'),
1786
+ 'MA' => __('Morocco','ultimate-member'),
1787
+ 'MZ' => __('Mozambique','ultimate-member'),
1788
+ 'MM' => __('Myanmar','ultimate-member'),
1789
+ 'NA' => __('Namibia','ultimate-member'),
1790
+ 'NR' => __('Nauru','ultimate-member'),
1791
+ 'NP' => __('Nepal','ultimate-member'),
1792
+ 'NL' => __('Netherlands','ultimate-member'),
1793
+ 'AN' => __('Netherlands Antilles','ultimate-member'),
1794
+ 'NC' => __('New Caledonia','ultimate-member'),
1795
+ 'NZ' => __('New Zealand','ultimate-member'),
1796
+ 'NI' => __('Nicaragua','ultimate-member'),
1797
+ 'NE' => __('Niger','ultimate-member'),
1798
+ 'NG' => __('Nigeria','ultimate-member'),
1799
+ 'NU' => __('Niue','ultimate-member'),
1800
+ 'NF' => __('Norfolk Island','ultimate-member'),
1801
+ 'MP' => __('Northern Mariana Islands','ultimate-member'),
1802
+ 'NO' => __('Norway','ultimate-member'),
1803
+ 'OM' => __('Oman','ultimate-member'),
1804
+ 'PK' => __('Pakistan','ultimate-member'),
1805
+ 'PW' => __('Palau','ultimate-member'),
1806
+ 'PS' => __('Palestine','ultimate-member'),
1807
+ 'PA' => __('Panama','ultimate-member'),
1808
+ 'PG' => __('Papua New Guinea','ultimate-member'),
1809
+ 'PY' => __('Paraguay','ultimate-member'),
1810
+ 'PE' => __('Peru','ultimate-member'),
1811
+ 'PH' => __('Philippines','ultimate-member'),
1812
+ 'PN' => __('Pitcairn','ultimate-member'),
1813
+ 'PL' => __('Poland','ultimate-member'),
1814
+ 'PT' => __('Portugal','ultimate-member'),
1815
+ 'PR' => __('Puerto Rico','ultimate-member'),
1816
+ 'QA' => __('Qatar','ultimate-member'),
1817
+ 'RE' => __('Réunion','ultimate-member'),
1818
+ 'RO' => __('Romania','ultimate-member'),
1819
+ 'RU' => __('Russian Federation','ultimate-member'),
1820
+ 'RW' => __('Rwanda','ultimate-member'),
1821
+ 'BL' => __('Saint Barthélemy','ultimate-member'),
1822
+ 'SH' => __('Saint Helena','ultimate-member'),
1823
+ 'KN' => __('Saint Kitts and Nevis','ultimate-member'),
1824
+ 'LC' => __('Saint Lucia','ultimate-member'),
1825
+ 'MF' => __('Saint Martin (French part)','ultimate-member'),
1826
+ 'PM' => __('Saint Pierre and Miquelon','ultimate-member'),
1827
+ 'VC' => __('Saint Vincent and the Grenadines','ultimate-member'),
1828
+ 'WS' => __('Samoa','ultimate-member'),
1829
+ 'SM' => __('San Marino','ultimate-member'),
1830
+ 'ST' => __('Sao Tome and Principe','ultimate-member'),
1831
+ 'SA' => __('Saudi Arabia','ultimate-member'),
1832
+ 'SN' => __('Senegal','ultimate-member'),
1833
+ 'RS' => __('Serbia','ultimate-member'),
1834
+ 'SC' => __('Seychelles','ultimate-member'),
1835
+ 'SL' => __('Sierra Leone','ultimate-member'),
1836
+ 'SG' => __('Singapore','ultimate-member'),
1837
+ 'SK' => __('Slovakia','ultimate-member'),
1838
+ 'SI' => __('Slovenia','ultimate-member'),
1839
+ 'SB' => __('Solomon Islands','ultimate-member'),
1840
+ 'SO' => __('Somalia','ultimate-member'),
1841
+ 'ZA' => __('South Africa','ultimate-member'),
1842
+ 'GS' => __('South Georgia and the South Sandwich Islands','ultimate-member'),
1843
+ 'SS' => __('South Sudan','ultimate-member'),
1844
+ 'ES' => __('Spain','ultimate-member'),
1845
+ 'LK' => __('Sri Lanka','ultimate-member'),
1846
+ 'SD' => __('Sudan','ultimate-member'),
1847
+ 'SR' => __('Suriname','ultimate-member'),
1848
+ 'SJ' => __('Svalbard and Jan Mayen','ultimate-member'),
1849
+ 'SZ' => __('Swaziland','ultimate-member'),
1850
+ 'SE' => __('Sweden','ultimate-member'),
1851
+ 'CH' => __('Switzerland','ultimate-member'),
1852
+ 'SY' => __('Syrian Arab Republic','ultimate-member'),
1853
+ 'TW' => __('Taiwan, Province of China','ultimate-member'),
1854
+ 'TJ' => __('Tajikistan','ultimate-member'),
1855
+ 'TZ' => __('Tanzania, United Republic of','ultimate-member'),
1856
+ 'TH' => __('Thailand','ultimate-member'),
1857
+ 'TL' => __('Timor-Leste','ultimate-member'),
1858
+ 'TG' => __('Togo','ultimate-member'),
1859
+ 'TK' => __('Tokelau','ultimate-member'),
1860
+ 'TO' => __('Tonga','ultimate-member'),
1861
+ 'TT' => __('Trinidad and Tobago','ultimate-member'),
1862
+ 'TN' => __('Tunisia','ultimate-member'),
1863
+ 'TR' => __('Turkey','ultimate-member'),
1864
+ 'TM' => __('Turkmenistan','ultimate-member'),
1865
+ 'TC' => __('Turks and Caicos Islands','ultimate-member'),
1866
+ 'TV' => __('Tuvalu','ultimate-member'),
1867
+ 'UG' => __('Uganda','ultimate-member'),
1868
+ 'UA' => __('Ukraine','ultimate-member'),
1869
+ 'AE' => __('United Arab Emirates','ultimate-member'),
1870
+ 'GB' => __('United Kingdom','ultimate-member'),
1871
+ 'US' => __('United States','ultimate-member'),
1872
+ 'UM' => __('United States Minor Outlying Islands','ultimate-member'),
1873
+ 'UY' => __('Uruguay','ultimate-member'),
1874
+ 'UZ' => __('Uzbekistan','ultimate-member'),
1875
+ 'VU' => __('Vanuatu','ultimate-member'),
1876
+ 'VE' => __('Venezuela, Bolivarian Republic of','ultimate-member'),
1877
+ 'VN' => __('Viet Nam','ultimate-member'),
1878
+ 'VG' => __('Virgin Islands, British','ultimate-member'),
1879
+ 'VI' => __('Virgin Islands, U.S.','ultimate-member'),
1880
+ 'WF' => __('Wallis and Futuna','ultimate-member'),
1881
+ 'EH' => __('Western Sahara','ultimate-member'),
1882
+ 'YE' => __('Yemen','ultimate-member'),
1883
+ 'ZM' => __('Zambia','ultimate-member'),
1884
+ 'ZW' => __('Zimbabwe','ultimate-member'),
1885
+ );
1886
+ break;
1887
+
1888
+ }
1889
+
1890
+ /**
1891
+ * UM hook
1892
+ *
1893
+ * @type filter
1894
+ * @title um_{$data}_predefined_field_options
1895
+ * @description Extend Predefined Fields options. Where $data - field key.
1896
+ * @input_vars
1897
+ * [{"var":"$options","type":"array","desc":"Field's Options"}]
1898
+ * @change_log
1899
+ * ["Since: 2.0"]
1900
+ * @usage add_filter( 'um_{$data}_predefined_field_options', 'function_name', 10, 1 );
1901
+ * @example
1902
+ * <?php
1903
+ * add_filter( 'um_{$data}_predefined_field_options', 'my_predefined_field', 10, 1 );
1904
+ * function my_predefined_field( $options ) {
1905
+ * // your code here
1906
+ * return $options;
1907
+ * }
1908
+ * ?>
1909
+ */
1910
+ $array = apply_filters( "um_{$data}_predefined_field_options", $array );
1911
+ return $array;
1912
+ }
1913
+
1914
+ }
1915
+ }
includes/core/class-fields.php CHANGED
@@ -50,7 +50,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
50
  * Set value on form submission
51
  */
52
  if ( isset( $_REQUEST[ $id ] ) ) {
53
- $checked = $_REQUEST[ $id ];
54
  }
55
 
56
  $class = $checked ? 'um-icon-android-checkbox-outline' : 'um-icon-android-checkbox-outline-blank';
@@ -60,7 +60,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
60
 
61
  <div class="um-field um-field-c">
62
  <div class="um-field-area">
63
- <label class="um-field-checkbox <?php echo ( $checked ) ? 'active' : '' ?>">
64
  <input type="checkbox" name="<?php echo esc_attr( $id ); ?>" value="1" <?php checked( $checked ) ?> />
65
  <span class="um-field-checkbox-state"><i class="<?php echo esc_attr( $class ) ?>"></i></span>
66
  <span class="um-field-checkbox-option"> <?php echo esc_html( $title ); ?></span>
@@ -2388,10 +2388,11 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
2388
  $key = 'confirm_' . $original_key;
2389
  $output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
2390
 
2391
- if ( isset( $data['label'] ) ) {
2392
-
 
 
2393
  $data['label'] = __( $data['label'], 'ultimate-member' );
2394
-
2395
  $output .= $this->field_label( sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] ), $key, $data );
2396
  }
2397
 
@@ -2408,9 +2409,11 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
2408
  $name = $key;
2409
  }
2410
 
2411
- if( ! empty( $placeholder ) && ! isset( $data['label'] ) ){
2412
- $placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $placeholder );
2413
- }else if( isset( $data['label'] ) ){
 
 
2414
  $placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] );
2415
  }
2416
 
@@ -4761,4 +4764,4 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
4761
  return $html_atts;
4762
  }
4763
  }
4764
- }
50
  * Set value on form submission
51
  */
52
  if ( isset( $_REQUEST[ $id ] ) ) {
53
+ $checked = (bool) $_REQUEST[ $id ];
54
  }
55
 
56
  $class = $checked ? 'um-icon-android-checkbox-outline' : 'um-icon-android-checkbox-outline-blank';
60
 
61
  <div class="um-field um-field-c">
62
  <div class="um-field-area">
63
+ <label class="um-field-checkbox<?php echo $checked ? ' active' : '' ?>">
64
  <input type="checkbox" name="<?php echo esc_attr( $id ); ?>" value="1" <?php checked( $checked ) ?> />
65
  <span class="um-field-checkbox-state"><i class="<?php echo esc_attr( $class ) ?>"></i></span>
66
  <span class="um-field-checkbox-option"> <?php echo esc_html( $title ); ?></span>
2388
  $key = 'confirm_' . $original_key;
2389
  $output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
2390
 
2391
+ if ( ! empty( $data['label_confirm_pass'] ) ) {
2392
+ $label_confirm_pass = __( $data['label_confirm_pass'], 'ultimate-member' );
2393
+ $output .= $this->field_label( $label_confirm_pass, $key, $data );
2394
+ } elseif ( isset( $data['label'] ) ) {
2395
  $data['label'] = __( $data['label'], 'ultimate-member' );
 
2396
  $output .= $this->field_label( sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] ), $key, $data );
2397
  }
2398
 
2409
  $name = $key;
2410
  }
2411
 
2412
+ if ( ! empty( $label_confirm_pass ) ) {
2413
+ $placeholder = $label_confirm_pass;
2414
+ } elseif( ! empty( $placeholder ) && ! isset( $data['label'] ) ) {
2415
+ $placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $placeholder );
2416
+ } elseif( isset( $data['label'] ) ) {
2417
  $placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] );
2418
  }
2419
 
4764
  return $html_atts;
4765
  }
4766
  }
4767
+ }
includes/core/class-files.php CHANGED
@@ -261,7 +261,7 @@ if ( ! class_exists( 'um\core\Files' ) ) {
261
  wp_send_json_error( __( 'Wrong mode', 'ultimate-member' ) );
262
  }
263
 
264
- $src = $_POST['src'];
265
  if ( strstr( $src, '?' ) ) {
266
  $splitted = explode( '?', $src );
267
  $src = $splitted[0];
@@ -286,7 +286,7 @@ if ( ! class_exists( 'um\core\Files' ) ) {
286
 
287
  $is_temp = um_is_temp_upload( $src );
288
  if ( ! $is_temp ) {
289
- if ( ! empty( $_POST['filename'] ) && file_exists( UM()->uploader()->get_upload_user_base_dir( $user_id ) . DIRECTORY_SEPARATOR . $_POST['filename'] ) ) {
290
  wp_send_json_success();
291
  }
292
  }
@@ -324,7 +324,7 @@ if ( ! class_exists( 'um\core\Files' ) ) {
324
  wp_send_json_error( esc_js( __( 'Invalid coordinates', 'ultimate-member' ) ) );
325
  }
326
 
327
- $user_id = empty( $_REQUEST['user_id'] ) ? get_current_user_id() : $_REQUEST['user_id'];
328
 
329
  UM()->fields()->set_id = filter_input( INPUT_POST, 'set_id', FILTER_SANITIZE_NUMBER_INT );
330
  UM()->fields()->set_mode = filter_input( INPUT_POST, 'set_mode', FILTER_SANITIZE_STRING );
@@ -334,13 +334,15 @@ if ( ! class_exists( 'um\core\Files' ) ) {
334
  wp_send_json_error( $ret );
335
  }
336
 
 
 
337
  $image_path = um_is_file_owner( $src, $user_id, true );
338
  if ( ! $image_path ) {
339
  wp_send_json_error( esc_js( __( 'Invalid file ownership', 'ultimate-member' ) ) );
340
  }
341
 
342
  UM()->uploader()->replace_upload_dir = true;
343
- $output = UM()->uploader()->resize_image( $image_path, $src, $key, $user_id, $coord );
344
  UM()->uploader()->replace_upload_dir = false;
345
 
346
  delete_option( "um_cache_userdata_{$user_id}" );
@@ -358,13 +360,13 @@ if ( ! class_exists( 'um\core\Files' ) ) {
358
  $ret['error'] = null;
359
  $ret = array();
360
 
361
- $id = $_POST['key'];
362
- $timestamp = $_POST['timestamp'];
363
- $nonce = $_POST['_wpnonce'];
364
  $user_id = empty( $_POST['user_id'] ) ? get_current_user_id() : absint( $_POST['user_id'] );
365
 
366
- UM()->fields()->set_id = $_POST['set_id'];
367
- UM()->fields()->set_mode = $_POST['set_mode'];
368
 
369
  if ( UM()->fields()->set_mode != 'register' && ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
370
  $ret['error'] = __( 'You have no permission to edit this user', 'ultimate-member' );
@@ -437,12 +439,12 @@ if ( ! class_exists( 'um\core\Files' ) ) {
437
  die( json_encode( $ret ) );
438
  }*/
439
 
440
- $nonce = $_POST['_wpnonce'];
441
- $id = $_POST['key'];
442
- $timestamp = $_POST['timestamp'];
443
 
444
- UM()->fields()->set_id = $_POST['set_id'];
445
- UM()->fields()->set_mode = $_POST['set_mode'];
446
 
447
  /**
448
  * UM hook
@@ -1296,4 +1298,4 @@ if ( ! class_exists( 'um\core\Files' ) ) {
1296
 
1297
 
1298
  }
1299
- }
261
  wp_send_json_error( __( 'Wrong mode', 'ultimate-member' ) );
262
  }
263
 
264
+ $src = esc_url_raw( $_POST['src'] );
265
  if ( strstr( $src, '?' ) ) {
266
  $splitted = explode( '?', $src );
267
  $src = $splitted[0];
286
 
287
  $is_temp = um_is_temp_upload( $src );
288
  if ( ! $is_temp ) {
289
+ if ( ! empty( $_POST['filename'] ) && file_exists( UM()->uploader()->get_upload_user_base_dir( $user_id ) . DIRECTORY_SEPARATOR . sanitize_file_name( $_POST['filename'] ) ) ) {
290
  wp_send_json_success();
291
  }
292
  }
324
  wp_send_json_error( esc_js( __( 'Invalid coordinates', 'ultimate-member' ) ) );
325
  }
326
 
327
+ $user_id = empty( $_REQUEST['user_id'] ) ? get_current_user_id() : absint( $_REQUEST['user_id'] );
328
 
329
  UM()->fields()->set_id = filter_input( INPUT_POST, 'set_id', FILTER_SANITIZE_NUMBER_INT );
330
  UM()->fields()->set_mode = filter_input( INPUT_POST, 'set_mode', FILTER_SANITIZE_STRING );
334
  wp_send_json_error( $ret );
335
  }
336
 
337
+ $src = esc_url_raw( $src );
338
+
339
  $image_path = um_is_file_owner( $src, $user_id, true );
340
  if ( ! $image_path ) {
341
  wp_send_json_error( esc_js( __( 'Invalid file ownership', 'ultimate-member' ) ) );
342
  }
343
 
344
  UM()->uploader()->replace_upload_dir = true;
345
+ $output = UM()->uploader()->resize_image( $image_path, $src, sanitize_text_field( $key ), $user_id, sanitize_text_field( $coord ) );
346
  UM()->uploader()->replace_upload_dir = false;
347
 
348
  delete_option( "um_cache_userdata_{$user_id}" );
360
  $ret['error'] = null;
361
  $ret = array();
362
 
363
+ $id = sanitize_text_field( $_POST['key'] );
364
+ $timestamp = absint( $_POST['timestamp'] );
365
+ $nonce = sanitize_text_field( $_POST['_wpnonce'] );
366
  $user_id = empty( $_POST['user_id'] ) ? get_current_user_id() : absint( $_POST['user_id'] );
367
 
368
+ UM()->fields()->set_id = absint( $_POST['set_id'] );
369
+ UM()->fields()->set_mode = sanitize_key( $_POST['set_mode'] );
370
 
371
  if ( UM()->fields()->set_mode != 'register' && ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
372
  $ret['error'] = __( 'You have no permission to edit this user', 'ultimate-member' );
439
  die( json_encode( $ret ) );
440
  }*/
441
 
442
+ $nonce = sanitize_text_field( $_POST['_wpnonce'] );
443
+ $id = sanitize_text_field( $_POST['key'] );
444
+ $timestamp = absint( $_POST['timestamp'] );
445
 
446
+ UM()->fields()->set_id = absint( $_POST['set_id'] );
447
+ UM()->fields()->set_mode = sanitize_key( $_POST['set_mode'] );
448
 
449
  /**
450
  * UM hook
1298
 
1299
 
1300
  }
1301
+ }
includes/core/class-form.php CHANGED
@@ -1,667 +1,749 @@
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
- /**
36
- * Form constructor.
37
- */
38
- function __construct() {
39
-
40
- $this->form_suffix = null;
41
-
42
- $this->errors = null;
43
-
44
- $this->processing = null;
45
-
46
- add_action( 'template_redirect', array( &$this, 'form_init' ), 2 );
47
-
48
- add_action( 'init', array( &$this, 'field_declare' ), 10 );
49
-
50
- }
51
-
52
-
53
- /**
54
- *
55
- */
56
- function ajax_muted_action() {
57
- UM()->check_ajax_nonce();
58
-
59
- extract( $_REQUEST );
60
-
61
- if ( ! UM()->roles()->um_current_user_can( 'edit', $user_id ) )
62
- die( __( 'You can not edit this user' ) );
63
-
64
- switch( $hook ) {
65
- default:
66
- /**
67
- * UM hook
68
- *
69
- * @type action
70
- * @title um_run_ajax_function__{$hook}
71
- * @description Action on AJAX muted action
72
- * @input_vars
73
- * [{"var":"$request","type":"int","desc":"Request"}]
74
- * @change_log
75
- * ["Since: 2.0"]
76
- * @usage add_action( 'um_run_ajax_function__{$hook}', 'function_name', 10, 1 );
77
- * @example
78
- * <?php
79
- * add_action( 'um_run_ajax_function__{$hook}', 'my_run_ajax_function', 10, 1 );
80
- * function my_run_ajax_function( $request ) {
81
- * // your code here
82
- * }
83
- * ?>
84
- */
85
- do_action( "um_run_ajax_function__{$hook}", $_REQUEST );
86
- break;
87
- }
88
- }
89
-
90
-
91
- /**
92
- *
93
- */
94
- function ajax_select_options() {
95
- UM()->check_ajax_nonce();
96
-
97
- $arr_options = array();
98
- $arr_options['status'] = 'success';
99
- $arr_options['post'] = $_POST;
100
-
101
- UM()->fields()->set_id = absint( $_POST['form_id'] );
102
- UM()->fields()->set_mode = 'profile';
103
- $form_fields = UM()->fields()->get_fields();
104
- $arr_options['fields'] = $form_fields;
105
-
106
- if ( isset( $arr_options['post']['members_directory'] ) && $arr_options['post']['members_directory'] == 'yes' ) {
107
- $ajax_source_func = $_POST['child_callback'];
108
- if ( function_exists( $ajax_source_func ) ) {
109
- $arr_options['items'] = call_user_func( $ajax_source_func, $arr_options['field']['parent_dropdown_relationship'] );
110
-
111
- global $wpdb;
112
-
113
- $values_array = $wpdb->get_col( $wpdb->prepare(
114
- "SELECT DISTINCT meta_value
115
- FROM $wpdb->usermeta
116
- WHERE meta_key = %s AND
117
- meta_value != ''",
118
- $arr_options['post']['child_name']
119
- ) );
120
-
121
- if ( ! empty( $values_array ) ) {
122
- $arr_options['items'] = array_intersect( $arr_options['items'], $values_array );
123
- } else {
124
- $arr_options['items'] = array();
125
- }
126
-
127
- wp_send_json( $arr_options );
128
- }
129
- } else {
130
- /**
131
- * UM hook
132
- *
133
- * @type filter
134
- * @title um_ajax_select_options__debug_mode
135
- * @description Activate debug mode for AJAX select options
136
- * @input_vars
137
- * [{"var":"$debug_mode","type":"bool","desc":"Enable Debug mode"}]
138
- * @change_log
139
- * ["Since: 2.0"]
140
- * @usage
141
- * <?php add_filter( 'um_ajax_select_options__debug_mode', 'function_name', 10, 1 ); ?>
142
- * @example
143
- * <?php
144
- * add_filter( 'um_ajax_select_options__debug_mode', 'my_ajax_select_options__debug_mode', 10, 1 );
145
- * function my_ajax_select_options__debug_mode( $debug_mode ) {
146
- * // your code here
147
- * return $debug_mode;
148
- * }
149
- * ?>
150
- */
151
- $debug = apply_filters('um_ajax_select_options__debug_mode', false );
152
- if( $debug ){
153
- $arr_options['debug'] = array(
154
- $_POST,
155
- $form_fields,
156
- );
157
- }
158
-
159
- if ( ! empty( $_POST['child_callback'] ) && isset( $form_fields[ $_POST['child_name'] ] ) ) {
160
-
161
- $ajax_source_func = $_POST['child_callback'];
162
-
163
- // If the requested callback function is added in the form or added in the field option, execute it with call_user_func.
164
- if ( isset( $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] ) &&
165
- ! empty( $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] ) &&
166
- $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] == $ajax_source_func ) {
167
-
168
- $arr_options['field'] = $form_fields[ $_POST['child_name'] ];
169
-
170
- if ( function_exists( $ajax_source_func ) ) {
171
- $arr_options['items'] = call_user_func( $ajax_source_func, $arr_options['field']['parent_dropdown_relationship'] );
172
- }
173
-
174
- } else {
175
- $arr_options['status'] = 'error';
176
- $arr_options['message'] = __( 'This is not possible for security reasons.', 'ultimate-member' );
177
- }
178
-
179
- }
180
-
181
- wp_send_json( $arr_options );
182
- }
183
- }
184
-
185
-
186
- /**
187
- * Count the form errors.
188
- * @return integer
189
- */
190
- function count_errors() {
191
- $errors = $this->errors;
192
-
193
- if( $errors && is_array( $errors ) ) {
194
- return count( $errors );
195
- }
196
-
197
- return 0;
198
- }
199
-
200
-
201
- /**
202
- * Appends field errors
203
- * @param string $key
204
- * @param string $error
205
- */
206
- function add_error( $key, $error ) {
207
- if ( ! isset( $this->errors[ $key ] ) ){
208
- /**
209
- * UM hook
210
- *
211
- * @type filter
212
- * @title um_submit_form_error
213
- * @description Change error text on submit form
214
- * @input_vars
215
- * [{"var":"$error","type":"string","desc":"Error String"},
216
- * {"var":"$key","type":"string","desc":"Error Key"}]
217
- * @change_log
218
- * ["Since: 2.0"]
219
- * @usage
220
- * <?php add_filter( 'um_submit_form_error', 'function_name', 10, 2 ); ?>
221
- * @example
222
- * <?php
223
- * add_filter( 'um_submit_form_error', 'my_submit_form_error', 10, 2 );
224
- * function my_submit_form_error( $error, $key ) {
225
- * // your code here
226
- * return $error;
227
- * }
228
- * ?>
229
- */
230
- $error = apply_filters( 'um_submit_form_error', $error, $key );
231
- $this->errors[ $key ] = $error;
232
- }
233
- }
234
-
235
- /**
236
- * Appends field notices
237
- * @param string $key
238
- * @param string $notice
239
- */
240
- function add_notice( $key, $notice ) {
241
- if ( ! isset( $this->notices[ $key ] ) ){
242
- /**
243
- * UM hook
244
- *
245
- * @type filter
246
- * @title um_submit_form_notice
247
- * @description Change notice text on submit form
248
- * @input_vars
249
- * [{"var":"$notice","type":"string","desc":"notice String"},
250
- * {"var":"$key","type":"string","desc":"notice Key"}]
251
- * @change_log
252
- * ["Since: 2.0"]
253
- * @usage
254
- * <?php add_filter( 'um_submit_form_notice', 'function_name', 10, 2 ); ?>
255
- * @example
256
- * <?php
257
- * add_filter( 'um_submit_form_notice', 'my_submit_form_notice', 10, 2 );
258
- * function my_submit_form_notice( $notice, $key ) {
259
- * // your code here
260
- * return $notice;
261
- * }
262
- * ?>
263
- */
264
- $notice = apply_filters( 'um_submit_form_notice', $notice, $key );
265
- $this->notices[ $key ] = $notice;
266
- }
267
- }
268
-
269
-
270
- /**
271
- * If a form has errors
272
- * @param string $key
273
- * @return boolean
274
- */
275
- function has_error( $key ) {
276
- if ( isset( $this->errors[ $key ] ) ) {
277
- return true;
278
- }
279
- return false;
280
- }
281
-
282
- /**
283
- * If a form has notices/info
284
- * @param string $key
285
- * @return boolean
286
- */
287
- function has_notice( $key ) {
288
- if ( isset( $this->notices[ $key ] ) ) {
289
- return true;
290
- }
291
- return false;
292
- }
293
-
294
-
295
- /**
296
- * Declare all fields
297
- */
298
- function field_declare() {
299
- if ( isset( UM()->builtin()->custom_fields ) ) {
300
- $this->all_fields = UM()->builtin()->custom_fields;
301
- } else {
302
- $this->all_fields = null;
303
- }
304
- }
305
-
306
-
307
- /**
308
- * Validate form on submit
309
- */
310
- function form_init() {
311
- if ( isset( $_SERVER['REQUEST_METHOD'] ) ) {
312
- $http_post = ( 'POST' == $_SERVER['REQUEST_METHOD'] );
313
- } else {
314
- $http_post = 'POST';
315
- }
316
-
317
- if ( $http_post && ! is_admin() && isset( $_POST['form_id'] ) && is_numeric( $_POST['form_id'] ) ) {
318
-
319
- /**
320
- * UM hook
321
- *
322
- * @type action
323
- * @title um_before_submit_form_post
324
- * @description Before submit form
325
- * @input_vars
326
- * [{"var":"$post","type":"int","desc":"Post data"}]
327
- * @change_log
328
- * ["Since: 2.0"]
329
- * @usage add_action( 'um_before_submit_form_post', 'function_name', 10, 1 );
330
- * @example
331
- * <?php
332
- * add_action( 'um_before_submit_form_post', 'my_before_submit_form_post', 10, 1 );
333
- * function my_run_ajax_function( $post ) {
334
- * // your code here
335
- * }
336
- * ?>
337
- */
338
- do_action( 'um_before_submit_form_post', $_POST );
339
-
340
- $this->form_id = $_POST['form_id'];
341
- $this->form_status = get_post_status( $this->form_id );
342
-
343
-
344
- if ( $this->form_status == 'publish' ) {
345
- /* save entire form as global */
346
- /**
347
- * UM hook
348
- *
349
- * @type filter
350
- * @title um_submit_post_form
351
- * @description Change submitted data on form submit
352
- * @input_vars
353
- * [{"var":"$data","type":"array","desc":"Submitted data"}]
354
- * @change_log
355
- * ["Since: 2.0"]
356
- * @usage
357
- * <?php add_filter( 'um_submit_post_form', 'function_name', 10, 1 ); ?>
358
- * @example
359
- * <?php
360
- * add_filter( 'um_submit_post_form', 'my_submit_post_form', 10, 1 );
361
- * function my_submit_post_form( $data ) {
362
- * // your code here
363
- * return $data;
364
- * }
365
- * ?>
366
- */
367
- $this->post_form = apply_filters( 'um_submit_post_form', $_POST );
368
-
369
- if ( isset( $this->post_form[ UM()->honeypot ] ) && $this->post_form[ UM()->honeypot ] != '' ) {
370
- wp_die( __( 'Hello, spam bot!', 'ultimate-member' ) );
371
- }
372
-
373
- $this->post_form = $this->beautify( $this->post_form );
374
- $this->post_form['submitted'] = $this->post_form;
375
-
376
- $this->form_data = UM()->query()->post_data( $this->form_id );
377
-
378
- $this->post_form = array_merge( $this->form_data, $this->post_form );
379
-
380
- // Remove role from post_form at first if role ! empty and there aren't custom fields with role name
381
- if ( ! empty( $_POST['role'] ) ) {
382
- if ( ! isset( $this->form_data['custom_fields'] ) || ! strstr( $this->form_data['custom_fields'], 'role_' ) ) {
383
- unset( $this->post_form['role'] );
384
- unset( $this->post_form['submitted']['role'] );
385
- }
386
- }
387
-
388
- // Secure sanitize of the submitted data
389
- if ( ! empty( $this->post_form ) ) {
390
- $this->post_form = array_diff_key( $this->post_form, array_flip( UM()->user()->banned_keys ) );
391
- }
392
- if ( ! empty( $this->post_form['submitted'] ) ) {
393
- $this->post_form['submitted'] = array_diff_key( $this->post_form['submitted'], array_flip( UM()->user()->banned_keys ) );
394
- }
395
-
396
- // set default role from settings on registration form
397
- if ( isset( $this->post_form['mode'] ) && $this->post_form['mode'] == 'register' ) {
398
-
399
- $role = $this->assigned_role( $this->form_id );
400
- $this->post_form['role'] = $role;
401
-
402
- }
403
-
404
- if ( isset( $this->form_data['custom_fields'] ) && strstr( $this->form_data['custom_fields'], 'role_' ) ) { // Secure selected role
405
-
406
- if ( ! empty( $_POST['role'] ) ) {
407
-
408
- $custom_field_roles = $this->custom_field_roles( $this->form_data['custom_fields'] );
409
-
410
- if ( ! empty( $custom_field_roles ) ) {
411
- $role = $_POST['role'];
412
-
413
- if ( is_array( $_POST['role'] ) ) {
414
- $role = current( $_POST['role'] );
415
- }
416
-
417
- global $wp_roles;
418
- $role_keys = array_map( function( $item ) {
419
- return 'um_' . $item;
420
- }, get_option( 'um_roles', array() ) );
421
- $exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
422
-
423
- if ( ! empty( $role ) &&
424
- ( ! in_array( $role, $custom_field_roles, true ) || in_array( $role, $exclude_roles ) ) ) {
425
- wp_die( __( 'This is not possible for security reasons.', 'ultimate-member' ) );
426
- }
427
-
428
- $this->post_form['role'] = $role;
429
- $this->post_form['submitted']['role'] = $role;
430
- } else {
431
- unset( $this->post_form['role'] );
432
- unset( $this->post_form['submitted']['role'] );
433
-
434
- // set default role for registration form if custom field hasn't proper value
435
- if ( isset( $this->post_form['mode'] ) && $this->post_form['mode'] == 'register' ) {
436
- $role = $this->assigned_role( $this->form_id );
437
- $this->post_form['role'] = $role;
438
- }
439
- }
440
- }
441
-
442
- }
443
-
444
- /**
445
- * UM hook
446
- *
447
- * @type filter
448
- * @title um_submit_form_data
449
- * @description Change submitted data on form submit
450
- * @input_vars
451
- * [{"var":"$data","type":"array","desc":"Submitted data"},
452
- * {"var":"$mode","type":"string","desc":"Form mode"}]
453
- * @change_log
454
- * ["Since: 2.0"]
455
- * @usage
456
- * <?php add_filter( 'um_submit_form_data', 'function_name', 10, 2 ); ?>
457
- * @example
458
- * <?php
459
- * add_filter( 'um_submit_form_data', 'my_submit_form_data', 10, 2 );
460
- * function my_submit_form_data( $data ) {
461
- * // your code here
462
- * return $data;
463
- * }
464
- * ?>
465
- */
466
- $this->post_form = apply_filters( 'um_submit_form_data', $this->post_form, $this->post_form['mode'] );
467
-
468
- /* Continue based on form mode - pre-validation */
469
-
470
- /**
471
- * UM hook
472
- *
473
- * @type action
474
- * @title um_submit_form_errors_hook
475
- * @description Action on submit form
476
- * @input_vars
477
- * [{"var":"$post","type":"int","desc":"Post data"}]
478
- * @change_log
479
- * ["Since: 2.0"]
480
- * @usage add_action( 'um_submit_form_errors_hook', 'function_name', 10, 1 );
481
- * @example
482
- * <?php
483
- * add_action( 'um_submit_form_errors_hook', 'my_submit_form_errors', 10, 1 );
484
- * function my_submit_form_errors( $post ) {
485
- * // your code here
486
- * }
487
- * ?>
488
- */
489
- do_action( 'um_submit_form_errors_hook', $this->post_form );
490
- /**
491
- * UM hook
492
- *
493
- * @type action
494
- * @title um_submit_form_{$mode}
495
- * @description Action on submit form
496
- * @input_vars
497
- * [{"var":"$post","type":"int","desc":"Post data"}]
498
- * @change_log
499
- * ["Since: 2.0"]
500
- * @usage add_action( 'um_submit_form_{$mode}', 'function_name', 10, 1 );
501
- * @example
502
- * <?php
503
- * add_action( 'um_submit_form_{$mode}', 'my_submit_form', 10, 1 );
504
- * function my_submit_form( $post ) {
505
- * // your code here
506
- * }
507
- * ?>
508
- */
509
- do_action( "um_submit_form_{$this->post_form['mode']}", $this->post_form );
510
-
511
- }
512
-
513
- }
514
-
515
- }
516
-
517
-
518
- /**
519
- * Beautify form data
520
- *
521
- * @param array $form
522
- * @return array $form
523
- */
524
- function beautify( $form ) {
525
-
526
- if ( isset( $form['form_id'] ) ) {
527
-
528
- $this->form_suffix = '-' . $form['form_id'];
529
-
530
- $this->processing = $form['form_id'];
531
-
532
- foreach ( $form as $key => $value ) {
533
- if ( strstr( $key, $this->form_suffix ) ) {
534
- $a_key = str_replace( $this->form_suffix, '', $key );
535
- $form[ $a_key ] = $value;
536
- unset( $form[ $key ] );
537
- }
538
- }
539
-
540
- }
541
-
542
- return $form;
543
- }
544
-
545
-
546
- /**
547
- * Display form type as Title
548
- * @param string $mode
549
- * @param integer $post_id
550
- * @return string $output
551
- */
552
- function display_form_type( $mode, $post_id ){
553
- $output = null;
554
- switch( $mode ){
555
- case 'login':
556
- $output = 'Login';
557
- break;
558
- case 'profile':
559
- $output = 'Profile';
560
- break;
561
- case 'register':
562
- $output = 'Register';
563
- break;
564
- }
565
- return $output;
566
- }
567
-
568
-
569
- /**
570
- * Assigned roles to a form
571
- * @param integer $post_id
572
- * @return string $role
573
- */
574
- function assigned_role( $post_id ) {
575
-
576
- $global_role = get_option( 'default_role' ); // WP Global settings
577
-
578
- $um_global_role = UM()->options()->get( 'register_role' ); // UM Settings Global settings
579
- if ( ! empty( $um_global_role ) ) {
580
- $global_role = $um_global_role; // Form Global settings
581
- }
582
-
583
- $mode = $this->form_type( $post_id );
584
-
585
- /**
586
- * @todo WPML integration to get role from original if it's empty
587
- */
588
- $use_custom = get_post_meta( $post_id, "_um_{$mode}_use_custom_settings", true );
589
- if ( $use_custom ) { // Custom Form settings
590
- $role = get_post_meta( $post_id, "_um_{$mode}_role", true );
591
- }
592
-
593
- if ( empty( $role ) ) { // custom role is default, return default role's slug
594
- $role = $global_role;
595
- }
596
-
597
- return $role;
598
- }
599
-
600
-
601
- /**
602
- * Get form type
603
- * @param integer $post_id
604
- * @return string
605
- */
606
- function form_type( $post_id ) {
607
- $mode = get_post_meta( $post_id, '_um_mode', true );
608
- return $mode;
609
- }
610
-
611
-
612
- /**
613
- * Get custom field roles
614
- * @param string $custom_fields serialized
615
- * @return bool|array roles
616
- */
617
- function custom_field_roles( $custom_fields ) {
618
-
619
- $fields = maybe_unserialize( $custom_fields );
620
- if ( ! is_array( $fields ) ) {
621
- return false;
622
- }
623
-
624
- // role field
625
- global $wp_roles;
626
- $role_keys = array_map( function( $item ) {
627
- return 'um_' . $item;
628
- }, get_option( 'um_roles', array() ) );
629
- $exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
630
-
631
- $roles = UM()->roles()->get_roles( false, $exclude_roles );
632
- $roles = array_map( function( $item ) {
633
- return html_entity_decode( $item, ENT_QUOTES );
634
- }, $roles );
635
-
636
- foreach ( $fields as $field_key => $field_settings ) {
637
-
638
- if ( strstr( $field_key, 'role_' ) && is_array( $field_settings['options'] ) ) {
639
-
640
- if ( isset( $this->post_form['mode'] ) && $this->post_form['mode'] == 'profile' &&
641
- isset( $field_settings['editable'] ) && $field_settings['editable'] == 0 ) {
642
- continue;
643
- }
644
-
645
- if ( ! um_can_view_field( $field_settings ) ) {
646
- continue;
647
- }
648
-
649
- $intersected_options = array();
650
- foreach ( $field_settings['options'] as $key => $title ) {
651
- if ( false !== $search_key = array_search( $title, $roles ) ) {
652
- $intersected_options[ $search_key ] = $title;
653
- } elseif ( isset( $roles[ $key ] ) ) {
654
- $intersected_options[ $key ] = $title;
655
- }
656
- }
657
-
658
- // getting roles only from the first role fields
659
- return array_keys( $intersected_options );
660
- }
661
-
662
- }
663
-
664
- return false;
665
- }
666
- }
667
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /**
36
+ * Form constructor.
37
+ */
38
+ function __construct() {
39
+
40
+ $this->form_suffix = null;
41
+
42
+ $this->errors = null;
43
+
44
+ $this->processing = null;
45
+
46
+ add_action( 'template_redirect', array( &$this, 'form_init' ), 2 );
47
+
48
+ add_action( 'init', array( &$this, 'field_declare' ), 10 );
49
+
50
+ }
51
+
52
+
53
+ /**
54
+ *
55
+ */
56
+ public function ajax_muted_action() {
57
+ UM()->check_ajax_nonce();
58
+
59
+ /**
60
+ * @var $user_id
61
+ * @var $hook
62
+ */
63
+ extract( $_REQUEST );
64
+
65
+ if ( isset( $user_id ) ) {
66
+ $user_id = absint( $user_id );
67
+ }
68
+
69
+ if ( isset( $hook ) ) {
70
+ $hook = sanitize_key( $hook );
71
+ }
72
+
73
+ if ( ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
74
+ die( esc_html__( 'You can not edit this user', 'ultimate-member' ) );
75
+ }
76
+
77
+ switch ( $hook ) {
78
+ default:
79
+ /**
80
+ * UM hook
81
+ *
82
+ * @type action
83
+ * @title um_run_ajax_function__{$hook}
84
+ * @description Action on AJAX muted action
85
+ * @input_vars
86
+ * [{"var":"$request","type":"int","desc":"Request"}]
87
+ * @change_log
88
+ * ["Since: 2.0"]
89
+ * @usage add_action( 'um_run_ajax_function__{$hook}', 'function_name', 10, 1 );
90
+ * @example
91
+ * <?php
92
+ * add_action( 'um_run_ajax_function__{$hook}', 'my_run_ajax_function', 10, 1 );
93
+ * function my_run_ajax_function( $request ) {
94
+ * // your code here
95
+ * }
96
+ * ?>
97
+ */
98
+ do_action( "um_run_ajax_function__{$hook}", $_REQUEST );
99
+ break;
100
+ }
101
+ }
102
+
103
+
104
+ /**
105
+ *
106
+ */
107
+ public function ajax_select_options() {
108
+ UM()->check_ajax_nonce();
109
+
110
+ $arr_options = array();
111
+ $arr_options['status'] = 'success';
112
+ $arr_options['post'] = $_POST;
113
+
114
+ UM()->fields()->set_id = absint( $_POST['form_id'] );
115
+ UM()->fields()->set_mode = 'profile';
116
+ $form_fields = UM()->fields()->get_fields();
117
+ $arr_options['fields'] = $form_fields;
118
+
119
+ if ( isset( $arr_options['post']['members_directory'] ) && 'yes' === $arr_options['post']['members_directory'] ) {
120
+ $ajax_source_func = $_POST['child_callback'];
121
+ if ( function_exists( $ajax_source_func ) ) {
122
+ $arr_options['items'] = call_user_func( $ajax_source_func, $arr_options['field']['parent_dropdown_relationship'] );
123
+
124
+ global $wpdb;
125
+
126
+ $values_array = $wpdb->get_col(
127
+ $wpdb->prepare(
128
+ "SELECT DISTINCT meta_value
129
+ FROM $wpdb->usermeta
130
+ WHERE meta_key = %s AND
131
+ meta_value != ''",
132
+ $arr_options['post']['child_name']
133
+ )
134
+ );
135
+
136
+ if ( ! empty( $values_array ) ) {
137
+ $arr_options['items'] = array_intersect( $arr_options['items'], $values_array );
138
+ } else {
139
+ $arr_options['items'] = array();
140
+ }
141
+
142
+ wp_send_json( $arr_options );
143
+ }
144
+ } else {
145
+ /**
146
+ * UM hook
147
+ *
148
+ * @type filter
149
+ * @title um_ajax_select_options__debug_mode
150
+ * @description Activate debug mode for AJAX select options
151
+ * @input_vars
152
+ * [{"var":"$debug_mode","type":"bool","desc":"Enable Debug mode"}]
153
+ * @change_log
154
+ * ["Since: 2.0"]
155
+ * @usage
156
+ * <?php add_filter( 'um_ajax_select_options__debug_mode', 'function_name', 10, 1 ); ?>
157
+ * @example
158
+ * <?php
159
+ * add_filter( 'um_ajax_select_options__debug_mode', 'my_ajax_select_options__debug_mode', 10, 1 );
160
+ * function my_ajax_select_options__debug_mode( $debug_mode ) {
161
+ * // your code here
162
+ * return $debug_mode;
163
+ * }
164
+ * ?>
165
+ */
166
+ $debug = apply_filters( 'um_ajax_select_options__debug_mode', false );
167
+ if ( $debug ) {
168
+ $arr_options['debug'] = array(
169
+ $_POST,
170
+ $form_fields,
171
+ );
172
+ }
173
+
174
+ if ( ! empty( $_POST['child_callback'] ) && isset( $form_fields[ $_POST['child_name'] ] ) ) {
175
+
176
+ $ajax_source_func = $_POST['child_callback'];
177
+
178
+ // If the requested callback function is added in the form or added in the field option, execute it with call_user_func.
179
+ if ( isset( $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] ) &&
180
+ ! empty( $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] ) &&
181
+ $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] === $ajax_source_func ) {
182
+
183
+ $arr_options['field'] = $form_fields[ $_POST['child_name'] ];
184
+
185
+ if ( function_exists( $ajax_source_func ) ) {
186
+ $arr_options['items'] = call_user_func( $ajax_source_func, $arr_options['field']['parent_dropdown_relationship'] );
187
+ }
188
+ } else {
189
+ $arr_options['status'] = 'error';
190
+ $arr_options['message'] = __( 'This is not possible for security reasons.', 'ultimate-member' );
191
+ }
192
+ }
193
+
194
+ wp_send_json( $arr_options );
195
+ }
196
+ }
197
+
198
+
199
+ /**
200
+ * Count the form errors.
201
+ * @return integer
202
+ */
203
+ public function count_errors() {
204
+ $errors = $this->errors;
205
+
206
+ if ( $errors && is_array( $errors ) ) {
207
+ return count( $errors );
208
+ }
209
+
210
+ return 0;
211
+ }
212
+
213
+
214
+ /**
215
+ * Appends field errors
216
+ *
217
+ * @param string $key
218
+ * @param string $error
219
+ */
220
+ public function add_error( $key, $error ) {
221
+ if ( ! isset( $this->errors[ $key ] ) ) {
222
+ /**
223
+ * UM hook
224
+ *
225
+ * @type filter
226
+ * @title um_submit_form_error
227
+ * @description Change error text on submit form
228
+ * @input_vars
229
+ * [{"var":"$error","type":"string","desc":"Error String"},
230
+ * {"var":"$key","type":"string","desc":"Error Key"}]
231
+ * @change_log
232
+ * ["Since: 2.0"]
233
+ * @usage
234
+ * <?php add_filter( 'um_submit_form_error', 'function_name', 10, 2 ); ?>
235
+ * @example
236
+ * <?php
237
+ * add_filter( 'um_submit_form_error', 'my_submit_form_error', 10, 2 );
238
+ * function my_submit_form_error( $error, $key ) {
239
+ * // your code here
240
+ * return $error;
241
+ * }
242
+ * ?>
243
+ */
244
+ $this->errors[ $key ] = apply_filters( 'um_submit_form_error', $error, $key );
245
+ }
246
+ }
247
+
248
+ /**
249
+ * Appends field notices
250
+ * @param string $key
251
+ * @param string $notice
252
+ */
253
+ public function add_notice( $key, $notice ) {
254
+ if ( ! isset( $this->notices[ $key ] ) ) {
255
+ /**
256
+ * UM hook
257
+ *
258
+ * @type filter
259
+ * @title um_submit_form_notice
260
+ * @description Change notice text on submit form
261
+ * @input_vars
262
+ * [{"var":"$notice","type":"string","desc":"notice String"},
263
+ * {"var":"$key","type":"string","desc":"notice Key"}]
264
+ * @change_log
265
+ * ["Since: 2.0"]
266
+ * @usage
267
+ * <?php add_filter( 'um_submit_form_notice', 'function_name', 10, 2 ); ?>
268
+ * @example
269
+ * <?php
270
+ * add_filter( 'um_submit_form_notice', 'my_submit_form_notice', 10, 2 );
271
+ * function my_submit_form_notice( $notice, $key ) {
272
+ * // your code here
273
+ * return $notice;
274
+ * }
275
+ * ?>
276
+ */
277
+ $this->notices[ $key ] = apply_filters( 'um_submit_form_notice', $notice, $key );
278
+ }
279
+ }
280
+
281
+
282
+ /**
283
+ * If a form has errors
284
+ *
285
+ * @param string $key
286
+ * @return boolean
287
+ */
288
+ public function has_error( $key ) {
289
+ if ( isset( $this->errors[ $key ] ) ) {
290
+ return true;
291
+ }
292
+ return false;
293
+ }
294
+
295
+
296
+ /**
297
+ * If a form has notices/info
298
+ *
299
+ * @param string $key
300
+ * @return boolean
301
+ */
302
+ public function has_notice( $key ) {
303
+ if ( isset( $this->notices[ $key ] ) ) {
304
+ return true;
305
+ }
306
+ return false;
307
+ }
308
+
309
+
310
+ /**
311
+ * Declare all fields
312
+ */
313
+ public function field_declare() {
314
+ if ( isset( UM()->builtin()->custom_fields ) ) {
315
+ $this->all_fields = UM()->builtin()->custom_fields;
316
+ } else {
317
+ $this->all_fields = null;
318
+ }
319
+ }
320
+
321
+
322
+ /**
323
+ * Validate form on submit
324
+ */
325
+ public function form_init() {
326
+ if ( isset( $_SERVER['REQUEST_METHOD'] ) ) {
327
+ $http_post = ( 'POST' === $_SERVER['REQUEST_METHOD'] );
328
+ } else {
329
+ $http_post = 'POST';
330
+ }
331
+
332
+ if ( $http_post && ! is_admin() && isset( $_POST['form_id'] ) && is_numeric( $_POST['form_id'] ) ) {
333
+
334
+ $this->form_id = absint( $_POST['form_id'] );
335
+ $this->form_status = get_post_status( $this->form_id );
336
+ $this->form_data = UM()->query()->post_data( $this->form_id );
337
+
338
+ if ( 'publish' !== $this->form_status ) {
339
+ return;
340
+ }
341
+
342
+ /**
343
+ * UM hook
344
+ *
345
+ * @type action
346
+ * @title um_before_submit_form_post
347
+ * @description Before submit form
348
+ * @change_log
349
+ * ["Since: 2.0"]
350
+ * @usage add_action( 'um_before_submit_form_post', 'function_name', 10, 1 );
351
+ * @example
352
+ * <?php
353
+ * add_action( 'um_before_submit_form_post', 'my_before_submit_form_post', 10, 1 );
354
+ * function my_run_ajax_function( $post ) {
355
+ * // your code here
356
+ * }
357
+ * ?>
358
+ */
359
+ do_action( 'um_before_submit_form_post' );
360
+
361
+ /* save entire form as global */
362
+ /**
363
+ * UM hook
364
+ *
365
+ * @type filter
366
+ * @title um_submit_post_form
367
+ * @description Change submitted data on form submit
368
+ * @input_vars
369
+ * [{"var":"$data","type":"array","desc":"Submitted data"}]
370
+ * @change_log
371
+ * ["Since: 2.0"]
372
+ * @usage
373
+ * <?php add_filter( 'um_submit_post_form', 'function_name', 10, 1 ); ?>
374
+ * @example
375
+ * <?php
376
+ * add_filter( 'um_submit_post_form', 'my_submit_post_form', 10, 1 );
377
+ * function my_submit_post_form( $data ) {
378
+ * // your code here
379
+ * return $data;
380
+ * }
381
+ * ?>
382
+ */
383
+ $this->post_form = apply_filters( 'um_submit_post_form', $_POST );
384
+
385
+ if ( isset( $this->post_form[ UM()->honeypot ] ) && '' !== $this->post_form[ UM()->honeypot ] ) {
386
+ wp_die( esc_html__( 'Hello, spam bot!', 'ultimate-member' ) );
387
+ }
388
+
389
+ $this->post_form = $this->beautify( $this->post_form );
390
+ $this->post_form = $this->sanitize( $this->post_form );
391
+ $this->post_form['submitted'] = $this->post_form;
392
+
393
+ $this->post_form = array_merge( $this->form_data, $this->post_form );
394
+
395
+ // Remove role from post_form at first if role ! empty and there aren't custom fields with role name
396
+ if ( ! empty( $_POST['role'] ) ) {
397
+ if ( ! isset( $this->form_data['custom_fields'] ) || ! strstr( $this->form_data['custom_fields'], 'role_' ) ) {
398
+ unset( $this->post_form['role'] );
399
+ unset( $this->post_form['submitted']['role'] );
400
+ }
401
+ }
402
+
403
+ // Secure sanitize of the submitted data
404
+ if ( ! empty( $this->post_form ) ) {
405
+ $this->post_form = array_diff_key( $this->post_form, array_flip( UM()->user()->banned_keys ) );
406
+ }
407
+ if ( ! empty( $this->post_form['submitted'] ) ) {
408
+ $this->post_form['submitted'] = array_diff_key( $this->post_form['submitted'], array_flip( UM()->user()->banned_keys ) );
409
+ }
410
+
411
+ // set default role from settings on registration form
412
+ if ( isset( $this->post_form['mode'] ) && 'register' === $this->post_form['mode'] ) {
413
+ $role = $this->assigned_role( $this->form_id );
414
+ $this->post_form['role'] = $role;
415
+ }
416
+
417
+ if ( isset( $this->form_data['custom_fields'] ) && strstr( $this->form_data['custom_fields'], 'role_' ) ) { // Secure selected role
418
+
419
+ if ( ! empty( $_POST['role'] ) ) {
420
+ $custom_field_roles = $this->custom_field_roles( $this->form_data['custom_fields'] );
421
+
422
+ if ( ! empty( $custom_field_roles ) ) {
423
+ if ( is_array( $_POST['role'] ) ) {
424
+ $role = current( $_POST['role'] );
425
+ $role = sanitize_key( $role );
426
+ } else {
427
+ $role = sanitize_key( $_POST['role'] );
428
+ }
429
+
430
+ global $wp_roles;
431
+ $role_keys = array_map(
432
+ function( $item ) {
433
+ return 'um_' . $item;
434
+ },
435
+ get_option( 'um_roles', array() )
436
+ );
437
+ $exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
438
+
439
+ if ( ! empty( $role ) &&
440
+ ( ! in_array( $role, $custom_field_roles, true ) || in_array( $role, $exclude_roles, true ) ) ) {
441
+ wp_die( esc_html__( 'This is not possible for security reasons.', 'ultimate-member' ) );
442
+ }
443
+
444
+ $this->post_form['role'] = $role;
445
+ $this->post_form['submitted']['role'] = $role;
446
+ } else {
447
+ unset( $this->post_form['role'] );
448
+ unset( $this->post_form['submitted']['role'] );
449
+
450
+ // set default role for registration form if custom field hasn't proper value
451
+ if ( isset( $this->post_form['mode'] ) && 'register' === $this->post_form['mode'] ) {
452
+ $role = $this->assigned_role( $this->form_id );
453
+ $this->post_form['role'] = $role;
454
+ }
455
+ }
456
+ }
457
+ }
458
+
459
+ /**
460
+ * UM hook
461
+ *
462
+ * @type filter
463
+ * @title um_submit_form_data
464
+ * @description Change submitted data on form submit
465
+ * @input_vars
466
+ * [{"var":"$data","type":"array","desc":"Submitted data"},
467
+ * {"var":"$mode","type":"string","desc":"Form mode"}]
468
+ * @change_log
469
+ * ["Since: 2.0"]
470
+ * @usage
471
+ * <?php add_filter( 'um_submit_form_data', 'function_name', 10, 2 ); ?>
472
+ * @example
473
+ * <?php
474
+ * add_filter( 'um_submit_form_data', 'my_submit_form_data', 10, 2 );
475
+ * function my_submit_form_data( $data ) {
476
+ * // your code here
477
+ * return $data;
478
+ * }
479
+ * ?>
480
+ */
481
+ $this->post_form = apply_filters( 'um_submit_form_data', $this->post_form, $this->post_form['mode'] );
482
+
483
+ /* Continue based on form mode - pre-validation */
484
+
485
+ /**
486
+ * UM hook
487
+ *
488
+ * @type action
489
+ * @title um_submit_form_errors_hook
490
+ * @description Action on submit form
491
+ * @input_vars
492
+ * [{"var":"$post","type":"int","desc":"Post data"}]
493
+ * @change_log
494
+ * ["Since: 2.0"]
495
+ * @usage add_action( 'um_submit_form_errors_hook', 'function_name', 10, 1 );
496
+ * @example
497
+ * <?php
498
+ * add_action( 'um_submit_form_errors_hook', 'my_submit_form_errors', 10, 1 );
499
+ * function my_submit_form_errors( $post ) {
500
+ * // your code here
501
+ * }
502
+ * ?>
503
+ */
504
+ do_action( 'um_submit_form_errors_hook', $this->post_form );
505
+ /**
506
+ * UM hook
507
+ *
508
+ * @type action
509
+ * @title um_submit_form_{$mode}
510
+ * @description Action on submit form
511
+ * @input_vars
512
+ * [{"var":"$post","type":"int","desc":"Post data"}]
513
+ * @change_log
514
+ * ["Since: 2.0"]
515
+ * @usage add_action( 'um_submit_form_{$mode}', 'function_name', 10, 1 );
516
+ * @example
517
+ * <?php
518
+ * add_action( 'um_submit_form_{$mode}', 'my_submit_form', 10, 1 );
519
+ * function my_submit_form( $post ) {
520
+ * // your code here
521
+ * }
522
+ * ?>
523
+ */
524
+ do_action( "um_submit_form_{$this->post_form['mode']}", $this->post_form );
525
+
526
+ }
527
+ }
528
+
529
+
530
+ /**
531
+ * Beautify form data
532
+ *
533
+ * @param array $form
534
+ *
535
+ * @return array $form
536
+ */
537
+ public function beautify( $form ) {
538
+ if ( isset( $form['form_id'] ) ) {
539
+ $this->form_suffix = '-' . $form['form_id'];
540
+ $this->processing = $form['form_id'];
541
+
542
+ foreach ( $form as $key => $value ) {
543
+ if ( strstr( $key, $this->form_suffix ) ) {
544
+ $a_key = str_replace( $this->form_suffix, '', $key );
545
+ $form[ $a_key ] = $value;
546
+ unset( $form[ $key ] );
547
+ }
548
+ }
549
+ }
550
+
551
+ return $form;
552
+ }
553
+
554
+
555
+ /**
556
+ * Beautify form data
557
+ *
558
+ * @param array $form
559
+ *
560
+ * @return array $form
561
+ */
562
+ public function sanitize( $form ) {
563
+
564
+ if ( isset( $form['form_id'] ) ) {
565
+ if ( isset( $this->form_data['custom_fields'] ) ) {
566
+ $custom_fields = maybe_unserialize( $this->form_data['custom_fields'] );
567
+
568
+ if ( is_array( $custom_fields ) ) {
569
+ foreach ( $custom_fields as $k => $field ) {
570
+
571
+ if ( isset( $field['type'] ) ) {
572
+ if ( isset( $form[ $k ] ) ) {
573
+
574
+ switch ( $field['type'] ) {
575
+ default:
576
+ $form[ $k ] = apply_filters( 'um_sanitize_form_field', $form[ $k ], $field );
577
+ break;
578
+ case 'number':
579
+ $form[ $k ] = (int) $form[ $k ];
580
+ break;
581
+ case 'textarea':
582
+ if ( ! empty( $field['html'] ) ) {
583
+ $form[ $k ] = wp_kses_post( $form[ $k ] );
584
+ } else {
585
+ $form[ $k ] = sanitize_textarea_field( $form[ $k ] );
586
+ }
587
+ break;
588
+ case 'url':
589
+ $form[ $k ] = esc_url_raw( $form[ $k ] );
590
+ break;
591
+ case 'text':
592
+ case 'select':
593
+ case 'password':
594
+ case 'image':
595
+ case 'file':
596
+ case 'date':
597
+ case 'time':
598
+ case 'rating':
599
+ case 'googlemap':
600
+ case 'youtube_video':
601
+ case 'vimeo_video':
602
+ case 'soundcloud_track':
603
+ $form[ $k ] = sanitize_text_field( $form[ $k ] );
604
+ break;
605
+ case 'multiselect':
606
+ case 'radio':
607
+ case 'checkbox':
608
+ $form[ $k ] = array_map( 'sanitize_text_field', $form[ $k ] );
609
+ break;
610
+ }
611
+ }
612
+ }
613
+ }
614
+ }
615
+ }
616
+ }
617
+
618
+ return $form;
619
+ }
620
+
621
+
622
+ /**
623
+ * Display form type as Title
624
+ * @param string $mode
625
+ * @param integer $post_id
626
+ * @return string $output
627
+ */
628
+ public function display_form_type( $mode, $post_id ) {
629
+ $output = null;
630
+ switch ( $mode ) {
631
+ case 'login':
632
+ $output = __( 'Login', 'ultimate-member' );
633
+ break;
634
+ case 'profile':
635
+ $output = __( 'Profile', 'ultimate-member' );
636
+ break;
637
+ case 'register':
638
+ $output = __( 'Register', 'ultimate-member' );
639
+ break;
640
+ }
641
+ return $output;
642
+ }
643
+
644
+
645
+ /**
646
+ * Assigned roles to a form
647
+ * @param integer $post_id
648
+ * @return string $role
649
+ */
650
+ public function assigned_role( $post_id ) {
651
+
652
+ $global_role = get_option( 'default_role' ); // WP Global settings
653
+
654
+ $um_global_role = UM()->options()->get( 'register_role' ); // UM Settings Global settings
655
+ if ( ! empty( $um_global_role ) ) {
656
+ $global_role = $um_global_role; // Form Global settings
657
+ }
658
+
659
+ $mode = $this->form_type( $post_id );
660
+
661
+ /**
662
+ * @todo WPML integration to get role from original if it's empty
663
+ */
664
+ $use_custom = get_post_meta( $post_id, "_um_{$mode}_use_custom_settings", true );
665
+ if ( $use_custom ) { // Custom Form settings
666
+ $role = get_post_meta( $post_id, "_um_{$mode}_role", true );
667
+ }
668
+
669
+ if ( empty( $role ) ) { // custom role is default, return default role's slug
670
+ $role = $global_role;
671
+ }
672
+
673
+ return $role;
674
+ }
675
+
676
+
677
+ /**
678
+ * Get form type
679
+ * @param integer $post_id
680
+ * @return string
681
+ */
682
+ public function form_type( $post_id ) {
683
+ $mode = get_post_meta( $post_id, '_um_mode', true );
684
+ return $mode;
685
+ }
686
+
687
+
688
+ /**
689
+ * Get custom field roles
690
+ *
691
+ * @param string $custom_fields serialized
692
+ * @return bool|array roles
693
+ */
694
+ public function custom_field_roles( $custom_fields ) {
695
+
696
+ $fields = maybe_unserialize( $custom_fields );
697
+ if ( ! is_array( $fields ) ) {
698
+ return false;
699
+ }
700
+
701
+ // role field
702
+ global $wp_roles;
703
+ $role_keys = array_map(
704
+ function( $item ) {
705
+ return 'um_' . $item;
706
+ },
707
+ get_option( 'um_roles', array() )
708
+ );
709
+ $exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
710
+
711
+ $roles = UM()->roles()->get_roles( false, $exclude_roles );
712
+ $roles = array_map(
713
+ function( $item ) {
714
+ return html_entity_decode( $item, ENT_QUOTES );
715
+ },
716
+ $roles
717
+ );
718
+
719
+ foreach ( $fields as $field_key => $field_settings ) {
720
+
721
+ if ( strstr( $field_key, 'role_' ) && is_array( $field_settings['options'] ) ) {
722
+
723
+ if ( isset( $this->post_form['mode'] ) && 'profile' === $this->post_form['mode'] &&
724
+ isset( $field_settings['editable'] ) && $field_settings['editable'] == 0 ) {
725
+ continue;
726
+ }
727
+
728
+ if ( ! um_can_view_field( $field_settings ) ) {
729
+ continue;
730
+ }
731
+
732
+ $intersected_options = array();
733
+ foreach ( $field_settings['options'] as $key => $title ) {
734
+ if ( false !== $search_key = array_search( $title, $roles ) ) {
735
+ $intersected_options[ $search_key ] = $title;
736
+ } elseif ( isset( $roles[ $key ] ) ) {
737
+ $intersected_options[ $key ] = $title;
738
+ }
739
+ }
740
+
741
+ // getting roles only from the first role fields
742
+ return array_keys( $intersected_options );
743
+ }
744
+ }
745
+
746
+ return false;
747
+ }
748
+ }
749
+ }
includes/core/class-logout.php CHANGED
@@ -70,12 +70,12 @@ if ( ! class_exists( 'um\core\Logout' ) ) {
70
 
71
  add_filter( 'wp_safe_redirect_fallback', array( &$this, 'safe_redirect_default' ), 10, 2 );
72
 
73
- if ( isset( $_REQUEST['redirect_to'] ) && $_REQUEST['redirect_to'] !== '' ) {
74
  wp_destroy_current_session();
75
  wp_logout();
76
  session_unset();
77
- exit( wp_safe_redirect( $_REQUEST['redirect_to'] ) );
78
- } else if ( um_user('after_logout') == 'redirect_home' ) {
79
  wp_destroy_current_session();
80
  wp_logout();
81
  session_unset();
@@ -120,4 +120,4 @@ if ( ! class_exists( 'um\core\Logout' ) ) {
120
  }
121
 
122
  }
123
- }
70
 
71
  add_filter( 'wp_safe_redirect_fallback', array( &$this, 'safe_redirect_default' ), 10, 2 );
72
 
73
+ if ( isset( $_REQUEST['redirect_to'] ) && '' !== $_REQUEST['redirect_to'] ) {
74
  wp_destroy_current_session();
75
  wp_logout();
76
  session_unset();
77
+ exit( wp_safe_redirect( esc_url_raw( $_REQUEST['redirect_to'] ) ) );
78
+ } else if ( 'redirect_home' === um_user( 'after_logout' ) ) {
79
  wp_destroy_current_session();
80
  wp_logout();
81
  session_unset();
120
  }
121
 
122
  }
123
+ }
includes/core/class-member-directory-meta.php CHANGED
@@ -571,7 +571,7 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
571
 
572
 
573
  if ( ! empty( $_POST['search'] ) ) {
574
- $search_line = trim( stripslashes( $_POST['search'] ) );
575
 
576
  $searches = array();
577
  foreach ( $this->core_search_fields as $field ) {
@@ -582,7 +582,7 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
582
 
583
  $this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_search ON umm_search.user_id = u.ID";
584
 
585
- $additional_search = apply_filters( 'um_member_directory_meta_general_search_meta_query', '', stripslashes( $_POST['search'] ) );
586
 
587
  $search_like_string = apply_filters( 'um_member_directory_meta_search_like_type', '%' . $search_line . '%', $search_line );
588
 
@@ -610,6 +610,13 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
610
  $i = 1;
611
  foreach ( $filter_query as $field => $value ) {
612
 
 
 
 
 
 
 
 
613
  $attrs = UM()->fields()->get_field( $field );
614
  // skip private invisible fields
615
  if ( ! um_can_view_field( $attrs ) ) {
@@ -642,7 +649,7 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
642
  //}
643
 
644
  $order = 'ASC';
645
- $sortby = ! empty( $_POST['sorting'] ) ? $_POST['sorting'] : $directory_data['sortby'];
646
  $sortby = ( $sortby == 'other' ) ? $directory_data['sortby_custom'] : $sortby;
647
 
648
  $custom_sort = array();
@@ -666,6 +673,10 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
666
 
667
  $this->sql_order = " ORDER BY CAST( umm_sort.um_value AS {$custom_sort_type} ) {$order} ";
668
 
 
 
 
 
669
  } elseif ( 'display_name' == $sortby ) {
670
 
671
  $display_name = UM()->options()->get( 'display_name' );
@@ -755,7 +766,7 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
755
  }
756
 
757
  $query_number = ( ! empty( $directory_data['max_users'] ) && $directory_data['max_users'] <= $profiles_per_page ) ? $directory_data['max_users'] : $profiles_per_page;
758
- $query_paged = ! empty( $_POST['page'] ) ? $_POST['page'] : 1;
759
 
760
  $number = $query_number;
761
  if ( ! empty( $directory_data['max_users'] ) && $query_paged*$query_number > $directory_data['max_users'] ) {
@@ -850,4 +861,4 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
850
  wp_send_json_success( $member_directory_response );
851
  }
852
  }
853
- }
571
 
572
 
573
  if ( ! empty( $_POST['search'] ) ) {
574
+ $search_line = trim( stripslashes( sanitize_text_field( $_POST['search'] ) ) );
575
 
576
  $searches = array();
577
  foreach ( $this->core_search_fields as $field ) {
582
 
583
  $this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_search ON umm_search.user_id = u.ID";
584
 
585
+ $additional_search = apply_filters( 'um_member_directory_meta_general_search_meta_query', '', stripslashes( sanitize_text_field( $_POST['search'] ) ) );
586
 
587
  $search_like_string = apply_filters( 'um_member_directory_meta_search_like_type', '%' . $search_line . '%', $search_line );
588
 
610
  $i = 1;
611
  foreach ( $filter_query as $field => $value ) {
612
 
613
+ $field = sanitize_text_field( $field );
614
+ if ( is_array( $value ) ) {
615
+ $value = array_map( 'sanitize_text_field', $value );
616
+ } else {
617
+ $value = sanitize_text_field( $value );
618
+ }
619
+
620
  $attrs = UM()->fields()->get_field( $field );
621
  // skip private invisible fields
622
  if ( ! um_can_view_field( $attrs ) ) {
649
  //}
650
 
651
  $order = 'ASC';
652
+ $sortby = ! empty( $_POST['sorting'] ) ? sanitize_text_field( $_POST['sorting'] ) : $directory_data['sortby'];
653
  $sortby = ( $sortby == 'other' ) ? $directory_data['sortby_custom'] : $sortby;
654
 
655
  $custom_sort = array();
673
 
674
  $this->sql_order = " ORDER BY CAST( umm_sort.um_value AS {$custom_sort_type} ) {$order} ";
675
 
676
+ } elseif ( 'username' == $sortby ) {
677
+
678
+ $this->sql_order = " ORDER BY u.user_login {$order} ";
679
+
680
  } elseif ( 'display_name' == $sortby ) {
681
 
682
  $display_name = UM()->options()->get( 'display_name' );
766
  }
767
 
768
  $query_number = ( ! empty( $directory_data['max_users'] ) && $directory_data['max_users'] <= $profiles_per_page ) ? $directory_data['max_users'] : $profiles_per_page;
769
+ $query_paged = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
770
 
771
  $number = $query_number;
772
  if ( ! empty( $directory_data['max_users'] ) && $query_paged*$query_number > $directory_data['max_users'] ) {
861
  wp_send_json_success( $member_directory_response );
862
  }
863
  }
864
+ }
includes/core/class-member-directory.php CHANGED
@@ -199,41 +199,46 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
199
  *
200
  * @return array
201
  */
202
- function before_save_data( $value, $key, $post_id ) {
203
 
204
  $post = get_post( $post_id );
205
 
206
- if ( $post->post_type == 'um_directory' ) {
207
 
208
- if ( ! empty( $value ) && in_array( $key, array( '_um_view_types', '_um_roles', '_um_roles_can_search', '_um_roles_can_filter' ) ) ) {
209
  $value = array_keys( $value );
210
- } elseif ( $key == '_um_search_filters' ) {
211
 
212
  $temp_value = array();
213
 
214
  if ( ! empty( $value ) ) {
215
  foreach ( $value as $k ) {
216
  $filter_type = $this->filter_types[ $k ];
217
- if ( ! empty( $filter_type ) ) {
218
- if ( $filter_type == 'slider' ) {
219
  if ( ! empty( $_POST[ $k ] ) ) {
220
- $temp_value[ $k ] = $_POST[ $k ];
221
  }
222
- } elseif ( $filter_type == 'timepicker' || $filter_type == 'datepicker' ) {
223
  if ( ! empty( $_POST[ $k . '_from' ] ) && ! empty( $_POST[ $k . '_to' ] ) ) {
224
- $temp_value[ $k ] = array( $_POST[ $k . '_from' ], $_POST[ $k . '_to' ] );
 
 
 
225
  }
226
- } elseif ( $filter_type == 'select' ) {
227
  if ( ! empty( $_POST[ $k ] ) ) {
228
  if ( is_array( $_POST[ $k ] ) ) {
229
  $temp_value[ $k ] = array_map( 'trim', $_POST[ $k ] );
230
  } else {
231
  $temp_value[ $k ] = array( trim( $_POST[ $k ] ) );
232
  }
 
 
233
  }
234
  } else {
235
  if ( ! empty( $_POST[ $k ] ) ) {
236
- $temp_value[ $k ] = trim( $_POST[ $k ] );
237
  }
238
  }
239
  }
@@ -241,7 +246,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
241
  }
242
 
243
  $value = $temp_value;
244
- } elseif ( $key == '_um_sorting_fields' ) {
245
  if ( ! empty( $value['other_data'] ) ) {
246
  $other_data = $value['other_data'];
247
  unset( $value['other_data'] );
@@ -254,15 +259,15 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
254
  $metalabel = wp_strip_all_tags( $other_data[ $k ]['label'] );
255
  }
256
  $row = array(
257
- $metakey => ! empty( $metalabel ) ? $metalabel : $metakey
258
  );
259
  }
260
  }
261
  }
262
  }
263
- } elseif ( $key == '_um_sortby_custom' ) {
264
  $value = sanitize_text_field( $value );
265
- } elseif ( $key == '_um_sortby_custom_label' ) {
266
  $value = wp_strip_all_tags( $value );
267
  }
268
  }
@@ -518,7 +523,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
518
  break;
519
  }
520
  case 'text': {
521
- $filter_from_url = ! empty( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) ? $_GET[ 'filter_' . $filter . '_' . $unique_hash ] : $default_value; ?>
522
  <input type="text" autocomplete="off" id="<?php echo $filter; ?>" name="<?php echo $filter; ?>"
523
  placeholder="<?php esc_attr_e( stripslashes( $attrs['label'] ), 'ultimate-member' ); ?>"
524
  value="<?php echo esc_attr( $filter_from_url ) ?>" class="um-form-field"
@@ -1224,7 +1229,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
1224
  }
1225
 
1226
  $this->query_args['number'] = ( ! empty( $directory_data['max_users'] ) && $directory_data['max_users'] <= $profiles_per_page ) ? $directory_data['max_users'] : $profiles_per_page;
1227
- $this->query_args['paged'] = ! empty( $_POST['page'] ) ? $_POST['page'] : 1;
1228
  }
1229
 
1230
 
@@ -1236,7 +1241,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
1236
  function sorting_query( $directory_data ) {
1237
  // sort members by
1238
  $this->query_args['order'] = 'ASC';
1239
- $sortby = ! empty( $_POST['sorting'] ) ? $_POST['sorting'] : $directory_data['sortby'];
1240
  $sortby = ( $sortby == 'other' ) ? $directory_data['sortby_custom'] : $sortby;
1241
 
1242
  $custom_sort = array();
@@ -1250,7 +1255,12 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
1250
  }
1251
  }
1252
 
1253
- if ( 'display_name' == $sortby ) {
 
 
 
 
 
1254
 
1255
  $display_name = UM()->options()->get( 'display_name' );
1256
  if ( $display_name == 'username' ) {
@@ -1428,7 +1438,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
1428
  if ( ! empty( $_POST['search'] ) ) {
1429
  // complex using with change_meta_sql function
1430
 
1431
- $search = trim( stripslashes( $_POST['search'] ) );
1432
 
1433
  $meta_query = array(
1434
  'relation' => 'OR',
@@ -1446,7 +1456,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
1446
  ),
1447
  );
1448
 
1449
- $meta_query = apply_filters( 'um_member_directory_general_search_meta_query', $meta_query, stripslashes( $_POST['search'] ) );
1450
 
1451
  $this->query_args['meta_query'][] = $meta_query;
1452
 
@@ -1471,7 +1481,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
1471
  function change_meta_sql( $sql, $queries, $type, $primary_table, $primary_id_column, $context ) {
1472
  if ( ! empty( $_POST['search'] ) ) {
1473
  global $wpdb;
1474
- $search = trim( stripslashes( $_POST['search'] ) );
1475
  if ( ! empty( $search ) ) {
1476
 
1477
  $meta_value = '%' . $wpdb->esc_like( $search ) . '%';
@@ -1534,6 +1544,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
1534
  $filter_query = array();
1535
  if ( ! empty( $directory_data['search_fields'] ) ) {
1536
  $search_filters = maybe_unserialize( $directory_data['search_fields'] );
 
1537
  if ( ! empty( $search_filters ) && is_array( $search_filters ) ) {
1538
  $filter_query = array_intersect_key( $_POST, array_flip( $search_filters ) );
1539
  }
@@ -1548,6 +1559,12 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
1548
 
1549
  $this->is_search = true;
1550
  foreach ( $filter_query as $field => $value ) {
 
 
 
 
 
 
1551
 
1552
  $attrs = UM()->fields()->get_field( $field );
1553
  // skip private invisible fields
@@ -1660,6 +1677,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
1660
  'value' => $value,
1661
  'compare' => 'BETWEEN',
1662
  'inclusive' => true,
 
1663
  );
1664
 
1665
  break;
@@ -2066,7 +2084,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
2066
  */
2067
  function calculate_pagination( $directory_data, $total_users ) {
2068
 
2069
- $current_page = ! empty( $_POST['page'] ) ? $_POST['page'] : 1;
2070
 
2071
  $total_users = ( ! empty( $directory_data['max_users'] ) && $directory_data['max_users'] <= $total_users ) ? $directory_data['max_users'] : $total_users;
2072
 
@@ -2320,7 +2338,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
2320
  function pagination_changes( $user_query ) {
2321
  global $wpdb;
2322
 
2323
- $directory_id = $this->get_directory_by_hash( $_POST['directory_id'] );
2324
  $directory_data = UM()->query()->post_data( $directory_id );
2325
 
2326
  $qv = $user_query->query_vars;
@@ -2367,7 +2385,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
2367
 
2368
  global $wpdb;
2369
 
2370
- $directory_id = $this->get_directory_by_hash( $_POST['directory_id'] );
2371
  $directory_data = UM()->query()->post_data( $directory_id );
2372
 
2373
  //predefined result for user without capabilities to see other members
@@ -2619,4 +2637,4 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
2619
  wp_send_json_success( array( 'field_html' => $html ) );
2620
  }
2621
  }
2622
- }
199
  *
200
  * @return array
201
  */
202
+ public function before_save_data( $value, $key, $post_id ) {
203
 
204
  $post = get_post( $post_id );
205
 
206
+ if ( 'um_directory' === $post->post_type ) {
207
 
208
+ if ( ! empty( $value ) && in_array( $key, array( '_um_view_types', '_um_roles', '_um_roles_can_search', '_um_roles_can_filter' ), true ) ) {
209
  $value = array_keys( $value );
210
+ } elseif ( '_um_search_filters' === $key ) {
211
 
212
  $temp_value = array();
213
 
214
  if ( ! empty( $value ) ) {
215
  foreach ( $value as $k ) {
216
  $filter_type = $this->filter_types[ $k ];
217
+ if ( ! empty( $filter_type ) ) {
218
+ if ( 'slider' === $filter_type ) {
219
  if ( ! empty( $_POST[ $k ] ) ) {
220
+ $temp_value[ $k ] = (int) $_POST[ $k ];
221
  }
222
+ } elseif ( 'timepicker' === $filter_type || 'datepicker' === $filter_type ) {
223
  if ( ! empty( $_POST[ $k . '_from' ] ) && ! empty( $_POST[ $k . '_to' ] ) ) {
224
+ $temp_value[ $k ] = array(
225
+ sanitize_text_field( $_POST[ $k . '_from' ] ),
226
+ sanitize_text_field( $_POST[ $k . '_to' ] ),
227
+ );
228
  }
229
+ } elseif ( 'select' === $filter_type ) {
230
  if ( ! empty( $_POST[ $k ] ) ) {
231
  if ( is_array( $_POST[ $k ] ) ) {
232
  $temp_value[ $k ] = array_map( 'trim', $_POST[ $k ] );
233
  } else {
234
  $temp_value[ $k ] = array( trim( $_POST[ $k ] ) );
235
  }
236
+
237
+ $temp_value[ $k ] = array_map( 'sanitize_text_field', $temp_value[ $k ] );
238
  }
239
  } else {
240
  if ( ! empty( $_POST[ $k ] ) ) {
241
+ $temp_value[ $k ] = trim( sanitize_text_field( $_POST[ $k ] ) );
242
  }
243
  }
244
  }
246
  }
247
 
248
  $value = $temp_value;
249
+ } elseif ( '_um_sorting_fields' === $key ) {
250
  if ( ! empty( $value['other_data'] ) ) {
251
  $other_data = $value['other_data'];
252
  unset( $value['other_data'] );
259
  $metalabel = wp_strip_all_tags( $other_data[ $k ]['label'] );
260
  }
261
  $row = array(
262
+ $metakey => ! empty( $metalabel ) ? $metalabel : $metakey,
263
  );
264
  }
265
  }
266
  }
267
  }
268
+ } elseif ( '_um_sortby_custom' === $key ) {
269
  $value = sanitize_text_field( $value );
270
+ } elseif ( '_um_sortby_custom_label' === $key ) {
271
  $value = wp_strip_all_tags( $value );
272
  }
273
  }
523
  break;
524
  }
525
  case 'text': {
526
+ $filter_from_url = ! empty( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) ? sanitize_text_field( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) : $default_value; ?>
527
  <input type="text" autocomplete="off" id="<?php echo $filter; ?>" name="<?php echo $filter; ?>"
528
  placeholder="<?php esc_attr_e( stripslashes( $attrs['label'] ), 'ultimate-member' ); ?>"
529
  value="<?php echo esc_attr( $filter_from_url ) ?>" class="um-form-field"
1229
  }
1230
 
1231
  $this->query_args['number'] = ( ! empty( $directory_data['max_users'] ) && $directory_data['max_users'] <= $profiles_per_page ) ? $directory_data['max_users'] : $profiles_per_page;
1232
+ $this->query_args['paged'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
1233
  }
1234
 
1235
 
1241
  function sorting_query( $directory_data ) {
1242
  // sort members by
1243
  $this->query_args['order'] = 'ASC';
1244
+ $sortby = ! empty( $_POST['sorting'] ) ? sanitize_text_field( $_POST['sorting'] ) : $directory_data['sortby'];
1245
  $sortby = ( $sortby == 'other' ) ? $directory_data['sortby_custom'] : $sortby;
1246
 
1247
  $custom_sort = array();
1255
  }
1256
  }
1257
 
1258
+ if ( 'username' == $sortby ) {
1259
+
1260
+ $this->query_args['orderby'] = 'user_login';
1261
+ $this->query_args['order'] = 'ASC';
1262
+
1263
+ } elseif ( 'display_name' == $sortby ) {
1264
 
1265
  $display_name = UM()->options()->get( 'display_name' );
1266
  if ( $display_name == 'username' ) {
1438
  if ( ! empty( $_POST['search'] ) ) {
1439
  // complex using with change_meta_sql function
1440
 
1441
+ $search = trim( stripslashes( sanitize_text_field( $_POST['search'] ) ) );
1442
 
1443
  $meta_query = array(
1444
  'relation' => 'OR',
1456
  ),
1457
  );
1458
 
1459
+ $meta_query = apply_filters( 'um_member_directory_general_search_meta_query', $meta_query, stripslashes( sanitize_text_field( $_POST['search'] ) ) );
1460
 
1461
  $this->query_args['meta_query'][] = $meta_query;
1462
 
1481
  function change_meta_sql( $sql, $queries, $type, $primary_table, $primary_id_column, $context ) {
1482
  if ( ! empty( $_POST['search'] ) ) {
1483
  global $wpdb;
1484
+ $search = trim( stripslashes( sanitize_text_field( $_POST['search'] ) ) );
1485
  if ( ! empty( $search ) ) {
1486
 
1487
  $meta_value = '%' . $wpdb->esc_like( $search ) . '%';
1544
  $filter_query = array();
1545
  if ( ! empty( $directory_data['search_fields'] ) ) {
1546
  $search_filters = maybe_unserialize( $directory_data['search_fields'] );
1547
+
1548
  if ( ! empty( $search_filters ) && is_array( $search_filters ) ) {
1549
  $filter_query = array_intersect_key( $_POST, array_flip( $search_filters ) );
1550
  }
1559
 
1560
  $this->is_search = true;
1561
  foreach ( $filter_query as $field => $value ) {
1562
+ $field = sanitize_text_field( $field );
1563
+ if ( is_array( $value ) ) {
1564
+ $value = array_map( 'sanitize_text_field', $value );
1565
+ } else {
1566
+ $value = sanitize_text_field( $value );
1567
+ }
1568
 
1569
  $attrs = UM()->fields()->get_field( $field );
1570
  // skip private invisible fields
1677
  'value' => $value,
1678
  'compare' => 'BETWEEN',
1679
  'inclusive' => true,
1680
+ 'type' => 'NUMERIC',
1681
  );
1682
 
1683
  break;
2084
  */
2085
  function calculate_pagination( $directory_data, $total_users ) {
2086
 
2087
+ $current_page = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
2088
 
2089
  $total_users = ( ! empty( $directory_data['max_users'] ) && $directory_data['max_users'] <= $total_users ) ? $directory_data['max_users'] : $total_users;
2090
 
2338
  function pagination_changes( $user_query ) {
2339
  global $wpdb;
2340
 
2341
+ $directory_id = $this->get_directory_by_hash( sanitize_key( $_POST['directory_id'] ) );
2342
  $directory_data = UM()->query()->post_data( $directory_id );
2343
 
2344
  $qv = $user_query->query_vars;
2385
 
2386
  global $wpdb;
2387
 
2388
+ $directory_id = $this->get_directory_by_hash( sanitize_key( $_POST['directory_id'] ) );
2389
  $directory_data = UM()->query()->post_data( $directory_id );
2390
 
2391
  //predefined result for user without capabilities to see other members
2637
  wp_send_json_success( array( 'field_html' => $html ) );
2638
  }
2639
  }
2640
+ }
includes/core/class-options.php CHANGED
@@ -100,8 +100,9 @@ if ( ! class_exists( 'um\core\Options' ) ) {
100
  * @param $option_id
101
  */
102
  function remove( $option_id ) {
103
- if ( ! empty( $this->options[ $option_id ] ) )
104
  unset( $this->options[ $option_id ] );
 
105
 
106
  update_option( 'um_options', $this->options );
107
  }
@@ -157,4 +158,4 @@ if ( ! class_exists( 'um\core\Options' ) ) {
157
  }
158
 
159
  }
160
- }
100
  * @param $option_id
101
  */
102
  function remove( $option_id ) {
103
+ if ( ! empty( $this->options[ $option_id ] ) ) {
104
  unset( $this->options[ $option_id ] );
105
+ }
106
 
107
  update_option( 'um_options', $this->options );
108
  }
158
  }
159
 
160
  }
161
+ }
includes/core/class-password.php CHANGED
@@ -247,7 +247,7 @@ if ( ! class_exists( 'um\core\Password' ) ) {
247
  * @return bool
248
  */
249
  function is_reset_request() {
250
- if ( um_is_core_page( 'password-reset' ) && isset( $_POST['_um_password_reset'] ) == 1 ) {
251
  return true;
252
  }
253
 
@@ -262,7 +262,7 @@ if ( ! class_exists( 'um\core\Password' ) ) {
262
  * @return bool
263
  */
264
  function is_change_request() {
265
- if ( isset( $_POST['_um_account'] ) == 1 && isset( $_POST['_um_account_tab'] ) && $_POST['_um_account_tab'] == 'password' ) {
266
  return true;
267
  } elseif ( isset( $_POST['_um_password_change'] ) && $_POST['_um_password_change'] == 1 ) {
268
  return true;
@@ -275,12 +275,12 @@ if ( ! class_exists( 'um\core\Password' ) ) {
275
  /**
276
  * Password page form
277
  */
278
- function form_init() {
279
  if ( um_is_core_page( 'password-reset' ) ) {
280
  UM()->fields()->set_mode = 'password';
281
  }
282
 
283
- if ( um_is_core_page( 'password-reset' ) && isset( $_REQUEST['act'] ) && $_REQUEST['act'] == 'reset_password' ) {
284
  wp_fix_server_vars();
285
 
286
  $rp_cookie = 'wp-resetpass-' . COOKIEHASH;
@@ -292,7 +292,7 @@ if ( ! class_exists( 'um\core\Password' ) ) {
292
  exit;
293
  }
294
  $rp_login = $userdata->user_login;
295
- $rp_key = wp_unslash( $_GET['hash'] );
296
 
297
  $user = check_password_reset_key( $rp_key, $rp_login );
298
 
@@ -300,11 +300,11 @@ if ( ! class_exists( 'um\core\Password' ) ) {
300
  $this->setcookie( $rp_cookie, false );
301
  wp_redirect( add_query_arg( array( 'updated' => 'invalidkey' ), get_permalink() ) );
302
  } else {
303
- $value = sprintf( '%s:%s', $rp_login, wp_unslash( $_GET['hash'] ) );
304
  $this->setcookie( $rp_cookie, $value );
305
  wp_safe_redirect( remove_query_arg( array( 'hash', 'user_id' ) ) );
306
  }
307
-
308
  exit;
309
  }
310
 
@@ -381,7 +381,6 @@ if ( ! class_exists( 'um\core\Password' ) ) {
381
  do_action( 'um_reset_password_process_hook', UM()->form()->post_form );
382
 
383
  }
384
-
385
  }
386
 
387
  if ( $this->is_change_request() ) {
@@ -432,7 +431,6 @@ if ( ! class_exists( 'um\core\Password' ) ) {
432
  do_action( 'um_change_password_process_hook', UM()->form()->post_form );
433
 
434
  }
435
-
436
  }
437
  }
438
 
@@ -442,26 +440,25 @@ if ( ! class_exists( 'um\core\Password' ) ) {
442
  *
443
  * @param $args
444
  */
445
- function um_reset_password_errors_hook( $args ) {
446
-
447
- if ( $_POST[ UM()->honeypot ] != '' ) {
448
- wp_die( __( 'Hello, spam bot!', 'ultimate-member' ) );
449
  }
450
 
451
- $user = "";
452
 
453
- foreach ( $_POST as $key => $val ) {
454
- if ( strstr( $key, "username_b") ) {
455
- $user = trim( $val );
456
  }
457
  }
458
 
459
  if ( empty( $user ) ) {
460
- UM()->form()->add_error('username_b', __( 'Please provide your username or email', 'ultimate-member' ) );
461
  }
462
 
463
  if ( ( ! is_email( $user ) && ! username_exists( $user ) ) || ( is_email( $user ) && ! email_exists( $user ) ) ) {
464
- UM()->form()->add_error('username_b', __( 'We can\'t find an account registered with that address or username','ultimate-member') );
465
  } else {
466
 
467
  if ( is_email( $user ) ) {
@@ -471,21 +468,19 @@ if ( ! class_exists( 'um\core\Password' ) ) {
471
  }
472
 
473
  $attempts = (int) get_user_meta( $user_id, 'password_rst_attempts', true );
474
- $is_admin = user_can( absint( $user_id ),'manage_options' );
475
 
476
  if ( UM()->options()->get( 'enable_reset_password_limit' ) ) { // if reset password limit is set
477
 
478
- if ( UM()->options()->get( 'disable_admin_reset_password_limit' ) && $is_admin ) {
479
- // Triggers this when a user has admin capabilities and when reset password limit is disabled for admins
480
- } else {
481
  $limit = UM()->options()->get( 'reset_password_limit_number' );
482
  if ( $attempts >= $limit ) {
483
- UM()->form()->add_error( 'username_b', __( 'You have reached the limit for requesting password change for this user already. Contact support if you cannot open the email','ultimate-member') );
484
  } else {
485
  update_user_meta( $user_id, 'password_rst_attempts', $attempts + 1 );
486
  }
487
  }
488
-
489
  }
490
  }
491
 
@@ -497,12 +492,12 @@ if ( ! class_exists( 'um\core\Password' ) ) {
497
  *
498
  * @param $args
499
  */
500
- function um_reset_password_process_hook( $args ) {
501
  $user = null;
502
 
503
- foreach ( $_POST as $key => $val ) {
504
- if ( strstr( $key, "username_b" ) ) {
505
- $user = trim( $val );
506
  }
507
  }
508
 
@@ -525,20 +520,27 @@ if ( ! class_exists( 'um\core\Password' ) ) {
525
  *
526
  * @param $args
527
  */
528
- function um_change_password_errors_hook( $args ) {
529
- if ( isset( $_POST[ UM()->honeypot ] ) && $_POST[ UM()->honeypot ] != '' ) {
530
- wp_die( __( 'Hello, spam bot!', 'ultimate-member' ) );
531
  }
532
 
533
  if ( ! is_user_logged_in() && isset( $args ) && ! um_is_core_page( 'password-reset' ) ||
534
- is_user_logged_in() && isset( $args['user_id'] ) && $args['user_id'] != get_current_user_id() ) {
535
- wp_die( __( 'This is not possible for security reasons.', 'ultimate-member' ) );
536
  }
537
 
538
  if ( isset( $args['user_password'] ) && empty( $args['user_password'] ) ) {
539
  UM()->form()->add_error( 'user_password', __( 'You must enter a new password', 'ultimate-member' ) );
540
  }
541
 
 
 
 
 
 
 
 
542
  if ( UM()->options()->get( 'reset_require_strongpass' ) ) {
543
 
544
  if ( strlen( utf8_decode( $args['user_password'] ) ) < 8 ) {
@@ -552,14 +554,13 @@ if ( ! class_exists( 'um\core\Password' ) ) {
552
  if ( ! UM()->validation()->strong_pass( $args['user_password'] ) ) {
553
  UM()->form()->add_error( 'user_password', __( 'Your password must contain at least one lowercase letter, one capital letter and one number', 'ultimate-member' ) );
554
  }
555
-
556
  }
557
 
558
  if ( isset( $args['confirm_user_password'] ) && empty( $args['confirm_user_password'] ) ) {
559
  UM()->form()->add_error( 'confirm_user_password', __( 'You must confirm your new password', 'ultimate-member' ) );
560
  }
561
 
562
- if ( isset( $args['user_password'] ) && isset( $args['confirm_user_password'] ) && $args['user_password'] != $args['confirm_user_password'] ) {
563
  UM()->form()->add_error( 'confirm_user_password', __( 'Your passwords do not match', 'ultimate-member' ) );
564
  }
565
 
@@ -571,13 +572,11 @@ if ( ! class_exists( 'um\core\Password' ) ) {
571
  *
572
  * @param $args
573
  */
574
- function um_change_password_process_hook( $args ) {
575
- extract( $args );
576
-
577
- if ( isset( $_POST['_um_password_change'] ) && $_POST['_um_password_change'] == 1 ) {
578
 
579
  $rp_cookie = 'wp-resetpass-' . COOKIEHASH;
580
- $user = get_userdata( $args['user_id'] );
581
 
582
  if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
583
  list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
@@ -586,7 +585,7 @@ if ( ! class_exists( 'um\core\Password' ) ) {
586
  $user = false;
587
  } else {
588
  $user = check_password_reset_key( $rp_key, $rp_login );
589
- if ( isset( $_POST['user_password'] ) && ! hash_equals( $rp_key, $_POST['rp_key'] ) ) {
590
  $user = false;
591
  }
592
  }
@@ -617,7 +616,7 @@ if ( ! class_exists( 'um\core\Password' ) ) {
617
  do_action( 'validate_password_reset', $errors, $user );
618
 
619
  if ( ( ! $errors->get_error_code() ) ) {
620
- reset_password( $user, $args['user_password'] );
621
 
622
  // send the Password Changed Email
623
  UM()->user()->password_changed();
@@ -653,9 +652,9 @@ if ( ! class_exists( 'um\core\Password' ) ) {
653
  * }
654
  * ?>
655
  */
656
- do_action( 'um_after_changing_user_password', $args['user_id'] );
657
 
658
- exit( wp_redirect( um_get_core_page('login', 'password_changed' ) ) );
659
  }
660
  }
661
  }
@@ -714,4 +713,4 @@ if ( ! class_exists( 'um\core\Password' ) ) {
714
  return $replace_placeholders;
715
  }
716
  }
717
- }
247
  * @return bool
248
  */
249
  function is_reset_request() {
250
+ if ( um_is_core_page( 'password-reset' ) && isset( $_POST['_um_password_reset'] ) ) {
251
  return true;
252
  }
253
 
262
  * @return bool
263
  */
264
  function is_change_request() {
265
+ if ( isset( $_POST['_um_account'] ) == 1 && isset( $_POST['_um_account_tab'] ) && sanitize_key( $_POST['_um_account_tab'] ) === 'password' ) {
266
  return true;
267
  } elseif ( isset( $_POST['_um_password_change'] ) && $_POST['_um_password_change'] == 1 ) {
268
  return true;
275
  /**
276
  * Password page form
277
  */
278
+ public function form_init() {
279
  if ( um_is_core_page( 'password-reset' ) ) {
280
  UM()->fields()->set_mode = 'password';
281
  }
282
 
283
+ if ( um_is_core_page( 'password-reset' ) && isset( $_REQUEST['act'] ) && 'reset_password' === sanitize_key( $_REQUEST['act'] ) ) {
284
  wp_fix_server_vars();
285
 
286
  $rp_cookie = 'wp-resetpass-' . COOKIEHASH;
292
  exit;
293
  }
294
  $rp_login = $userdata->user_login;
295
+ $rp_key = wp_unslash( sanitize_text_field( $_GET['hash'] ) );
296
 
297
  $user = check_password_reset_key( $rp_key, $rp_login );
298
 
300
  $this->setcookie( $rp_cookie, false );
301
  wp_redirect( add_query_arg( array( 'updated' => 'invalidkey' ), get_permalink() ) );
302
  } else {
303
+ $value = sprintf( '%s:%s', $rp_login, wp_unslash( sanitize_text_field( $_GET['hash'] ) ) );
304
  $this->setcookie( $rp_cookie, $value );
305
  wp_safe_redirect( remove_query_arg( array( 'hash', 'user_id' ) ) );
306
  }
307
+
308
  exit;
309
  }
310
 
381
  do_action( 'um_reset_password_process_hook', UM()->form()->post_form );
382
 
383
  }
 
384
  }
385
 
386
  if ( $this->is_change_request() ) {
431
  do_action( 'um_change_password_process_hook', UM()->form()->post_form );
432
 
433
  }
 
434
  }
435
  }
436
 
440
  *
441
  * @param $args
442
  */
443
+ public function um_reset_password_errors_hook( $args ) {
444
+ if ( '' !== $args[ UM()->honeypot ] ) {
445
+ wp_die( esc_html__( 'Hello, spam bot!', 'ultimate-member' ) );
 
446
  }
447
 
448
+ $user = '';
449
 
450
+ foreach ( $args as $key => $val ) {
451
+ if ( strstr( $key, 'username_b' ) ) {
452
+ $user = trim( sanitize_text_field( $val ) );
453
  }
454
  }
455
 
456
  if ( empty( $user ) ) {
457
+ UM()->form()->add_error( 'username_b', __( 'Please provide your username or email', 'ultimate-member' ) );
458
  }
459
 
460
  if ( ( ! is_email( $user ) && ! username_exists( $user ) ) || ( is_email( $user ) && ! email_exists( $user ) ) ) {
461
+ UM()->form()->add_error( 'username_b', __( 'We can\'t find an account registered with that address or username', 'ultimate-member' ) );
462
  } else {
463
 
464
  if ( is_email( $user ) ) {
468
  }
469
 
470
  $attempts = (int) get_user_meta( $user_id, 'password_rst_attempts', true );
471
+ $is_admin = user_can( absint( $user_id ), 'manage_options' );
472
 
473
  if ( UM()->options()->get( 'enable_reset_password_limit' ) ) { // if reset password limit is set
474
 
475
+ if ( ! ( UM()->options()->get( 'disable_admin_reset_password_limit' ) && $is_admin ) ) {
476
+ // Doesn't trigger this when a user has admin capabilities and when reset password limit is disabled for admins
 
477
  $limit = UM()->options()->get( 'reset_password_limit_number' );
478
  if ( $attempts >= $limit ) {
479
+ UM()->form()->add_error( 'username_b', __( 'You have reached the limit for requesting password change for this user already. Contact support if you cannot open the email', 'ultimate-member' ) );
480
  } else {
481
  update_user_meta( $user_id, 'password_rst_attempts', $attempts + 1 );
482
  }
483
  }
 
484
  }
485
  }
486
 
492
  *
493
  * @param $args
494
  */
495
+ public function um_reset_password_process_hook( $args ) {
496
  $user = null;
497
 
498
+ foreach ( $args as $key => $val ) {
499
+ if ( strstr( $key, 'username_b' ) ) {
500
+ $user = trim( sanitize_text_field( $val ) );
501
  }
502
  }
503
 
520
  *
521
  * @param $args
522
  */
523
+ public function um_change_password_errors_hook( $args ) {
524
+ if ( isset( $args[ UM()->honeypot ] ) && '' !== $args[ UM()->honeypot ] ) {
525
+ wp_die( esc_html__( 'Hello, spam bot!', 'ultimate-member' ) );
526
  }
527
 
528
  if ( ! is_user_logged_in() && isset( $args ) && ! um_is_core_page( 'password-reset' ) ||
529
+ is_user_logged_in() && isset( $args['user_id'] ) && absint( $args['user_id'] ) !== get_current_user_id() ) {
530
+ wp_die( esc_html__( 'This is not possible for security reasons.', 'ultimate-member' ) );
531
  }
532
 
533
  if ( isset( $args['user_password'] ) && empty( $args['user_password'] ) ) {
534
  UM()->form()->add_error( 'user_password', __( 'You must enter a new password', 'ultimate-member' ) );
535
  }
536
 
537
+ if ( isset( $args['user_password'] ) ) {
538
+ $args['user_password'] = sanitize_text_field( $args['user_password'] );
539
+ }
540
+ if ( isset( $args['confirm_user_password'] ) ) {
541
+ $args['confirm_user_password'] = sanitize_text_field( $args['confirm_user_password'] );
542
+ }
543
+
544
  if ( UM()->options()->get( 'reset_require_strongpass' ) ) {
545
 
546
  if ( strlen( utf8_decode( $args['user_password'] ) ) < 8 ) {
554
  if ( ! UM()->validation()->strong_pass( $args['user_password'] ) ) {
555
  UM()->form()->add_error( 'user_password', __( 'Your password must contain at least one lowercase letter, one capital letter and one number', 'ultimate-member' ) );
556
  }
 
557
  }
558
 
559
  if ( isset( $args['confirm_user_password'] ) && empty( $args['confirm_user_password'] ) ) {
560
  UM()->form()->add_error( 'confirm_user_password', __( 'You must confirm your new password', 'ultimate-member' ) );
561
  }
562
 
563
+ if ( isset( $args['user_password'] ) && isset( $args['confirm_user_password'] ) && $args['user_password'] !== $args['confirm_user_password'] ) {
564
  UM()->form()->add_error( 'confirm_user_password', __( 'Your passwords do not match', 'ultimate-member' ) );
565
  }
566
 
572
  *
573
  * @param $args
574
  */
575
+ public function um_change_password_process_hook( $args ) {
576
+ if ( isset( $args['_um_password_change'] ) && $args['_um_password_change'] == 1 ) {
 
 
577
 
578
  $rp_cookie = 'wp-resetpass-' . COOKIEHASH;
579
+ $user = get_userdata( absint( $args['user_id'] ) );
580
 
581
  if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
582
  list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
585
  $user = false;
586
  } else {
587
  $user = check_password_reset_key( $rp_key, $rp_login );
588
+ if ( isset( $args['user_password'] ) && ! hash_equals( $rp_key, $args['rp_key'] ) ) {
589
  $user = false;
590
  }
591
  }
616
  do_action( 'validate_password_reset', $errors, $user );
617
 
618
  if ( ( ! $errors->get_error_code() ) ) {
619
+ reset_password( $user, sanitize_text_field( $args['user_password'] ) );
620
 
621
  // send the Password Changed Email
622
  UM()->user()->password_changed();
652
  * }
653
  * ?>
654
  */
655
+ do_action( 'um_after_changing_user_password', absint( $args['user_id'] ) );
656
 
657
+ exit( wp_redirect( um_get_core_page( 'login', 'password_changed' ) ) );
658
  }
659
  }
660
  }
713
  return $replace_placeholders;
714
  }
715
  }
716
+ }
includes/core/class-permalinks.php CHANGED
@@ -175,15 +175,15 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) {
175
  /**
176
  * Activates an account via email
177
  */
178
- function activate_account_via_email_link() {
179
- if ( isset( $_REQUEST['act'] ) && $_REQUEST['act'] == 'activate_via_email' && isset( $_REQUEST['hash'] ) && is_string( $_REQUEST['hash'] ) && strlen( $_REQUEST['hash'] ) == 40 &&
180
  isset( $_REQUEST['user_id'] ) && is_numeric( $_REQUEST['user_id'] ) ) { // valid token
181
 
182
  $user_id = absint( $_REQUEST['user_id'] );
183
  delete_option( "um_cache_userdata_{$user_id}" );
184
 
185
  $account_secret_hash = get_user_meta( $user_id, 'account_secret_hash', true );
186
- if ( empty( $account_secret_hash ) || strtolower( $_REQUEST['hash'] ) !== strtolower( $account_secret_hash ) ) {
187
  wp_die( __( 'This activation link is expired or have already been used.', 'ultimate-member' ) );
188
  }
189
 
@@ -536,4 +536,4 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) {
536
  return $url;
537
  }
538
  }
539
- }
175
  /**
176
  * Activates an account via email
177
  */
178
+ public function activate_account_via_email_link() {
179
+ if ( isset( $_REQUEST['act'] ) && 'activate_via_email' === sanitize_key( $_REQUEST['act'] ) && isset( $_REQUEST['hash'] ) && is_string( $_REQUEST['hash'] ) && strlen( $_REQUEST['hash'] ) == 40 &&
180
  isset( $_REQUEST['user_id'] ) && is_numeric( $_REQUEST['user_id'] ) ) { // valid token
181
 
182
  $user_id = absint( $_REQUEST['user_id'] );
183
  delete_option( "um_cache_userdata_{$user_id}" );
184
 
185
  $account_secret_hash = get_user_meta( $user_id, 'account_secret_hash', true );
186
+ if ( empty( $account_secret_hash ) || strtolower( sanitize_text_field( $_REQUEST['hash'] ) ) !== strtolower( $account_secret_hash ) ) {
187
  wp_die( __( 'This activation link is expired or have already been used.', 'ultimate-member' ) );
188
  }
189
 
536
  return $url;
537
  }
538
  }
539
+ }
includes/core/class-profile.php CHANGED
@@ -55,16 +55,17 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
55
  /**
56
  * Delete profile avatar AJAX handler
57
  */
58
- function ajax_delete_profile_photo() {
59
  UM()->check_ajax_nonce();
60
 
61
- /**
62
- * @var $user_id
63
- */
64
- extract( $_REQUEST );
 
65
 
66
  if ( ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
67
- die( __( 'You can not edit this user' ) );
68
  }
69
 
70
  UM()->files()->delete_core_user_photo( $user_id, 'profile_photo' );
@@ -74,16 +75,17 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
74
  /**
75
  * Delete cover photo AJAX handler
76
  */
77
- function ajax_delete_cover_photo() {
78
  UM()->check_ajax_nonce();
79
 
80
- /**
81
- * @var $user_id
82
- */
83
- extract( $_REQUEST );
 
84
 
85
  if ( ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
86
- die( __( 'You can not edit this user' ) );
87
  }
88
 
89
  UM()->files()->delete_core_user_photo( $user_id, 'cover_photo' );
@@ -95,15 +97,18 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
95
  *
96
  * @return array
97
  */
98
- function tabs_privacy() {
99
- $privacy = apply_filters( 'um_profile_tabs_privacy_list', array(
100
- 0 => __( 'Anyone', 'ultimate-member' ),
101
- 1 => __( 'Guests only', 'ultimate-member' ),
102
- 2 => __( 'Members only', 'ultimate-member' ),
103
- 3 => __( 'Only the owner', 'ultimate-member' ),
104
- 4 => __( 'Only specific roles', 'ultimate-member' ),
105
- 5 => __( 'Owner and specific roles', 'ultimate-member' ),
106
- ) );
 
 
 
107
 
108
  return $privacy;
109
  }
@@ -505,4 +510,4 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
505
  }
506
 
507
  }
508
- }
55
  /**
56
  * Delete profile avatar AJAX handler
57
  */
58
+ public function ajax_delete_profile_photo() {
59
  UM()->check_ajax_nonce();
60
 
61
+ if ( ! array_key_exists( 'user_id', $_REQUEST ) ) {
62
+ wp_send_json_error( __( 'Invalid data', 'ultimate-member' ) );
63
+ }
64
+
65
+ $user_id = absint( $_REQUEST['user_id'] );
66
 
67
  if ( ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
68
+ die( esc_html__( 'You can not edit this user', 'ultimate-member' ) );
69
  }
70
 
71
  UM()->files()->delete_core_user_photo( $user_id, 'profile_photo' );
75
  /**
76
  * Delete cover photo AJAX handler
77
  */
78
+ public function ajax_delete_cover_photo() {
79
  UM()->check_ajax_nonce();
80
 
81
+ if ( ! array_key_exists( 'user_id', $_REQUEST ) ) {
82
+ wp_send_json_error( __( 'Invalid data', 'ultimate-member' ) );
83
+ }
84
+
85
+ $user_id = absint( $_REQUEST['user_id'] );
86
 
87
  if ( ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
88
+ die( esc_html__( 'You can not edit this user', 'ultimate-member' ) );
89
  }
90
 
91
  UM()->files()->delete_core_user_photo( $user_id, 'cover_photo' );
97
  *
98
  * @return array
99
  */
100
+ public function tabs_privacy() {
101
+ $privacy = apply_filters(
102
+ 'um_profile_tabs_privacy_list',
103
+ array(
104
+ 0 => __( 'Anyone', 'ultimate-member' ),
105
+ 1 => __( 'Guests only', 'ultimate-member' ),
106
+ 2 => __( 'Members only', 'ultimate-member' ),
107
+ 3 => __( 'Only the owner', 'ultimate-member' ),
108
+ 4 => __( 'Only specific roles', 'ultimate-member' ),
109
+ 5 => __( 'Owner and specific roles', 'ultimate-member' ),
110
+ )
111
+ );
112
 
113
  return $privacy;
114
  }
510
  }
511
 
512
  }
513
+ }
includes/core/class-query.php CHANGED
@@ -29,7 +29,7 @@ if ( ! class_exists( 'um\core\Query' ) ) {
29
  /**
30
  * Query constructor.
31
  */
32
- function __construct() {
33
 
34
 
35
  }
@@ -38,7 +38,7 @@ if ( ! class_exists( 'um\core\Query' ) ) {
38
  /**
39
  * Ajax pagination for posts
40
  */
41
- function ajax_paginate() {
42
  UM()->check_ajax_nonce();
43
 
44
  /**
29
  /**
30
  * Query constructor.
31
  */
32
+ public function __construct() {
33
 
34
 
35
  }
38
  /**
39
  * Ajax pagination for posts
40
  */
41
+ public function ajax_paginate() {
42
  UM()->check_ajax_nonce();
43
 
44
  /**
includes/core/class-roles-capabilities.php CHANGED
@@ -382,21 +382,25 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
382
  function get_priority_user_role( $user_id ) {
383
  $user = get_userdata( $user_id );
384
 
385
- if ( empty( $user->roles ) )
386
  return false;
 
387
 
388
  // User has roles so look for a UM Role one
389
  $um_roles_keys = get_option( 'um_roles', array() );
390
 
391
  if ( ! empty( $um_roles_keys ) ) {
392
- $um_roles_keys = array_map( function( $item ) {
393
- return 'um_' . $item;
394
- }, $um_roles_keys );
 
 
 
395
  }
396
 
397
  $orders = array();
398
  foreach ( array_values( $user->roles ) as $userrole ) {
399
- if ( ! empty( $um_roles_keys ) && in_array( $userrole, $um_roles_keys ) ) {
400
  $userrole_metakey = substr( $userrole, 3 );
401
  } else {
402
  $userrole_metakey = $userrole;
@@ -727,4 +731,4 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
727
  return false;
728
  }
729
  }
730
- }
382
  function get_priority_user_role( $user_id ) {
383
  $user = get_userdata( $user_id );
384
 
385
+ if ( empty( $user->roles ) ) {
386
  return false;
387
+ }
388
 
389
  // User has roles so look for a UM Role one
390
  $um_roles_keys = get_option( 'um_roles', array() );
391
 
392
  if ( ! empty( $um_roles_keys ) ) {
393
+ $um_roles_keys = array_map(
394
+ function( $item ) {
395
+ return 'um_' . $item;
396
+ },
397
+ $um_roles_keys
398
+ );
399
  }
400
 
401
  $orders = array();
402
  foreach ( array_values( $user->roles ) as $userrole ) {
403
+ if ( ! empty( $um_roles_keys ) && in_array( $userrole, $um_roles_keys, true ) ) {
404
  $userrole_metakey = substr( $userrole, 3 );
405
  } else {
406
  $userrole_metakey = $userrole;
731
  return false;
732
  }
733
  }
734
+ }
includes/core/class-shortcodes.php CHANGED
@@ -161,18 +161,16 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
161
  */
162
  function parse_shortcode_args( $args ) {
163
  if ( $this->message_mode == true ) {
164
-
165
  if ( ! empty( $_REQUEST['um_role'] ) ) {
166
  $args['template'] = 'message';
167
- $roleID = esc_attr( $_REQUEST['um_role'] );
168
  $role = UM()->roles()->role_data( $roleID );
169
 
170
- if ( ! empty( $role ) && ! empty( $role["status"] ) ) {
171
- $message_key = $role["status"] . '_message';
172
  $this->custom_message = ! empty( $role[ $message_key ] ) ? stripslashes( $role[ $message_key ] ) : '';
173
  }
174
  }
175
-
176
  }
177
 
178
  foreach ( $args as $k => $v ) {
@@ -676,7 +674,7 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
676
  extract( $args, EXTR_SKIP );
677
 
678
  //not display on admin preview
679
- if ( empty( $_POST['act_id'] ) || $_POST['act_id'] != 'um_admin_preview_form' ) {
680
 
681
  $enable_loggedin_registration = apply_filters( 'um_registration_for_loggedin_users', false, $args );
682
 
@@ -1266,7 +1264,7 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
1266
 
1267
  $hash = UM()->member_directory()->get_directory_hash( $directory_id );
1268
 
1269
- $query[ 'search_' . $hash ] = ! empty( $_GET[ 'search_' . $hash ] ) ? $_GET[ 'search_' . $hash ] : '';
1270
  }
1271
 
1272
  if ( empty( $query ) ) {
161
  */
162
  function parse_shortcode_args( $args ) {
163
  if ( $this->message_mode == true ) {
 
164
  if ( ! empty( $_REQUEST['um_role'] ) ) {
165
  $args['template'] = 'message';
166
+ $roleID = sanitize_key( $_REQUEST['um_role'] );
167
  $role = UM()->roles()->role_data( $roleID );
168
 
169
+ if ( ! empty( $role ) && ! empty( $role['status'] ) ) {
170
+ $message_key = $role['status'] . '_message';
171
  $this->custom_message = ! empty( $role[ $message_key ] ) ? stripslashes( $role[ $message_key ] ) : '';
172
  }
173
  }
 
174
  }
175
 
176
  foreach ( $args as $k => $v ) {
674
  extract( $args, EXTR_SKIP );
675
 
676
  //not display on admin preview
677
+ if ( empty( $_POST['act_id'] ) || sanitize_key( $_POST['act_id'] ) !== 'um_admin_preview_form' ) {
678
 
679
  $enable_loggedin_registration = apply_filters( 'um_registration_for_loggedin_users', false, $args );
680
 
1264
 
1265
  $hash = UM()->member_directory()->get_directory_hash( $directory_id );
1266
 
1267
+ $query[ 'search_' . $hash ] = ! empty( $_GET[ 'search_' . $hash ] ) ? sanitize_text_field( $_GET[ 'search_' . $hash ] ) : '';
1268
  }
1269
 
1270
  if ( empty( $query ) ) {
includes/core/class-user-posts.php CHANGED
@@ -103,8 +103,8 @@ if ( ! class_exists( 'um\core\User_posts' ) ) {
103
  function load_posts() {
104
  UM()->check_ajax_nonce();
105
 
106
- $author = ! empty( $_POST['author'] ) ? $_POST['author'] : get_current_user_id();
107
- $page = ! empty( $_POST['page'] ) ? $_POST['page'] : 0;
108
 
109
  $args = array(
110
  'post_type' => 'post',
@@ -244,4 +244,4 @@ if ( ! class_exists( 'um\core\User_posts' ) ) {
244
  }
245
 
246
  }
247
- }
103
  function load_posts() {
104
  UM()->check_ajax_nonce();
105
 
106
+ $author = ! empty( $_POST['author'] ) ? absint( $_POST['author'] ) : get_current_user_id();
107
+ $page = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 0;
108
 
109
  $args = array(
110
  'post_type' => 'post',
244
  }
245
 
246
  }
247
+ }
includes/core/class-user.php CHANGED
@@ -1,2177 +1,2177 @@
1
- <?php
2
- namespace um\core;
3
-
4
- // Exit if accessed directly
5
- if ( ! defined( 'ABSPATH' ) ) exit;
6
-
7
-
8
- if ( ! class_exists( 'um\core\User' ) ) {
9
-
10
-
11
- /**
12
- * Class User
13
- * @package um\core
14
- */
15
- class User {
16
-
17
-
18
- /**
19
- * User constructor.
20
- */
21
- function __construct() {
22
-
23
- $this->id = 0;
24
- $this->usermeta = null;
25
- $this->data = null;
26
- $this->profile = null;
27
- $this->cannot_edit = null;
28
- $this->password_reset_key = null;
29
-
30
- global $wpdb;
31
-
32
- $this->banned_keys = array(
33
- 'metabox','postbox','meta-box',
34
- 'dismissed_wp_pointers', 'session_tokens',
35
- 'screen_layout', 'wp_user-', 'dismissed',
36
- 'cap_key', $wpdb->get_blog_prefix(). 'capabilities',
37
- 'managenav', 'nav_menu', 'user_activation_key',
38
- 'level_', $wpdb->get_blog_prefix() . 'user_level'
39
- );
40
-
41
- add_action( 'init', array( &$this, 'set' ), 1 );
42
-
43
- $this->preview = false;
44
- $this->send_mail_on_delete = true;
45
-
46
- // a list of keys that should never be in wp_usermeta
47
- $this->update_user_keys = array(
48
- 'user_email',
49
- 'user_pass',
50
- 'user_password',
51
- 'display_name',
52
- 'user_url',
53
- 'role',
54
- );
55
-
56
- $this->target_id = null;
57
-
58
- // When the cache should be cleared
59
- add_action( 'um_delete_user_hook', array( &$this, 'remove_cached_queue' ) );
60
- add_action( 'um_delete_user', array( &$this, 'remove_cache' ), 10, 1 );
61
-
62
- add_action( 'um_after_user_status_is_changed_hook', array( &$this, 'remove_cached_queue' ) );
63
-
64
- // When user cache should be cleared
65
- add_action( 'um_after_user_updated', array( &$this, 'remove_cache' ) );
66
- add_action( 'um_after_user_account_updated', array( &$this, 'remove_cache' ) );
67
- add_action( 'personal_options_update', array( &$this, 'remove_cache' ) );
68
- //add_action('edit_user_profile_update', array(&$this, 'remove_cache') );
69
- add_action( 'um_when_role_is_set', array( &$this, 'remove_cache' ) );
70
- add_action( 'um_when_status_is_set', array( &$this, 'remove_cache' ) );
71
-
72
- add_action( 'show_user_profile', array( $this, 'profile_form_additional_section' ), 10 );
73
- add_action( 'user_new_form', array( $this, 'profile_form_additional_section' ), 10 );
74
- add_action( 'edit_user_profile', array( $this, 'profile_form_additional_section' ), 10 );
75
- add_filter( 'um_user_profile_additional_fields', array( $this, 'secondary_role_field' ), 1, 2 );
76
-
77
- //on every update of user profile (hook from wp_update_user)
78
- add_action( 'profile_update', array( &$this, 'profile_update' ), 10, 2 ); // user_id and old_user_data
79
-
80
- //on user update profile page
81
- //add_action( 'edit_user_profile_update', array( &$this, 'profile_update' ), 10, 1 );
82
-
83
- add_action( 'user_register', array( &$this, 'user_register_via_admin' ), 10, 1 );
84
- add_action( 'user_register', array( &$this, 'set_gravatar' ), 11, 1 );
85
-
86
-
87
- if ( is_multisite() ) {
88
- add_action( 'added_existing_user', array( &$this, 'add_um_role_existing_user' ), 10, 2 );
89
- add_action( 'wpmu_activate_user', array( &$this, 'add_um_role_wpmu_new_user' ), 10, 1 );
90
- }
91
-
92
- add_action( 'init', array( &$this, 'check_membership' ), 10 );
93
-
94
- if ( is_multisite() ) {
95
- add_action( 'wpmu_delete_user', array( &$this, 'delete_user_handler' ), 10, 1 );
96
- } else {
97
- add_action( 'delete_user', array( &$this, 'delete_user_handler' ), 10, 1 );
98
- }
99
-
100
-
101
- add_action( 'updated_user_meta', array( &$this, 'on_update_usermeta' ), 10, 4 );
102
- add_action( 'added_user_meta', array( &$this, 'on_update_usermeta' ), 10, 4 );
103
-
104
- add_action( 'deleted_user_meta', array( &$this, 'on_delete_usermeta' ), 10, 4 );
105
- }
106
-
107
-
108
- /**
109
- * When you delete usermeta connected with member directory - reset it to default value
110
- *
111
- * @param int|array $meta_ids
112
- * @param int $object_id
113
- * @param string $meta_key
114
- * @param mixed $_meta_value
115
- */
116
- function on_delete_usermeta( $meta_ids, $object_id, $meta_key, $_meta_value ) {
117
- $metakeys = array( 'account_status', 'hide_in_members', 'synced_gravatar_hashed_id', 'synced_profile_photo', 'profile_photo', 'cover_photo', '_um_verified' );
118
- if ( ! in_array( $meta_key, $metakeys ) ) {
119
- return;
120
- }
121
-
122
- $md_data = get_user_meta( $object_id, 'um_member_directory_data', true );
123
- if ( empty( $md_data ) ) {
124
- $md_data = array(
125
- 'account_status' => 'approved',
126
- 'hide_in_members' => UM()->member_directory()->get_hide_in_members_default(),
127
- 'profile_photo' => false,
128
- 'cover_photo' => false,
129
- 'verified' => false,
130
- );
131
- }
132
-
133
- switch ( $meta_key ) {
134
- case 'account_status':
135
- $md_data['account_status'] = 'approved';
136
- break;
137
- case 'hide_in_members':
138
- $md_data['hide_in_members'] = UM()->member_directory()->get_hide_in_members_default();
139
- break;
140
- case 'synced_gravatar_hashed_id':
141
- if ( UM()->options()->get( 'use_gravatars' ) ) {
142
- $profile_photo = get_user_meta( $object_id, 'profile_photo', true );
143
- $synced_profile_photo = get_user_meta( $object_id, 'synced_profile_photo', true );
144
-
145
- $md_data['profile_photo'] = ! empty( $profile_photo ) || ! empty( $synced_profile_photo );
146
- }
147
-
148
- break;
149
- case 'synced_profile_photo':
150
- $profile_photo = get_user_meta( $object_id, 'profile_photo', true );
151
-
152
- $synced_gravatar_hashed_id = false;
153
- if ( UM()->options()->get( 'use_gravatars' ) ) {
154
- $synced_gravatar_hashed_id = get_user_meta( $object_id, 'synced_gravatar_hashed_id', true );
155
- }
156
-
157
- $md_data['profile_photo'] = ! empty( $profile_photo ) || ! empty( $synced_gravatar_hashed_id );
158
- break;
159
- case 'profile_photo':
160
- $synced_profile_photo = get_user_meta( $object_id, 'synced_profile_photo', true );
161
-
162
- $synced_gravatar_hashed_id = false;
163
- if ( UM()->options()->get( 'use_gravatars' ) ) {
164
- $synced_gravatar_hashed_id = get_user_meta( $object_id, 'synced_gravatar_hashed_id', true );
165
- }
166
-
167
- $md_data['profile_photo'] = ! empty( $synced_profile_photo ) || ! empty( $synced_gravatar_hashed_id );
168
- break;
169
- case 'cover_photo':
170
- $md_data['cover_photo'] = false;
171
- break;
172
- case '_um_verified':
173
- $md_data['verified'] = false;
174
- break;
175
- }
176
-
177
- update_user_meta( $object_id, 'um_member_directory_data', $md_data );
178
- }
179
-
180
-
181
- /**
182
- * When you add/update usermeta connected with member directories - set this data to member directory metakey
183
- *
184
- * @param int $meta_id
185
- * @param int $object_id
186
- * @param string $meta_key
187
- * @param mixed $_meta_value
188
- */
189
- function on_update_usermeta( $meta_id, $object_id, $meta_key, $_meta_value ) {
190
-
191
- $metakeys = array( 'account_status', 'hide_in_members', 'synced_gravatar_hashed_id', 'synced_profile_photo', 'profile_photo', 'cover_photo', '_um_verified' );
192
- if ( ! in_array( $meta_key, $metakeys ) ) {
193
- return;
194
- }
195
-
196
- $md_data = get_user_meta( $object_id, 'um_member_directory_data', true );
197
- if ( empty( $md_data ) ) {
198
- $md_data = array(
199
- 'account_status' => 'approved',
200
- 'hide_in_members' => UM()->member_directory()->get_hide_in_members_default(),
201
- 'profile_photo' => false,
202
- 'cover_photo' => false,
203
- 'verified' => false,
204
- );
205
- }
206
-
207
- switch ( $meta_key ) {
208
- case 'account_status':
209
- $md_data['account_status'] = $_meta_value;
210
- break;
211
- case 'hide_in_members':
212
-
213
- $hide_in_members = UM()->member_directory()->get_hide_in_members_default();
214
- if ( ! empty( $_meta_value ) ) {
215
- if ( $_meta_value == 'Yes' || $_meta_value == __( 'Yes', 'ultimate-member' ) ||
216
- array_intersect( array( 'Yes', __( 'Yes', 'ultimate-member' ) ), $_meta_value ) ) {
217
- $hide_in_members = true;
218
- } else {
219
- $hide_in_members = false;
220
- }
221
- }
222
-
223
- $md_data['hide_in_members'] = $hide_in_members;
224
-
225
- break;
226
- case 'synced_gravatar_hashed_id':
227
- if ( UM()->options()->get( 'use_gravatars' ) ) {
228
- if ( empty( $md_data['profile_photo'] ) ) {
229
- $md_data['profile_photo'] = ! empty( $_meta_value );
230
- }
231
- }
232
-
233
- break;
234
- case 'synced_profile_photo':
235
- case 'profile_photo':
236
- if ( empty( $md_data['profile_photo'] ) ) {
237
- $md_data['profile_photo'] = ! empty( $_meta_value );
238
- }
239
- break;
240
- case 'cover_photo':
241
- $md_data['cover_photo'] = ! empty( $_meta_value );
242
- break;
243
- case '_um_verified':
244
- $md_data['verified'] = $_meta_value == 'verified' ? true : false;
245
- break;
246
- }
247
-
248
- update_user_meta( $object_id, 'um_member_directory_data', $md_data );
249
- }
250
-
251
-
252
- /**
253
- * @param $user_id
254
- */
255
- function delete_user_handler( $user_id ) {
256
- um_fetch_user( $user_id );
257
-
258
- /**
259
- * UM hook
260
- *
261
- * @type action
262
- * @title um_delete_user_hook
263
- * @description On delete user
264
- * @change_log
265
- * ["Since: 2.0"]
266
- * @usage add_action( 'um_delete_user_hook', 'function_name', 10 );
267
- * @example
268
- * <?php
269
- * add_action( 'um_delete_user_hook', 'my_delete_user', 10 );
270
- * function my_delete_user() {
271
- * // your code here
272
- * }
273
- * ?>
274
- */
275
- do_action( 'um_delete_user_hook' );
276
-
277
- /**
278
- * UM hook
279
- *
280
- * @type action
281
- * @title um_delete_user
282
- * @description On delete user
283
- * @input_vars
284
- * [{"var":"$user_id","type":"int","desc":"User ID"}]
285
- * @change_log
286
- * ["Since: 2.0"]
287
- * @usage add_action( 'um_delete_user', 'function_name', 10, 1 );
288
- * @example
289
- * <?php
290
- * add_action( 'um_delete_user', 'my_delete_user', 10, 1 );
291
- * function my_delete_user( $user_id ) {
292
- * // your code here
293
- * }
294
- * ?>
295
- */
296
- do_action( 'um_delete_user', um_user( 'ID' ) );
297
-
298
- // send email notifications
299
- if ( $this->send_mail_on_delete ) {
300
- UM()->mail()->send( um_user( 'user_email' ), 'deletion_email' );
301
-
302
- $emails = um_multi_admin_email();
303
- if ( ! empty( $emails ) ) {
304
- foreach ( $emails as $email ) {
305
- UM()->mail()->send( $email, 'notification_deletion', array( 'admin' => true ) );
306
- }
307
- }
308
- }
309
-
310
- // remove uploads
311
- UM()->files()->remove_dir( UM()->files()->upload_temp );
312
- UM()->files()->remove_dir( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR );
313
- }
314
-
315
-
316
- /**
317
- *
318
- */
319
- function check_membership() {
320
- if ( ! is_user_logged_in() ) {
321
- return;
322
- }
323
-
324
- um_fetch_user( get_current_user_id() );
325
- $status = um_user( 'account_status' );
326
-
327
- if ( 'rejected' == $status ) {
328
- wp_logout();
329
- session_unset();
330
- exit( wp_redirect( um_get_core_page( 'login' ) ) );
331
- }
332
-
333
- um_reset_user();
334
- }
335
-
336
-
337
- /**
338
- * Multisite add existing user
339
- *
340
- * @param $user_id
341
- * @param $result
342
- */
343
- function add_um_role_existing_user( $user_id, $result ) {
344
- // Bail if no user ID was passed
345
- if ( empty( $user_id ) ) {
346
- return;
347
- }
348
-
349
- if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
350
- if ( ! user_can( $user_id, $_POST['um-role'] ) ) {
351
- UM()->roles()->set_role( $user_id, $_POST['um-role'] );
352
- }
353
- }
354
-
355
- $this->remove_cache( $user_id );
356
- }
357
-
358
-
359
- /**
360
- * Multisite add existing user
361
- *
362
- * @param $user_id
363
- */
364
- function add_um_role_wpmu_new_user( $user_id ) {
365
- // Bail if no user ID was passed
366
- if ( empty( $user_id ) ) {
367
- return;
368
- }
369
-
370
- if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
371
- if ( ! user_can( $user_id, $_POST['um-role'] ) ) {
372
- UM()->roles()->set_role( $user_id, $_POST['um-role'] );
373
- }
374
- }
375
-
376
- $this->remove_cache( $user_id );
377
- }
378
-
379
-
380
- /**
381
- * Get pending users (in queue)
382
- */
383
- function get_pending_users_count() {
384
-
385
- $cached_users_queue = get_option( 'um_cached_users_queue' );
386
- if ( $cached_users_queue > 0 && ! isset( $_REQUEST['delete_count'] ) ){
387
- return $cached_users_queue;
388
- }
389
-
390
- $args = array( 'fields' => 'ID', 'number' => 1 );
391
- $args['meta_query']['relation'] = 'OR';
392
- $args['meta_query'][] = array(
393
- 'key' => 'account_status',
394
- 'value' => 'awaiting_email_confirmation',
395
- 'compare' => '='
396
- );
397
- $args['meta_query'][] = array(
398
- 'key' => 'account_status',
399
- 'value' => 'awaiting_admin_review',
400
- 'compare' => '='
401
- );
402
-
403
- /**
404
- * UM hook
405
- *
406
- * @type filter
407
- * @title um_admin_pending_queue_filter
408
- * @description Change user query arguments when get pending users
409
- * @input_vars
410
- * [{"var":"$args","type":"array","desc":"WP_Users query arguments"}]
411
- * @change_log
412
- * ["Since: 2.0"]
413
- * @usage
414
- * <?php add_filter( 'um_admin_pending_queue_filter', 'function_name', 10, 1 ); ?>
415
- * @example
416
- * <?php
417
- * add_filter( 'um_admin_pending_queue_filter', 'my_admin_pending_queue', 10, 1 );
418
- * function my_admin_pending_queue( $args ) {
419
- * // your code here
420
- * return $args;
421
- * }
422
- * ?>
423
- */
424
- $args = apply_filters( 'um_admin_pending_queue_filter', $args );
425
- $users = new \WP_User_Query( $args );
426
-
427
- delete_option( 'um_cached_users_queue' );
428
- add_option( 'um_cached_users_queue', $users->get_total(), '', 'no' );
429
-
430
- return $users->get_total();
431
- }
432
-
433
-
434
- /**
435
- * @param $user_id
436
- *
437
- * @return bool|mixed
438
- */
439
- function get_profile_slug( $user_id ) {
440
- // Permalink base
441
- $permalink_base = UM()->options()->get( 'permalink_base' );
442
- $profile_slug = get_user_meta( $user_id, "um_user_profile_url_slug_{$permalink_base}", true );
443
-
444
- //get default username permalink if it's empty then return false
445
- if ( empty( $profile_slug ) ) {
446
- if ( $permalink_base != 'user_login' ) {
447
- $profile_slug = get_user_meta( $user_id, 'um_user_profile_url_slug_user_login', true );
448
- }
449
-
450
- if ( empty( $profile_slug ) ) {
451
- return false;
452
- }
453
- }
454
-
455
- return $profile_slug;
456
- }
457
-
458
-
459
- /**
460
- * @param $user_id
461
- *
462
- * @return bool|string
463
- */
464
- function get_profile_link( $user_id ) {
465
- $profile_slug = $this->get_profile_slug( $user_id );
466
-
467
- if ( empty( $profile_slug ) ) {
468
- return false;
469
- }
470
-
471
- return UM()->permalinks()->profile_permalink( $profile_slug );
472
- }
473
-
474
-
475
- /**
476
- * Generate User Profile Slug and save to meta
477
- *
478
- * @param int $user_id
479
- * @param bool $force
480
- */
481
- function generate_profile_slug( $user_id, $force = false ) {
482
- $userdata = get_userdata( $user_id );
483
-
484
- if ( empty( $userdata ) ) {
485
- return;
486
- }
487
-
488
- delete_option( "um_cache_userdata_{$user_id}" );
489
-
490
- $current_profile_slug = $this->get_profile_slug( $user_id );
491
-
492
- $user_in_url = '';
493
- $permalink_base = UM()->options()->get( 'permalink_base' );
494
-
495
- // User ID
496
- if ( $permalink_base == 'user_id' ) {
497
- $user_in_url = $user_id;
498
- }
499
-
500
- // Username
501
- if ( $permalink_base == 'user_login' ) {
502
-
503
- $user_in_url = $userdata->user_login;
504
-
505
- if ( is_email( $user_in_url ) ) {
506
-
507
- $user_email = $user_in_url;
508
- $user_in_url = str_replace( '@', '', $user_in_url );
509
-
510
- if ( ( $pos = strrpos( $user_in_url, '.' ) ) !== false ) {
511
- $search_length = strlen( '.' );
512
- $user_in_url = substr_replace( $user_in_url, '-', $pos, $search_length );
513
- }
514
- update_user_meta( $user_id, "um_email_as_username_{$user_in_url}", $user_email );
515
-
516
- } else {
517
-
518
- $user_in_url = urlencode( $user_in_url );
519
-
520
- }
521
- }
522
-
523
- // Fisrt and Last name
524
- $full_name_permalinks = array( 'name', 'name_dash', 'name_plus' );
525
- if ( in_array( $permalink_base, $full_name_permalinks ) ) {
526
- $separated = array( 'name' => '.', 'name_dash' => '-', 'name_plus' => '+' );
527
- $separate = $separated[ $permalink_base ];
528
- $first_name = $userdata->first_name;
529
- $last_name = $userdata->last_name;
530
- $full_name = trim( sprintf( '%s %s', $first_name, $last_name ) );
531
- $full_name = preg_replace( '/\s+/', ' ', $full_name ); // Remove double spaces
532
- $profile_slug = UM()->permalinks()->profile_slug( $full_name, $first_name, $last_name );
533
-
534
- $append = 0;
535
- $username = $full_name;
536
- $_username = $full_name;
537
-
538
- while ( 1 ) {
539
- $username = $_username . ( empty( $append ) ? '' : " $append" );
540
- $slug_exists_user_id = UM()->permalinks()->slug_exists_user_id( $profile_slug . ( empty( $append ) ? '' : "{$separate}{$append}" ) );
541
- if ( empty( $slug_exists_user_id ) || $user_id == $slug_exists_user_id ) {
542
- break;
543
- }
544
- $append++;
545
- }
546
-
547
- $user_in_url = UM()->permalinks()->profile_slug( $username, $first_name, $last_name );
548
- if ( empty( $user_in_url ) ) {
549
- $user_in_url = $userdata->user_login;
550
-
551
- if ( is_email( $user_in_url ) ) {
552
-
553
- $user_email = $user_in_url;
554
- $user_in_url = str_replace( '@', '', $user_in_url );
555
-
556
- if ( ( $pos = strrpos( $user_in_url, '.' ) ) !== false ) {
557
- $search_length = strlen( '.' );
558
- $user_in_url = substr_replace( $user_in_url, '-', $pos, $search_length );
559
- }
560
- update_user_meta( $user_id, "um_email_as_username_{$user_in_url}", $user_email );
561
-
562
- } else {
563
-
564
- $user_in_url = sanitize_title( $user_in_url );
565
-
566
- }
567
- }
568
-
569
- $user_in_url = trim( $user_in_url, $separate );
570
- }
571
-
572
- $user_in_url = apply_filters( 'um_change_user_profile_slug', $user_in_url, $user_id );
573
-
574
- if ( $force || empty( $current_profile_slug ) || $current_profile_slug != $user_in_url ) {
575
- update_user_meta( $user_id, "um_user_profile_url_slug_{$permalink_base}", $user_in_url );
576
- }
577
- }
578
-
579
-
580
- /**
581
- * Backend user creation
582
- *
583
- * @param $user_id
584
- */
585
- function user_register_via_admin( $user_id ) {
586
-
587
- if ( empty( $user_id ) ) {
588
- return;
589
- }
590
-
591
- if ( is_admin() ) {
592
- //if there custom 2 role not empty
593
- if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
594
- $user = get_userdata( $user_id );
595
- $user->add_role( $_POST['um-role'] );
596
- UM()->user()->profile['role'] = $_POST['um-role'];
597
- UM()->user()->update_usermeta_info( 'role' );
598
- }
599
-
600
- /**
601
- * UM hook
602
- *
603
- * @type action
604
- * @title um_user_register
605
- * @description Action on user registration
606
- * @input_vars
607
- * [{"var":"$user_id","type":"int","desc":"User ID"},
608
- * {"var":"$submitted","type":"array","desc":"Registration form submitted"}]
609
- * @change_log
610
- * ["Since: 2.0"]
611
- * @usage add_action( 'um_user_register', 'function_name', 10, 2 );
612
- * @example
613
- * <?php
614
- * add_action( 'um_user_register', 'my_user_register', 10, 2 );
615
- * function my_user_register( $user_id, $submitted ) {
616
- * // your code here
617
- * }
618
- * ?>
619
- */
620
- do_action( 'um_user_register', $user_id, $_POST );
621
- }
622
-
623
- }
624
-
625
-
626
- /**
627
- * On wp_update_user function complete
628
- *
629
- * @param int $user_id
630
- * @param \WP_User $old_data
631
- */
632
- function profile_update( $user_id, $old_data ) {
633
- // Bail if no user ID was passed
634
- if ( empty( $user_id ) ) {
635
- return;
636
- }
637
-
638
- $old_roles = $old_data->roles;
639
- $userdata = get_userdata( $user_id );
640
- $new_roles = $userdata->roles;
641
-
642
- if ( is_admin() ) {
643
- if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
644
- $new_roles = array_merge( $new_roles, array( $_POST['um-role'] ) );
645
- if ( ! user_can( $user_id, $_POST['um-role'] ) ) {
646
- UM()->roles()->set_role( $user_id, $_POST['um-role'] );
647
- }
648
- }
649
- }
650
-
651
- /**
652
- * UM hook
653
- *
654
- * @type action
655
- * @title um_after_member_role_upgrade
656
- * @description Action on user registration
657
- * @input_vars
658
- * [{"var":"$new_roles","type":"array","desc":"User new roles"},
659
- * {"var":"$old_roles","type":"array","desc":"Old roles"}]
660
- * @change_log
661
- * ["Since: 2.0"]
662
- * @usage add_action( 'um_after_member_role_upgrade', 'function_name', 10, 2 );
663
- * @example
664
- * <?php
665
- * add_action( 'um_after_member_role_upgrade', 'my_after_member_role_upgrade', 10, 2 );
666
- * function my_after_member_role_upgrade( $new_roles, $old_roles ) {
667
- * // your code here
668
- * }
669
- * ?>
670
- */
671
- do_action( 'um_after_member_role_upgrade', $new_roles, $old_roles, $user_id );
672
-
673
- //Update permalink
674
- $this->generate_profile_slug( $user_id, true );
675
-
676
- $this->remove_cache( $user_id );
677
- }
678
-
679
-
680
- /**
681
- * Additional section for WP Profile page with UM data fields
682
- *
683
- * @param \WP_User $userdata User data
684
- * @return void
685
- */
686
- function profile_form_additional_section( $userdata ) {
687
-
688
- /**
689
- * UM hook
690
- *
691
- * @type filter
692
- * @title um_user_profile_additional_fields
693
- * @description Make additional content section
694
- * @input_vars
695
- * [{"var":"$content","type":"array","desc":"Additional section content"},
696
- * {"var":"$userdata","type":"array","desc":"Userdata"}]
697
- * @change_log
698
- * ["Since: 2.0"]
699
- * @usage
700
- * <?php add_filter( 'um_user_profile_additional_fields', 'function_name', 10, 2 ); ?>
701
- * @example
702
- * <?php
703
- * add_filter( 'um_user_profile_additional_fields', 'my_admin_pending_queue', 10, 2 );
704
- * function my_admin_pending_queue( $content, $userdata ) {
705
- * // your code here
706
- * return $content;
707
- * }
708
- * ?>
709
- */
710
- $section_content = apply_filters( 'um_user_profile_additional_fields', '', $userdata );
711
-
712
- if ( ! empty( $section_content ) && ! ( is_multisite() && is_network_admin() ) ) {
713
-
714
- if ( $userdata !== 'add-new-user' && $userdata !== 'add-existing-user' ) { ?>
715
- <h3 id="um_user_screen_block"><?php esc_html_e( 'Ultimate Member', 'ultimate-member' ); ?></h3>
716
- <?php }
717
-
718
- echo $section_content;
719
- }
720
- }
721
-
722
-
723
- /**
724
- * Default interface for setting a ultimatemember role
725
- *
726
- * @param string $content Section HTML
727
- * @param \WP_User $userdata User data
728
- * @return string
729
- */
730
- public function secondary_role_field( $content, $userdata ) {
731
- $roles = array();
732
-
733
- $role_keys = get_option( 'um_roles', array() );
734
- if ( $role_keys ) {
735
- foreach ( $role_keys as $role_key ) {
736
- $role_meta = get_option( "um_role_{$role_key}_meta" );
737
-
738
- if ( $role_meta ) {
739
- $roles[ 'um_' . $role_key ] = $role_meta;
740
- }
741
- }
742
- }
743
-
744
- if ( empty( $roles ) ) {
745
- return $content;
746
- }
747
-
748
- global $pagenow;
749
- if ( 'profile.php' == $pagenow ) {
750
- return $content;
751
- }
752
-
753
- $style = '';
754
- $user_role = false;
755
- if ( $userdata !== 'add-new-user' && $userdata !== 'add-existing-user' ) {
756
- // Bail if current user cannot edit users
757
- if ( ! current_user_can( 'edit_user', $userdata->ID ) ) {
758
- return $content;
759
- }
760
-
761
- $user_role = UM()->roles()->get_um_user_role( $userdata->ID );
762
- if ( $user_role && ! empty( $userdata->roles ) && count( $userdata->roles ) == 1 ) {
763
- $style = 'style="display:none;"';
764
- }
765
-
766
- }
767
-
768
- $class = ( $userdata == 'add-existing-user' ) ? 'um_role_existing_selector_wrapper' : 'um_role_selector_wrapper';
769
-
770
- ob_start(); ?>
771
-
772
- <div id="<?php echo esc_attr( $class ) ?>" <?php echo $style ?>>
773
- <table class="form-table">
774
- <tbody>
775
- <tr>
776
- <th><label for="um-role"><?php esc_html_e( 'Ultimate Member Role', 'ultimate-member' ); ?></label></th>
777
- <td>
778
- <select name="um-role" id="um-role">
779
- <option value="" <?php selected( empty( $user_role ) ) ?>><?php esc_html_e( '&mdash; No role for Ultimate Member &mdash;', 'ultimate-member' ); ?></option>
780
- <?php foreach ( $roles as $role_id => $details ) { ?>
781
- <option <?php selected( $user_role, $role_id ); ?> value="<?php echo esc_attr( $role_id ); ?>"><?php echo esc_html( $details['name'] ); ?></option>
782
- <?php } ?>
783
- </select>
784
- </td>
785
- </tr>
786
- </tbody>
787
- </table>
788
- </div>
789
-
790
- <?php $content .= ob_get_clean();
791
-
792
- return $content;
793
- }
794
-
795
-
796
- /**
797
- * Remove cached queue from Users backend
798
- */
799
- function remove_cached_queue() {
800
- delete_option( 'um_cached_users_queue' );
801
- }
802
-
803
-
804
- /**
805
- * Converts object to array
806
- *
807
- * @param $obj
808
- *
809
- * @return array
810
- */
811
- function toArray( $obj ) {
812
- if ( is_object( $obj ) ) {
813
- $obj = (array) $obj;
814
- }
815
- if ( is_array( $obj ) ) {
816
- $new = array();
817
- foreach ( $obj as $key => $val ) {
818
- $new[ $key ] = $this->toArray( $val );
819
- }
820
- } else {
821
- $new = $obj;
822
- }
823
-
824
- return $new;
825
- }
826
-
827
-
828
- /**
829
- * @param $user_id
830
- *
831
- * @return mixed|string
832
- */
833
- function get_cached_data( $user_id ) {
834
-
835
- $disallow_cache = UM()->options()->get( 'um_profile_object_cache_stop' );
836
- if ( $disallow_cache ) {
837
- return '';
838
- }
839
-
840
- if ( is_numeric( $user_id ) && $user_id > 0 ) {
841
- $find_user = get_option( "um_cache_userdata_{$user_id}" );
842
- if ( $find_user ) {
843
- /**
844
- * UM hook
845
- *
846
- * @type filter
847
- * @title um_user_permissions_filter
848
- * @description Change User Permissions
849
- * @input_vars
850
- * [{"var":"$permissions","type":"array","desc":"User Permissions"},
851
- * {"var":"$user_id","type":"int","desc":"User ID"}]
852
- * @change_log
853
- * ["Since: 2.0"]
854
- * @usage
855
- * <?php add_filter( 'um_user_permissions_filter', 'function_name', 10, 2 ); ?>
856
- * @example
857
- * <?php
858
- * add_filter( 'um_user_permissions_filter', 'my_user_permissions', 10, 2 );
859
- * function my_user_permissions( $permissions, $user_id ) {
860
- * // your code here
861
- * return $permissions;
862
- * }
863
- * ?>
864
- */
865
- $find_user = apply_filters( 'um_user_permissions_filter', $find_user, $user_id );
866
- return $find_user;
867
- }
868
- }
869
- return '';
870
- }
871
-
872
-
873
- /**
874
- * @param $user_id
875
- * @param $profile
876
- */
877
- function setup_cache( $user_id, $profile ) {
878
-
879
- $disallow_cache = UM()->options()->get( 'um_profile_object_cache_stop' );
880
- if ( $disallow_cache ) {
881
- return;
882
- }
883
-
884
- update_option( "um_cache_userdata_{$user_id}", $profile, false );
885
- }
886
-
887
-
888
- /**
889
- * @param $user_id
890
- */
891
- function remove_cache( $user_id ) {
892
- delete_option( "um_cache_userdata_{$user_id}" );
893
- }
894
-
895
-
896
- /**
897
- * Remove cache for all users
898
- */
899
- function remove_cache_all_users() {
900
- global $wpdb;
901
- $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" );
902
- }
903
-
904
-
905
- /**
906
- * This method lets you set a user. For example, to retrieve a profile or anything related to that user.
907
- *
908
- * @usage <?php UM()->user()->set( $user_id, $clean = false ); ?>
909
- *
910
- * @param null|int $user_id Which user to retrieve. A numeric user ID
911
- * @param bool $clean Should be true or false. Basically, if you did not provide a user ID It will set the current logged in user as a profile
912
- *
913
- * @example The following example makes you set a user and retrieve their display name after that using the user API.
914
-
915
- <?php
916
-
917
- UM()->user()->set( 12 );
918
- $display_name = UM()->user()->profile['display_name']; // Should print user display name
919
-
920
- ?>
921
- *
922
- */
923
- function set( $user_id = null, $clean = false ) {
924
- if ( isset( $this->profile ) ) {
925
- unset( $this->profile );
926
- }
927
-
928
- if ( $user_id ) {
929
- $this->id = $user_id;
930
- } elseif ( is_user_logged_in() && $clean == false ) {
931
- $this->id = get_current_user_id();
932
- } else {
933
- $this->id = 0;
934
- }
935
-
936
- if ( $this->get_cached_data( $this->id ) ) {
937
- $this->profile = $this->get_cached_data( $this->id );
938
- } else {
939
-
940
- if ( $user_id ) {
941
-
942
- $this->id = $user_id;
943
- $this->usermeta = get_user_meta( $user_id );
944
- $this->data = get_userdata( $this->id );
945
-
946
- } elseif ( is_user_logged_in() && $clean == false ) {
947
-
948
- $this->id = get_current_user_id();
949
- $this->usermeta = get_user_meta($this->id);
950
- $this->data = get_userdata($this->id);
951
-
952
- } else {
953
-
954
- $this->id = 0;
955
- $this->usermeta = null;
956
- $this->data = null;
957
-
958
- }
959
-
960
- // we have a user, populate a profile
961
- if ( $this->id && $this->toArray( $this->data ) ) {
962
-
963
- // add user data
964
- $this->data = $this->toArray( $this->data );
965
-
966
- foreach ( $this->data as $k=>$v ) {
967
- if ( $k == 'roles') {
968
- $this->profile['wp_roles'] = implode(',',$v);
969
- } else if ( is_array( $v ) ) {
970
- foreach($v as $k2 => $v2){
971
- $this->profile[$k2] = $v2;
972
- }
973
- } else {
974
- $this->profile[$k] = $v;
975
- }
976
- }
977
-
978
- // add account status
979
- if ( !isset( $this->usermeta['account_status'][0] ) ) {
980
- $this->usermeta['account_status'][0] = 'approved';
981
- }
982
-
983
- if ( $this->usermeta['account_status'][0] == 'approved' ) {
984
- $this->usermeta['account_status_name'][0] = __('Approved','ultimate-member');
985
- }
986
-
987
- if ( $this->usermeta['account_status'][0] == 'awaiting_email_confirmation' ) {
988
- $this->usermeta['account_status_name'][0] = __('Awaiting E-mail Confirmation','ultimate-member');
989
- }
990
-
991
- if ( $this->usermeta['account_status'][0] == 'awaiting_admin_review' ) {
992
- $this->usermeta['account_status_name'][0] = __('Pending Review','ultimate-member');
993
- }
994
-
995
- if ( $this->usermeta['account_status'][0] == 'rejected' ) {
996
- $this->usermeta['account_status_name'][0] = __('Membership Rejected','ultimate-member');
997
- }
998
-
999
- if ( $this->usermeta['account_status'][0] == 'inactive' ) {
1000
- $this->usermeta['account_status_name'][0] = __('Membership Inactive','ultimate-member');
1001
- }
1002
-
1003
- // add user meta
1004
- foreach ( $this->usermeta as $k => $v ) {
1005
- if ( $k == 'display_name') {
1006
- continue;
1007
- }
1008
- $this->profile[ $k ] = $v[0];
1009
- }
1010
-
1011
- // add permissions
1012
- $user_role = UM()->roles()->get_priority_user_role( $this->id );
1013
- $this->profile['role'] = $user_role;
1014
- $this->profile['roles'] = UM()->roles()->get_all_user_roles( $this->id );
1015
-
1016
- $role_meta = UM()->roles()->role_data( $user_role );
1017
- /**
1018
- * UM hook
1019
- *
1020
- * @type filter
1021
- * @title um_user_permissions_filter
1022
- * @description Change User Permissions
1023
- * @input_vars
1024
- * [{"var":"$permissions","type":"array","desc":"User Permissions"},
1025
- * {"var":"$user_id","type":"int","desc":"User ID"}]
1026
- * @change_log
1027
- * ["Since: 2.0"]
1028
- * @usage
1029
- * <?php add_filter( 'um_user_permissions_filter', 'function_name', 10, 2 ); ?>
1030
- * @example
1031
- * <?php
1032
- * add_filter( 'um_user_permissions_filter', 'my_user_permissions', 10, 2 );
1033
- * function my_user_permissions( $permissions, $user_id ) {
1034
- * // your code here
1035
- * return $permissions;
1036
- * }
1037
- * ?>
1038
- */
1039
- $role_meta = apply_filters( 'um_user_permissions_filter', $role_meta, $this->id );
1040
-
1041
- /*$role_meta = array_map( function( $key, $item ) {
1042
- if ( strpos( $key, '_um_' ) === 0 )
1043
- $key = str_replace( '_um_', '', $key );
1044
-
1045
- return array( $key => $item );
1046
- }, array_keys( $role_meta ), $role_meta );*/
1047
-
1048
- $this->profile = array_merge( $this->profile, (array)$role_meta );
1049
-
1050
- $this->profile['super_admin'] = ( is_super_admin( $this->id ) ) ? 1 : 0;
1051
-
1052
- // clean profile
1053
- $this->clean();
1054
-
1055
- // Setup cache
1056
- $this->setup_cache( $this->id, $this->profile );
1057
-
1058
- }
1059
-
1060
- }
1061
-
1062
- }
1063
-
1064
-
1065
- /**
1066
- * Reset user data
1067
- *
1068
- * @param bool $clean
1069
- */
1070
- function reset( $clean = false ){
1071
- $this->set(0, $clean);
1072
- }
1073
-
1074
-
1075
- /**
1076
- * Clean user profile
1077
- */
1078
- function clean() {
1079
- foreach ( $this->profile as $key => $value ) {
1080
- foreach ( $this->banned_keys as $ban ) {
1081
- if ( strstr( $key, $ban ) || is_numeric( $key ) ) {
1082
- unset( $this->profile[ $key ] );
1083
- }
1084
- }
1085
- }
1086
- }
1087
-
1088
-
1089
- /**
1090
- * This method lets you auto sign-in a user to your site.
1091
- *
1092
- * @usage <?php UM()->user()->auto_login( $user_id, $rememberme = false ); ?>
1093
- *
1094
- * @param int $user_id Which user ID to sign in automatically
1095
- * @param int|bool $rememberme Should be true or false. If you want the user sign in session to use cookies, use true
1096
- *
1097
- * @example The following example lets you sign in a user automatically by their ID.
1098
-
1099
- <?php UM()->user()->auto_login( 2 ); ?>
1100
- *
1101
- *
1102
- * @example The following example lets you sign in a user automatically by their ID and makes the plugin remember their session.
1103
-
1104
- <?php UM()->user()->auto_login( 10, true ); ?>
1105
- *
1106
- */
1107
- function auto_login( $user_id, $rememberme = 0 ) {
1108
-
1109
- wp_set_current_user( $user_id );
1110
-
1111
- wp_set_auth_cookie( $user_id, $rememberme );
1112
-
1113
- $user = get_user_by( 'ID', $user_id );
1114
-
1115
- do_action( 'wp_login', $user->user_login, $user );
1116
-
1117
- }
1118
-
1119
-
1120
- /**
1121
- * Set user's registration details
1122
- *
1123
- * @param array $submitted
1124
- * @param array $args
1125
- */
1126
- function set_registration_details( $submitted, $args ) {
1127
-
1128
- if ( isset( $submitted['user_pass'] ) ) {
1129
- unset( $submitted['user_pass'] );
1130
- }
1131
-
1132
- if ( isset( $submitted['user_password'] ) ) {
1133
- unset( $submitted['user_password'] );
1134
- }
1135
-
1136
- if ( isset( $submitted['confirm_user_password'] ) ) {
1137
- unset( $submitted['confirm_user_password'] );
1138
- }
1139
-
1140
- //remove all password field values from submitted details
1141
- $password_fields = array();
1142
- foreach ( $submitted as $k => $v ) {
1143
- if ( UM()->fields()->get_field_type( $k ) == 'password' ) {
1144
- $password_fields[] = $k;
1145
- $password_fields[] = 'confirm_' . $k;
1146
- }
1147
- }
1148
-
1149
- foreach ( $password_fields as $pw_field ) {
1150
- unset( $submitted[ $pw_field ] );
1151
- }
1152
-
1153
-
1154
- /**
1155
- * UM hook
1156
- *
1157
- * @type filter
1158
- * @title um_before_save_filter_submitted
1159
- * @description Change submitted data before save usermeta "submitted" on registration process
1160
- * @input_vars
1161
- * [{"var":"$submitted","type":"array","desc":"Submitted data"},
1162
- * {"var":"$args","type":"array","desc":"Form Args"}]
1163
- * @change_log
1164
- * ["Since: 2.0"]
1165
- * @usage
1166
- * <?php add_filter( 'um_before_save_filter_submitted', 'function_name', 10, 2 ); ?>
1167
- * @example
1168
- * <?php
1169
- * add_filter( 'um_before_save_filter_submitted', 'my_before_save_filter_submitted', 10, 2 );
1170
- * function my_before_save_filter_submitted( $submitted, $args ) {
1171
- * // your code here
1172
- * return $submitted;
1173
- * }
1174
- * ?>
1175
- */
1176
- $submitted = apply_filters( 'um_before_save_filter_submitted', $submitted, $args );
1177
-
1178
- /**
1179
- * UM hook
1180
- *
1181
- * @type action
1182
- * @title um_before_save_registration_details
1183
- * @description Action on user registration before save details
1184
- * @input_vars
1185
- * [{"var":"$user_id","type":"int","desc":"User ID"},
1186
- * {"var":"$submitted","type":"array","desc":"Registration form submitted"}]
1187
- * @change_log
1188
- * ["Since: 2.0"]
1189
- * @usage add_action( 'um_before_save_registration_details', 'function_name', 10, 2 );
1190
- * @example
1191
- * <?php
1192
- * add_action( 'um_before_save_registration_details', 'my_before_save_registration_details', 10, 2 );
1193
- * function my_before_save_registration_details( $user_id, $submitted ) {
1194
- * // your code here
1195
- * }
1196
- * ?>
1197
- */
1198
- do_action( 'um_before_save_registration_details', $this->id, $submitted );
1199
-
1200
- update_user_meta( $this->id, 'submitted', $submitted );
1201
-
1202
- $this->update_profile( $submitted );
1203
- /**
1204
- * UM hook
1205
- *
1206
- * @type action
1207
- * @title um_after_save_registration_details
1208
- * @description Action on user registration after save details
1209
- * @input_vars
1210
- * [{"var":"$user_id","type":"int","desc":"User ID"},
1211
- * {"var":"$submitted","type":"array","desc":"Registration form submitted"}]
1212
- * @change_log
1213
- * ["Since: 2.0"]
1214
- * @usage add_action( 'um_after_save_registration_details', 'function_name', 10, 2 );
1215
- * @example
1216
- * <?php
1217
- * add_action( 'um_after_save_registration_details', 'my_after_save_registration_details', 10, 2 );
1218
- * function my_after_save_registration_details( $user_id, $submitted ) {
1219
- * // your code here
1220
- * }
1221
- * ?>
1222
- */
1223
- do_action( 'um_after_save_registration_details', $this->id, $submitted );
1224
-
1225
- }
1226
-
1227
-
1228
- /**
1229
- * Set last login for new registered users
1230
- */
1231
- function set_last_login() {
1232
- update_user_meta( $this->id, '_um_last_login', current_time( 'timestamp' ) );
1233
- }
1234
-
1235
-
1236
- /**
1237
- * Set user's account status
1238
- *
1239
- * @param $status
1240
- */
1241
- function set_status( $status ) {
1242
-
1243
- /**
1244
- * UM hook
1245
- *
1246
- * @type action
1247
- * @title um_when_status_is_set
1248
- * @description Action on user status changed
1249
- * @input_vars
1250
- * [{"var":"$user_id","type":"int","desc":"User ID"}]
1251
- * @change_log
1252
- * ["Since: 2.0"]
1253
- * @usage add_action( 'um_when_status_is_set', 'function_name', 10, 1 );
1254
- * @example
1255
- * <?php
1256
- * add_action( 'um_when_status_is_set', 'my_when_status_is_set', 10, 1 );
1257
- * function my_when_status_is_set( $user_id ) {
1258
- * // your code here
1259
- * }
1260
- * ?>
1261
- */
1262
- do_action( 'um_when_status_is_set', um_user( 'ID' ) );
1263
-
1264
- $this->profile['account_status'] = $status;
1265
-
1266
- $this->update_usermeta_info( 'account_status' );
1267
-
1268
- /**
1269
- * UM hook
1270
- *
1271
- * @type action
1272
- * @title um_after_user_status_is_changed_hook
1273
- * @description Action after user status changed
1274
- * @input_vars
1275
- * [{"var":"$user_id","type":"int","desc":"User ID"}]
1276
- * @change_log
1277
- * ["Since: 2.0"]
1278
- * @usage add_action( 'um_after_user_status_is_changed_hook', 'function_name', 10 );
1279
- * @example
1280
- * <?php
1281
- * add_action( 'um_after_user_status_is_changed_hook', 'my_after_user_status_is_changed', 10 );
1282
- * function my_after_user_status_is_changed() {
1283
- * // your code here
1284
- * }
1285
- * ?>
1286
- */
1287
- do_action( 'um_after_user_status_is_changed_hook', um_user( 'ID' ) );
1288
-
1289
- /**
1290
- * UM hook
1291
- *
1292
- * @type action
1293
- * @title um_after_user_status_is_changed
1294
- * @description Action after user status changed
1295
- * @input_vars
1296
- * [{"var":"$status","type":"string","desc":"User Status"},
1297
- * {"var":"$user_id","type":"integer","desc":"User ID"}]
1298
- * @change_log
1299
- * ["Since: 2.0"]
1300
- * @usage add_action( 'um_after_user_status_is_changed', 'function_name', 10, 1 );
1301
- * @example
1302
- * <?php
1303
- * add_action( 'um_after_user_status_is_changed', 'my_after_user_status_is_changed', 10, 1 );
1304
- * function my_after_user_status_is_changed( $status ) {
1305
- * // your code here
1306
- * }
1307
- * ?>
1308
- */
1309
- do_action( 'um_after_user_status_is_changed', $status, um_user( 'ID' ) );
1310
-
1311
- }
1312
-
1313
-
1314
- /**
1315
- * Set user's hash
1316
- */
1317
- function assign_secretkey() {
1318
- /**
1319
- * UM hook
1320
- *
1321
- * @type action
1322
- * @title um_before_user_hash_is_changed
1323
- * @description Action before user hash is changed
1324
- * @change_log
1325
- * ["Since: 2.0"]
1326
- * @usage add_action( 'um_before_user_hash_is_changed', 'function_name', 10 );
1327
- * @example
1328
- * <?php
1329
- * add_action( 'um_before_user_hash_is_changed', 'my_before_user_hash_is_changed', 10 );
1330
- * function my_before_user_hash_is_changed() {
1331
- * // your code here
1332
- * }
1333
- * ?>
1334
- */
1335
- do_action( 'um_before_user_hash_is_changed' );
1336
-
1337
- $this->profile['account_secret_hash'] = UM()->validation()->generate();
1338
- $this->update_usermeta_info( 'account_secret_hash' );
1339
-
1340
- $expiry_time = UM()->options()->get( 'activation_link_expiry_time' );
1341
- if ( ! empty( $expiry_time ) && is_numeric( $expiry_time ) ) {
1342
- $this->profile['account_secret_hash_expiry'] = time() + $expiry_time;
1343
- $this->update_usermeta_info( 'account_secret_hash_expiry' );
1344
- }
1345
-
1346
- /**
1347
- * UM hook
1348
- *
1349
- * @type action
1350
- * @title um_after_user_hash_is_changed
1351
- * @description Action after user hash is changed
1352
- * @change_log
1353
- * ["Since: 2.0"]
1354
- * @usage add_action( 'um_after_user_hash_is_changed', 'function_name', 10 );
1355
- * @example
1356
- * <?php
1357
- * add_action( 'um_after_user_hash_is_changed', 'my_after_user_hash_is_changed', 10 );
1358
- * function my_after_user_hash_is_changed() {
1359
- * // your code here
1360
- * }
1361
- * ?>
1362
- */
1363
- do_action( 'um_after_user_hash_is_changed' );
1364
- }
1365
-
1366
-
1367
- /**
1368
- * @param \WP_User $userdata
1369
- *
1370
- * @return string|\WP_Error
1371
- */
1372
- function maybe_generate_password_reset_key( $userdata ) {
1373
- if ( empty( $this->password_reset_key ) ) {
1374
- $this->password_reset_key = get_password_reset_key( $userdata );
1375
- }
1376
-
1377
- return $this->password_reset_key ;
1378
- }
1379
-
1380
-
1381
- /**
1382
- * Password reset email
1383
- */
1384
- function password_reset() {
1385
- $userdata = get_userdata( um_user( 'ID' ) );
1386
-
1387
- $this->maybe_generate_password_reset_key( $userdata );
1388
-
1389
- add_filter( 'um_template_tags_patterns_hook', array( UM()->password(), 'add_placeholder' ), 10, 1 );
1390
- add_filter( 'um_template_tags_replaces_hook', array( UM()->password(), 'add_replace_placeholder' ), 10, 1 );
1391
-
1392
- UM()->mail()->send( um_user( 'user_email' ), 'resetpw_email' );
1393
- }
1394
-
1395
-
1396
- /**
1397
- * Password changed email
1398
- */
1399
- function password_changed() {
1400
- UM()->mail()->send( um_user( 'user_email' ), 'changedpw_email' );
1401
- }
1402
-
1403
-
1404
- /**
1405
- * This method approves a user membership and sends them an optional welcome/approval e-mail.
1406
- *
1407
- * @usage <?php UM()->user()->approve(); ?>
1408
- *
1409
- * @example Approve a pending user and allow him to sign-in to your site.
1410
-
1411
- <?php
1412
-
1413
- um_fetch_user( 352 );
1414
- UM()->user()->approve();
1415
-
1416
- ?>
1417
- *
1418
- */
1419
- function approve( $repeat = true ) {
1420
- $user_id = um_user('ID');
1421
-
1422
- if ( ! $repeat ) {
1423
- $status = get_user_meta( $user_id, 'account_status', true );
1424
- if ( 'approved' === $status ) {
1425
- return;
1426
- }
1427
- }
1428
-
1429
- delete_option( "um_cache_userdata_{$user_id}" );
1430
-
1431
- if ( um_user( 'account_status' ) == 'awaiting_admin_review' ) {
1432
- $userdata = get_userdata( $user_id );
1433
-
1434
- $this->maybe_generate_password_reset_key( $userdata );
1435
-
1436
- UM()->mail()->send( um_user( 'user_email' ), 'approved_email' );
1437
-
1438
- } else {
1439
- //$userdata = get_userdata( $user_id );
1440
- //get_password_reset_key( $userdata );
1441
- UM()->mail()->send( um_user( 'user_email' ), 'welcome_email' );
1442
- }
1443
-
1444
- $this->set_status( 'approved' );
1445
- $this->delete_meta( 'account_secret_hash' );
1446
- $this->delete_meta( 'account_secret_hash_expiry' );
1447
-
1448
- /**
1449
- * UM hook
1450
- *
1451
- * @type action
1452
- * @title um_after_user_is_approved
1453
- * @description Action after user was approved
1454
- * @input_vars
1455
- * [{"var":"$user_id","type":"int","desc":"User ID"}]
1456
- * @change_log
1457
- * ["Since: 2.0"]
1458
- * @usage add_action( 'um_after_user_is_approved', 'function_name', 10, 1 );
1459
- * @example
1460
- * <?php
1461
- * add_action( 'um_after_user_is_approved', 'my_after_user_is_approved', 10, 1 );
1462
- * function my_after_user_hash_is_changed( $user_id ) {
1463
- * // your code here
1464
- * }
1465
- * ?>
1466
- */
1467
- do_action( 'um_after_user_is_approved', um_user( 'ID' ) );
1468
- }
1469
-
1470
-
1471
- /**
1472
- * Pending email
1473
- */
1474
- function email_pending() {
1475
- $this->assign_secretkey();
1476
- $this->set_status( 'awaiting_email_confirmation' );
1477
- UM()->mail()->send( um_user( 'user_email' ), 'checkmail_email' );
1478
- }
1479
-
1480
-
1481
- /**
1482
- * This method puts a user under manual review by administrator and sends them an optional e-mail.
1483
- *
1484
- * @usage <?php UM()->user()->pending(); ?>
1485
- *
1486
- * @example An example of putting a user pending manual review
1487
-
1488
- <?php
1489
-
1490
- um_fetch_user( 54 );
1491
- UM()->user()->pending();
1492
-
1493
- ?>
1494
- *
1495
- */
1496
- function pending() {
1497
- $this->set_status( 'awaiting_admin_review' );
1498
- UM()->mail()->send( um_user( 'user_email' ), 'pending_email' );
1499
- }
1500
-
1501
-
1502
- /**
1503
- * This method rejects a user membership and sends them an optional e-mail.
1504
- *
1505
- * @usage <?php UM()->user()->reject(); ?>
1506
- *
1507
- * @example Reject a user membership example
1508
-
1509
- <?php
1510
-
1511
- um_fetch_user( 114 );
1512
- UM()->user()->reject();
1513
-
1514
- ?>
1515
-
1516
- *
1517
- */
1518
- function reject() {
1519
- $this->set_status( 'rejected' );
1520
- UM()->mail()->send( um_user( 'user_email' ), 'rejected_email' );
1521
- }
1522
-
1523
-
1524
- /**
1525
- * This method deactivates a user membership and sends them an optional e-mail.
1526
- *
1527
- * @usage <?php UM()->user()->deactivate(); ?>
1528
- *
1529
- * @example Deactivate a user membership with the following example
1530
-
1531
- <?php
1532
-
1533
- um_fetch_user( 32 );
1534
- $ultimatemember->user->deactivate();
1535
-
1536
- ?>
1537
- *
1538
- */
1539
- function deactivate() {
1540
- $this->set_status( 'inactive' );
1541
- /**
1542
- * UM hook
1543
- *
1544
- * @type action
1545
- * @title um_after_user_is_inactive
1546
- * @description Action after user was inactive
1547
- * @input_vars
1548
- * [{"var":"$user_id","type":"int","desc":"User ID"}]
1549
- * @change_log
1550
- * ["Since: 2.0"]
1551
- * @usage add_action( 'um_after_user_is_inactive', 'function_name', 10, 1 );
1552
- * @example
1553
- * <?php
1554
- * add_action( 'um_after_user_is_inactive', 'my_after_user_is_inactive', 10, 1 );
1555
- * function my_after_user_is_inactive( $user_id ) {
1556
- * // your code here
1557
- * }
1558
- * ?>
1559
- */
1560
- do_action( 'um_after_user_is_inactive', um_user( 'ID' ) );
1561
-
1562
- UM()->mail()->send( um_user( 'user_email' ), 'inactive_email' );
1563
- }
1564
-
1565
-
1566
- /**
1567
- * Delete user
1568
- *
1569
- * @param bool $send_mail
1570
- */
1571
- function delete( $send_mail = true ) {
1572
-
1573
- $this->send_mail_on_delete = $send_mail;
1574
- //don't send email notification to not approved user
1575
- if ( 'approved' != um_user( 'account_status' ) ) {
1576
- $this->send_mail_on_delete = false;
1577
- }
1578
-
1579
- // remove user
1580
- if ( is_multisite() ) {
1581
-
1582
- if ( ! function_exists( 'wpmu_delete_user' ) ) {
1583
- require_once( ABSPATH . 'wp-admin/includes/ms.php' );
1584
- }
1585
-
1586
- wpmu_delete_user( $this->id );
1587
-
1588
- } else {
1589
-
1590
- if ( ! function_exists( 'wp_delete_user' ) ) {
1591
- require_once( ABSPATH . 'wp-admin/includes/user.php' );
1592
- }
1593
-
1594
- wp_delete_user( $this->id );
1595
-
1596
- }
1597
-
1598
- }
1599
-
1600
-
1601
- /**
1602
- * This method gets a user role in slug format. e.g. member
1603
- *
1604
- * @usage <?php UM()->user()->get_role(); ?>
1605
- *
1606
- * @return string
1607
- *
1608
- * @example Do something if the user's role is paid-member
1609
-
1610
- <?php
1611
-
1612
- um_fetch_user( 12 );
1613
-
1614
- if ( UM()->user()->get_role() == 'paid-member' ) {
1615
- // Show this to paid customers
1616
- } else {
1617
- // You are a free member
1618
- }
1619
-
1620
- ?>
1621
- *
1622
- */
1623
- function get_role() {
1624
- if ( ! empty( $this->profile['role'] ) ) {
1625
- return $this->profile['role'];
1626
- } else {
1627
- if ( ! empty( $this->profile['wp_roles'] ) && $this->profile['wp_roles'] == 'administrator' ) {
1628
- return 'admin';
1629
- } else {
1630
- return 'member';
1631
- }
1632
- }
1633
- }
1634
-
1635
-
1636
- /**
1637
- * Update one key in user meta
1638
- *
1639
- * @param $key
1640
- */
1641
- function update_usermeta_info( $key ) {
1642
- // delete the key first just in case
1643
- delete_user_meta( $this->id, $key );
1644
- update_user_meta( $this->id, $key, $this->profile[ $key ] );
1645
- }
1646
-
1647
-
1648
- /**
1649
- * This method can be used to delete user's meta key.
1650
- *
1651
- * @usage <?php UM()->user()->delete_meta( $key ); ?>
1652
- *
1653
- * @param string $key The meta field key to remove from user
1654
- *
1655
- * @example Delete user's age field
1656
-
1657
- <?php
1658
-
1659
- um_fetch_user( 15 );
1660
- UM()->user()->delete_meta( 'age' );
1661
-
1662
- ?>
1663
-
1664
- *
1665
- */
1666
- function delete_meta( $key ) {
1667
- delete_user_meta( $this->id, $key );
1668
- }
1669
-
1670
-
1671
- /**
1672
- * Get admin actions for individual user
1673
- *
1674
- * @return array|bool
1675
- */
1676
- function get_admin_actions() {
1677
- $items = array();
1678
-
1679
- /**
1680
- * UM hook
1681
- *
1682
- * @type filter
1683
- * @title um_admin_user_actions_hook
1684
- * @description Extend admin actions for each user
1685
- * @input_vars
1686
- * [{"var":"$actions","type":"array","desc":"Actions for user"}]
1687
- * @change_log
1688
- * ["Since: 2.0"]
1689
- * @usage
1690
- * <?php add_filter( 'um_admin_user_actions_hook', 'function_name', 10, 1 ); ?>
1691
- * @example
1692
- * <?php
1693
- * add_filter( 'um_admin_user_actions_hook', 'my_admin_user_actions', 10, 1 );
1694
- * function my_admin_user_actions( $actions ) {
1695
- * // your code here
1696
- * return $actions;
1697
- * }
1698
- * ?>
1699
- */
1700
- $actions = apply_filters( 'um_admin_user_actions_hook', array(), um_profile_id() );
1701
- if ( empty( $actions ) ) {
1702
- return $items;
1703
- }
1704
-
1705
- foreach ( $actions as $id => $arr ) {
1706
- $url = add_query_arg( array( 'um_action' => $id, 'uid' => um_profile_id() ) );
1707
- /*$url = add_query_arg( 'um_action', $id );
1708
- $url = add_query_arg( 'uid', um_profile_id(), $url );*/
1709
- $items[] = '<a href="' . esc_url( $url ) .'" class="real_url ' . esc_attr( $id ) . '-item">' . esc_html( $arr['label'] ) . '</a>';
1710
- }
1711
- return $items;
1712
- }
1713
-
1714
-
1715
- /**
1716
- * This method checks if the profile indexing is disabled
1717
- *
1718
- * @param int $user_id
1719
- *
1720
- * @since 2.1.16
1721
- * @usage <?php UM()->user()->is_profile_noindex( $user_id ); ?>
1722
- *
1723
- * @return boolean Is the profile indexing disabled?
1724
- */
1725
- function is_profile_noindex( $user_id ) {
1726
- $profile_noindex = false;
1727
-
1728
- if ( ! get_option( 'blog_public' ) ) {
1729
- // Option "Search engine visibility" in [wp-admin > Settings > Reading]
1730
- $profile_noindex = true;
1731
-
1732
- } elseif ( $this->is_private_profile( $user_id ) ) {
1733
- // Setting "Profile Privacy" in [Account > Privacy]
1734
- $profile_noindex = true;
1735
-
1736
- } elseif ( get_user_meta( $user_id, 'profile_noindex', true ) === '1' ) {
1737
- // Setting "Avoid indexing my profile by search engines in [Account > Privacy]
1738
- $profile_noindex = true;
1739
-
1740
- }
1741
-
1742
- if ( ! $profile_noindex ) {
1743
- $role = UM()->roles()->get_priority_user_role( $user_id );
1744
- $permissions = UM()->roles()->role_data( $role );
1745
-
1746
- if ( isset( $permissions['profile_noindex'] ) && (bool) $permissions['profile_noindex'] ) {
1747
- // Setting "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > User Roles > Edit Role]
1748
- $profile_noindex = true;
1749
-
1750
- } elseif ( ( ! isset( $permissions['profile_noindex'] ) || $permissions['profile_noindex'] === '' ) && (bool) UM()->options()->get( 'profile_noindex' ) ) {
1751
- // Setting "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > Settings > General > Users]
1752
- $profile_noindex = true;
1753
-
1754
- }
1755
- }
1756
-
1757
- return apply_filters( 'um_user_is_profile_noindex', $profile_noindex, $user_id, $this );
1758
- }
1759
-
1760
-
1761
- /**
1762
- * This method checks if give user profile is private.
1763
- *
1764
- * @usage <?php UM()->user()->is_private_profile( $user_id ); ?>
1765
- *
1766
- * @param int $user_id A user ID must be passed to check if the user profile is private
1767
- *
1768
- * @return bool
1769
- *
1770
- * @example This example display a specific user's name If his profile is public
1771
-
1772
- <?php
1773
-
1774
- um_fetch_user( 60 );
1775
- $is_private = UM()->user()->is_private_profile( 60 );
1776
- if ( ! $is_private ) {
1777
- echo 'User is public and his name is ' . um_user('display_name');
1778
- }
1779
-
1780
- ?>
1781
- *
1782
- */
1783
- function is_private_profile( $user_id ) {
1784
- $privacy = get_user_meta( $user_id, 'profile_privacy', true );
1785
- if ( $privacy == __( 'Only me', 'ultimate-member' ) || $privacy == 'Only me' ) {
1786
- return true;
1787
- }
1788
- return $this->is_private_case( $user_id, $privacy );
1789
- }
1790
-
1791
-
1792
- /**
1793
- * This method can be used to determine If a certain user is approved or not.
1794
- *
1795
- * @usage <?php UM()->user()->is_approved( $user_id ); ?>
1796
- *
1797
- * @param int $user_id The user ID to check approval status for
1798
- *
1799
- * @return bool
1800
- *
1801
- * @example Do something If a user's membership is approved
1802
-
1803
- <?php
1804
-
1805
- if ( UM()->user()->is_approved( 55 ) {
1806
- // User account is approved
1807
- } else {
1808
- // User account is not approved
1809
- }
1810
-
1811
- ?>
1812
- *
1813
- */
1814
- function is_approved( $user_id ) {
1815
- $status = get_user_meta( $user_id, 'account_status', true );
1816
- if ( $status == 'approved' || $status == '' ) {
1817
- return true;
1818
- }
1819
- return false;
1820
- }
1821
-
1822
-
1823
- /**
1824
- * Is private
1825
- *
1826
- * @param $user_id
1827
- * @param $case
1828
- *
1829
- * @return bool
1830
- */
1831
- function is_private_case( $user_id, $case ) {
1832
- $privacy = get_user_meta( $user_id, 'profile_privacy', true );
1833
-
1834
- if ( $privacy == $case ) {
1835
- /**
1836
- * UM hook
1837
- *
1838
- * @type filter
1839
- * @title um_is_private_filter_hook
1840
- * @description Change user privacy
1841
- * @input_vars
1842
- * [{"var":"$is_private","type":"bool","desc":"Is user private"},
1843
- * {"var":"$privacy","type":"bool","desc":"Profile Privacy"},
1844
- * {"var":"$user_id","type":"int","desc":"User ID"}]
1845
- * @change_log
1846
- * ["Since: 2.0"]
1847
- * @usage
1848
- * <?php add_filter( 'um_is_private_filter_hook', 'function_name', 10, 3 ); ?>
1849
- * @example
1850
- * <?php
1851
- * add_filter( 'um_is_private_filter_hook', 'my_is_private_filter', 10, 3 );
1852
- * function my_is_private_filter( $is_private ) {
1853
- * // your code here
1854
- * return $is_private;
1855
- * }
1856
- * ?>
1857
- */
1858
- $bool = apply_filters( 'um_is_private_filter_hook', false, $privacy, $user_id );
1859
- return $bool;
1860
- }
1861
-
1862
- return false;
1863
- }
1864
-
1865
-
1866
- /**
1867
- * Update files
1868
- *
1869
- * @param $changes
1870
- *
1871
- * @deprecated 2.1.0
1872
- */
1873
- function update_files( $changes ) {
1874
- um_deprecated_function( 'update_files', '2.1.0', '' );
1875
- }
1876
-
1877
-
1878
- /**
1879
- * Update profile
1880
- *
1881
- * @param $changes
1882
- */
1883
- function update_profile( $changes ) {
1884
-
1885
- $args['ID'] = $this->id;
1886
-
1887
- /**
1888
- * UM hook
1889
- *
1890
- * @type filter
1891
- * @title um_before_update_profile
1892
- * @description Change update profile changes data
1893
- * @input_vars
1894
- * [{"var":"$changes","type":"array","desc":"User Profile Changes"},
1895
- * {"var":"$user_id","type":"int","desc":"User ID"}]
1896
- * @change_log
1897
- * ["Since: 2.0"]
1898
- * @usage
1899
- * <?php add_filter( 'um_before_update_profile', 'function_name', 10, 2 ); ?>
1900
- * @example
1901
- * <?php
1902
- * add_filter( 'um_before_update_profile', 'my_before_update_profile', 10, 2 );
1903
- * function my_before_update_profile( $changes, $user_id ) {
1904
- * // your code here
1905
- * return $changes;
1906
- * }
1907
- * ?>
1908
- */
1909
- $changes = apply_filters( 'um_before_update_profile', $changes, $args['ID'] );
1910
-
1911
- foreach ( $changes as $key => $value ) {
1912
- if ( in_array( $key, $this->banned_keys ) ) {
1913
- continue;
1914
- }
1915
-
1916
- if ( ! in_array( $key, $this->update_user_keys ) ) {
1917
- if ( $value === 0 ) {
1918
- update_user_meta( $this->id, $key, '0' );
1919
- } else {
1920
- update_user_meta( $this->id, $key, $value );
1921
- }
1922
- } else {
1923
- $args[ $key ] = esc_attr( $changes[ $key ] );
1924
- }
1925
- }
1926
-
1927
-
1928
- // update user
1929
- if ( count( $args ) > 1 ) {
1930
- //if isset roles argument validate role to properly for security reasons
1931
- if ( isset( $args['role'] ) ) {
1932
- global $wp_roles;
1933
- $um_roles = get_option( 'um_roles', array() );
1934
-
1935
- if ( ! empty( $um_roles ) ) {
1936
- $role_keys = array_map( function( $item ) {
1937
- return 'um_' . $item;
1938
- }, $um_roles );
1939
- } else {
1940
- $role_keys = array();
1941
- }
1942
-
1943
- $exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
1944
-
1945
- if ( in_array( $args['role'], $exclude_roles ) ) {
1946
- unset( $args['role'] );
1947
- }
1948
- }
1949
-
1950
- wp_update_user( $args );
1951
- }
1952
-
1953
- }
1954
-
1955
-
1956
- /**
1957
- * User exists by meta key and value
1958
- *
1959
- * @param $key
1960
- * @param $value
1961
- *
1962
- * @return bool|int
1963
- */
1964
- function user_has_metadata( $key, $value ) {
1965
-
1966
- $value = UM()->validation()->safe_name_in_url( $value );
1967
-
1968
- $ids = get_users( array( 'fields' => 'ID', 'meta_key' => $key, 'meta_value' => $value, 'meta_compare' => '=' ) );
1969
- if ( ! isset( $ids ) || empty( $ids ) ) {
1970
- return false;
1971
- }
1972
-
1973
- foreach ( $ids as $k => $id ) {
1974
-
1975
- if ( $id == um_user('ID') ) {
1976
- unset( $ids[ $k ] );
1977
- } else {
1978
- $duplicates[] = $id;
1979
- }
1980
-
1981
- }
1982
-
1983
- if ( ! empty( $duplicates ) ) {
1984
- return count( $duplicates );
1985
- }
1986
- return false;
1987
- }
1988
-
1989
-
1990
- /**
1991
- * User exists by name
1992
- *
1993
- * @param $value
1994
- *
1995
- * @return bool
1996
- */
1997
- function user_exists_by_name( $value ) {
1998
-
1999
- // Permalink base
2000
- $permalink_base = UM()->options()->get( 'permalink_base' );
2001
-
2002
- $raw_value = $value;
2003
- $value = UM()->validation()->safe_name_in_url( $value );
2004
- $value = um_clean_user_basename( $value );
2005
-
2006
- // Search by Profile Slug
2007
- $args = array(
2008
- 'fields' => array( 'ID' ),
2009
- 'meta_query' => array(
2010
- 'relation' => 'OR',
2011
- array(
2012
- 'key' => 'um_user_profile_url_slug_' . $permalink_base,
2013
- 'value' => strtolower( $raw_value ),
2014
- 'compare' => '=',
2015
- ),
2016
- ),
2017
- );
2018
-
2019
-
2020
- $ids = new \WP_User_Query( $args );
2021
-
2022
- if ( $ids->total_users > 0 ) {
2023
- $um_user_query = current( $ids->get_results() );
2024
- return $um_user_query->ID;
2025
- }
2026
-
2027
- // Search by Display Name or ID
2028
- $args = array(
2029
- 'fields' => array( 'ID' ),
2030
- 'search' => $value,
2031
- 'search_columns' => array( 'display_name', 'ID' ),
2032
- );
2033
-
2034
- $ids = new \WP_User_Query( $args );
2035
-
2036
- if ( $ids->total_users > 0 ) {
2037
- $um_user_query = current( $ids->get_results() );
2038
- return $um_user_query->ID;
2039
- }
2040
-
2041
-
2042
- // Search By User Login
2043
- $value = str_replace( ".", "_", $value );
2044
- $value = str_replace( " ", "", $value );
2045
-
2046
- $args = array(
2047
- 'fields' => array( 'ID' ),
2048
- 'search' => $value,
2049
- 'search_columns' => array(
2050
- 'user_login',
2051
- )
2052
- );
2053
-
2054
- $ids = new \WP_User_Query( $args );
2055
-
2056
- if ( $ids->total_users > 0 ) {
2057
- $um_user_query = current( $ids->get_results() );
2058
- return $um_user_query->ID;
2059
- }
2060
-
2061
- return false;
2062
- }
2063
-
2064
-
2065
- /**
2066
- * This method checks if a user exists or not in your site based on the user ID.
2067
- *
2068
- * @usage <?php UM()->user()->user_exists_by_id( $user_id ); ?>
2069
- *
2070
- * @param int $user_id A user ID must be passed to check if the user exists
2071
- *
2072
- * @return bool|int
2073
- *
2074
- * @example Basic Usage
2075
-
2076
- <?php
2077
-
2078
- $boolean = UM()->user()->user_exists_by_id( 15 );
2079
- if ( $boolean ) {
2080
- // That user exists
2081
- }
2082
-
2083
- ?>
2084
-
2085
- *
2086
- */
2087
- function user_exists_by_id( $user_id ) {
2088
- $aux = get_userdata( absint( $user_id ) );
2089
- if ( $aux == false ) {
2090
- return false;
2091
- } else {
2092
- return $user_id;
2093
- }
2094
- }
2095
-
2096
-
2097
- /**
2098
- * This method checks if a user exists or not in your site based on the user email as username
2099
- *
2100
- * @param string $slug A user slug must be passed to check if the user exists
2101
- *
2102
- * @usage <?php UM()->user()->user_exists_by_email_as_username( $slug ); ?>
2103
- *
2104
- * @return bool
2105
- *
2106
- * @example Basic Usage
2107
-
2108
- <?php
2109
-
2110
- $boolean = UM()->user()->user_exists_by_email_as_username( 'calumgmail-com' );
2111
- if ( $boolean ) {
2112
- // That user exists
2113
- }
2114
-
2115
- ?>
2116
- */
2117
- function user_exists_by_email_as_username( $slug ) {
2118
-
2119
- $user_id = false;
2120
-
2121
- $ids = get_users( array( 'fields' => 'ID', 'meta_key' => 'um_email_as_username_' . $slug ) );
2122
- if ( ! empty( $ids[0] ) ) {
2123
- $user_id = $ids[0];
2124
- }
2125
-
2126
- return $user_id;
2127
- }
2128
-
2129
-
2130
- /**
2131
- * Set gravatar hash id
2132
- *
2133
- * @param $user_id
2134
- * @return string
2135
- */
2136
- function set_gravatar( $user_id ) {
2137
-
2138
- um_fetch_user( $user_id );
2139
- $email_address = um_user( 'user_email' );
2140
- $hash_email_address = '';
2141
-
2142
- if ( $email_address ) {
2143
- $hash_email_address = md5( $email_address );
2144
- $this->profile['synced_gravatar_hashed_id'] = $hash_email_address;
2145
- $this->update_usermeta_info( 'synced_gravatar_hashed_id' );
2146
- }
2147
-
2148
- return $hash_email_address;
2149
- }
2150
-
2151
-
2152
- /**
2153
- * UM Placeholders for activation link in email
2154
- *
2155
- * @param $placeholders
2156
- *
2157
- * @return array
2158
- */
2159
- function add_activation_placeholder( $placeholders ) {
2160
- $placeholders[] = '{account_activation_link}';
2161
- return $placeholders;
2162
- }
2163
-
2164
-
2165
- /**
2166
- * UM Replace Placeholders for activation link in email
2167
- *
2168
- * @param $replace_placeholders
2169
- *
2170
- * @return array
2171
- */
2172
- function add_activation_replace_placeholder( $replace_placeholders ) {
2173
- $replace_placeholders[] = um_user( 'account_activation_link' );
2174
- return $replace_placeholders;
2175
- }
2176
- }
2177
- }
1
+ <?php
2
+ namespace um\core;
3
+
4
+ // Exit if accessed directly
5
+ if ( ! defined( 'ABSPATH' ) ) exit;
6
+
7
+
8
+ if ( ! class_exists( 'um\core\User' ) ) {
9
+
10
+
11
+ /**
12
+ * Class User
13
+ * @package um\core
14
+ */
15
+ class User {
16
+
17
+
18
+ /**
19
+ * User constructor.
20
+ */
21
+ function __construct() {
22
+
23
+ $this->id = 0;
24
+ $this->usermeta = null;
25
+ $this->data = null;
26
+ $this->profile = null;
27
+ $this->cannot_edit = null;
28
+ $this->password_reset_key = null;
29
+
30
+ global $wpdb;
31
+
32
+ $this->banned_keys = array(
33
+ 'metabox','postbox','meta-box',
34
+ 'dismissed_wp_pointers', 'session_tokens',
35
+ 'screen_layout', 'wp_user-', 'dismissed',
36
+ 'cap_key', $wpdb->get_blog_prefix(). 'capabilities',
37
+ 'managenav', 'nav_menu', 'user_activation_key',
38
+ 'level_', $wpdb->get_blog_prefix() . 'user_level'
39
+ );
40
+
41
+ add_action( 'init', array( &$this, 'set' ), 1 );
42
+
43
+ $this->preview = false;
44
+ $this->send_mail_on_delete = true;
45
+
46
+ // a list of keys that should never be in wp_usermeta
47
+ $this->update_user_keys = array(
48
+ 'user_email',
49
+ 'user_pass',
50
+ 'user_password',
51
+ 'display_name',
52
+ 'user_url',
53
+ 'role',
54
+ );
55
+
56
+ $this->target_id = null;
57
+
58
+ // When the cache should be cleared
59
+ add_action( 'um_delete_user_hook', array( &$this, 'remove_cached_queue' ) );
60
+ add_action( 'um_delete_user', array( &$this, 'remove_cache' ), 10, 1 );
61
+
62
+ add_action( 'um_after_user_status_is_changed_hook', array( &$this, 'remove_cached_queue' ) );
63
+
64
+ // When user cache should be cleared
65
+ add_action( 'um_after_user_updated', array( &$this, 'remove_cache' ) );
66
+ add_action( 'um_after_user_account_updated', array( &$this, 'remove_cache' ) );
67
+ add_action( 'personal_options_update', array( &$this, 'remove_cache' ) );
68
+ //add_action('edit_user_profile_update', array(&$this, 'remove_cache') );
69
+ add_action( 'um_when_role_is_set', array( &$this, 'remove_cache' ) );
70
+ add_action( 'um_when_status_is_set', array( &$this, 'remove_cache' ) );
71
+
72
+ add_action( 'show_user_profile', array( $this, 'profile_form_additional_section' ), 10 );
73
+ add_action( 'user_new_form', array( $this, 'profile_form_additional_section' ), 10 );
74
+ add_action( 'edit_user_profile', array( $this, 'profile_form_additional_section' ), 10 );
75
+ add_filter( 'um_user_profile_additional_fields', array( $this, 'secondary_role_field' ), 1, 2 );
76
+
77
+ //on every update of user profile (hook from wp_update_user)
78
+ add_action( 'profile_update', array( &$this, 'profile_update' ), 10, 2 ); // user_id and old_user_data
79
+
80
+ //on user update profile page
81
+ //add_action( 'edit_user_profile_update', array( &$this, 'profile_update' ), 10, 1 );
82
+
83
+ add_action( 'user_register', array( &$this, 'user_register_via_admin' ), 10, 1 );
84
+ add_action( 'user_register', array( &$this, 'set_gravatar' ), 11, 1 );
85
+
86
+
87
+ if ( is_multisite() ) {
88
+ add_action( 'added_existing_user', array( &$this, 'add_um_role_existing_user' ), 10, 2 );
89
+ add_action( 'wpmu_activate_user', array( &$this, 'add_um_role_wpmu_new_user' ), 10, 1 );
90
+ }
91
+
92
+ add_action( 'init', array( &$this, 'check_membership' ), 10 );
93
+
94
+ if ( is_multisite() ) {
95
+ add_action( 'wpmu_delete_user', array( &$this, 'delete_user_handler' ), 10, 1 );
96
+ } else {
97
+ add_action( 'delete_user', array( &$this, 'delete_user_handler' ), 10, 1 );
98
+ }
99
+
100
+
101
+ add_action( 'updated_user_meta', array( &$this, 'on_update_usermeta' ), 10, 4 );
102
+ add_action( 'added_user_meta', array( &$this, 'on_update_usermeta' ), 10, 4 );
103
+
104
+ add_action( 'deleted_user_meta', array( &$this, 'on_delete_usermeta' ), 10, 4 );
105
+ }
106
+
107
+
108
+ /**
109
+ * When you delete usermeta connected with member directory - reset it to default value
110
+ *
111
+ * @param int|array $meta_ids
112
+ * @param int $object_id
113
+ * @param string $meta_key
114
+ * @param mixed $_meta_value
115
+ */
116
+ function on_delete_usermeta( $meta_ids, $object_id, $meta_key, $_meta_value ) {
117
+ $metakeys = array( 'account_status', 'hide_in_members', 'synced_gravatar_hashed_id', 'synced_profile_photo', 'profile_photo', 'cover_photo', '_um_verified' );
118
+ if ( ! in_array( $meta_key, $metakeys ) ) {
119
+ return;
120
+ }
121
+
122
+ $md_data = get_user_meta( $object_id, 'um_member_directory_data', true );
123
+ if ( empty( $md_data ) ) {
124
+ $md_data = array(
125
+ 'account_status' => 'approved',
126
+ 'hide_in_members' => UM()->member_directory()->get_hide_in_members_default(),
127
+ 'profile_photo' => false,
128
+ 'cover_photo' => false,
129
+ 'verified' => false,
130
+ );
131
+ }
132
+
133
+ switch ( $meta_key ) {
134
+ case 'account_status':
135
+ $md_data['account_status'] = 'approved';
136
+ break;
137
+ case 'hide_in_members':
138
+ $md_data['hide_in_members'] = UM()->member_directory()->get_hide_in_members_default();
139
+ break;
140
+ case 'synced_gravatar_hashed_id':
141
+ if ( UM()->options()->get( 'use_gravatars' ) ) {
142
+ $profile_photo = get_user_meta( $object_id, 'profile_photo', true );
143
+ $synced_profile_photo = get_user_meta( $object_id, 'synced_profile_photo', true );
144
+
145
+ $md_data['profile_photo'] = ! empty( $profile_photo ) || ! empty( $synced_profile_photo );
146
+ }
147
+
148
+ break;
149
+ case 'synced_profile_photo':
150
+ $profile_photo = get_user_meta( $object_id, 'profile_photo', true );
151
+
152
+ $synced_gravatar_hashed_id = false;
153
+ if ( UM()->options()->get( 'use_gravatars' ) ) {
154
+ $synced_gravatar_hashed_id = get_user_meta( $object_id, 'synced_gravatar_hashed_id', true );
155
+ }
156
+
157
+ $md_data['profile_photo'] = ! empty( $profile_photo ) || ! empty( $synced_gravatar_hashed_id );
158
+ break;
159
+ case 'profile_photo':
160
+ $synced_profile_photo = get_user_meta( $object_id, 'synced_profile_photo', true );
161
+
162
+ $synced_gravatar_hashed_id = false;
163
+ if ( UM()->options()->get( 'use_gravatars' ) ) {
164
+ $synced_gravatar_hashed_id = get_user_meta( $object_id, 'synced_gravatar_hashed_id', true );
165
+ }
166
+
167
+ $md_data['profile_photo'] = ! empty( $synced_profile_photo ) || ! empty( $synced_gravatar_hashed_id );
168
+ break;
169
+ case 'cover_photo':
170
+ $md_data['cover_photo'] = false;
171
+ break;
172
+ case '_um_verified':
173
+ $md_data['verified'] = false;
174
+ break;
175
+ }
176
+
177
+ update_user_meta( $object_id, 'um_member_directory_data', $md_data );
178
+ }
179
+
180
+
181
+ /**
182
+ * When you add/update usermeta connected with member directories - set this data to member directory metakey
183
+ *
184
+ * @param int $meta_id
185
+ * @param int $object_id
186
+ * @param string $meta_key
187
+ * @param mixed $_meta_value
188
+ */
189
+ function on_update_usermeta( $meta_id, $object_id, $meta_key, $_meta_value ) {
190
+
191
+ $metakeys = array( 'account_status', 'hide_in_members', 'synced_gravatar_hashed_id', 'synced_profile_photo', 'profile_photo', 'cover_photo', '_um_verified' );
192
+ if ( ! in_array( $meta_key, $metakeys ) ) {
193
+ return;
194
+ }
195
+
196
+ $md_data = get_user_meta( $object_id, 'um_member_directory_data', true );
197
+ if ( empty( $md_data ) ) {
198
+ $md_data = array(
199
+ 'account_status' => 'approved',
200
+ 'hide_in_members' => UM()->member_directory()->get_hide_in_members_default(),
201
+ 'profile_photo' => false,
202
+ 'cover_photo' => false,
203
+ 'verified' => false,
204
+ );
205
+ }
206
+
207
+ switch ( $meta_key ) {
208
+ case 'account_status':
209
+ $md_data['account_status'] = $_meta_value;
210
+ break;
211
+ case 'hide_in_members':
212
+
213
+ $hide_in_members = UM()->member_directory()->get_hide_in_members_default();
214
+ if ( ! empty( $_meta_value ) ) {
215
+ if ( $_meta_value == 'Yes' || $_meta_value == __( 'Yes', 'ultimate-member' ) ||
216
+ array_intersect( array( 'Yes', __( 'Yes', 'ultimate-member' ) ), $_meta_value ) ) {
217
+ $hide_in_members = true;
218
+ } else {
219
+ $hide_in_members = false;
220
+ }
221
+ }
222
+
223
+ $md_data['hide_in_members'] = $hide_in_members;
224
+
225
+ break;
226
+ case 'synced_gravatar_hashed_id':
227
+ if ( UM()->options()->get( 'use_gravatars' ) ) {
228
+ if ( empty( $md_data['profile_photo'] ) ) {
229
+ $md_data['profile_photo'] = ! empty( $_meta_value );
230
+ }
231
+ }
232
+
233
+ break;
234
+ case 'synced_profile_photo':
235
+ case 'profile_photo':
236
+ if ( empty( $md_data['profile_photo'] ) ) {
237
+ $md_data['profile_photo'] = ! empty( $_meta_value );
238
+ }
239
+ break;
240
+ case 'cover_photo':
241
+ $md_data['cover_photo'] = ! empty( $_meta_value );
242
+ break;
243
+ case '_um_verified':
244
+ $md_data['verified'] = $_meta_value == 'verified' ? true : false;
245
+ break;
246
+ }
247
+
248
+ update_user_meta( $object_id, 'um_member_directory_data', $md_data );
249
+ }
250
+
251
+
252
+ /**
253
+ * @param $user_id
254
+ */
255
+ function delete_user_handler( $user_id ) {
256
+ um_fetch_user( $user_id );
257
+
258
+ /**
259
+ * UM hook
260
+ *
261
+ * @type action
262
+ * @title um_delete_user_hook
263
+ * @description On delete user
264
+ * @change_log
265
+ * ["Since: 2.0"]
266
+ * @usage add_action( 'um_delete_user_hook', 'function_name', 10 );
267
+ * @example
268
+ * <?php
269
+ * add_action( 'um_delete_user_hook', 'my_delete_user', 10 );
270
+ * function my_delete_user() {
271
+ * // your code here
272
+ * }
273
+ * ?>
274
+ */
275
+ do_action( 'um_delete_user_hook' );
276
+
277
+ /**
278
+ * UM hook
279
+ *
280
+ * @type action
281
+ * @title um_delete_user
282
+ * @description On delete user
283
+ * @input_vars
284
+ * [{"var":"$user_id","type":"int","desc":"User ID"}]
285
+ * @change_log
286
+ * ["Since: 2.0"]
287
+ * @usage add_action( 'um_delete_user', 'function_name', 10, 1 );
288
+ * @example
289
+ * <?php
290
+ * add_action( 'um_delete_user', 'my_delete_user', 10, 1 );
291
+ * function my_delete_user( $user_id ) {
292
+ * // your code here
293
+ * }
294
+ * ?>
295
+ */
296
+ do_action( 'um_delete_user', um_user( 'ID' ) );
297
+
298
+ // send email notifications
299
+ if ( $this->send_mail_on_delete ) {
300
+ UM()->mail()->send( um_user( 'user_email' ), 'deletion_email' );
301
+
302
+ $emails = um_multi_admin_email();
303
+ if ( ! empty( $emails ) ) {
304
+ foreach ( $emails as $email ) {
305
+ UM()->mail()->send( $email, 'notification_deletion', array( 'admin' => true ) );
306
+ }
307
+ }
308
+ }
309
+
310
+ // remove uploads
311
+ UM()->files()->remove_dir( UM()->files()->upload_temp );
312
+ UM()->files()->remove_dir( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR );
313
+ }
314
+
315
+
316
+ /**
317
+ *
318
+ */
319
+ function check_membership() {
320
+ if ( ! is_user_logged_in() ) {
321
+ return;
322
+ }
323
+
324
+ um_fetch_user( get_current_user_id() );
325
+ $status = um_user( 'account_status' );
326
+
327
+ if ( 'rejected' == $status ) {
328
+ wp_logout();
329
+ session_unset();
330
+ exit( wp_redirect( um_get_core_page( 'login' ) ) );
331
+ }
332
+
333
+ um_reset_user();
334
+ }
335
+
336
+
337
+ /**
338
+ * Multisite add existing user
339
+ *
340
+ * @param $user_id
341
+ * @param $result
342
+ */
343
+ function add_um_role_existing_user( $user_id, $result ) {
344
+ // Bail if no user ID was passed
345
+ if ( empty( $user_id ) ) {
346
+ return;
347
+ }
348
+
349
+ if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
350
+ if ( ! user_can( $user_id, sanitize_key( $_POST['um-role'] ) ) ) {
351
+ UM()->roles()->set_role( $user_id, sanitize_key( $_POST['um-role'] ) );
352
+ }
353
+ }
354
+
355
+ $this->remove_cache( $user_id );
356
+ }
357
+
358
+
359
+ /**
360
+ * Multisite add existing user
361
+ *
362
+ * @param $user_id
363
+ */
364
+ function add_um_role_wpmu_new_user( $user_id ) {
365
+ // Bail if no user ID was passed
366
+ if ( empty( $user_id ) ) {
367
+ return;
368
+ }
369
+
370
+ if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
371
+ if ( ! user_can( $user_id, sanitize_key( $_POST['um-role'] ) ) ) {
372
+ UM()->roles()->set_role( $user_id, sanitize_key( $_POST['um-role'] ) );
373
+ }
374
+ }
375
+
376
+ $this->remove_cache( $user_id );
377
+ }
378
+
379
+
380
+ /**
381
+ * Get pending users (in queue)
382
+ */
383
+ function get_pending_users_count() {
384
+
385
+ $cached_users_queue = get_option( 'um_cached_users_queue' );
386
+ if ( $cached_users_queue > 0 && ! isset( $_REQUEST['delete_count'] ) ) {
387
+ return $cached_users_queue;
388
+ }
389
+
390
+ $args = array( 'fields' => 'ID', 'number' => 1 );
391
+ $args['meta_query']['relation'] = 'OR';
392
+ $args['meta_query'][] = array(
393
+ 'key' => 'account_status',
394
+ 'value' => 'awaiting_email_confirmation',
395
+ 'compare' => '='
396
+ );
397
+ $args['meta_query'][] = array(
398
+ 'key' => 'account_status',
399
+ 'value' => 'awaiting_admin_review',
400
+ 'compare' => '='
401
+ );
402
+
403
+ /**
404
+ * UM hook
405
+ *
406
+ * @type filter
407
+ * @title um_admin_pending_queue_filter
408
+ * @description Change user query arguments when get pending users
409
+ * @input_vars
410
+ * [{"var":"$args","type":"array","desc":"WP_Users query arguments"}]
411
+ * @change_log
412
+ * ["Since: 2.0"]
413
+ * @usage
414
+ * <?php add_filter( 'um_admin_pending_queue_filter', 'function_name', 10, 1 ); ?>
415
+ * @example
416
+ * <?php
417
+ * add_filter( 'um_admin_pending_queue_filter', 'my_admin_pending_queue', 10, 1 );
418
+ * function my_admin_pending_queue( $args ) {
419
+ * // your code here
420
+ * return $args;
421
+ * }
422
+ * ?>
423
+ */
424
+ $args = apply_filters( 'um_admin_pending_queue_filter', $args );
425
+ $users = new \WP_User_Query( $args );
426
+
427
+ delete_option( 'um_cached_users_queue' );
428
+ add_option( 'um_cached_users_queue', $users->get_total(), '', 'no' );
429
+
430
+ return $users->get_total();
431
+ }
432
+
433
+
434
+ /**
435
+ * @param $user_id
436
+ *
437
+ * @return bool|mixed
438
+ */
439
+ function get_profile_slug( $user_id ) {
440
+ // Permalink base
441
+ $permalink_base = UM()->options()->get( 'permalink_base' );
442
+ $profile_slug = get_user_meta( $user_id, "um_user_profile_url_slug_{$permalink_base}", true );
443
+
444
+ //get default username permalink if it's empty then return false
445
+ if ( empty( $profile_slug ) ) {
446
+ if ( $permalink_base != 'user_login' ) {
447
+ $profile_slug = get_user_meta( $user_id, 'um_user_profile_url_slug_user_login', true );
448
+ }
449
+
450
+ if ( empty( $profile_slug ) ) {
451
+ return false;
452
+ }
453
+ }
454
+
455
+ return $profile_slug;
456
+ }
457
+
458
+
459
+ /**
460
+ * @param $user_id
461
+ *
462
+ * @return bool|string
463
+ */
464
+ function get_profile_link( $user_id ) {
465
+ $profile_slug = $this->get_profile_slug( $user_id );
466
+
467
+ if ( empty( $profile_slug ) ) {
468
+ return false;
469
+ }
470
+
471
+ return UM()->permalinks()->profile_permalink( $profile_slug );
472
+ }
473
+
474
+
475
+ /**
476
+ * Generate User Profile Slug and save to meta
477
+ *
478
+ * @param int $user_id
479
+ * @param bool $force
480
+ */
481
+ function generate_profile_slug( $user_id, $force = false ) {
482
+ $userdata = get_userdata( $user_id );
483
+
484
+ if ( empty( $userdata ) ) {
485
+ return;
486
+ }
487
+
488
+ delete_option( "um_cache_userdata_{$user_id}" );
489
+
490
+ $current_profile_slug = $this->get_profile_slug( $user_id );
491
+
492
+ $user_in_url = '';
493
+ $permalink_base = UM()->options()->get( 'permalink_base' );
494
+
495
+ // User ID
496
+ if ( $permalink_base == 'user_id' ) {
497
+ $user_in_url = $user_id;
498
+ }
499
+
500
+ // Username
501
+ if ( $permalink_base == 'user_login' ) {
502
+
503
+ $user_in_url = $userdata->user_login;
504
+
505
+ if ( is_email( $user_in_url ) ) {
506
+
507
+ $user_email = $user_in_url;
508
+ $user_in_url = str_replace( '@', '', $user_in_url );
509
+
510
+ if ( ( $pos = strrpos( $user_in_url, '.' ) ) !== false ) {
511
+ $search_length = strlen( '.' );
512
+ $user_in_url = substr_replace( $user_in_url, '-', $pos, $search_length );
513
+ }
514
+ update_user_meta( $user_id, "um_email_as_username_{$user_in_url}", $user_email );
515
+
516
+ } else {
517
+
518
+ $user_in_url = urlencode( $user_in_url );
519
+
520
+ }
521
+ }
522
+
523
+ // Fisrt and Last name
524
+ $full_name_permalinks = array( 'name', 'name_dash', 'name_plus' );
525
+ if ( in_array( $permalink_base, $full_name_permalinks ) ) {
526
+ $separated = array( 'name' => '.', 'name_dash' => '-', 'name_plus' => '+' );
527
+ $separate = $separated[ $permalink_base ];
528
+ $first_name = $userdata->first_name;
529
+ $last_name = $userdata->last_name;
530
+ $full_name = trim( sprintf( '%s %s', $first_name, $last_name ) );
531
+ $full_name = preg_replace( '/\s+/', ' ', $full_name ); // Remove double spaces
532
+ $profile_slug = UM()->permalinks()->profile_slug( $full_name, $first_name, $last_name );
533
+
534
+ $append = 0;
535
+ $username = $full_name;
536
+ $_username = $full_name;
537
+
538
+ while ( 1 ) {
539
+ $username = $_username . ( empty( $append ) ? '' : " $append" );
540
+ $slug_exists_user_id = UM()->permalinks()->slug_exists_user_id( $profile_slug . ( empty( $append ) ? '' : "{$separate}{$append}" ) );
541
+ if ( empty( $slug_exists_user_id ) || $user_id == $slug_exists_user_id ) {
542
+ break;
543
+ }
544
+ $append++;
545
+ }
546
+
547
+ $user_in_url = UM()->permalinks()->profile_slug( $username, $first_name, $last_name );
548
+ if ( empty( $user_in_url ) ) {
549
+ $user_in_url = $userdata->user_login;
550
+
551
+ if ( is_email( $user_in_url ) ) {
552
+
553
+ $user_email = $user_in_url;
554
+ $user_in_url = str_replace( '@', '', $user_in_url );
555
+
556
+ if ( ( $pos = strrpos( $user_in_url, '.' ) ) !== false ) {
557
+ $search_length = strlen( '.' );
558
+ $user_in_url = substr_replace( $user_in_url, '-', $pos, $search_length );
559
+ }
560
+ update_user_meta( $user_id, "um_email_as_username_{$user_in_url}", $user_email );
561
+
562
+ } else {
563
+
564
+ $user_in_url = sanitize_title( $user_in_url );
565
+
566
+ }
567
+ }
568
+
569
+ $user_in_url = trim( $user_in_url, $separate );
570
+ }
571
+
572
+ $user_in_url = apply_filters( 'um_change_user_profile_slug', $user_in_url, $user_id );
573
+
574
+ if ( $force || empty( $current_profile_slug ) || $current_profile_slug != $user_in_url ) {
575
+ update_user_meta( $user_id, "um_user_profile_url_slug_{$permalink_base}", $user_in_url );
576
+ }
577
+ }
578
+
579
+
580
+ /**
581
+ * Backend user creation
582
+ *
583
+ * @param $user_id
584
+ */
585
+ function user_register_via_admin( $user_id ) {
586
+
587
+ if ( empty( $user_id ) ) {
588
+ return;
589
+ }
590
+
591
+ if ( is_admin() ) {
592
+ //if there custom 2 role not empty
593
+ if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
594
+ $user = get_userdata( $user_id );
595
+ $user->add_role( sanitize_key( $_POST['um-role'] ) );
596
+ UM()->user()->profile['role'] = sanitize_key( $_POST['um-role'] );
597
+ UM()->user()->update_usermeta_info( 'role' );
598
+ }
599
+
600
+ /**
601
+ * UM hook
602
+ *
603
+ * @type action
604
+ * @title um_user_register
605
+ * @description Action on user registration
606
+ * @input_vars
607
+ * [{"var":"$user_id","type":"int","desc":"User ID"},
608
+ * {"var":"$submitted","type":"array","desc":"Registration form submitted"}]
609
+ * @change_log
610
+ * ["Since: 2.0"]
611
+ * @usage add_action( 'um_user_register', 'function_name', 10, 2 );
612
+ * @example
613
+ * <?php
614
+ * add_action( 'um_user_register', 'my_user_register', 10, 2 );
615
+ * function my_user_register( $user_id, $submitted ) {
616
+ * // your code here
617
+ * }
618
+ * ?>
619
+ */
620
+ do_action( 'um_user_register', $user_id, $_POST );
621
+ }
622
+
623
+ }
624
+
625
+
626
+ /**
627
+ * On wp_update_user function complete
628
+ *
629
+ * @param int $user_id
630
+ * @param \WP_User $old_data
631
+ */
632
+ function profile_update( $user_id, $old_data ) {
633
+ // Bail if no user ID was passed
634
+ if ( empty( $user_id ) ) {
635
+ return;
636
+ }
637
+
638
+ $old_roles = $old_data->roles;
639
+ $userdata = get_userdata( $user_id );
640
+ $new_roles = $userdata->roles;
641
+
642
+ if ( is_admin() ) {
643
+ if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
644
+ $new_roles = array_merge( $new_roles, array( sanitize_key( $_POST['um-role'] ) ) );
645
+ if ( ! user_can( $user_id, sanitize_key( $_POST['um-role'] ) ) ) {
646
+ UM()->roles()->set_role( $user_id, sanitize_key( $_POST['um-role'] ) );
647
+ }
648
+ }
649
+ }
650
+
651
+ /**
652
+ * UM hook
653
+ *
654
+ * @type action
655
+ * @title um_after_member_role_upgrade
656
+ * @description Action on user registration
657
+ * @input_vars
658
+ * [{"var":"$new_roles","type":"array","desc":"User new roles"},
659
+ * {"var":"$old_roles","type":"array","desc":"Old roles"}]
660
+ * @change_log
661
+ * ["Since: 2.0"]
662
+ * @usage add_action( 'um_after_member_role_upgrade', 'function_name', 10, 2 );
663
+ * @example
664
+ * <?php
665
+ * add_action( 'um_after_member_role_upgrade', 'my_after_member_role_upgrade', 10, 2 );
666
+ * function my_after_member_role_upgrade( $new_roles, $old_roles ) {
667
+ * // your code here
668
+ * }
669
+ * ?>
670
+ */
671
+ do_action( 'um_after_member_role_upgrade', $new_roles, $old_roles, $user_id );
672
+
673
+ //Update permalink
674
+ $this->generate_profile_slug( $user_id, true );
675
+
676
+ $this->remove_cache( $user_id );
677
+ }
678
+
679
+
680
+ /**
681
+ * Additional section for WP Profile page with UM data fields
682
+ *
683
+ * @param \WP_User $userdata User data
684
+ * @return void
685
+ */
686
+ function profile_form_additional_section( $userdata ) {
687
+
688
+ /**
689
+ * UM hook
690
+ *
691
+ * @type filter
692
+ * @title um_user_profile_additional_fields
693
+ * @description Make additional content section
694
+ * @input_vars
695
+ * [{"var":"$content","type":"array","desc":"Additional section content"},
696
+ * {"var":"$userdata","type":"array","desc":"Userdata"}]
697
+ * @change_log
698
+ * ["Since: 2.0"]
699
+ * @usage
700
+ * <?php add_filter( 'um_user_profile_additional_fields', 'function_name', 10, 2 ); ?>
701
+ * @example
702
+ * <?php
703
+ * add_filter( 'um_user_profile_additional_fields', 'my_admin_pending_queue', 10, 2 );
704
+ * function my_admin_pending_queue( $content, $userdata ) {
705
+ * // your code here
706
+ * return $content;
707
+ * }
708
+ * ?>
709
+ */
710
+ $section_content = apply_filters( 'um_user_profile_additional_fields', '', $userdata );
711
+
712
+ if ( ! empty( $section_content ) && ! ( is_multisite() && is_network_admin() ) ) {
713
+
714
+ if ( $userdata !== 'add-new-user' && $userdata !== 'add-existing-user' ) { ?>
715
+ <h3 id="um_user_screen_block"><?php esc_html_e( 'Ultimate Member', 'ultimate-member' ); ?></h3>
716
+ <?php }
717
+
718
+ echo $section_content;
719
+ }
720
+ }
721
+
722
+
723
+ /**
724
+ * Default interface for setting a ultimatemember role
725
+ *
726
+ * @param string $content Section HTML
727
+ * @param \WP_User $userdata User data
728
+ * @return string
729
+ */
730
+ public function secondary_role_field( $content, $userdata ) {
731
+ $roles = array();
732
+
733
+ $role_keys = get_option( 'um_roles', array() );
734
+ if ( $role_keys ) {
735
+ foreach ( $role_keys as $role_key ) {
736
+ $role_meta = get_option( "um_role_{$role_key}_meta" );
737
+
738
+ if ( $role_meta ) {
739
+ $roles[ 'um_' . $role_key ] = $role_meta;
740
+ }
741
+ }
742
+ }
743
+
744
+ if ( empty( $roles ) ) {
745
+ return $content;
746
+ }
747
+
748
+ global $pagenow;
749
+ if ( 'profile.php' == $pagenow ) {
750
+ return $content;
751
+ }
752
+
753
+ $style = '';
754
+ $user_role = false;
755
+ if ( $userdata !== 'add-new-user' && $userdata !== 'add-existing-user' ) {
756
+ // Bail if current user cannot edit users
757
+ if ( ! current_user_can( 'edit_user', $userdata->ID ) ) {
758
+ return $content;
759
+ }
760
+
761
+ $user_role = UM()->roles()->get_um_user_role( $userdata->ID );
762
+ if ( $user_role && ! empty( $userdata->roles ) && count( $userdata->roles ) == 1 ) {
763
+ $style = 'style="display:none;"';
764
+ }
765
+
766
+ }
767
+
768
+ $class = ( $userdata == 'add-existing-user' ) ? 'um_role_existing_selector_wrapper' : 'um_role_selector_wrapper';
769
+
770
+ ob_start(); ?>
771
+
772
+ <div id="<?php echo esc_attr( $class ) ?>" <?php echo $style ?>>
773
+ <table class="form-table">
774
+ <tbody>
775
+ <tr>
776
+ <th><label for="um-role"><?php esc_html_e( 'Ultimate Member Role', 'ultimate-member' ); ?></label></th>
777
+ <td>
778
+ <select name="um-role" id="um-role">
779
+ <option value="" <?php selected( empty( $user_role ) ) ?>><?php esc_html_e( '&mdash; No role for Ultimate Member &mdash;', 'ultimate-member' ); ?></option>
780
+ <?php foreach ( $roles as $role_id => $details ) { ?>
781
+ <option <?php selected( $user_role, $role_id ); ?> value="<?php echo esc_attr( $role_id ); ?>"><?php echo esc_html( $details['name'] ); ?></option>
782
+ <?php } ?>
783
+ </select>
784
+ </td>
785
+ </tr>
786
+ </tbody>
787
+ </table>
788
+ </div>
789
+
790
+ <?php $content .= ob_get_clean();
791
+
792
+ return $content;
793
+ }
794
+
795
+
796
+ /**
797
+ * Remove cached queue from Users backend
798
+ */
799
+ function remove_cached_queue() {
800
+ delete_option( 'um_cached_users_queue' );
801
+ }
802
+
803
+
804
+ /**
805
+ * Converts object to array
806
+ *
807
+ * @param $obj
808
+ *
809
+ * @return array
810
+ */
811
+ function toArray( $obj ) {
812
+ if ( is_object( $obj ) ) {
813
+ $obj = (array) $obj;
814
+ }
815
+ if ( is_array( $obj ) ) {
816
+ $new = array();
817
+ foreach ( $obj as $key => $val ) {
818
+ $new[ $key ] = $this->toArray( $val );
819
+ }
820
+ } else {
821
+ $new = $obj;
822
+ }
823
+
824
+ return $new;
825
+ }
826
+
827
+
828
+ /**
829
+ * @param $user_id
830
+ *
831
+ * @return mixed|string
832
+ */
833
+ function get_cached_data( $user_id ) {
834
+
835
+ $disallow_cache = UM()->options()->get( 'um_profile_object_cache_stop' );
836
+ if ( $disallow_cache ) {
837
+ return '';
838
+ }
839
+
840
+ if ( is_numeric( $user_id ) && $user_id > 0 ) {
841
+ $find_user = get_option( "um_cache_userdata_{$user_id}" );
842
+ if ( $find_user ) {
843
+ /**
844
+ * UM hook
845
+ *
846
+ * @type filter
847
+ * @title um_user_permissions_filter
848
+ * @description Change User Permissions
849
+ * @input_vars
850
+ * [{"var":"$permissions","type":"array","desc":"User Permissions"},
851
+ * {"var":"$user_id","type":"int","desc":"User ID"}]
852
+ * @change_log
853
+ * ["Since: 2.0"]
854
+ * @usage
855
+ * <?php add_filter( 'um_user_permissions_filter', 'function_name', 10, 2 ); ?>
856
+ * @example
857
+ * <?php
858
+ * add_filter( 'um_user_permissions_filter', 'my_user_permissions', 10, 2 );
859
+ * function my_user_permissions( $permissions, $user_id ) {
860
+ * // your code here
861
+ * return $permissions;
862
+ * }
863
+ * ?>
864
+ */
865
+ $find_user = apply_filters( 'um_user_permissions_filter', $find_user, $user_id );
866
+ return $find_user;
867
+ }
868
+ }
869
+ return '';
870
+ }
871
+
872
+
873
+ /**
874
+ * @param $user_id
875
+ * @param $profile
876
+ */
877
+ function setup_cache( $user_id, $profile ) {
878
+
879
+ $disallow_cache = UM()->options()->get( 'um_profile_object_cache_stop' );
880
+ if ( $disallow_cache ) {
881
+ return;
882
+ }
883
+
884
+ update_option( "um_cache_userdata_{$user_id}", $profile, false );
885
+ }
886
+
887
+
888
+ /**
889
+ * @param $user_id
890
+ */
891
+ function remove_cache( $user_id ) {
892
+ delete_option( "um_cache_userdata_{$user_id}" );
893
+ }
894
+
895
+
896
+ /**
897
+ * Remove cache for all users
898
+ */
899
+ function remove_cache_all_users() {
900
+ global $wpdb;
901
+ $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" );
902
+ }
903
+
904
+
905
+ /**
906
+ * This method lets you set a user. For example, to retrieve a profile or anything related to that user.
907
+ *
908
+ * @usage <?php UM()->user()->set( $user_id, $clean = false ); ?>
909
+ *
910
+ * @param null|int $user_id Which user to retrieve. A numeric user ID
911
+ * @param bool $clean Should be true or false. Basically, if you did not provide a user ID It will set the current logged in user as a profile
912
+ *
913
+ * @example The following example makes you set a user and retrieve their display name after that using the user API.
914
+
915
+ <?php
916
+
917
+ UM()->user()->set( 12 );
918
+ $display_name = UM()->user()->profile['display_name']; // Should print user display name
919
+
920
+ ?>
921
+ *
922
+ */
923
+ function set( $user_id = null, $clean = false ) {
924
+ if ( isset( $this->profile ) ) {
925
+ unset( $this->profile );
926
+ }
927
+
928
+ if ( $user_id ) {
929
+ $this->id = $user_id;
930
+ } elseif ( is_user_logged_in() && $clean == false ) {
931
+ $this->id = get_current_user_id();
932
+ } else {
933
+ $this->id = 0;
934
+ }
935
+
936
+ if ( $this->get_cached_data( $this->id ) ) {
937
+ $this->profile = $this->get_cached_data( $this->id );
938
+ } else {
939
+
940
+ if ( $user_id ) {
941
+
942
+ $this->id = $user_id;
943
+ $this->usermeta = get_user_meta( $user_id );
944
+ $this->data = get_userdata( $this->id );
945
+
946
+ } elseif ( is_user_logged_in() && $clean == false ) {
947
+
948
+ $this->id = get_current_user_id();
949
+ $this->usermeta = get_user_meta($this->id);
950
+ $this->data = get_userdata($this->id);
951
+
952
+ } else {
953
+
954
+ $this->id = 0;
955
+ $this->usermeta = null;
956
+ $this->data = null;
957
+
958
+ }
959
+
960
+ // we have a user, populate a profile
961
+ if ( $this->id && $this->toArray( $this->data ) ) {
962
+
963
+ // add user data
964
+ $this->data = $this->toArray( $this->data );
965
+
966
+ foreach ( $this->data as $k=>$v ) {
967
+ if ( $k == 'roles') {
968
+ $this->profile['wp_roles'] = implode(',',$v);
969
+ } else if ( is_array( $v ) ) {
970
+ foreach($v as $k2 => $v2){
971
+ $this->profile[$k2] = $v2;
972
+ }
973
+ } else {
974
+ $this->profile[$k] = $v;
975
+ }
976
+ }
977
+
978
+ // add account status
979
+ if ( !isset( $this->usermeta['account_status'][0] ) ) {
980
+ $this->usermeta['account_status'][0] = 'approved';
981
+ }
982
+
983
+ if ( $this->usermeta['account_status'][0] == 'approved' ) {
984
+ $this->usermeta['account_status_name'][0] = __('Approved','ultimate-member');
985
+ }
986
+
987
+ if ( $this->usermeta['account_status'][0] == 'awaiting_email_confirmation' ) {
988
+ $this->usermeta['account_status_name'][0] = __('Awaiting E-mail Confirmation','ultimate-member');
989
+ }
990
+
991
+ if ( $this->usermeta['account_status'][0] == 'awaiting_admin_review' ) {
992
+ $this->usermeta['account_status_name'][0] = __('Pending Review','ultimate-member');
993
+ }
994
+
995
+ if ( $this->usermeta['account_status'][0] == 'rejected' ) {
996
+ $this->usermeta['account_status_name'][0] = __('Membership Rejected','ultimate-member');
997
+ }
998
+
999
+ if ( $this->usermeta['account_status'][0] == 'inactive' ) {
1000
+ $this->usermeta['account_status_name'][0] = __('Membership Inactive','ultimate-member');
1001
+ }
1002
+
1003
+ // add user meta
1004
+ foreach ( $this->usermeta as $k => $v ) {
1005
+ if ( $k == 'display_name') {
1006
+ continue;
1007
+ }
1008
+ $this->profile[ $k ] = $v[0];
1009
+ }
1010
+
1011
+ // add permissions
1012
+ $user_role = UM()->roles()->get_priority_user_role( $this->id );
1013
+ $this->profile['role'] = $user_role;
1014
+ $this->profile['roles'] = UM()->roles()->get_all_user_roles( $this->id );
1015
+
1016
+ $role_meta = UM()->roles()->role_data( $user_role );
1017
+ /**
1018
+ * UM hook
1019
+ *
1020
+ * @type filter
1021
+ * @title um_user_permissions_filter
1022
+ * @description Change User Permissions
1023
+ * @input_vars
1024
+ * [{"var":"$permissions","type":"array","desc":"User Permissions"},
1025
+ * {"var":"$user_id","type":"int","desc":"User ID"}]
1026
+ * @change_log
1027
+ * ["Since: 2.0"]
1028
+ * @usage
1029
+ * <?php add_filter( 'um_user_permissions_filter', 'function_name', 10, 2 ); ?>
1030
+ * @example
1031
+ * <?php
1032
+ * add_filter( 'um_user_permissions_filter', 'my_user_permissions', 10, 2 );
1033
+ * function my_user_permissions( $permissions, $user_id ) {
1034
+ * // your code here
1035
+ * return $permissions;
1036
+ * }
1037
+ * ?>
1038
+ */
1039
+ $role_meta = apply_filters( 'um_user_permissions_filter', $role_meta, $this->id );
1040
+
1041
+ /*$role_meta = array_map( function( $key, $item ) {
1042
+ if ( strpos( $key, '_um_' ) === 0 )
1043
+ $key = str_replace( '_um_', '', $key );
1044
+
1045
+ return array( $key => $item );
1046
+ }, array_keys( $role_meta ), $role_meta );*/
1047
+
1048
+ $this->profile = array_merge( $this->profile, (array)$role_meta );
1049
+
1050
+ $this->profile['super_admin'] = ( is_super_admin( $this->id ) ) ? 1 : 0;
1051
+
1052
+ // clean profile
1053
+ $this->clean();
1054
+
1055
+ // Setup cache
1056
+ $this->setup_cache( $this->id, $this->profile );
1057
+
1058
+ }
1059
+
1060
+ }
1061
+
1062
+ }
1063
+
1064
+
1065
+ /**
1066
+ * Reset user data
1067
+ *
1068
+ * @param bool $clean
1069
+ */
1070
+ function reset( $clean = false ){
1071
+ $this->set(0, $clean);
1072
+ }
1073
+
1074
+
1075
+ /**
1076
+ * Clean user profile
1077
+ */
1078
+ function clean() {
1079
+ foreach ( $this->profile as $key => $value ) {
1080
+ foreach ( $this->banned_keys as $ban ) {
1081
+ if ( strstr( $key, $ban ) || is_numeric( $key ) ) {
1082
+ unset( $this->profile[ $key ] );
1083
+ }
1084
+ }
1085
+ }
1086
+ }
1087
+
1088
+
1089
+ /**
1090
+ * This method lets you auto sign-in a user to your site.
1091
+ *
1092
+ * @usage <?php UM()->user()->auto_login( $user_id, $rememberme = false ); ?>
1093
+ *
1094
+ * @param int $user_id Which user ID to sign in automatically
1095
+ * @param int|bool $rememberme Should be true or false. If you want the user sign in session to use cookies, use true
1096
+ *
1097
+ * @example The following example lets you sign in a user automatically by their ID.
1098
+
1099
+ <?php UM()->user()->auto_login( 2 ); ?>
1100
+ *
1101
+ *
1102
+ * @example The following example lets you sign in a user automatically by their ID and makes the plugin remember their session.
1103
+
1104
+ <?php UM()->user()->auto_login( 10, true ); ?>
1105
+ *
1106
+ */
1107
+ function auto_login( $user_id, $rememberme = 0 ) {
1108
+
1109
+ wp_set_current_user( $user_id );
1110
+
1111
+ wp_set_auth_cookie( $user_id, $rememberme );
1112
+
1113
+ $user = get_user_by( 'ID', $user_id );
1114
+
1115
+ do_action( 'wp_login', $user->user_login, $user );
1116
+
1117
+ }
1118
+
1119
+
1120
+ /**
1121
+ * Set user's registration details
1122
+ *
1123
+ * @param array $submitted
1124
+ * @param array $args
1125
+ */
1126
+ function set_registration_details( $submitted, $args ) {
1127
+
1128
+ if ( isset( $submitted['user_pass'] ) ) {
1129
+ unset( $submitted['user_pass'] );
1130
+ }
1131
+
1132
+ if ( isset( $submitted['user_password'] ) ) {
1133
+ unset( $submitted['user_password'] );
1134
+ }
1135
+
1136
+ if ( isset( $submitted['confirm_user_password'] ) ) {
1137
+ unset( $submitted['confirm_user_password'] );
1138
+ }
1139
+
1140
+ //remove all password field values from submitted details
1141
+ $password_fields = array();
1142
+ foreach ( $submitted as $k => $v ) {
1143
+ if ( UM()->fields()->get_field_type( $k ) == 'password' ) {
1144
+ $password_fields[] = $k;
1145
+ $password_fields[] = 'confirm_' . $k;
1146
+ }
1147
+ }
1148
+
1149
+ foreach ( $password_fields as $pw_field ) {
1150
+ unset( $submitted[ $pw_field ] );
1151
+ }
1152
+
1153
+
1154
+ /**
1155
+ * UM hook
1156
+ *
1157
+ * @type filter
1158
+ * @title um_before_save_filter_submitted
1159
+ * @description Change submitted data before save usermeta "submitted" on registration process
1160
+ * @input_vars
1161
+ * [{"var":"$submitted","type":"array","desc":"Submitted data"},
1162
+ * {"var":"$args","type":"array","desc":"Form Args"}]
1163
+ * @change_log
1164
+ * ["Since: 2.0"]
1165
+ * @usage
1166
+ * <?php add_filter( 'um_before_save_filter_submitted', 'function_name', 10, 2 ); ?>
1167
+ * @example
1168
+ * <?php
1169
+ * add_filter( 'um_before_save_filter_submitted', 'my_before_save_filter_submitted', 10, 2 );
1170
+ * function my_before_save_filter_submitted( $submitted, $args ) {
1171
+ * // your code here
1172
+ * return $submitted;
1173
+ * }
1174
+ * ?>
1175
+ */
1176
+ $submitted = apply_filters( 'um_before_save_filter_submitted', $submitted, $args );
1177
+
1178
+ /**
1179
+ * UM hook
1180
+ *
1181
+ * @type action
1182
+ * @title um_before_save_registration_details
1183
+ * @description Action on user registration before save details
1184
+ * @input_vars
1185
+ * [{"var":"$user_id","type":"int","desc":"User ID"},
1186
+ * {"var":"$submitted","type":"array","desc":"Registration form submitted"}]
1187
+ * @change_log
1188
+ * ["Since: 2.0"]
1189
+ * @usage add_action( 'um_before_save_registration_details', 'function_name', 10, 2 );
1190
+ * @example
1191
+ * <?php
1192
+ * add_action( 'um_before_save_registration_details', 'my_before_save_registration_details', 10, 2 );
1193
+ * function my_before_save_registration_details( $user_id, $submitted ) {
1194
+ * // your code here
1195
+ * }
1196
+ * ?>
1197
+ */
1198
+ do_action( 'um_before_save_registration_details', $this->id, $submitted );
1199
+
1200
+ update_user_meta( $this->id, 'submitted', $submitted );
1201
+
1202
+ $this->update_profile( $submitted );
1203
+ /**
1204
+ * UM hook
1205
+ *
1206
+ * @type action
1207
+ * @title um_after_save_registration_details
1208
+ * @description Action on user registration after save details
1209
+ * @input_vars
1210
+ * [{"var":"$user_id","type":"int","desc":"User ID"},
1211
+ * {"var":"$submitted","type":"array","desc":"Registration form submitted"}]
1212
+ * @change_log
1213
+ * ["Since: 2.0"]
1214
+ * @usage add_action( 'um_after_save_registration_details', 'function_name', 10, 2 );
1215
+ * @example
1216
+ * <?php
1217
+ * add_action( 'um_after_save_registration_details', 'my_after_save_registration_details', 10, 2 );
1218
+ * function my_after_save_registration_details( $user_id, $submitted ) {
1219
+ * // your code here
1220
+ * }
1221
+ * ?>
1222
+ */
1223
+ do_action( 'um_after_save_registration_details', $this->id, $submitted );
1224
+
1225
+ }
1226
+
1227
+
1228
+ /**
1229
+ * Set last login for new registered users
1230
+ */
1231
+ function set_last_login() {
1232
+ update_user_meta( $this->id, '_um_last_login', current_time( 'timestamp' ) );
1233
+ }
1234
+
1235
+
1236
+ /**
1237
+ * Set user's account status
1238
+ *
1239
+ * @param $status
1240
+ */
1241
+ function set_status( $status ) {
1242
+
1243
+ /**
1244
+ * UM hook
1245
+ *
1246
+ * @type action
1247
+ * @title um_when_status_is_set
1248
+ * @description Action on user status changed
1249
+ * @input_vars
1250
+ * [{"var":"$user_id","type":"int","desc":"User ID"}]
1251
+ * @change_log
1252
+ * ["Since: 2.0"]
1253
+ * @usage add_action( 'um_when_status_is_set', 'function_name', 10, 1 );
1254
+ * @example
1255
+ * <?php
1256
+ * add_action( 'um_when_status_is_set', 'my_when_status_is_set', 10, 1 );
1257
+ * function my_when_status_is_set( $user_id ) {
1258
+ * // your code here
1259
+ * }
1260
+ * ?>
1261
+ */
1262
+ do_action( 'um_when_status_is_set', um_user( 'ID' ) );
1263
+
1264
+ $this->profile['account_status'] = $status;
1265
+
1266
+ $this->update_usermeta_info( 'account_status' );
1267
+
1268
+ /**
1269
+ * UM hook
1270
+ *
1271
+ * @type action
1272
+ * @title um_after_user_status_is_changed_hook
1273
+ * @description Action after user status changed
1274
+ * @input_vars
1275
+ * [{"var":"$user_id","type":"int","desc":"User ID"}]
1276
+ * @change_log
1277
+ * ["Since: 2.0"]
1278
+ * @usage add_action( 'um_after_user_status_is_changed_hook', 'function_name', 10 );
1279
+ * @example
1280
+ * <?php
1281
+ * add_action( 'um_after_user_status_is_changed_hook', 'my_after_user_status_is_changed', 10 );
1282
+ * function my_after_user_status_is_changed() {
1283
+ * // your code here
1284
+ * }
1285
+ * ?>
1286
+ */
1287
+ do_action( 'um_after_user_status_is_changed_hook', um_user( 'ID' ) );
1288
+
1289
+ /**
1290
+ * UM hook
1291
+ *
1292
+ * @type action
1293
+ * @title um_after_user_status_is_changed
1294
+ * @description Action after user status changed
1295
+ * @input_vars
1296
+ * [{"var":"$status","type":"string","desc":"User Status"},
1297
+ * {"var":"$user_id","type":"integer","desc":"User ID"}]
1298
+ * @change_log
1299
+ * ["Since: 2.0"]
1300
+ * @usage add_action( 'um_after_user_status_is_changed', 'function_name', 10, 1 );
1301
+ * @example
1302
+ * <?php
1303
+ * add_action( 'um_after_user_status_is_changed', 'my_after_user_status_is_changed', 10, 1 );
1304
+ * function my_after_user_status_is_changed( $status ) {
1305
+ * // your code here
1306
+ * }
1307
+ * ?>
1308
+ */
1309
+ do_action( 'um_after_user_status_is_changed', $status, um_user( 'ID' ) );
1310
+
1311
+ }
1312
+
1313
+
1314
+ /**
1315
+ * Set user's hash
1316
+ */
1317
+ function assign_secretkey() {
1318
+ /**
1319
+ * UM hook
1320
+ *
1321
+ * @type action
1322
+ * @title um_before_user_hash_is_changed
1323
+ * @description Action before user hash is changed
1324
+ * @change_log
1325
+ * ["Since: 2.0"]
1326
+ * @usage add_action( 'um_before_user_hash_is_changed', 'function_name', 10 );
1327
+ * @example
1328
+ * <?php
1329
+ * add_action( 'um_before_user_hash_is_changed', 'my_before_user_hash_is_changed', 10 );
1330
+ * function my_before_user_hash_is_changed() {
1331
+ * // your code here
1332
+ * }
1333
+ * ?>
1334
+ */
1335
+ do_action( 'um_before_user_hash_is_changed' );
1336
+
1337
+ $this->profile['account_secret_hash'] = UM()->validation()->generate();
1338
+ $this->update_usermeta_info( 'account_secret_hash' );
1339
+
1340
+ $expiry_time = UM()->options()->get( 'activation_link_expiry_time' );
1341
+ if ( ! empty( $expiry_time ) && is_numeric( $expiry_time ) ) {
1342
+ $this->profile['account_secret_hash_expiry'] = time() + $expiry_time;
1343
+ $this->update_usermeta_info( 'account_secret_hash_expiry' );
1344
+ }
1345
+
1346
+ /**
1347
+ * UM hook
1348
+ *
1349
+ * @type action
1350
+ * @title um_after_user_hash_is_changed
1351
+ * @description Action after user hash is changed
1352
+ * @change_log
1353
+ * ["Since: 2.0"]
1354
+ * @usage add_action( 'um_after_user_hash_is_changed', 'function_name', 10 );
1355
+ * @example
1356
+ * <?php
1357
+ * add_action( 'um_after_user_hash_is_changed', 'my_after_user_hash_is_changed', 10 );
1358
+ * function my_after_user_hash_is_changed() {
1359
+ * // your code here
1360
+ * }
1361
+ * ?>
1362
+ */
1363
+ do_action( 'um_after_user_hash_is_changed' );
1364
+ }
1365
+
1366
+
1367
+ /**
1368
+ * @param \WP_User $userdata
1369
+ *
1370
+ * @return string|\WP_Error
1371
+ */
1372
+ function maybe_generate_password_reset_key( $userdata ) {
1373
+ if ( empty( $this->password_reset_key ) ) {
1374
+ $this->password_reset_key = get_password_reset_key( $userdata );
1375
+ }
1376
+
1377
+ return $this->password_reset_key ;
1378
+ }
1379
+
1380
+
1381
+ /**
1382
+ * Password reset email
1383
+ */
1384
+ function password_reset() {
1385
+ $userdata = get_userdata( um_user( 'ID' ) );
1386
+
1387
+ $this->maybe_generate_password_reset_key( $userdata );
1388
+
1389
+ add_filter( 'um_template_tags_patterns_hook', array( UM()->password(), 'add_placeholder' ), 10, 1 );
1390
+ add_filter( 'um_template_tags_replaces_hook', array( UM()->password(), 'add_replace_placeholder' ), 10, 1 );
1391
+
1392
+ UM()->mail()->send( um_user( 'user_email' ), 'resetpw_email' );
1393
+ }
1394
+
1395
+
1396
+ /**
1397
+ * Password changed email
1398
+ */
1399
+ function password_changed() {
1400
+ UM()->mail()->send( um_user( 'user_email' ), 'changedpw_email' );
1401
+ }
1402
+
1403
+
1404
+ /**
1405
+ * This method approves a user membership and sends them an optional welcome/approval e-mail.
1406
+ *
1407
+ * @usage <?php UM()->user()->approve(); ?>
1408
+ *
1409
+ * @example Approve a pending user and allow him to sign-in to your site.
1410
+
1411
+ <?php
1412
+
1413
+ um_fetch_user( 352 );
1414
+ UM()->user()->approve();
1415
+
1416
+ ?>
1417
+ *
1418
+ */
1419
+ function approve( $repeat = true ) {
1420
+ $user_id = um_user('ID');
1421
+
1422
+ if ( ! $repeat ) {
1423
+ $status = get_user_meta( $user_id, 'account_status', true );
1424
+ if ( 'approved' === $status ) {
1425
+ return;
1426
+ }
1427
+ }
1428
+
1429
+ delete_option( "um_cache_userdata_{$user_id}" );
1430
+
1431
+ if ( um_user( 'account_status' ) == 'awaiting_admin_review' ) {
1432
+ $userdata = get_userdata( $user_id );
1433
+
1434
+ $this->maybe_generate_password_reset_key( $userdata );
1435
+
1436
+ UM()->mail()->send( um_user( 'user_email' ), 'approved_email' );
1437
+
1438
+ } else {
1439
+ //$userdata = get_userdata( $user_id );
1440
+ //get_password_reset_key( $userdata );
1441
+ UM()->mail()->send( um_user( 'user_email' ), 'welcome_email' );
1442
+ }
1443
+
1444
+ $this->set_status( 'approved' );
1445
+ $this->delete_meta( 'account_secret_hash' );
1446
+ $this->delete_meta( 'account_secret_hash_expiry' );
1447
+
1448
+ /**
1449
+ * UM hook
1450
+ *
1451
+ * @type action
1452
+ * @title um_after_user_is_approved
1453
+ * @description Action after user was approved
1454
+ * @input_vars
1455
+ * [{"var":"$user_id","type":"int","desc":"User ID"}]
1456
+ * @change_log
1457
+ * ["Since: 2.0"]
1458
+ * @usage add_action( 'um_after_user_is_approved', 'function_name', 10, 1 );
1459
+ * @example
1460
+ * <?php
1461
+ * add_action( 'um_after_user_is_approved', 'my_after_user_is_approved', 10, 1 );
1462
+ * function my_after_user_hash_is_changed( $user_id ) {
1463
+ * // your code here
1464
+ * }
1465
+ * ?>
1466
+ */
1467
+ do_action( 'um_after_user_is_approved', um_user( 'ID' ) );
1468
+ }
1469
+
1470
+
1471
+ /**
1472
+ * Pending email
1473
+ */
1474
+ function email_pending() {
1475
+ $this->assign_secretkey();
1476
+ $this->set_status( 'awaiting_email_confirmation' );
1477
+ UM()->mail()->send( um_user( 'user_email' ), 'checkmail_email' );
1478
+ }
1479
+
1480
+
1481
+ /**
1482
+ * This method puts a user under manual review by administrator and sends them an optional e-mail.
1483
+ *
1484
+ * @usage <?php UM()->user()->pending(); ?>
1485
+ *
1486
+ * @example An example of putting a user pending manual review
1487
+
1488
+ <?php
1489
+
1490
+ um_fetch_user( 54 );
1491
+ UM()->user()->pending();
1492
+
1493
+ ?>
1494
+ *
1495
+ */
1496
+ function pending() {
1497
+ $this->set_status( 'awaiting_admin_review' );
1498
+ UM()->mail()->send( um_user( 'user_email' ), 'pending_email' );
1499
+ }
1500
+
1501
+
1502
+ /**
1503
+ * This method rejects a user membership and sends them an optional e-mail.
1504
+ *
1505
+ * @usage <?php UM()->user()->reject(); ?>
1506
+ *
1507
+ * @example Reject a user membership example
1508
+
1509
+ <?php
1510
+
1511
+ um_fetch_user( 114 );
1512
+ UM()->user()->reject();
1513
+
1514
+ ?>
1515
+
1516
+ *
1517
+ */
1518
+ function reject() {
1519
+ $this->set_status( 'rejected' );
1520
+ UM()->mail()->send( um_user( 'user_email' ), 'rejected_email' );
1521
+ }
1522
+
1523
+
1524
+ /**
1525
+ * This method deactivates a user membership and sends them an optional e-mail.
1526
+ *
1527
+ * @usage <?php UM()->user()->deactivate(); ?>
1528
+ *
1529
+ * @example Deactivate a user membership with the following example
1530
+
1531
+ <?php
1532
+
1533
+ um_fetch_user( 32 );
1534
+ $ultimatemember->user->deactivate();
1535
+
1536
+ ?>
1537
+ *
1538
+ */
1539
+ function deactivate() {
1540
+ $this->set_status( 'inactive' );
1541
+ /**
1542
+ * UM hook
1543
+ *
1544
+ * @type action
1545
+ * @title um_after_user_is_inactive
1546
+ * @description Action after user was inactive
1547
+ * @input_vars
1548
+ * [{"var":"$user_id","type":"int","desc":"User ID"}]
1549
+ * @change_log
1550
+ * ["Since: 2.0"]
1551
+ * @usage add_action( 'um_after_user_is_inactive', 'function_name', 10, 1 );
1552
+ * @example
1553
+ * <?php
1554
+ * add_action( 'um_after_user_is_inactive', 'my_after_user_is_inactive', 10, 1 );
1555
+ * function my_after_user_is_inactive( $user_id ) {
1556
+ * // your code here
1557
+ * }
1558
+ * ?>
1559
+ */
1560
+ do_action( 'um_after_user_is_inactive', um_user( 'ID' ) );
1561
+
1562
+ UM()->mail()->send( um_user( 'user_email' ), 'inactive_email' );
1563
+ }
1564
+
1565
+
1566
+ /**
1567
+ * Delete user
1568
+ *
1569
+ * @param bool $send_mail
1570
+ */
1571
+ function delete( $send_mail = true ) {
1572
+
1573
+ $this->send_mail_on_delete = $send_mail;
1574
+ //don't send email notification to not approved user
1575
+ if ( 'approved' != um_user( 'account_status' ) ) {
1576
+ $this->send_mail_on_delete = false;
1577
+ }
1578
+
1579
+ // remove user
1580
+ if ( is_multisite() ) {
1581
+
1582
+ if ( ! function_exists( 'wpmu_delete_user' ) ) {
1583
+ require_once( ABSPATH . 'wp-admin/includes/ms.php' );
1584
+ }
1585
+
1586
+ wpmu_delete_user( $this->id );
1587
+
1588
+ } else {
1589
+
1590
+ if ( ! function_exists( 'wp_delete_user' ) ) {
1591
+ require_once( ABSPATH . 'wp-admin/includes/user.php' );
1592
+ }
1593
+
1594
+ wp_delete_user( $this->id );
1595
+
1596
+ }
1597
+
1598
+ }
1599
+
1600
+
1601
+ /**
1602
+ * This method gets a user role in slug format. e.g. member
1603
+ *
1604
+ * @usage <?php UM()->user()->get_role(); ?>
1605
+ *
1606
+ * @return string
1607
+ *
1608
+ * @example Do something if the user's role is paid-member
1609
+
1610
+ <?php
1611
+
1612
+ um_fetch_user( 12 );
1613
+
1614
+ if ( UM()->user()->get_role() == 'paid-member' ) {
1615
+ // Show this to paid customers
1616
+ } else {
1617
+ // You are a free member
1618
+ }
1619
+
1620
+ ?>
1621
+ *
1622
+ */
1623
+ function get_role() {
1624
+ if ( ! empty( $this->profile['role'] ) ) {
1625
+ return $this->profile['role'];
1626
+ } else {
1627
+ if ( ! empty( $this->profile['wp_roles'] ) && $this->profile['wp_roles'] == 'administrator' ) {
1628
+ return 'admin';
1629
+ } else {
1630
+ return 'member';
1631
+ }
1632
+ }
1633
+ }
1634
+
1635
+
1636
+ /**
1637
+ * Update one key in user meta
1638
+ *
1639
+ * @param $key
1640
+ */
1641
+ function update_usermeta_info( $key ) {
1642
+ // delete the key first just in case
1643
+ delete_user_meta( $this->id, $key );
1644
+ update_user_meta( $this->id, $key, $this->profile[ $key ] );
1645
+ }
1646
+
1647
+
1648
+ /**
1649
+ * This method can be used to delete user's meta key.
1650
+ *
1651
+ * @usage <?php UM()->user()->delete_meta( $key ); ?>
1652
+ *
1653
+ * @param string $key The meta field key to remove from user
1654
+ *
1655
+ * @example Delete user's age field
1656
+
1657
+ <?php
1658
+
1659
+ um_fetch_user( 15 );
1660
+ UM()->user()->delete_meta( 'age' );
1661
+
1662
+ ?>
1663
+
1664
+ *
1665
+ */
1666
+ function delete_meta( $key ) {
1667
+ delete_user_meta( $this->id, $key );
1668
+ }
1669
+
1670
+
1671
+ /**
1672
+ * Get admin actions for individual user
1673
+ *
1674
+ * @return array|bool
1675
+ */
1676
+ function get_admin_actions() {
1677
+ $items = array();
1678
+
1679
+ /**
1680
+ * UM hook
1681
+ *
1682
+ * @type filter
1683
+ * @title um_admin_user_actions_hook
1684
+ * @description Extend admin actions for each user
1685
+ * @input_vars
1686
+ * [{"var":"$actions","type":"array","desc":"Actions for user"}]
1687
+ * @change_log
1688
+ * ["Since: 2.0"]
1689
+ * @usage
1690
+ * <?php add_filter( 'um_admin_user_actions_hook', 'function_name', 10, 1 ); ?>
1691
+ * @example
1692
+ * <?php
1693
+ * add_filter( 'um_admin_user_actions_hook', 'my_admin_user_actions', 10, 1 );
1694
+ * function my_admin_user_actions( $actions ) {
1695
+ * // your code here
1696
+ * return $actions;
1697
+ * }
1698
+ * ?>
1699
+ */
1700
+ $actions = apply_filters( 'um_admin_user_actions_hook', array(), um_profile_id() );
1701
+ if ( empty( $actions ) ) {
1702
+ return $items;
1703
+ }
1704
+
1705
+ foreach ( $actions as $id => $arr ) {
1706
+ $url = add_query_arg( array( 'um_action' => $id, 'uid' => um_profile_id() ) );
1707
+ /*$url = add_query_arg( 'um_action', $id );
1708
+ $url = add_query_arg( 'uid', um_profile_id(), $url );*/
1709
+ $items[] = '<a href="' . esc_url( $url ) .'" class="real_url ' . esc_attr( $id ) . '-item">' . esc_html( $arr['label'] ) . '</a>';
1710
+ }
1711
+ return $items;
1712
+ }
1713
+
1714
+
1715
+ /**
1716
+ * This method checks if the profile indexing is disabled
1717
+ *
1718
+ * @param int $user_id
1719
+ *
1720
+ * @since 2.1.16
1721
+ * @usage <?php UM()->user()->is_profile_noindex( $user_id ); ?>
1722
+ *
1723
+ * @return boolean Is the profile indexing disabled?
1724
+ */
1725
+ function is_profile_noindex( $user_id ) {
1726
+ $profile_noindex = false;
1727
+
1728
+ if ( ! get_option( 'blog_public' ) ) {
1729
+ // Option "Search engine visibility" in [wp-admin > Settings > Reading]
1730
+ $profile_noindex = true;
1731
+
1732
+ } elseif ( $this->is_private_profile( $user_id ) ) {
1733
+ // Setting "Profile Privacy" in [Account > Privacy]
1734
+ $profile_noindex = true;
1735
+
1736
+ } elseif ( get_user_meta( $user_id, 'profile_noindex', true ) === '1' ) {
1737
+ // Setting "Avoid indexing my profile by search engines in [Account > Privacy]
1738
+ $profile_noindex = true;
1739
+
1740
+ }
1741
+
1742
+ if ( ! $profile_noindex ) {
1743
+ $role = UM()->roles()->get_priority_user_role( $user_id );
1744
+ $permissions = UM()->roles()->role_data( $role );
1745
+
1746
+ if ( isset( $permissions['profile_noindex'] ) && (bool) $permissions['profile_noindex'] ) {
1747
+ // Setting "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > User Roles > Edit Role]
1748
+ $profile_noindex = true;
1749
+
1750
+ } elseif ( ( ! isset( $permissions['profile_noindex'] ) || $permissions['profile_noindex'] === '' ) && (bool) UM()->options()->get( 'profile_noindex' ) ) {
1751
+ // Setting "Avoid indexing profile by search engines" in [wp-admin > Ultimate Member > Settings > General > Users]
1752
+ $profile_noindex = true;
1753
+
1754
+ }
1755
+ }
1756
+
1757
+ return apply_filters( 'um_user_is_profile_noindex', $profile_noindex, $user_id, $this );
1758
+ }
1759
+
1760
+
1761
+ /**
1762
+ * This method checks if give user profile is private.
1763
+ *
1764
+ * @usage <?php UM()->user()->is_private_profile( $user_id ); ?>
1765
+ *
1766
+ * @param int $user_id A user ID must be passed to check if the user profile is private
1767
+ *
1768
+ * @return bool
1769
+ *
1770
+ * @example This example display a specific user's name If his profile is public
1771
+
1772
+ <?php
1773
+
1774
+ um_fetch_user( 60 );
1775
+ $is_private = UM()->user()->is_private_profile( 60 );
1776
+ if ( ! $is_private ) {
1777
+ echo 'User is public and his name is ' . um_user('display_name');
1778
+ }
1779
+
1780
+ ?>
1781
+ *
1782
+ */
1783
+ function is_private_profile( $user_id ) {
1784
+ $privacy = get_user_meta( $user_id, 'profile_privacy', true );
1785
+ if ( $privacy == __( 'Only me', 'ultimate-member' ) || $privacy == 'Only me' ) {
1786
+ return true;
1787
+ }
1788
+ return $this->is_private_case( $user_id, $privacy );
1789
+ }
1790
+
1791
+
1792
+ /**
1793
+ * This method can be used to determine If a certain user is approved or not.
1794
+ *
1795
+ * @usage <?php UM()->user()->is_approved( $user_id ); ?>
1796
+ *
1797
+ * @param int $user_id The user ID to check approval status for
1798
+ *
1799
+ * @return bool
1800
+ *
1801
+ * @example Do something If a user's membership is approved
1802
+
1803
+ <?php
1804
+
1805
+ if ( UM()->user()->is_approved( 55 ) {
1806
+ // User account is approved
1807
+ } else {
1808
+ // User account is not approved
1809
+ }
1810
+
1811
+ ?>
1812
+ *
1813
+ */
1814
+ function is_approved( $user_id ) {
1815
+ $status = get_user_meta( $user_id, 'account_status', true );
1816
+ if ( $status == 'approved' || $status == '' ) {
1817
+ return true;
1818
+ }
1819
+ return false;
1820
+ }
1821
+
1822
+
1823
+ /**
1824
+ * Is private
1825
+ *
1826
+ * @param $user_id
1827
+ * @param $case
1828
+ *
1829
+ * @return bool
1830
+ */
1831
+ function is_private_case( $user_id, $case ) {
1832
+ $privacy = get_user_meta( $user_id, 'profile_privacy', true );
1833
+
1834
+ if ( $privacy == $case ) {
1835
+ /**
1836
+ * UM hook
1837
+ *
1838
+ * @type filter
1839
+ * @title um_is_private_filter_hook
1840
+ * @description Change user privacy
1841
+ * @input_vars
1842
+ * [{"var":"$is_private","type":"bool","desc":"Is user private"},
1843
+ * {"var":"$privacy","type":"bool","desc":"Profile Privacy"},
1844
+ * {"var":"$user_id","type":"int","desc":"User ID"}]
1845
+ * @change_log
1846
+ * ["Since: 2.0"]
1847
+ * @usage
1848
+ * <?php add_filter( 'um_is_private_filter_hook', 'function_name', 10, 3 ); ?>
1849
+ * @example
1850
+ * <?php
1851
+ * add_filter( 'um_is_private_filter_hook', 'my_is_private_filter', 10, 3 );
1852
+ * function my_is_private_filter( $is_private ) {
1853
+ * // your code here
1854
+ * return $is_private;
1855
+ * }
1856
+ * ?>
1857
+ */
1858
+ $bool = apply_filters( 'um_is_private_filter_hook', false, $privacy, $user_id );
1859
+ return $bool;
1860
+ }
1861
+
1862
+ return false;
1863
+ }
1864
+
1865
+
1866
+ /**
1867
+ * Update files
1868
+ *
1869
+ * @param $changes
1870
+ *
1871
+ * @deprecated 2.1.0
1872
+ */
1873
+ function update_files( $changes ) {
1874
+ um_deprecated_function( 'update_files', '2.1.0', '' );
1875
+ }
1876
+
1877
+
1878
+ /**
1879
+ * Update profile
1880
+ *
1881
+ * @param $changes
1882
+ */
1883
+ function update_profile( $changes ) {
1884
+
1885
+ $args['ID'] = $this->id;
1886
+
1887
+ /**
1888
+ * UM hook
1889
+ *
1890
+ * @type filter
1891
+ * @title um_before_update_profile
1892
+ * @description Change update profile changes data
1893
+ * @input_vars
1894
+ * [{"var":"$changes","type":"array","desc":"User Profile Changes"},
1895
+ * {"var":"$user_id","type":"int","desc":"User ID"}]
1896
+ * @change_log
1897
+ * ["Since: 2.0"]
1898
+ * @usage
1899
+ * <?php add_filter( 'um_before_update_profile', 'function_name', 10, 2 ); ?>
1900
+ * @example
1901
+ * <?php
1902
+ * add_filter( 'um_before_update_profile', 'my_before_update_profile', 10, 2 );
1903
+ * function my_before_update_profile( $changes, $user_id ) {
1904
+ * // your code here
1905
+ * return $changes;
1906
+ * }
1907
+ * ?>
1908
+ */
1909
+ $changes = apply_filters( 'um_before_update_profile', $changes, $args['ID'] );
1910
+
1911
+ foreach ( $changes as $key => $value ) {
1912
+ if ( in_array( $key, $this->banned_keys ) ) {
1913
+ continue;
1914
+ }
1915
+
1916
+ if ( ! in_array( $key, $this->update_user_keys ) ) {
1917
+ if ( $value === 0 ) {
1918
+ update_user_meta( $this->id, $key, '0' );
1919
+ } else {
1920
+ update_user_meta( $this->id, $key, $value );
1921
+ }
1922
+ } else {
1923
+ $args[ $key ] = esc_attr( $changes[ $key ] );
1924
+ }
1925
+ }
1926
+
1927
+
1928
+ // update user
1929
+ if ( count( $args ) > 1 ) {
1930
+ //if isset roles argument validate role to properly for security reasons
1931
+ if ( isset( $args['role'] ) ) {
1932
+ global $wp_roles;
1933
+ $um_roles = get_option( 'um_roles', array() );
1934
+
1935
+ if ( ! empty( $um_roles ) ) {
1936
+ $role_keys = array_map( function( $item ) {
1937
+ return 'um_' . $item;
1938
+ }, $um_roles );
1939
+ } else {
1940
+ $role_keys = array();
1941
+ }
1942
+
1943
+ $exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
1944
+
1945
+ if ( in_array( $args['role'], $exclude_roles ) ) {
1946
+ unset( $args['role'] );
1947
+ }
1948
+ }
1949
+
1950
+ wp_update_user( $args );
1951
+ }
1952
+
1953
+ }
1954
+
1955
+
1956
+ /**
1957
+ * User exists by meta key and value
1958
+ *
1959
+ * @param $key
1960
+ * @param $value
1961
+ *
1962
+ * @return bool|int
1963
+ */
1964
+ function user_has_metadata( $key, $value ) {
1965
+
1966
+ $value = UM()->validation()->safe_name_in_url( $value );
1967
+
1968
+ $ids = get_users( array( 'fields' => 'ID', 'meta_key' => $key, 'meta_value' => $value, 'meta_compare' => '=' ) );
1969
+ if ( ! isset( $ids ) || empty( $ids ) ) {
1970
+ return false;
1971
+ }
1972
+
1973
+ foreach ( $ids as $k => $id ) {
1974
+
1975
+ if ( $id == um_user('ID') ) {
1976
+ unset( $ids[ $k ] );
1977
+ } else {
1978
+ $duplicates[] = $id;
1979
+ }
1980
+
1981
+ }
1982
+
1983
+ if ( ! empty( $duplicates ) ) {
1984
+ return count( $duplicates );
1985
+ }
1986
+ return false;
1987
+ }
1988
+
1989
+
1990
+ /**
1991
+ * User exists by name
1992
+ *
1993
+ * @param $value
1994
+ *
1995
+ * @return bool
1996
+ */
1997
+ function user_exists_by_name( $value ) {
1998
+
1999
+ // Permalink base
2000
+ $permalink_base = UM()->options()->get( 'permalink_base' );
2001
+
2002
+ $raw_value = $value;
2003
+ $value = UM()->validation()->safe_name_in_url( $value );
2004
+ $value = um_clean_user_basename( $value );
2005
+
2006
+ // Search by Profile Slug
2007
+ $args = array(
2008
+ 'fields' => array( 'ID' ),
2009
+ 'meta_query' => array(
2010
+ 'relation' => 'OR',
2011
+ array(
2012
+ 'key' => 'um_user_profile_url_slug_' . $permalink_base,
2013
+ 'value' => strtolower( $raw_value ),
2014
+ 'compare' => '=',
2015
+ ),
2016
+ ),
2017
+ );
2018
+
2019
+
2020
+ $ids = new \WP_User_Query( $args );
2021
+
2022
+ if ( $ids->total_users > 0 ) {
2023
+ $um_user_query = current( $ids->get_results() );
2024
+ return $um_user_query->ID;
2025
+ }
2026
+
2027
+ // Search by Display Name or ID
2028
+ $args = array(
2029
+ 'fields' => array( 'ID' ),
2030
+ 'search' => $value,
2031
+ 'search_columns' => array( 'display_name', 'ID' ),
2032
+ );
2033
+
2034
+ $ids = new \WP_User_Query( $args );
2035
+
2036
+ if ( $ids->total_users > 0 ) {
2037
+ $um_user_query = current( $ids->get_results() );
2038
+ return $um_user_query->ID;
2039
+ }
2040
+
2041
+
2042
+ // Search By User Login
2043
+ $value = str_replace( ".", "_", $value );
2044
+ $value = str_replace( " ", "", $value );
2045
+
2046
+ $args = array(
2047
+ 'fields' => array( 'ID' ),
2048
+ 'search' => $value,
2049
+ 'search_columns' => array(
2050
+ 'user_login',
2051
+ )
2052
+ );
2053
+
2054
+ $ids = new \WP_User_Query( $args );
2055
+
2056
+ if ( $ids->total_users > 0 ) {
2057
+ $um_user_query = current( $ids->get_results() );
2058
+ return $um_user_query->ID;
2059
+ }
2060
+
2061
+ return false;
2062
+ }
2063
+
2064
+
2065
+ /**
2066
+ * This method checks if a user exists or not in your site based on the user ID.
2067
+ *
2068
+ * @usage <?php UM()->user()->user_exists_by_id( $user_id ); ?>
2069
+ *
2070
+ * @param int $user_id A user ID must be passed to check if the user exists
2071
+ *
2072
+ * @return bool|int
2073
+ *
2074
+ * @example Basic Usage
2075
+
2076
+ <?php
2077
+
2078
+ $boolean = UM()->user()->user_exists_by_id( 15 );
2079
+ if ( $boolean ) {
2080
+ // That user exists
2081
+ }
2082
+
2083
+ ?>
2084
+
2085
+ *
2086
+ */
2087
+ function user_exists_by_id( $user_id ) {
2088
+ $aux = get_userdata( absint( $user_id ) );
2089
+ if ( $aux == false ) {
2090
+ return false;
2091
+ } else {
2092
+ return $user_id;
2093
+ }
2094
+ }
2095
+
2096
+
2097
+ /**
2098
+ * This method checks if a user exists or not in your site based on the user email as username
2099
+ *
2100
+ * @param string $slug A user slug must be passed to check if the user exists
2101
+ *
2102
+ * @usage <?php UM()->user()->user_exists_by_email_as_username( $slug ); ?>
2103
+ *
2104
+ * @return bool
2105
+ *
2106
+ * @example Basic Usage
2107
+
2108
+ <?php
2109
+
2110
+ $boolean = UM()->user()->user_exists_by_email_as_username( 'calumgmail-com' );
2111
+ if ( $boolean ) {
2112
+ // That user exists
2113
+ }
2114
+
2115
+ ?>
2116
+ */
2117
+ function user_exists_by_email_as_username( $slug ) {
2118
+
2119
+ $user_id = false;
2120
+
2121
+ $ids = get_users( array( 'fields' => 'ID', 'meta_key' => 'um_email_as_username_' . $slug ) );
2122
+ if ( ! empty( $ids[0] ) ) {
2123
+ $user_id = $ids[0];
2124
+ }
2125
+
2126
+ return $user_id;
2127
+ }
2128
+
2129
+
2130
+ /**
2131
+ * Set gravatar hash id
2132
+ *
2133
+ * @param $user_id
2134
+ * @return string
2135
+ */
2136
+ function set_gravatar( $user_id ) {
2137
+
2138
+ um_fetch_user( $user_id );
2139
+ $email_address = um_user( 'user_email' );
2140
+ $hash_email_address = '';
2141
+
2142
+ if ( $email_address ) {
2143
+ $hash_email_address = md5( $email_address );
2144
+ $this->profile['synced_gravatar_hashed_id'] = $hash_email_address;
2145
+ $this->update_usermeta_info( 'synced_gravatar_hashed_id' );
2146
+ }
2147
+
2148
+ return $hash_email_address;
2149
+ }
2150
+
2151
+
2152
+ /**
2153
+ * UM Placeholders for activation link in email
2154
+ *
2155
+ * @param $placeholders
2156
+ *
2157
+ * @return array
2158
+ */
2159
+ function add_activation_placeholder( $placeholders ) {
2160
+ $placeholders[] = '{account_activation_link}';
2161
+ return $placeholders;
2162
+ }
2163
+
2164
+
2165
+ /**
2166
+ * UM Replace Placeholders for activation link in email
2167
+ *
2168
+ * @param $replace_placeholders
2169
+ *
2170
+ * @return array
2171
+ */
2172
+ function add_activation_replace_placeholder( $replace_placeholders ) {
2173
+ $replace_placeholders[] = um_user( 'account_activation_link' );
2174
+ return $replace_placeholders;
2175
+ }
2176
+ }
2177
+ }
includes/core/um-actions-account.php CHANGED
@@ -1,4 +1,6 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit;
 
 
2
 
3
 
4
  /**
@@ -7,161 +9,182 @@
7
  * @param array $args
8
  */
9
  function um_submit_account_errors_hook( $args ) {
10
- if ( ! isset( $_POST['_um_account'] ) && ! isset( $_POST['_um_account_tab'] ) ) {
11
  return;
12
  }
13
 
14
- if ( ! wp_verify_nonce( $_POST[ 'um_account_nonce_' . $_POST['_um_account_tab'] ], 'um_update_account_' . $_POST['_um_account_tab'] ) ) {
15
- UM()->form()->add_error('um_account_security', __( 'Are you hacking? Please try again!', 'ultimate-member' ) );
 
 
16
  }
17
 
18
  $user = get_user_by( 'login', um_user( 'user_login' ) );
19
 
20
- if ( isset( $_POST['_um_account_tab'] ) ) {
21
- switch ( $_POST['_um_account_tab'] ) {
22
- case 'delete': {
23
- // delete account
24
- if ( UM()->account()->current_password_is_required( 'delete' ) ) {
25
- if ( strlen( trim( $_POST['single_user_password'] ) ) == 0 ) {
26
- UM()->form()->add_error( 'single_user_password', __( 'You must enter your password', 'ultimate-member' ) );
27
- } else {
28
- if ( ! wp_check_password( $_POST['single_user_password'], $user->data->user_pass, $user->data->ID ) ) {
29
- UM()->form()->add_error( 'single_user_password', __( 'This is not your password', 'ultimate-member' ) );
30
- }
31
  }
32
  }
 
 
 
 
 
 
 
 
33
 
34
- UM()->account()->current_tab = 'delete';
 
35
 
36
- break;
 
37
  }
38
 
39
- case 'password': {
 
 
40
 
41
- // change password
42
- UM()->account()->current_tab = 'password';
 
 
43
 
44
- if ( empty( $_POST['user_password'] ) ) {
45
- UM()->form()->add_error('user_password', __( 'Password is required', 'ultimate-member' ) );
46
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  }
48
 
49
- if ( empty( $_POST['confirm_user_password'] ) ) {
50
- UM()->form()->add_error('user_password', __( 'Password confirmation is required', 'ultimate-member' ) );
51
  return;
52
  }
53
 
54
- if ( ! empty( $_POST['user_password'] ) && ! empty( $_POST['confirm_user_password'] ) ) {
55
-
56
- if ( UM()->account()->current_password_is_required( 'password' ) ) {
57
- if ( empty( $_POST['current_user_password'] ) ) {
58
- UM()->form()->add_error('current_user_password', __( 'This is not your password', 'ultimate-member' ) );
59
- return;
60
- } else {
61
- if ( ! wp_check_password( $_POST['current_user_password'], $user->data->user_pass, $user->data->ID ) ) {
62
- UM()->form()->add_error('current_user_password', __( 'This is not your password', 'ultimate-member' ) );
63
- return;
64
- }
65
- }
66
  }
67
 
68
- if ( $_POST['user_password'] != $_POST['confirm_user_password'] && $_POST['user_password'] ) {
69
- UM()->form()->add_error('user_password', __( 'Your new password does not match', 'ultimate-member' ) );
70
- return;
71
  }
72
 
73
- if ( UM()->options()->get( 'account_require_strongpass' ) ) {
74
- if ( strlen( utf8_decode( $_POST['user_password'] ) ) < 8 ) {
75
- UM()->form()->add_error( 'user_password', __( 'Your password must contain at least 8 characters', 'ultimate-member' ) );
76
- }
 
77
 
78
- if ( strlen( utf8_decode( $_POST['user_password'] ) ) > 30 ) {
79
- UM()->form()->add_error( 'user_password', __( 'Your password must contain less than 30 characters', 'ultimate-member' ) );
80
- }
81
 
82
- if ( ! UM()->validation()->strong_pass( $_POST['user_password'] ) ) {
83
- UM()->form()->add_error( 'user_password', __( 'Your password must contain at least one lowercase letter, one capital letter and one number', 'ultimate-member' ) );
84
- }
85
- }
86
 
87
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
 
89
- break;
 
 
90
  }
91
 
92
- case 'account':
93
- case 'general': {
94
- // errors on general tab
95
 
96
- $account_name_require = UM()->options()->get( 'account_name_require' );
 
 
97
 
98
- if ( ! empty( $_POST['user_login'] ) && ! validate_username( $_POST['user_login'] ) ) {
99
- UM()->form()->add_error('user_login', __( 'Your username is invalid', 'ultimate-member' ) );
100
- return;
101
- }
102
 
103
- if ( isset( $_POST['first_name'] ) && ( strlen( trim( $_POST['first_name'] ) ) == 0 && $account_name_require ) ) {
104
- UM()->form()->add_error( 'first_name', __( 'You must provide your first name', 'ultimate-member' ) );
105
  }
106
 
107
- if ( isset( $_POST['last_name'] ) && ( strlen( trim( $_POST['last_name'] ) ) == 0 && $account_name_require ) ) {
108
- UM()->form()->add_error( 'last_name', __( 'You must provide your last name', 'ultimate-member' ) );
109
  }
110
 
111
- if ( isset( $_POST['user_email'] ) ) {
112
-
113
- if ( strlen( trim( $_POST['user_email'] ) ) == 0 ) {
114
- UM()->form()->add_error( 'user_email', __( 'You must provide your e-mail', 'ultimate-member' ) );
115
- }
116
-
117
- if ( ! is_email( $_POST['user_email'] ) ) {
118
- UM()->form()->add_error( 'user_email', __( 'Please provide a valid e-mail', 'ultimate-member' ) );
119
- }
120
-
121
- if ( email_exists( $_POST['user_email'] ) && email_exists( $_POST['user_email'] ) != get_current_user_id() ) {
122
- UM()->form()->add_error( 'user_email', __( 'Email already linked to another account', 'ultimate-member' ) );
123
- }
124
  }
 
125
 
126
- // check account password
127
- if ( UM()->account()->current_password_is_required( 'general' ) ) {
128
- if ( strlen( trim( $_POST['single_user_password'] ) ) == 0 ) {
129
- UM()->form()->add_error('single_user_password', __( 'You must enter your password', 'ultimate-member' ) );
130
- } else {
131
- if ( ! wp_check_password( $_POST['single_user_password'], $user->data->user_pass, $user->data->ID ) ) {
132
- UM()->form()->add_error('single_user_password', __( 'This is not your password', 'ultimate-member' ) );
133
- }
134
  }
135
  }
136
-
137
- break;
138
  }
139
 
140
- default:
141
- /**
142
- * UM hook
143
- *
144
- * @type action
145
- * @title um_submit_account_{$tab}_tab_errors_hook
146
- * @description On submit account current $tab validation
147
- * @change_log
148
- * ["Since: 2.0"]
149
- * @usage add_action( 'um_submit_account_{$tab}_tab_errors_hook', 'function_name', 10 );
150
- * @example
151
- * <?php
152
- * add_action( 'um_submit_account_{$tab}_tab_errors_hook', 'my_submit_account_tab_errors', 10 );
153
- * function my_submit_account_tab_errors() {
154
- * // your code here
155
- * }
156
- * ?>
157
- */
158
- do_action( 'um_submit_account_' . $_POST['_um_account_tab'] . '_tab_errors_hook' );
159
- break;
160
  }
161
 
162
- UM()->account()->current_tab = $_POST['_um_account_tab'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  }
164
 
 
165
  }
166
  add_action( 'um_submit_account_errors_hook', 'um_submit_account_errors_hook' );
167
 
@@ -172,16 +195,16 @@ add_action( 'um_submit_account_errors_hook', 'um_submit_account_errors_hook' );
172
  * @param $args
173
  */
174
  function um_submit_account_details( $args ) {
175
- $tab = ( get_query_var('um_tab') ) ? get_query_var('um_tab') : 'general';
176
 
177
- $current_tab = isset( $_POST['_um_account_tab'] ) ? $_POST['_um_account_tab']: '';
178
 
179
- $user_id = um_user('ID');
180
 
181
  //change password account's tab
182
- if ( 'password' == $current_tab && $_POST['user_password'] && $_POST['confirm_user_password'] ) {
183
 
184
- $changes['user_pass'] = $_POST['user_password'];
185
 
186
  $args['user_id'] = $user_id;
187
 
@@ -195,16 +218,20 @@ function um_submit_account_details( $args ) {
195
 
196
  wp_set_password( $changes['user_pass'], $user_id );
197
 
198
- wp_signon( array( 'user_login' => um_user( 'user_login' ), 'user_password' => $changes['user_pass'] ) );
 
 
 
 
 
199
  }
200
 
201
-
202
  // delete account
203
- if ( 'delete' == $current_tab ) {
204
  if ( current_user_can( 'delete_users' ) || um_user( 'can_delete_profile' ) ) {
205
  UM()->user()->delete();
206
 
207
- if ( um_user( 'after_delete' ) && um_user( 'after_delete' ) == 'redirect_home' ) {
208
  um_redirect_home();
209
  } elseif ( um_user( 'delete_redirect_url' ) ) {
210
  /**
@@ -271,26 +298,40 @@ function um_submit_account_details( $args ) {
271
  }
272
 
273
  $changes = array();
274
- foreach ( $_POST as $k => $v ) {
275
- if ( ! in_array( $k, $arr_fields ) ) {
276
  continue;
277
  }
278
 
279
- if ( $k == 'single_user_password' ) {
280
  continue;
281
  }
282
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  $changes[ $k ] = $v;
284
  }
285
 
286
  if ( isset( $changes['hide_in_members'] ) ) {
287
  if ( UM()->member_directory()->get_hide_in_members_default() ) {
288
- if ( $changes['hide_in_members'] == __( 'Yes', 'ultimate-member' ) || $changes['hide_in_members'] == 'Yes' || array_intersect( array( 'Yes', __( 'Yes', 'ultimate-member' ) ), $changes['hide_in_members'] ) ) {
289
  delete_user_meta( $user_id, 'hide_in_members' );
290
  unset( $changes['hide_in_members'] );
291
  }
292
  } else {
293
- if ( $changes['hide_in_members'] == __( 'No', 'ultimate-member' ) || $changes['hide_in_members'] == 'No' || array_intersect( array( 'No', __( 'No', 'ultimate-member' ) ), $changes['hide_in_members'] ) ) {
294
  delete_user_meta( $user_id, 'hide_in_members' );
295
  unset( $changes['hide_in_members'] );
296
  }
@@ -667,19 +708,20 @@ function um_request_user_data() {
667
  wp_send_json_error( __( 'Wrong request.', 'ultimate-member' ) );
668
  }
669
 
670
- $user_id = get_current_user_id();
671
- $password = ! empty( $_POST['password'] ) ? $_POST['password'] : '';
672
- $user = get_userdata( $user_id );
673
- $hash = $user->data->user_pass;
 
674
 
675
- if ( $_POST['request_action'] == 'um-export-data' ) {
676
  if ( UM()->account()->current_password_is_required( 'privacy_download_data' ) ) {
677
  if ( ! wp_check_password( $password, $hash ) ) {
678
  $answer = esc_html__( 'The password you entered is incorrect.', 'ultimate-member' );
679
  wp_send_json_success( array( 'answer' => $answer ) );
680
  }
681
  }
682
- } elseif ( $_POST['request_action'] == 'um-erase-data' ) {
683
  if ( UM()->account()->current_password_is_required( 'privacy_erase_data' ) ) {
684
  if ( ! wp_check_password( $password, $hash ) ) {
685
  $answer = esc_html__( 'The password you entered is incorrect.', 'ultimate-member' );
@@ -688,13 +730,13 @@ function um_request_user_data() {
688
  }
689
  }
690
 
691
- if ( $_POST['request_action'] == 'um-export-data' ) {
692
  $request_id = wp_create_user_request( $user->data->user_email, 'export_personal_data' );
693
- } elseif ( $_POST['request_action'] == 'um-erase-data' ) {
694
  $request_id = wp_create_user_request( $user->data->user_email, 'remove_personal_data' );
695
  }
696
 
697
- if ( ! isset( $request_id ) || empty( $request_id ) ) {
698
  wp_send_json_error( __( 'Wrong request.', 'ultimate-member' ) );
699
  }
700
 
@@ -707,4 +749,4 @@ function um_request_user_data() {
707
 
708
  wp_send_json_success( array( 'answer' => $answer ) );
709
  }
710
- add_action( 'wp_ajax_um_request_user_data', 'um_request_user_data' );
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
 
5
 
6
  /**
9
  * @param array $args
10
  */
11
  function um_submit_account_errors_hook( $args ) {
12
+ if ( ! isset( $args['_um_account'] ) && ! isset( $args['_um_account_tab'] ) ) {
13
  return;
14
  }
15
 
16
+ $tab = sanitize_key( $args['_um_account_tab'] );
17
+
18
+ if ( ! wp_verify_nonce( $args[ 'um_account_nonce_' . $tab ], 'um_update_account_' . $tab ) ) {
19
+ UM()->form()->add_error( 'um_account_security', __( 'Are you hacking? Please try again!', 'ultimate-member' ) );
20
  }
21
 
22
  $user = get_user_by( 'login', um_user( 'user_login' ) );
23
 
24
+ switch ( $tab ) {
25
+ case 'delete': {
26
+ // delete account
27
+ if ( UM()->account()->current_password_is_required( 'delete' ) ) {
28
+ if ( strlen( trim( sanitize_text_field( $args['single_user_password'] ) ) ) === 0 ) {
29
+ UM()->form()->add_error( 'single_user_password', __( 'You must enter your password', 'ultimate-member' ) );
30
+ } else {
31
+ if ( ! wp_check_password( sanitize_text_field( $args['single_user_password'] ), $user->data->user_pass, $user->data->ID ) ) {
32
+ UM()->form()->add_error( 'single_user_password', __( 'This is not your password', 'ultimate-member' ) );
 
 
33
  }
34
  }
35
+ }
36
+
37
+ UM()->account()->current_tab = 'delete';
38
+
39
+ break;
40
+ }
41
+
42
+ case 'password': {
43
 
44
+ // change password
45
+ UM()->account()->current_tab = 'password';
46
 
47
+ if ( isset( $args['user_password'] ) ) {
48
+ $args['user_password'] = sanitize_text_field( $args['user_password'] );
49
  }
50
 
51
+ if ( isset( $args['confirm_user_password'] ) ) {
52
+ $args['confirm_user_password'] = sanitize_text_field( $args['confirm_user_password'] );
53
+ }
54
 
55
+ if ( empty( $args['user_password'] ) ) {
56
+ UM()->form()->add_error( 'user_password', __( 'Password is required', 'ultimate-member' ) );
57
+ return;
58
+ }
59
 
60
+ if ( empty( $args['confirm_user_password'] ) ) {
61
+ UM()->form()->add_error( 'user_password', __( 'Password confirmation is required', 'ultimate-member' ) );
62
+ return;
63
+ }
64
+
65
+ if ( ! empty( $args['user_password'] ) && ! empty( $args['confirm_user_password'] ) ) {
66
+
67
+ if ( UM()->account()->current_password_is_required( 'password' ) ) {
68
+ if ( empty( $args['current_user_password'] ) ) {
69
+ UM()->form()->add_error( 'current_user_password', __( 'This is not your password', 'ultimate-member' ) );
70
+ return;
71
+ } else {
72
+ if ( ! wp_check_password( $args['current_user_password'], $user->data->user_pass, $user->data->ID ) ) {
73
+ UM()->form()->add_error( 'current_user_password', __( 'This is not your password', 'ultimate-member' ) );
74
+ return;
75
+ }
76
+ }
77
  }
78
 
79
+ if ( $args['user_password'] && $args['user_password'] !== $args['confirm_user_password'] ) {
80
+ UM()->form()->add_error( 'user_password', __( 'Your new password does not match', 'ultimate-member' ) );
81
  return;
82
  }
83
 
84
+ if ( UM()->options()->get( 'account_require_strongpass' ) ) {
85
+ if ( strlen( utf8_decode( $args['user_password'] ) ) < 8 ) {
86
+ UM()->form()->add_error( 'user_password', __( 'Your password must contain at least 8 characters', 'ultimate-member' ) );
 
 
 
 
 
 
 
 
 
87
  }
88
 
89
+ if ( strlen( utf8_decode( $args['user_password'] ) ) > 30 ) {
90
+ UM()->form()->add_error( 'user_password', __( 'Your password must contain less than 30 characters', 'ultimate-member' ) );
 
91
  }
92
 
93
+ if ( ! UM()->validation()->strong_pass( $args['user_password'] ) ) {
94
+ UM()->form()->add_error( 'user_password', __( 'Your password must contain at least one lowercase letter, one capital letter and one number', 'ultimate-member' ) );
95
+ }
96
+ }
97
+ }
98
 
99
+ break;
100
+ }
 
101
 
102
+ case 'account':
103
+ case 'general': {
104
+ // errors on general tab
105
+ $account_name_require = UM()->options()->get( 'account_name_require' );
106
 
107
+ if ( isset( $args['user_login'] ) ) {
108
+ $args['user_login'] = sanitize_text_field( $args['user_login'] );
109
+ }
110
+ if ( isset( $args['first_name'] ) ) {
111
+ $args['first_name'] = sanitize_text_field( $args['first_name'] );
112
+ }
113
+ if ( isset( $args['last_name'] ) ) {
114
+ $args['last_name'] = sanitize_text_field( $args['last_name'] );
115
+ }
116
+ if ( isset( $args['user_email'] ) ) {
117
+ $args['user_email'] = sanitize_email( $args['user_email'] );
118
+ }
119
+ if ( isset( $args['single_user_password'] ) ) {
120
+ $args['single_user_password'] = sanitize_text_field( $args['single_user_password'] );
121
+ }
122
 
123
+ if ( ! empty( $args['user_login'] ) && ! validate_username( $args['user_login'] ) ) {
124
+ UM()->form()->add_error( 'user_login', __( 'Your username is invalid', 'ultimate-member' ) );
125
+ return;
126
  }
127
 
128
+ if ( isset( $args['first_name'] ) && ( strlen( trim( $args['first_name'] ) ) === 0 && $account_name_require ) ) {
129
+ UM()->form()->add_error( 'first_name', __( 'You must provide your first name', 'ultimate-member' ) );
130
+ }
131
 
132
+ if ( isset( $args['last_name'] ) && ( strlen( trim( $args['last_name'] ) ) === 0 && $account_name_require ) ) {
133
+ UM()->form()->add_error( 'last_name', __( 'You must provide your last name', 'ultimate-member' ) );
134
+ }
135
 
136
+ if ( isset( $args['user_email'] ) ) {
 
 
 
137
 
138
+ if ( strlen( trim( $args['user_email'] ) ) === 0 ) {
139
+ UM()->form()->add_error( 'user_email', __( 'You must provide your e-mail', 'ultimate-member' ) );
140
  }
141
 
142
+ if ( ! is_email( $args['user_email'] ) ) {
143
+ UM()->form()->add_error( 'user_email', __( 'Please provide a valid e-mail', 'ultimate-member' ) );
144
  }
145
 
146
+ if ( email_exists( $args['user_email'] ) && email_exists( $args['user_email'] ) !== get_current_user_id() ) {
147
+ UM()->form()->add_error( 'user_email', __( 'Email already linked to another account', 'ultimate-member' ) );
 
 
 
 
 
 
 
 
 
 
 
148
  }
149
+ }
150
 
151
+ // check account password
152
+ if ( UM()->account()->current_password_is_required( 'general' ) ) {
153
+ if ( strlen( trim( $args['single_user_password'] ) ) === 0 ) {
154
+ UM()->form()->add_error( 'single_user_password', __( 'You must enter your password', 'ultimate-member' ) );
155
+ } else {
156
+ if ( ! wp_check_password( $args['single_user_password'], $user->data->user_pass, $user->data->ID ) ) {
157
+ UM()->form()->add_error( 'single_user_password', __( 'This is not your password', 'ultimate-member' ) );
 
158
  }
159
  }
 
 
160
  }
161
 
162
+ break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  }
164
 
165
+ default:
166
+ /**
167
+ * UM hook
168
+ *
169
+ * @type action
170
+ * @title um_submit_account_{$tab}_tab_errors_hook
171
+ * @description On submit account current $tab validation
172
+ * @change_log
173
+ * ["Since: 2.0"]
174
+ * @usage add_action( 'um_submit_account_{$tab}_tab_errors_hook', 'function_name', 10 );
175
+ * @example
176
+ * <?php
177
+ * add_action( 'um_submit_account_{$tab}_tab_errors_hook', 'my_submit_account_tab_errors', 10 );
178
+ * function my_submit_account_tab_errors() {
179
+ * // your code here
180
+ * }
181
+ * ?>
182
+ */
183
+ do_action( 'um_submit_account_' . $tab . '_tab_errors_hook' );
184
+ break;
185
  }
186
 
187
+ UM()->account()->current_tab = $tab;
188
  }
189
  add_action( 'um_submit_account_errors_hook', 'um_submit_account_errors_hook' );
190
 
195
  * @param $args
196
  */
197
  function um_submit_account_details( $args ) {
198
+ $tab = ( get_query_var( 'um_tab' ) ) ? get_query_var( 'um_tab' ) : 'general';
199
 
200
+ $current_tab = isset( $args['_um_account_tab'] ) ? sanitize_key( $args['_um_account_tab'] ) : '';
201
 
202
+ $user_id = um_user( 'ID' );
203
 
204
  //change password account's tab
205
+ if ( 'password' === $current_tab && $args['user_password'] && $args['confirm_user_password'] ) {
206
 
207
+ $changes['user_pass'] = sanitize_text_field( $args['user_password'] );
208
 
209
  $args['user_id'] = $user_id;
210
 
218
 
219
  wp_set_password( $changes['user_pass'], $user_id );
220
 
221
+ wp_signon(
222
+ array(
223
+ 'user_login' => um_user( 'user_login' ),
224
+ 'user_password' => $changes['user_pass'],
225
+ )
226
+ );
227
  }
228
 
 
229
  // delete account
230
+ if ( 'delete' === $current_tab ) {
231
  if ( current_user_can( 'delete_users' ) || um_user( 'can_delete_profile' ) ) {
232
  UM()->user()->delete();
233
 
234
+ if ( um_user( 'after_delete' ) && um_user( 'after_delete' ) === 'redirect_home' ) {
235
  um_redirect_home();
236
  } elseif ( um_user( 'delete_redirect_url' ) ) {
237
  /**
298
  }
299
 
300
  $changes = array();
301
+ foreach ( $args as $k => $v ) {
302
+ if ( ! in_array( $k, $arr_fields, true ) ) {
303
  continue;
304
  }
305
 
306
+ if ( 'single_user_password' === $k ) {
307
  continue;
308
  }
309
 
310
+ if ( 'user_login' === $k ) {
311
+ $v = sanitize_user( $v );
312
+ } elseif ( 'first_name' === $k ) {
313
+ $v = sanitize_text_field( $v );
314
+ } elseif ( 'last_name' === $k ) {
315
+ $v = sanitize_text_field( $v );
316
+ } elseif ( 'user_email' === $k ) {
317
+ $v = sanitize_email( $v );
318
+ } elseif ( 'user_password' === $k ) {
319
+ $v = sanitize_text_field( $v );
320
+ } elseif ( 'hide_in_members' === $k ) {
321
+ $v = array_map( 'sanitize_text_field', $v );
322
+ }
323
+
324
  $changes[ $k ] = $v;
325
  }
326
 
327
  if ( isset( $changes['hide_in_members'] ) ) {
328
  if ( UM()->member_directory()->get_hide_in_members_default() ) {
329
+ if ( __( 'Yes', 'ultimate-member' ) === $changes['hide_in_members'] || 'Yes' === $changes['hide_in_members'] || array_intersect( array( 'Yes', __( 'Yes', 'ultimate-member' ) ), $changes['hide_in_members'] ) ) {
330
  delete_user_meta( $user_id, 'hide_in_members' );
331
  unset( $changes['hide_in_members'] );
332
  }
333
  } else {
334
+ if ( __( 'No', 'ultimate-member' ) === $changes['hide_in_members'] || 'No' === $changes['hide_in_members'] || array_intersect( array( 'No', __( 'No', 'ultimate-member' ) ), $changes['hide_in_members'] ) ) {
335
  delete_user_meta( $user_id, 'hide_in_members' );
336
  unset( $changes['hide_in_members'] );
337
  }
708
  wp_send_json_error( __( 'Wrong request.', 'ultimate-member' ) );
709
  }
710
 
711
+ $user_id = get_current_user_id();
712
+ $password = ! empty( $_POST['password'] ) ? sanitize_text_field( $_POST['password'] ) : '';
713
+ $user = get_userdata( $user_id );
714
+ $hash = $user->data->user_pass;
715
+ $request_action = sanitize_key( $_POST['request_action'] );
716
 
717
+ if ( 'um-export-data' === $request_action ) {
718
  if ( UM()->account()->current_password_is_required( 'privacy_download_data' ) ) {
719
  if ( ! wp_check_password( $password, $hash ) ) {
720
  $answer = esc_html__( 'The password you entered is incorrect.', 'ultimate-member' );
721
  wp_send_json_success( array( 'answer' => $answer ) );
722
  }
723
  }
724
+ } elseif ( 'um-erase-data' === $request_action ) {
725
  if ( UM()->account()->current_password_is_required( 'privacy_erase_data' ) ) {
726
  if ( ! wp_check_password( $password, $hash ) ) {
727
  $answer = esc_html__( 'The password you entered is incorrect.', 'ultimate-member' );
730
  }
731
  }
732
 
733
+ if ( 'um-export-data' === $request_action ) {
734
  $request_id = wp_create_user_request( $user->data->user_email, 'export_personal_data' );
735
+ } elseif ( 'um-erase-data' === $request_action ) {
736
  $request_id = wp_create_user_request( $user->data->user_email, 'remove_personal_data' );
737
  }
738
 
739
+ if ( ! isset( $request_id ) || empty( $request_id ) ) {
740
  wp_send_json_error( __( 'Wrong request.', 'ultimate-member' ) );
741
  }
742
 
749
 
750
  wp_send_json_success( array( 'answer' => $answer ) );
751
  }
752
+ add_action( 'wp_ajax_um_request_user_data', 'um_request_user_data' );
includes/core/um-actions-ajax.php CHANGED
@@ -10,7 +10,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
10
  function ultimatemember_check_username_exists() {
11
  UM()->check_ajax_nonce();
12
 
13
- $username = isset( $_REQUEST['username'] ) ? $_REQUEST['username'] : '';
14
  $exists = username_exists( $username );
15
 
16
  /**
@@ -46,4 +46,4 @@ function ultimatemember_check_username_exists() {
46
  die();
47
  }
48
  add_action('wp_ajax_nopriv_ultimatemember_check_username_exists', 'ultimatemember_check_username_exists');
49
- add_action('wp_ajax_ultimatemember_check_username_exists', 'ultimatemember_check_username_exists');
10
  function ultimatemember_check_username_exists() {
11
  UM()->check_ajax_nonce();
12
 
13
+ $username = isset( $_REQUEST['username'] ) ? sanitize_user( $_REQUEST['username'] ) : '';
14
  $exists = username_exists( $username );
15
 
16
  /**
46
  die();
47
  }
48
  add_action('wp_ajax_nopriv_ultimatemember_check_username_exists', 'ultimatemember_check_username_exists');
49
+ add_action('wp_ajax_ultimatemember_check_username_exists', 'ultimatemember_check_username_exists');
includes/core/um-actions-core.php CHANGED
@@ -1,5 +1,6 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
-
 
3
 
4
  /**
5
  * Processes the requests of UM actions
@@ -18,29 +19,25 @@ function um_action_request_process() {
18
  return;
19
  }
20
 
21
- if ( isset( $_REQUEST['uid'] ) && ! UM()->user()->user_exists_by_id( absint( $_REQUEST['uid'] ) ) ) {
22
- return;
23
- }
24
 
 
25
  if ( isset( $_REQUEST['uid'] ) ) {
26
- if ( is_super_admin( $_REQUEST['uid'] ) ) {
27
- wp_die( __( 'Super administrators can not be modified.', 'ultimate-member' ) );
28
- }
29
  }
30
 
31
- // if ( isset( $_REQUEST['um_action'] ) && $_REQUEST['um_action'] != "edit" && ! current_user_can( 'edit_users' ) ) {
32
- // wp_die( __( 'You do not have enough permissions to do that.','ultimate-member') );
33
- // }
34
 
35
- $uid = 0;
36
- if ( isset( $_REQUEST['uid'] ) ) {
37
- $uid = absint( $_REQUEST['uid'] );
38
  }
39
 
40
- $role = get_role( UM()->roles()->get_priority_user_role( get_current_user_id() ) );
41
  $can_edit_users = current_user_can( 'edit_users' ) && $role->has_cap( 'edit_users' );
42
 
43
- switch ( $_REQUEST['um_action'] ) {
44
  default:
45
  /**
46
  * UM hook
@@ -62,7 +59,7 @@ function um_action_request_process() {
62
  * }
63
  * ?>
64
  */
65
- do_action( 'um_action_user_request_hook', $_REQUEST['um_action'], $uid );
66
  break;
67
 
68
  case 'edit':
@@ -89,7 +86,7 @@ function um_action_request_process() {
89
 
90
  case 'um_reject_membership':
91
  if ( ! $can_edit_users ) {
92
- wp_die( __( 'You do not have permission to make this action.', 'ultimate-member' ) );
93
  }
94
 
95
  um_fetch_user( $uid );
@@ -100,7 +97,7 @@ function um_action_request_process() {
100
  case 'um_approve_membership':
101
  case 'um_reenable':
102
  if ( ! $can_edit_users ) {
103
- wp_die( __( 'You do not have permission to make this action.', 'ultimate-member' ) );
104
  }
105
 
106
  add_filter( 'um_template_tags_patterns_hook', array( UM()->password(), 'add_placeholder' ), 10, 1 );
@@ -113,7 +110,7 @@ function um_action_request_process() {
113
 
114
  case 'um_put_as_pending':
115
  if ( ! $can_edit_users ) {
116
- wp_die( __( 'You do not have permission to make this action.', 'ultimate-member' ) );
117
  }
118
 
119
  um_fetch_user( $uid );
@@ -123,7 +120,7 @@ function um_action_request_process() {
123
 
124
  case 'um_resend_activation':
125
  if ( ! $can_edit_users ) {
126
- wp_die( __( 'You do not have permission to make this action.', 'ultimate-member' ) );
127
  }
128
 
129
  add_filter( 'um_template_tags_patterns_hook', array( UM()->user(), 'add_activation_placeholder' ), 10, 1 );
@@ -136,7 +133,7 @@ function um_action_request_process() {
136
 
137
  case 'um_deactivate':
138
  if ( ! $can_edit_users ) {
139
- wp_die( __( 'You do not have permission to make this action.', 'ultimate-member' ) );
140
  }
141
 
142
  um_fetch_user( $uid );
@@ -146,7 +143,7 @@ function um_action_request_process() {
146
 
147
  case 'um_delete':
148
  if ( ! UM()->roles()->um_current_user_can( 'delete', $uid ) ) {
149
- wp_die( __( 'You do not have permission to delete this user.', 'ultimate-member' ) );
150
  }
151
 
152
  um_fetch_user( $uid );
@@ -156,4 +153,4 @@ function um_action_request_process() {
156
 
157
  }
158
  }
159
- add_action( 'template_redirect', 'um_action_request_process', 10000 );
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
 
5
  /**
6
  * Processes the requests of UM actions
19
  return;
20
  }
21
 
22
+ $action = sanitize_key( $_REQUEST['um_action'] );
 
 
23
 
24
+ $uid = 0;
25
  if ( isset( $_REQUEST['uid'] ) ) {
26
+ $uid = absint( $_REQUEST['uid'] );
 
 
27
  }
28
 
29
+ if ( ! empty( $uid ) && ! UM()->user()->user_exists_by_id( $uid ) ) {
30
+ return;
31
+ }
32
 
33
+ if ( ! empty( $uid ) && is_super_admin( $uid ) ) {
34
+ wp_die( esc_html__( 'Super administrators can not be modified.', 'ultimate-member' ) );
 
35
  }
36
 
37
+ $role = get_role( UM()->roles()->get_priority_user_role( get_current_user_id() ) );
38
  $can_edit_users = current_user_can( 'edit_users' ) && $role->has_cap( 'edit_users' );
39
 
40
+ switch ( $action ) {
41
  default:
42
  /**
43
  * UM hook
59
  * }
60
  * ?>
61
  */
62
+ do_action( 'um_action_user_request_hook', $action, $uid );
63
  break;
64
 
65
  case 'edit':
86
 
87
  case 'um_reject_membership':
88
  if ( ! $can_edit_users ) {
89
+ wp_die( esc_html__( 'You do not have permission to make this action.', 'ultimate-member' ) );
90
  }
91
 
92
  um_fetch_user( $uid );
97
  case 'um_approve_membership':
98
  case 'um_reenable':
99
  if ( ! $can_edit_users ) {
100
+ wp_die( esc_html__( 'You do not have permission to make this action.', 'ultimate-member' ) );
101
  }
102
 
103
  add_filter( 'um_template_tags_patterns_hook', array( UM()->password(), 'add_placeholder' ), 10, 1 );
110
 
111
  case 'um_put_as_pending':
112
  if ( ! $can_edit_users ) {
113
+ wp_die( esc_html__( 'You do not have permission to make this action.', 'ultimate-member' ) );
114
  }
115
 
116
  um_fetch_user( $uid );
120
 
121
  case 'um_resend_activation':
122
  if ( ! $can_edit_users ) {
123
+ wp_die( esc_html__( 'You do not have permission to make this action.', 'ultimate-member' ) );
124
  }
125
 
126
  add_filter( 'um_template_tags_patterns_hook', array( UM()->user(), 'add_activation_placeholder' ), 10, 1 );
133
 
134
  case 'um_deactivate':
135
  if ( ! $can_edit_users ) {
136
+ wp_die( esc_html__( 'You do not have permission to make this action.', 'ultimate-member' ) );
137
  }
138
 
139
  um_fetch_user( $uid );
143
 
144
  case 'um_delete':
145
  if ( ! UM()->roles()->um_current_user_can( 'delete', $uid ) ) {
146
+ wp_die( esc_html__( 'You do not have permission to delete this user.', 'ultimate-member' ) );
147
  }
148
 
149
  um_fetch_user( $uid );
153
 
154
  }
155
  }
156
+ add_action( 'template_redirect', 'um_action_request_process', 10000 );
includes/core/um-actions-login.php CHANGED
@@ -127,7 +127,7 @@ function um_submit_form_errors_hook_logincheck( $args ) {
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':
@@ -135,7 +135,7 @@ function um_submit_form_errors_hook_logincheck( $args ) {
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
  }
@@ -183,10 +183,10 @@ add_action( 'wp_login', 'um_store_lastlogin_timestamp_' );
183
  function um_user_login( $args ) {
184
  extract( $args );
185
 
186
- $rememberme = ( isset( $args['rememberme'] ) && 1 == $args['rememberme'] && isset( $_REQUEST['rememberme'] ) ) ? 1 : 0;
187
 
188
  if ( ( UM()->options()->get( 'deny_admin_frontend_login' ) && ! isset( $_GET['provider'] ) ) && strrpos( um_user('wp_roles' ), 'administrator' ) !== false ) {
189
- wp_die( __( 'This action has been prevented for security measures.', 'ultimate-member' ) );
190
  }
191
 
192
  UM()->user()->auto_login( um_user( 'ID' ), $rememberme );
@@ -475,4 +475,4 @@ add_action( 'um_after_login_fields', 'um_after_login_submit', 1001 );
475
  function um_add_login_fields( $args ) {
476
  echo UM()->fields()->display( 'login', $args );
477
  }
478
- add_action( 'um_main_login_fields', 'um_add_login_fields', 100 );
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':
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
  }
183
  function um_user_login( $args ) {
184
  extract( $args );
185
 
186
+ $rememberme = ( isset( $args['rememberme'] ) && 1 == $args['rememberme'] && isset( $_REQUEST['rememberme'] ) ) ? 1 : 0;
187
 
188
  if ( ( UM()->options()->get( 'deny_admin_frontend_login' ) && ! isset( $_GET['provider'] ) ) && strrpos( um_user('wp_roles' ), 'administrator' ) !== false ) {
189
+ wp_die( esc_html__( 'This action has been prevented for security measures.', 'ultimate-member' ) );
190
  }
191
 
192
  UM()->user()->auto_login( um_user( 'ID' ), $rememberme );
475
  function um_add_login_fields( $args ) {
476
  echo UM()->fields()->display( 'login', $args );
477
  }
478
+ add_action( 'um_main_login_fields', 'um_add_login_fields', 100 );
includes/core/um-actions-misc.php CHANGED
@@ -1,6 +1,6 @@
1
- <?php
2
- // Exit if accessed directly
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
 
5
 
6
  /**
@@ -13,7 +13,7 @@ function um_browser_url_redirect_to( $args ) {
13
 
14
  if ( ! empty( $_REQUEST['redirect_to'] ) ) {
15
 
16
- $url = $_REQUEST['redirect_to'];
17
 
18
  } elseif ( ! empty( $args['after_login'] ) ) {
19
 
@@ -75,12 +75,12 @@ add_action( 'um_after_form_fields', 'um_browser_url_redirect_to' );
75
  function um_add_update_notice( $args ) {
76
  extract( $args );
77
 
78
- $output = '';
79
- $err = '';
80
  $success = '';
81
 
82
  if ( ! empty( $_REQUEST['updated'] ) && ! UM()->form()->errors ) {
83
- switch ( $_REQUEST['updated'] ) {
84
  default:
85
  /**
86
  * UM hook
@@ -104,7 +104,7 @@ function um_add_update_notice( $args ) {
104
  * }
105
  * ?>
106
  */
107
- $success = apply_filters( 'um_custom_success_message_handler', $success, $_REQUEST['updated'] );
108
  break;
109
 
110
  case 'account':
@@ -123,7 +123,7 @@ function um_add_update_notice( $args ) {
123
  }
124
 
125
  if ( ! empty( $_REQUEST['err'] ) && ! UM()->form()->errors ) {
126
- switch( $_REQUEST['err'] ) {
127
 
128
  default:
129
  /**
@@ -148,7 +148,7 @@ function um_add_update_notice( $args ) {
148
  * }
149
  * ?>
150
  */
151
- $err = apply_filters( 'um_custom_error_message_handler', $err, $_REQUEST['err'] );
152
  if ( ! $err ) {
153
  $err = __( 'An error has been encountered', 'ultimate-member' );
154
  }
@@ -203,4 +203,4 @@ function um_add_update_notice( $args ) {
203
 
204
  echo $output;
205
  }
206
- add_action( 'um_before_form', 'um_add_update_notice', 500 );
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
 
5
 
6
  /**
13
 
14
  if ( ! empty( $_REQUEST['redirect_to'] ) ) {
15
 
16
+ $url = esc_url_raw( $_REQUEST['redirect_to'] );
17
 
18
  } elseif ( ! empty( $args['after_login'] ) ) {
19
 
75
  function um_add_update_notice( $args ) {
76
  extract( $args );
77
 
78
+ $output = '';
79
+ $err = '';
80
  $success = '';
81
 
82
  if ( ! empty( $_REQUEST['updated'] ) && ! UM()->form()->errors ) {
83
+ switch ( sanitize_key( $_REQUEST['updated'] ) ) {
84
  default:
85
  /**
86
  * UM hook
104
  * }
105
  * ?>
106
  */
107
+ $success = apply_filters( 'um_custom_success_message_handler', $success, sanitize_key( $_REQUEST['updated'] ) );
108
  break;
109
 
110
  case 'account':
123
  }
124
 
125
  if ( ! empty( $_REQUEST['err'] ) && ! UM()->form()->errors ) {
126
+ switch( sanitize_key( $_REQUEST['err'] ) ) {
127
 
128
  default:
129
  /**
148
  * }
149
  * ?>
150
  */
151
+ $err = apply_filters( 'um_custom_error_message_handler', $err, sanitize_key( $_REQUEST['err'] ) );
152
  if ( ! $err ) {
153
  $err = __( 'An error has been encountered', 'ultimate-member' );
154
  }
203
 
204
  echo $output;
205
  }
206
+ add_action( 'um_before_form', 'um_add_update_notice', 500 );
includes/core/um-actions-profile.php CHANGED
@@ -168,16 +168,16 @@ function um_profile_content_main( $args ) {
168
  */
169
  do_action( 'um_after_form', $args );
170
 
171
- } else { ?>
172
-
173
  <div class="um-profile-note">
174
  <span>
175
  <i class="um-faicon-lock"></i>
176
  <?php echo $can_view; ?>
177
  </span>
178
  </div>
179
-
180
- <?php }
181
  }
182
  add_action( 'um_profile_content_main', 'um_profile_content_main' );
183
 
@@ -1732,4 +1732,4 @@ function um_profile_menu( $args ) {
1732
  }
1733
 
1734
  }
1735
- add_action( 'um_profile_menu', 'um_profile_menu', 9 );
168
  */
169
  do_action( 'um_after_form', $args );
170
 
171
+ } else {
172
+ ?>
173
  <div class="um-profile-note">
174
  <span>
175
  <i class="um-faicon-lock"></i>
176
  <?php echo $can_view; ?>
177
  </span>
178
  </div>
179
+ <?php
180
+ }
181
  }
182
  add_action( 'um_profile_content_main', 'um_profile_content_main' );
183
 
1732
  }
1733
 
1734
  }
1735
+ add_action( 'um_profile_menu', 'um_profile_menu', 9 );
includes/core/um-actions-wpadmin.php CHANGED
@@ -1,13 +1,12 @@
1
- <?php
2
- // Exit if accessed directly
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
 
5
 
6
  /**
7
  * Checks if user can access the backend
8
  */
9
  function um_block_wpadmin_by_user_role() {
10
-
11
  global $pagenow;
12
 
13
  if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
@@ -49,4 +48,4 @@ add_filter( 'show_admin_bar', 'um_control_admin_bar', 9999, 1 );
49
  function um_force_admin_bar() {
50
  um_reset_user();
51
  }
52
- add_action( 'wp_footer', 'um_force_admin_bar' );
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
 
5
 
6
  /**
7
  * Checks if user can access the backend
8
  */
9
  function um_block_wpadmin_by_user_role() {
 
10
  global $pagenow;
11
 
12
  if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
48
  function um_force_admin_bar() {
49
  um_reset_user();
50
  }
51
+ add_action( 'wp_footer', 'um_force_admin_bar' );
includes/core/um-filters-fields.php CHANGED
@@ -1,4 +1,6 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
2
 
3
 
4
  /**
@@ -55,7 +57,7 @@ function um_profile_field_filter_hook__youtube_video( $value, $data ) {
55
  if ( empty( $value ) ) {
56
  return '';
57
  }
58
- $value = ( strstr( $value, 'http') || strstr( $value, '://' ) ) ? um_youtube_id_from_url( $value ) : $value;
59
  $value = '<div class="um-youtube">
60
  <iframe width="600" height="450" src="https://www.youtube.com/embed/' . $value . '" frameborder="0" allowfullscreen></iframe>
61
  </div>';
@@ -78,9 +80,9 @@ function um_profile_field_filter_hook__vimeo_video( $value, $data ) {
78
  return '';
79
  }
80
 
81
- $value = ( !is_numeric( $value ) ) ? (int) substr(parse_url($value, PHP_URL_PATH), 1) : $value;
82
  $value = '<div class="um-vimeo">
83
- <iframe src="https://player.vimeo.com/video/'. $value . '" width="600" height="450" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
84
  </div>';
85
  return $value;
86
  }
@@ -341,10 +343,10 @@ function um_profile_field_filter_hook__( $value, $data, $type = '' ) {
341
  return '';
342
  }
343
 
344
- if ( ( isset( $data['validate'] ) && $data['validate'] != '' && strstr( $data['validate'], 'url' ) ) || ( isset( $data['type'] ) && $data['type'] == 'url' ) ) {
345
  $alt = ( isset( $data['url_text'] ) && !empty( $data['url_text'] ) ) ? $data['url_text'] : $value;
346
  $url_rel = ( isset( $data['url_rel'] ) && $data['url_rel'] == 'nofollow' ) ? 'rel="nofollow"' : '';
347
- if( !strstr( $value, 'http' )
348
  && !strstr( $value, '://' )
349
  && !strstr( $value, 'www.' )
350
  && !strstr( $value, '.com' )
@@ -363,13 +365,9 @@ function um_profile_field_filter_hook__( $value, $data, $type = '' ) {
363
  }
364
 
365
 
366
- if ( isset( $data['validate'] ) && $data['validate'] == 'skype' ) {
367
-
368
- $value = $value;
369
-
370
- } else {
371
 
372
- if ( strpos($value, 'http://') !== 0 ) {
373
  $value = 'http://' . $value;
374
  }
375
  $data['url_target'] = ( isset( $data['url_target'] ) ) ? $data['url_target'] : '_blank';
@@ -456,7 +454,7 @@ function um_get_custom_field_array( $array, $fields ) {
456
  $condition_metakey = $fields[ $value[1] ]['metakey'];
457
 
458
  if ( isset( $_POST[ $condition_metakey ] ) ) {
459
- $cond_value = ( $fields[ $value[1] ]['type'] == 'radio' ) ? $_POST[ $condition_metakey ][0] : $_POST[ $condition_metakey ];
460
  list( $visibility, $parent_key, $op, $parent_value ) = $value;
461
 
462
  if ( $visibility == 'hide' ) {
@@ -849,4 +847,4 @@ function um_edit_url_field_value( $value, $key ) {
849
  $value = esc_attr( $value );
850
  return $value;
851
  }
852
- add_filter( 'um_edit_url_field_value', 'um_edit_url_field_value', 10, 2 );
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
 
5
 
6
  /**
57
  if ( empty( $value ) ) {
58
  return '';
59
  }
60
+ $value = ( strstr( $value, 'http' ) || strstr( $value, '://' ) ) ? um_youtube_id_from_url( $value ) : $value;
61
  $value = '<div class="um-youtube">
62
  <iframe width="600" height="450" src="https://www.youtube.com/embed/' . $value . '" frameborder="0" allowfullscreen></iframe>
63
  </div>';
80
  return '';
81
  }
82
 
83
+ $value = ! is_numeric( $value ) ? (int) substr( parse_url( $value, PHP_URL_PATH ), 1 ) : $value;
84
  $value = '<div class="um-vimeo">
85
+ <iframe src="https://player.vimeo.com/video/' . $value . '" width="600" height="450" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
86
  </div>';
87
  return $value;
88
  }
343
  return '';
344
  }
345
 
346
+ if ( ( isset( $data['validate'] ) && $data['validate'] !== '' && strstr( $data['validate'], 'url' ) ) || ( isset( $data['type'] ) && $data['type'] == 'url' ) ) {
347
  $alt = ( isset( $data['url_text'] ) && !empty( $data['url_text'] ) ) ? $data['url_text'] : $value;
348
  $url_rel = ( isset( $data['url_rel'] ) && $data['url_rel'] == 'nofollow' ) ? 'rel="nofollow"' : '';
349
+ if ( ! strstr( $value, 'http' )
350
  && !strstr( $value, '://' )
351
  && !strstr( $value, 'www.' )
352
  && !strstr( $value, '.com' )
365
  }
366
 
367
 
368
+ if ( ! ( isset( $data['validate'] ) && $data['validate'] == 'skype' ) ) {
 
 
 
 
369
 
370
+ if ( strpos( $value, 'http://' ) !== 0 ) {
371
  $value = 'http://' . $value;
372
  }
373
  $data['url_target'] = ( isset( $data['url_target'] ) ) ? $data['url_target'] : '_blank';
454
  $condition_metakey = $fields[ $value[1] ]['metakey'];
455
 
456
  if ( isset( $_POST[ $condition_metakey ] ) ) {
457
+ $cond_value = ( $fields[ $value[1] ]['type'] === 'radio' ) ? $_POST[ $condition_metakey ][0] : $_POST[ $condition_metakey ];
458
  list( $visibility, $parent_key, $op, $parent_value ) = $value;
459
 
460
  if ( $visibility == 'hide' ) {
847
  $value = esc_attr( $value );
848
  return $value;
849
  }
850
+ add_filter( 'um_edit_url_field_value', 'um_edit_url_field_value', 10, 2 );
includes/core/um-filters-login.php CHANGED
@@ -1,4 +1,6 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
2
 
3
 
4
  /**
@@ -10,16 +12,18 @@
10
  */
11
  function um_whitelisted_wpadmin_access( $allowed ) {
12
  $ips = UM()->options()->get( 'wpadmin_allow_ips' );
13
-
14
- if ( !$ips )
15
  return $allowed;
16
-
17
- $ips = array_map("rtrim", explode("\n", $ips));
 
18
  $user_ip = um_user_ip();
19
 
20
- if ( in_array( $user_ip, $ips ) )
21
  $allowed = 1;
22
-
 
23
  return $allowed;
24
  }
25
  add_filter( 'um_whitelisted_wpadmin_access', 'um_whitelisted_wpadmin_access' );
@@ -35,7 +39,7 @@ add_filter( 'um_whitelisted_wpadmin_access', 'um_whitelisted_wpadmin_access' );
35
  function um_custom_wp_err_messages( $message ) {
36
 
37
  if ( ! empty( $_REQUEST['err'] ) ) {
38
- switch( $_REQUEST['err'] ) {
39
  case 'blocked_email':
40
  $err = __( 'This email address has been blocked.', 'ultimate-member' );
41
  break;
@@ -126,4 +130,4 @@ function um_lostpassword_url( $lostpassword_url ) {
126
 
127
  return $lostpassword_url;
128
  }
129
- add_filter( 'lostpassword_url', 'um_lostpassword_url', 10, 1 );
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ }
4
 
5
 
6
  /**
12
  */
13
  function um_whitelisted_wpadmin_access( $allowed ) {
14
  $ips = UM()->options()->get( 'wpadmin_allow_ips' );
15
+
16
+ if ( ! $ips ) {
17
  return $allowed;
18
+ }
19
+
20
+ $ips = array_map( 'rtrim', explode( "\n", $ips ) );
21
  $user_ip = um_user_ip();
22
 
23
+ if ( in_array( $user_ip, $ips, true ) ) {
24
  $allowed = 1;
25
+ }
26
+
27
  return $allowed;
28
  }
29
  add_filter( 'um_whitelisted_wpadmin_access', 'um_whitelisted_wpadmin_access' );
39
  function um_custom_wp_err_messages( $message ) {
40
 
41
  if ( ! empty( $_REQUEST['err'] ) ) {
42
+ switch ( sanitize_key( $_REQUEST['err'] ) ) {
43
  case 'blocked_email':
44
  $err = __( 'This email address has been blocked.', 'ultimate-member' );
45
  break;
130
 
131
  return $lostpassword_url;
132
  }
133
+ add_filter( 'lostpassword_url', 'um_lostpassword_url', 10, 1 );
includes/um-short-functions.php CHANGED
@@ -1490,7 +1490,7 @@ function um_edit_my_profile_cancel_uri( $url = '' ) {
1490
  * @return bool
1491
  */
1492
  function um_is_on_edit_profile() {
1493
- if ( isset( $_REQUEST['um_action'] ) && $_REQUEST['um_action'] == 'edit' ) {
1494
  return true;
1495
  }
1496
 
@@ -2623,15 +2623,15 @@ function um_secure_media_uri( $url ) {
2623
  */
2624
  function um_force_utf8_string( $value ) {
2625
 
2626
- if (is_array( $value )) {
2627
  $arr_value = array();
2628
- foreach ($value as $key => $value) {
2629
- $utf8_decoded_value = utf8_decode( $value );
2630
 
2631
- if (mb_check_encoding( $utf8_decoded_value, 'UTF-8' )) {
2632
  array_push( $arr_value, $utf8_decoded_value );
2633
  } else {
2634
- array_push( $arr_value, $value );
2635
  }
2636
 
2637
  }
@@ -2798,4 +2798,4 @@ function um_is_amp( $check_theme_support = true ) {
2798
  }
2799
 
2800
  return apply_filters( 'um_is_amp', $is_amp );
2801
- }
1490
  * @return bool
1491
  */
1492
  function um_is_on_edit_profile() {
1493
+ if ( isset( $_REQUEST['um_action'] ) && sanitize_key( $_REQUEST['um_action'] ) == 'edit' ) {
1494
  return true;
1495
  }
1496
 
2623
  */
2624
  function um_force_utf8_string( $value ) {
2625
 
2626
+ if ( is_array( $value ) ) {
2627
  $arr_value = array();
2628
+ foreach ( $value as $key => $v ) {
2629
+ $utf8_decoded_value = utf8_decode( $v );
2630
 
2631
+ if ( mb_check_encoding( $utf8_decoded_value, 'UTF-8' ) ) {
2632
  array_push( $arr_value, $utf8_decoded_value );
2633
  } else {
2634
+ array_push( $arr_value, $v );
2635
  }
2636
 
2637
  }
2798
  }
2799
 
2800
  return apply_filters( 'um_is_amp', $is_amp );
2801
+ }
includes/widgets/class-um-search-widget.php CHANGED
@@ -1,110 +1,111 @@
1
- <?php
2
- namespace um\widgets;
3
-
4
-
5
- // Exit if accessed directly
6
- if ( ! defined( 'ABSPATH' ) ) exit;
7
-
8
-
9
- /**
10
- * Class UM_Search_Widget
11
- * @package um\widgets
12
- */
13
- class UM_Search_Widget extends \WP_Widget {
14
-
15
-
16
- /**
17
- * UM_Search_Widget constructor.
18
- */
19
- function __construct() {
20
-
21
- parent::__construct(
22
-
23
- // Base ID of your widget
24
- 'um_search_widget',
25
-
26
- // Widget name will appear in UI
27
- __( 'Ultimate Member - Search', 'ultimate-member' ),
28
-
29
- // Widget description
30
- array( 'description' => __( 'Shows the search member form.', 'ultimate-member' ), )
31
- );
32
-
33
- }
34
-
35
-
36
- /**
37
- * Creating widget front-end
38
- *
39
- * @param array $args
40
- * @param array $instance
41
- */
42
- public function widget( $args, $instance ) {
43
-
44
- $title = apply_filters( 'widget_title', $instance['title'] );
45
-
46
- // before and after widget arguments are defined by themes
47
- echo $args['before_widget'];
48
- if ( ! empty( $title ) ) {
49
- echo $args['before_title'] . $title . $args['after_title'];
50
- }
51
-
52
- // display the search form
53
- if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
54
- echo do_shortcode( '[ultimatemember_searchform /]' );
55
- } else {
56
- echo apply_shortcodes( '[ultimatemember_searchform /]' );
57
- }
58
-
59
-
60
- echo $args['after_widget'];
61
- }
62
-
63
-
64
- /**
65
- * Widget Backend
66
- *
67
- * @param array $instance
68
- */
69
- public function form( $instance ) {
70
- if ( isset( $instance[ 'title' ] ) ) {
71
- $title = $instance[ 'title' ];
72
- } else {
73
- $title = __( 'Search Users', 'ultimate-member' );
74
- }
75
-
76
- if ( isset( $instance[ 'max' ] ) ) {
77
- $max = $instance[ 'max' ];
78
- } else {
79
- $max = 11;
80
- }
81
-
82
- // Widget admin form
83
- ?>
84
-
85
- <p>
86
- <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title', 'ultimate-member' ); ?>:</label>
87
- <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"
88
- name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text"
89
- value="<?php echo esc_attr( $title ); ?>" />
90
- </p>
91
-
92
- <?php
93
- }
94
-
95
-
96
- /**
97
- * Updating widget replacing old instances with new
98
- *
99
- * @param array $new_instance
100
- * @param array $old_instance
101
- *
102
- * @return array
103
- */
104
- public function update( $new_instance, $old_instance ) {
105
- $instance = array();
106
- $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
107
- return $instance;
108
- }
109
-
110
- }
 
1
+ <?php
2
+ namespace um\widgets;
3
+
4
+
5
+ // Exit if accessed directly
6
+ if ( ! defined( 'ABSPATH' ) ) exit;
7
+
8
+
9
+ /**
10
+ * Class UM_Search_Widget
11
+ * @package um\widgets
12
+ */
13
+ class UM_Search_Widget extends \WP_Widget {
14
+
15
+
16
+ /**
17
+ * UM_Search_Widget constructor.
18
+ */
19
+ function __construct() {
20
+
21
+ parent::__construct(
22
+
23
+ // Base ID of your widget
24
+ 'um_search_widget',
25
+
26
+ // Widget name will appear in UI
27
+ __( 'Ultimate Member - Search', 'ultimate-member' ),
28
+
29
+ // Widget description
30
+ array( 'description' => __( 'Shows the search member form.', 'ultimate-member' ), )
31
+ );
32
+
33
+ }
34
+
35
+
36
+ /**
37
+ * Creating widget front-end
38
+ *
39
+ * @param array $args
40
+ * @param array $instance
41
+ */
42
+ public function widget( $args, $instance ) {
43
+
44
+ $title = array_key_exists( 'title', $instance ) ? $instance['title'] : '';
45
+ $title = apply_filters( 'widget_title', $title );
46
+
47
+ // before and after widget arguments are defined by themes
48
+ echo $args['before_widget'];
49
+ if ( ! empty( $title ) ) {
50
+ echo $args['before_title'] . $title . $args['after_title'];
51
+ }
52
+
53
+ // display the search form
54
+ if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
55
+ echo do_shortcode( '[ultimatemember_searchform /]' );
56
+ } else {
57
+ echo apply_shortcodes( '[ultimatemember_searchform /]' );
58
+ }
59
+
60
+
61
+ echo $args['after_widget'];
62
+ }
63
+
64
+
65
+ /**
66
+ * Widget Backend
67
+ *
68
+ * @param array $instance
69
+ */
70
+ public function form( $instance ) {
71
+ if ( isset( $instance[ 'title' ] ) ) {
72
+ $title = $instance[ 'title' ];
73
+ } else {
74
+ $title = __( 'Search Users', 'ultimate-member' );
75
+ }
76
+
77
+ if ( isset( $instance[ 'max' ] ) ) {
78
+ $max = $instance[ 'max' ];
79
+ } else {
80
+ $max = 11;
81
+ }
82
+
83
+ // Widget admin form
84
+ ?>
85
+
86
+ <p>
87
+ <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title', 'ultimate-member' ); ?>:</label>
88
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"
89
+ name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text"
90
+ value="<?php echo esc_attr( $title ); ?>" />
91
+ </p>
92
+
93
+ <?php
94
+ }
95
+
96
+
97
+ /**
98
+ * Updating widget replacing old instances with new
99
+ *
100
+ * @param array $new_instance
101
+ * @param array $old_instance
102
+ *
103
+ * @return array
104
+ */
105
+ public function update( $new_instance, $old_instance ) {
106
+ $instance = array();
107
+ $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
108
+ return $instance;
109
+ }
110
+
111
+ }
readme.txt CHANGED
@@ -155,6 +155,31 @@ The plugin works with popular caching plugins by automatically excluding Ultimat
155
  * To learn more about version 2.1 please see this [docs](https://docs.ultimatemember.com/article/1512-upgrade-2-1-0)
156
  * 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
157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  = 2.1.21: June 17, 2021 =
159
 
160
  * Enhancements:
155
  * To learn more about version 2.1 please see this [docs](https://docs.ultimatemember.com/article/1512-upgrade-2-1-0)
156
  * 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
157
 
158
+ = 2.2.0: July 20, 2021 =
159
+
160
+ * Enhancements:
161
+
162
+ - Added: Sanitizing handlers to the Ultimate Member > Settings forms' fields
163
+ - Added: Sanitizing handlers to the Ultimate Member > User Role Add/Edit forms' fields
164
+ - Added: Sanitizing handlers to the Ultimate Member > Forms forms' fields
165
+ - Added: Sanitizing handlers to the Ultimate Member > Forms > Add Field/Edit Field forms' fields
166
+ - Added: Sanitizing handlers to the Ultimate Member > User Roles forms' fields
167
+ - Added: Sanitizing handlers to the Restriction Content forms' fields in the posts/pages/menus additional fields
168
+ - Added: Custom placeholder setting for the Confirm Password field
169
+
170
+ * Bugfixes:
171
+
172
+ - Fixed: Content restriction settings using in Avada theme with active page headers
173
+ - Fixed: Content restriction (CPT + Terms). Avoid displaying comments if the post is restricted
174
+ - Fixed: Content restriction (CPT + Terms). Avoid displaying comments and posts feed
175
+ - Fixed: Content restriction (CPT + Terms). Displaying the proper count of the posts. Restricted are excluded
176
+ - Fixed: Saving and displaying settings on the UM > Settings > Access screen
177
+ - Fixed: Saving and displaying default Member Directory settings
178
+
179
+ * Tweaks:
180
+
181
+ - WordPress 5.8 compatibility. Widgets screen changes based on the new features with Legacy Widget block
182
+
183
  = 2.1.21: June 17, 2021 =
184
 
185
  * Enhancements:
templates/email/checkmail_email.php CHANGED
@@ -25,4 +25,4 @@
25
 
26
  </div>
27
 
28
- </div>
25
 
26
  </div>
27
 
28
+ </div>
templates/members.php CHANGED
@@ -95,17 +95,17 @@ if ( ! empty( $args['enable_sorting'] ) ) {
95
  }
96
 
97
  $sorting_options = apply_filters( 'um_member_directory_pre_display_sorting', $sorting_options, $args );
98
- $sort_from_url = ( ! empty( $_GET[ 'sort_' . $unique_hash ] ) && in_array( $_GET[ 'sort_' . $unique_hash ], array_keys( $sorting_options ) ) ) ? $_GET[ 'sort_' . $unique_hash ] : $default_sorting;
99
  }
100
 
101
- $current_page = ( ! empty( $_GET[ 'page_' . $unique_hash ] ) && is_numeric( $_GET[ 'page_' . $unique_hash ] ) ) ? (int) $_GET[ 'page_' . $unique_hash ] : 1;
102
 
103
  //Search
104
  $search = isset( $args['search'] ) ? $args['search'] : false;
105
  $show_search = empty( $args['roles_can_search'] ) || ( ! empty( $priority_user_role ) && in_array( $priority_user_role, $args['roles_can_search'] ) );
106
  $search_from_url = '';
107
  if ( $search && $show_search ) {
108
- $search_from_url = ! empty( $_GET[ 'search_' . $unique_hash ] ) ? stripslashes( $_GET[ 'search_' . $unique_hash ] ) : '';
109
  }
110
 
111
 
@@ -374,4 +374,4 @@ if ( ( ( $search && $show_search ) || ( $filters && $show_filters && count( $sea
374
  */
375
  do_action( 'um_members_directory_footer', $args, $form_id, $not_searched ); ?>
376
 
377
- </div>
95
  }
96
 
97
  $sorting_options = apply_filters( 'um_member_directory_pre_display_sorting', $sorting_options, $args );
98
+ $sort_from_url = ( ! empty( $_GET[ 'sort_' . $unique_hash ] ) && in_array( sanitize_text_field( $_GET[ 'sort_' . $unique_hash ] ), array_keys( $sorting_options ) ) ) ? sanitize_text_field( $_GET[ 'sort_' . $unique_hash ] ) : $default_sorting;
99
  }
100
 
101
+ $current_page = ( ! empty( $_GET[ 'page_' . $unique_hash ] ) && is_numeric( $_GET[ 'page_' . $unique_hash ] ) ) ? absint( $_GET[ 'page_' . $unique_hash ] ) : 1;
102
 
103
  //Search
104
  $search = isset( $args['search'] ) ? $args['search'] : false;
105
  $show_search = empty( $args['roles_can_search'] ) || ( ! empty( $priority_user_role ) && in_array( $priority_user_role, $args['roles_can_search'] ) );
106
  $search_from_url = '';
107
  if ( $search && $show_search ) {
108
+ $search_from_url = ! empty( $_GET[ 'search_' . $unique_hash ] ) ? stripslashes( sanitize_text_field( $_GET[ 'search_' . $unique_hash ] ) ) : '';
109
  }
110
 
111
 
374
  */
375
  do_action( 'um_members_directory_footer', $args, $form_id, $not_searched ); ?>
376
 
377
+ </div>
templates/password-reset.php CHANGED
@@ -1,13 +1,15 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
 
 
2
 
3
  <div class="um <?php echo esc_attr( $this->get_class( $mode ) ); ?> um-<?php echo esc_attr( $form_id ); ?>">
4
  <div class="um-form">
5
  <form method="post" action="">
6
- <?php if ( isset( $_GET['updated'] ) && 'checkemail' == $_GET['updated'] ) { ?>
7
  <div class="um-field um-field-block um-field-type_block">
8
  <div class="um-field-block">
9
  <div style="text-align:center;">
10
- <?php _e( 'We have sent you a password reset link to your e-mail. Please check your inbox.', 'ultimate-member' ); ?>
11
  </div>
12
  </div>
13
  </div>
@@ -41,9 +43,9 @@
41
  <div class="um-field um-field-block um-field-type_block">
42
  <div class="um-field-block">
43
  <div style="text-align:center;">
44
- <?php if ( 'expiredkey' == $_GET['updated'] ) {
45
  _e( 'Your password reset link has expired. Please request a new link below.', 'ultimate-member' );
46
- } elseif ( 'invalidkey' == $_GET['updated'] ) {
47
  _e( 'Your password reset link appears to be invalid. Please request a new link below.', 'ultimate-member' );
48
  } ?>
49
  </div>
@@ -143,4 +145,4 @@
143
  } ?>
144
  </form>
145
  </div>
146
- </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) {
2
+ exit;
3
+ } ?>
4
 
5
  <div class="um <?php echo esc_attr( $this->get_class( $mode ) ); ?> um-<?php echo esc_attr( $form_id ); ?>">
6
  <div class="um-form">
7
  <form method="post" action="">
8
+ <?php if ( isset( $_GET['updated'] ) && 'checkemail' === sanitize_key( $_GET['updated'] ) ) { ?>
9
  <div class="um-field um-field-block um-field-type_block">
10
  <div class="um-field-block">
11
  <div style="text-align:center;">
12
+ <?php esc_html_e( 'We have sent you a password reset link to your e-mail. Please check your inbox.', 'ultimate-member' ); ?>
13
  </div>
14
  </div>
15
  </div>
43
  <div class="um-field um-field-block um-field-type_block">
44
  <div class="um-field-block">
45
  <div style="text-align:center;">
46
+ <?php if ( 'expiredkey' === sanitize_key( $_GET['updated'] ) ) {
47
  _e( 'Your password reset link has expired. Please request a new link below.', 'ultimate-member' );
48
+ } elseif ( 'invalidkey' === sanitize_key( $_GET['updated'] ) ) {
49
  _e( 'Your password reset link appears to be invalid. Please request a new link below.', 'ultimate-member' );
50
  } ?>
51
  </div>
145
  } ?>
146
  </form>
147
  </div>
148
+ </div>
ultimate-member.php CHANGED
@@ -1,24 +1,24 @@
1
- <?php
2
- /*
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.1.21
7
- Author: Ultimate Member
8
- Author URI: http://ultimatemember.com/
9
- Text Domain: ultimate-member
10
- */
11
-
12
- defined( 'ABSPATH' ) || exit;
13
-
14
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
15
- $plugin_data = get_plugin_data( __FILE__ );
16
-
17
- define( 'um_url', plugin_dir_url( __FILE__ ) );
18
- define( 'um_path', plugin_dir_path( __FILE__ ) );
19
- define( 'um_plugin', plugin_basename( __FILE__ ) );
20
- define( 'ultimatemember_version', $plugin_data['Version'] );
21
- define( 'ultimatemember_plugin_name', $plugin_data['Name'] );
22
-
23
- require_once 'includes/class-functions.php';
24
- require_once 'includes/class-init.php';
1
+ <?php
2
+ /*
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.2.0-rc.1
7
+ Author: Ultimate Member
8
+ Author URI: http://ultimatemember.com/
9
+ Text Domain: ultimate-member
10
+ */
11
+
12
+ defined( 'ABSPATH' ) || exit;
13
+
14
+ require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
15
+ $plugin_data = get_plugin_data( __FILE__ );
16
+
17
+ define( 'um_url', plugin_dir_url( __FILE__ ) );
18
+ define( 'um_path', plugin_dir_path( __FILE__ ) );
19
+ define( 'um_plugin', plugin_basename( __FILE__ ) );
20
+ define( 'ultimatemember_version', $plugin_data['Version'] );
21
+ define( 'ultimatemember_plugin_name', $plugin_data['Name'] );
22
+
23
+ require_once 'includes/class-functions.php';
24
+ require_once 'includes/class-init.php';