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