PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.0.3.2
Adminify – White Label, Admin Menu Editor, Login Customizer v4.0.3.2
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
← All changes | Inc/Modules/MenuEditor/MenuEditor.php +192 -488 4.2.104.0.3.2 View file →
@@ -1,11 +1,12 @@
1 1 <?php
2 2
3 -namespace PXLBSAdminify\Inc\Modules\MenuEditor;
3 +namespace WPAdminify\Inc\Modules\MenuEditor;
4 4
5 -use PXLBSAdminify\Inc\Utils;
6 -use PXLBSAdminify\Inc\Admin\AdminSettings;
7 -use PXLBSAdminify\Inc\Modules\MenuEditor\MenuEditorAssets;
5 +use WPAdminify\Inc\Utils;
6 +use WPAdminify\Inc\Admin\AdminSettings;
7 +use WPAdminify\Inc\Modules\MenuEditor\MenuEditorAssets;
8 +use WPAdminify\Inc\Admin\AdminSettingsModel;
8 9 use enshrined\svgSanitize\Sanitizer;
9 10 // no direct access allowed
10 11 if ( !defined( 'ABSPATH' ) ) {
11 12 exit;
@@ -46,23 +47,17 @@
46 47 $this->menu_settings = ( new MenuEditorOptions() )->get();
47 48 $this->options = (array) AdminSettings::get_instance()->get();
48 49 add_filter( 'upload_mimes', [$this, 'custom_icon_mime_types'] );
49 50 add_filter( 'wp_handle_upload_prefilter', [$this, 'sanitize_svg_file'] );
50 - add_filter( 'admin_body_class', [$this, 'menu_editor_body_class'] );
51 - // add_filter('parent_file', [$this, 'set_menu'], 800);
52 - // add_filter('parent_file', [$this, 'apply_menu'], 900);
53 - // add_action('modules_menu_editor_render', [$this, 'modules_menu_editor_render']);
54 - if ( apply_filters( 'pxlbsadminify_enable_menu_editor_render', true ) ) {
55 - add_filter( 'parent_file', [$this, 'set_menu'], 800 );
56 - add_filter( 'parent_file', [$this, 'apply_menu'], 900 );
57 - }
58 - add_action( 'wp_ajax_pxlbsadminify_save_menu_settings', [$this, 'save_menu_settings'] );
59 - add_action( 'wp_ajax_pxlbsadminify_reset_menu_settings', [$this, 'reset_menu_settings'] );
60 - add_action( 'wp_ajax_pxlbsadminify_export_menu_settings', [$this, 'export_menu_settings'] );
61 - add_action( 'wp_ajax_pxlbsadminify_import_menu_settings', [$this, 'import_menu_settings'] );
62 - add_action( 'wp_ajax_pxlbsadminify_file_upload', [$this, 'file_upload_callback'] );
63 - add_action( 'wp_ajax_pxlbsadminify_load_custom_icons', [$this, 'load_custom_icons_callback'] );
64 - add_action( 'wp_ajax_pxlbsadminify_search_users', [$this, 'search_users_callback'] );
51 + add_filter( 'admin_body_class', [$this, 'jltwp_adminify_menu_editor_body_class'] );
52 + add_filter( 'parent_file', [$this, 'set_menu'], 800 );
53 + add_filter( 'parent_file', [$this, 'apply_menu'], 900 );
54 + add_action( 'wp_ajax_adminify_save_menu_settings', [$this, 'adminify_save_menu_settings'] );
55 + add_action( 'wp_ajax_adminify_reset_menu_settings', [$this, 'adminify_reset_menu_settings'] );
56 + add_action( 'wp_ajax_adminify_export_menu_settings', [$this, 'adminify_export_menu_settings'] );
57 + add_action( 'wp_ajax_adminify_import_menu_settings', [$this, 'adminify_import_menu_settings'] );
58 + add_action( 'wp_ajax_adminify_file_upload', [$this, 'adminify_file_upload_callback'] );
59 + add_action( 'wp_ajax_adminify_load_custom_icons', [$this, 'adminify_load_custom_icons_callback'] );
65 60 new MenuEditorAssets();
66 61 }
67 62
68 63 public function custom_icon_mime_types( $mimes ) {
@@ -102,16 +97,9 @@
102 97 // return $value->post_title == 'adminify-custom-icon';
103 98 return strpos( $value->guid, 'adminify-custom-icon' ) !== false;
104 99 }
105 100
106 - public function load_custom_icons_callback() {
107 - // Security check - verify nonce and capability
108 - check_ajax_referer( 'pxlbsadminify-menu-editor-security-nonce', 'security' );
109 - if ( !current_user_can( 'manage_options' ) ) {
110 - wp_send_json_error( array(
111 - 'message' => __( 'You do not have permission to perform this action.', 'adminify' ),
112 - ) );
113 - }
101 + public function adminify_load_custom_icons_callback() {
114 102 $result['images'] = null;
115 103 $query = get_posts( [
116 104 'post_type' => 'attachment',
117 105 'numberposts' => -1,
@@ -123,28 +111,17 @@
123 111 echo wp_json_encode( $result );
124 112 die;
125 113 }
126 114
127 - public function file_upload_callback() {
115 + public function adminify_file_upload_callback() {
128 116 $result['status'] = false;
129 - check_ajax_referer( 'pxlbsadminify-menu-editor-security-nonce', 'security' );
130 - if ( !current_user_can( 'manage_options' ) ) {
131 - wp_send_json_error( array(
132 - 'message' => __( 'You do not have permission to perform this action.', 'adminify' ),
133 - ) );
134 - }
117 + check_ajax_referer( 'adminify-menu-editor-security-nonce', 'security' );
135 118 $upload_dir = wp_upload_dir();
136 119 $targeted_dir = $upload_dir['basedir'] . '/adminify-custom-icons';
137 120 if ( !is_dir( $targeted_dir ) ) {
138 121 wp_mkdir_p( $targeted_dir );
139 122 }
140 - add_filter( 'upload_dir', [$this, 'icon_custom_upload_dir'] );
141 - if ( !isset( $_FILES['my_file_upload'] ) ) {
142 - wp_send_json_error( array(
143 - 'message' => __( 'No file was uploaded.', 'adminify' ),
144 - ) );
145 - }
146 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- $_FILES is sanitized by the WP upload handler.
123 + add_filter( 'upload_dir', [$this, 'adminify_icon_custom_upload_dir'] );
147 124 $files = wp_kses_post_deep( wp_unslash( $_FILES['my_file_upload'] ) );
148 125 foreach ( $files['name'] as $key => $value ) {
149 126 if ( $files['name'][$key] ) {
150 127 $file = [
@@ -169,14 +146,14 @@
169 146 $result['images'][$attachment_id] = wp_get_attachment_url( $attachment_id );
170 147 }
171 148 }
172 149 }
173 - remove_filter( 'upload_dir', [$this, 'icon_custom_upload_dir'] );
150 + remove_filter( 'upload_dir', [$this, 'adminify_icon_custom_upload_dir'] );
174 151 echo wp_json_encode( $result );
175 152 wp_die();
176 153 }
177 154
178 - public function icon_custom_upload_dir( $dir_data ) {
155 + public function adminify_icon_custom_upload_dir( $dir_data ) {
179 156 // $dir_data already you might want to use
180 157 $custom_dir = 'adminify-custom-icons';
181 158 return [
182 159 'path' => $dir_data['basedir'] . '/' . $custom_dir,
@@ -187,75 +164,10 @@
187 164 'error' => $dir_data['error'],
188 165 ];
189 166 }
190 167
191 - /**
192 - * AJAX callback to search users for Select2
193 - * Uses 'fields' parameter for optimized database query performance
194 - */
195 - public function search_users_callback() {
196 - check_ajax_referer( 'pxlbsadminify-menu-editor-security-nonce', 'security' );
197 - if ( !current_user_can( 'manage_options' ) ) {
198 - wp_send_json_error( array(
199 - 'message' => __( 'You do not have permission to perform this action.', 'adminify' ),
200 - ) );
201 - }
202 - $search = ( isset( $_GET['search'] ) ? sanitize_text_field( wp_unslash( $_GET['search'] ) ) : '' );
203 - // If no search term or less than 3 chars, return first 3 users
204 - if ( strlen( $search ) < 3 ) {
205 - $args = array(
206 - 'number' => 3,
207 - 'orderby' => 'ID',
208 - 'order' => 'DESC',
209 - 'fields' => array('ID', 'user_login', 'display_name'),
210 - );
211 - $users = get_users( $args );
212 - $results = array();
213 - foreach ( $users as $user ) {
214 - $results[] = array(
215 - 'id' => $user->user_login,
216 - 'text' => $user->user_login . ' (' . $user->display_name . ')',
217 - );
218 - }
219 - // Get total user count efficiently
220 - $user_count = count_users();
221 - $total_users = $user_count['total_users'];
222 - wp_send_json( array(
223 - 'results' => $results,
224 - 'pagination' => array(
225 - 'more' => $total_users > 3,
226 - ),
227 - 'total_users' => $total_users,
228 - ) );
229 - return;
230 - }
231 - // Search users when 3+ characters typed
232 - $args = array(
233 - 'search' => '*' . $search . '*',
234 - 'search_columns' => array('user_login', 'user_email', 'display_name'),
235 - 'number' => 20,
236 - 'orderby' => 'display_name',
237 - 'order' => 'ASC',
238 - 'fields' => array('ID', 'user_login', 'display_name'),
239 - );
240 - $users = get_users( $args );
241 - $results = array();
242 - foreach ( $users as $user ) {
243 - $results[] = array(
244 - 'id' => $user->user_login,
245 - 'text' => $user->user_login . ' (' . $user->display_name . ')',
246 - );
247 - }
248 - wp_send_json( array(
249 - 'results' => $results,
250 - 'pagination' => array(
251 - 'more' => false,
252 - ),
253 - ) );
254 - }
255 -
256 168 // Menu Editor Body Class
257 - public function menu_editor_body_class( $classes ) {
169 + public function jltwp_adminify_menu_editor_body_class( $classes ) {
258 170 $classes .= ' adminify_menu_editor ';
259 171 return $classes;
260 172 }
261 173
@@ -270,13 +182,13 @@
270 182 foreach ( $values as $index => $in ) {
271 183 if ( is_array( $in ) ) {
272 184 $values[$index] = $this->clean_ajax_input( $in );
273 185 } else {
274 - $values[$index] = wp_strip_all_tags( $in );
186 + $values[$index] = strip_tags( $in );
275 187 }
276 188 }
277 189 } else {
278 - $values = wp_strip_all_tags( $values );
190 + $values = strip_tags( $values );
279 191 }
280 192 return $values;
281 193 }
282 194
@@ -289,25 +201,18 @@
289 201 public function ajax_error_message( $message ) {
290 202 $returndata = [];
291 203 $returndata['error'] = true;
292 204 $returndata['error_message'] = $message;
293 - return wp_json_encode( $returndata );
205 + return json_encode( $returndata );
294 206 }
295 207
296 - public function save_menu_settings() {
297 - if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'pxlbsadminify-menu-editor-security-nonce', 'security' ) > 0 ) {
298 - if ( !current_user_can( 'manage_options' ) ) {
299 - wp_send_json_error( array(
300 - 'message' => __( 'You do not have permission to perform this action.', 'adminify' ),
301 - ) );
302 - }
303 - $options = ( isset( $_POST['options'] ) ? wp_kses_post_deep( wp_unslash( $_POST['options'] ) ) : '' );
304 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- sanitized via wp_kses_post_deep() and clean_ajax_input() below.
208 + public function adminify_save_menu_settings() {
209 + if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'adminify-menu-editor-security-nonce', 'security' ) > 0 ) {
210 + $options = wp_kses_post_deep( wp_unslash( $_POST['options'] ) );
305 211 $options = $this->clean_ajax_input( $options );
306 212 if ( $options == '' || !is_array( $options ) ) {
307 213 $message = __( 'No options supplied to save', 'adminify' );
308 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- kses_custom() is a wp_kses() wrapper; output already escaped.
309 - echo Utils::kses_custom( $this->ajax_error_message( $message ) );
214 + echo Utils::wp_kses_custom( $this->ajax_error_message( $message ) );
310 215 die;
311 216 }
312 217 if ( is_array( $options ) ) {
313 218 update_option( $this->prefix, $options );
@@ -313,14 +218,13 @@
313 218 update_option( $this->prefix, $options );
314 219 $returndata = [];
315 220 $returndata['success'] = true;
316 221 $returndata['message'] = __( 'Settings saved', 'adminify' );
317 - echo wp_json_encode( $returndata );
222 + echo json_encode( $returndata );
318 223 die;
319 224 } else {
320 225 $message = __( 'Something went wrong', 'adminify' );
321 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- kses_custom() is a wp_kses() wrapper; output already escaped.
322 - echo Utils::kses_custom( $this->ajax_error_message( $message ) );
226 + echo Utils::wp_kses_custom( $this->ajax_error_message( $message ) );
323 227 die;
324 228 }
325 229 }
326 230 die;
@@ -330,15 +234,10 @@
330 234 * Menu Editor Settings Reset
331 235 *
332 236 * @return void
333 237 */
334 - public function reset_menu_settings() {
335 - if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'pxlbsadminify-menu-editor-security-nonce', 'security' ) > 0 ) {
336 - if ( !current_user_can( 'manage_options' ) ) {
337 - wp_send_json_error( array(
338 - 'message' => __( 'You do not have permission to perform this action.', 'adminify' ),
339 - ) );
340 - }
238 + public function adminify_reset_menu_settings() {
239 + if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'adminify-menu-editor-security-nonce', 'security' ) > 0 ) {
341 240 update_option( $this->prefix, [] );
342 241 $menu_editor_options = get_option( $this->prefix );
343 242 if ( !$menu_editor_options ) {
344 243 $returndata = [];
@@ -343,14 +242,13 @@
343 242 if ( !$menu_editor_options ) {
344 243 $returndata = [];
345 244 $returndata['success'] = true;
346 245 $returndata['message'] = __( 'Settings reset', 'adminify' );
347 - echo wp_json_encode( $returndata );
246 + echo json_encode( $returndata );
348 247 die;
349 248 } else {
350 249 $message = __( 'Something went wrong', 'adminify' );
351 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- kses_custom() is a wp_kses() wrapper; output already escaped.
352 - echo Utils::kses_custom( $this->ajax_error_message( $message ) );
250 + echo Utils::wp_kses_custom( $this->ajax_error_message( $message ) );
353 251 die;
354 252 }
355 253 }
356 254 die;
@@ -360,17 +258,12 @@
360 258 * Export Menu Editor Settings
361 259 *
362 260 * @return void
363 261 */
364 - public function export_menu_settings() {
365 - if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'pxlbsadminify-menu-editor-security-nonce', 'security' ) > 0 ) {
366 - if ( !current_user_can( 'manage_options' ) ) {
367 - wp_send_json_error( array(
368 - 'message' => __( 'You do not have permission to perform this action.', 'adminify' ),
369 - ) );
370 - }
262 + public function adminify_export_menu_settings() {
263 + if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'adminify-menu-editor-security-nonce', 'security' ) > 0 ) {
371 264 $menu_editor_options = get_option( $this->prefix );
372 - echo wp_json_encode( $menu_editor_options );
265 + echo json_encode( $menu_editor_options );
373 266 }
374 267 die;
375 268 }
376 269
@@ -378,21 +271,14 @@
378 271 * Import Menu Editor Settings
379 272 *
380 273 * @since 1.0.0
381 274 */
382 - public function import_menu_settings() {
383 - if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'pxlbsadminify-menu-editor-security-nonce', 'security' ) > 0 ) {
384 - if ( !current_user_can( 'manage_options' ) ) {
385 - wp_send_json_error( array(
386 - 'message' => __( 'You do not have permission to perform this action.', 'adminify' ),
387 - ) );
388 - }
389 - $new_options = ( isset( $_POST['settings'] ) ? wp_kses_post_deep( wp_unslash( $_POST['settings'] ) ) : '' );
390 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- sanitized via wp_kses_post_deep().
275 + public function adminify_import_menu_settings() {
276 + if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'adminify-menu-editor-security-nonce', 'security' ) > 0 ) {
277 + $new_options = wp_kses_post_deep( $_POST['settings'] );
391 278 if ( $new_options == '' || !is_array( $new_options ) ) {
392 279 $message = __( 'No options supplied to save', 'adminify' );
393 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- kses_custom() is a wp_kses() wrapper; output already escaped.
394 - echo Utils::kses_custom( $this->ajax_error_message( $message ) );
280 + echo Utils::wp_kses_custom( $this->ajax_error_message( $message ) );
395 281 die;
396 282 }
397 283 if ( is_array( $new_options ) ) {
398 284 update_option( $this->prefix, $new_options );
@@ -398,14 +284,13 @@
398 284 update_option( $this->prefix, $new_options );
399 285 $returndata = [];
400 286 $returndata['success'] = true;
401 287 $returndata['message'] = __( 'Menu Imported', 'adminify' );
402 - echo wp_json_encode( $returndata );
288 + echo json_encode( $returndata );
403 289 die;
404 290 } else {
405 291 $message = __( 'Something went wrong', 'adminify' );
406 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- kses_custom() is a wp_kses() wrapper; output already escaped.
407 - echo Utils::kses_custom( $this->ajax_error_message( $message ) );
292 + echo Utils::wp_kses_custom( $this->ajax_error_message( $message ) );
408 293 die;
409 294 }
410 295 }
411 296 die;
@@ -411,37 +296,8 @@
411 296 die;
412 297 }
413 298
414 299 /**
415 - * Find menu settings for a given slug.
416 - * Some plugins (e.g. Yoast SEO) register different top-level menu slugs
417 - * depending on user capabilities. The admin sees slug 'wpseo_dashboard'
418 - * but the editor sees 'wpseo_tools'. This method handles that mismatch
419 - * by falling back to checking if the slug appears as a submenu key.
420 - *
421 - * @param string $slug The menu slug to look up.
422 - * @return array|null The matching settings array, or null if not found.
423 - */
424 - public function find_menu_settings_by_slug( $slug ) {
425 - // Direct match
426 - if ( isset( $this->menu_settings[$slug] ) ) {
427 - return $this->menu_settings[$slug];
428 - }
429 - // Fallback: check if this slug is a submenu of any saved parent menu
430 - if ( is_array( $this->menu_settings ) ) {
431 - foreach ( $this->menu_settings as $parent_slug => $parent_settings ) {
432 - if ( !is_array( $parent_settings ) || !isset( $parent_settings['submenu'] ) || !is_array( $parent_settings['submenu'] ) ) {
433 - continue;
434 - }
435 - if ( isset( $parent_settings['submenu'][$slug] ) ) {
436 - return $parent_settings;
437 - }
438 - }
439 - }
440 - return null;
441 - }
442 -
443 - /**
444 300 * Get menu items
445 301 *
446 302 * @param [type] $parent_file
447 303 *
@@ -460,21 +316,12 @@
460 316 public function sort_menu_settings( $thismenu ) {
461 317 $menu_settings = $this->menu_settings;
462 318 $tempmenu = [];
463 319 foreach ( $thismenu as $key => $current_menu_item ) {
464 - if ( $current_menu_item[4] === "wp-menu-separator" ) {
465 - unset($thismenu[$key]);
466 - continue;
467 - }
468 - if ( !current_user_can( 'administrator' ) && $current_menu_item[2] === 'vc-welcome' ) {
469 - unset($thismenu[$key]);
470 - continue;
471 - }
472 320 $next_menu_item = next( $thismenu );
473 321 $optiongroup = [];
474 322 $order = $key;
475 323 $separator = 0;
476 - $external_link = 0;
477 324 $icon = null;
478 325 $hidden_for = [];
479 326 if ( !empty( $next_menu_item ) && strpos( $next_menu_item[2], 'separator' ) !== false ) {
480 327 $separator = 1;
@@ -479,18 +326,10 @@
479 326 if ( !empty( $next_menu_item ) && strpos( $next_menu_item[2], 'separator' ) !== false ) {
480 327 $separator = 1;
481 328 }
482 329 if ( is_array( $menu_settings ) ) {
483 - // Direct slug match first, then fallback for dynamic-slug plugins (e.g. Yoast SEO)
484 330 if ( isset( $menu_settings[$current_menu_item[2]] ) ) {
485 331 $optiongroup = $menu_settings[$current_menu_item[2]];
486 - } else {
487 - $fallback = $this->find_menu_settings_by_slug( $current_menu_item[2] );
488 - if ( $fallback !== null ) {
489 - $optiongroup = $fallback;
490 - }
491 - }
492 - if ( !empty( $optiongroup ) ) {
493 332 if ( isset( $optiongroup['order'] ) ) {
494 333 $order = $optiongroup['order'];
495 334 }
496 335 if ( isset( $optiongroup['separator'] ) ) {
@@ -495,11 +334,8 @@
495 334 }
496 335 if ( isset( $optiongroup['separator'] ) ) {
497 336 $separator = $optiongroup['separator'];
498 337 }
499 - if ( isset( $optiongroup['external_link'] ) ) {
500 - $external_link = $optiongroup['external_link'];
501 - }
502 338 if ( !empty( $optiongroup['icon'] ) ) {
503 339 $icon = $optiongroup['icon'];
504 340 }
505 341 if ( !empty( $optiongroup['hidden_for'] ) ) {
@@ -509,9 +345,8 @@
509 345 }
510 346 $current_menu_item['order'] = $order;
511 347 $current_menu_item['hidden_for'] = $hidden_for;
512 348 $current_menu_item['separator'] = $separator;
513 - $current_menu_item['external_link'] = $external_link;
514 349 // if (empty($this->options['admin_ui'])) {
515 350 if ( $icon !== null ) {
516 351 if ( strpos( $icon, 'dashicons ' ) !== false ) {
517 352 $menu_icon = str_replace( 'dashicons ', '', $icon );
@@ -535,22 +370,8 @@
535 370 }
536 371 }
537 372 if ( is_array( $menu_settings ) && !array_key_exists( 0, $menu_settings ) ) {
538 373 foreach ( $menu_settings as $key => $menu_s ) {
539 - // Skip if $menu_s is not an array
540 - if ( !is_array( $menu_s ) ) {
541 - continue;
542 - }
543 - // Ensure required keys exist with defaults
544 - $menu_s = wp_parse_args( $menu_s, [
545 - 'name' => '',
546 - 'link' => '',
547 - 'icon' => '',
548 - 'order' => 0,
549 - 'separator' => 0,
550 - 'external_link' => 0,
551 - 'hidden_for' => [],
552 - ] );
553 374 $new_array = [
554 375 $menu_s['name'],
555 376 'read',
556 377 ( !empty( $menu_s['link'] ) ? $menu_s['link'] : '' ),
@@ -559,9 +380,8 @@
559 380 $key,
560 381 ( !empty( $menu_s['icon'] ) ? $menu_s['icon'] : '' ),
561 382 'order' => $menu_s['order'],
562 383 'separator' => ( !empty( $menu_s['separator'] ) ? $menu_s['separator'] : 0 ),
563 - 'external_link' => ( !empty( $menu_s['external_link'] ) ? $menu_s['external_link'] : 0 ),
564 384 'hidden_for' => ( !empty( $menu_s['hidden_for'] ) ? $menu_s['hidden_for'] : [] )
565 385 ];
566 386 // if (empty($this->options['admin_ui'])) {
567 387 if ( strpos( $menu_s['icon'], 'dashicons ' ) !== false ) {
@@ -568,9 +388,9 @@
568 388 $menu_icon = str_replace( 'dashicons ', '', $menu_s['icon'] );
569 389 } else {
570 390 if ( empty( $menu_s['icon'] ) || strpos( $menu_s['icon'], ',' ) !== false ) {
571 391 if ( empty( $menu_s['icon'] ) ) {
572 - $menu_icon = PXLBSADMINIFY_ASSETS_IMAGE . 'logos/menu-icon.svg';
392 + $menu_icon = WP_ADMINIFY_ASSETS_IMAGE . 'logos/menu-icon.svg';
573 393 } else {
574 394 $menu_icon = explode( ',', $menu_s['icon'] )[1];
575 395 }
576 396 } else {
@@ -579,11 +399,8 @@
579 399 }
580 400 if ( !empty( $menu_s['separator'] ) && $menu_s['separator'] == 1 ) {
581 401 $new_array[4] = $new_array[4] . ' adminify-menu-separator';
582 402 }
583 - // if (!empty($menu_s['external_link']) && $menu_s['external_link'] == 1) {
584 - // $new_array[4] = $new_array[4] . ' adminify-menu-external_link';
585 - // }
586 403 $new_array[6] = $menu_icon;
587 404 // }
588 405 array_push( $tempmenu, $new_array );
589 406 }
@@ -717,9 +534,9 @@
717 534 $separator_order = $this->menu[$key]['order'];
718 535 $empty_separator = array(
719 536 0 => '',
720 537 1 => 'read',
721 - 2 => 'separator_' . wp_rand( 200, 1000 ) * 1000,
538 + 2 => 'separator_' . rand( 200, 1000 ) * 1000,
722 539 3 => '',
723 540 4 => 'wp-menu-separator',
724 541 'order' => $separator_order + 0.5,
725 542 );
@@ -760,9 +577,9 @@
760 577 }
761 578 $submenu_settings = $this->menu_settings[$parentname]['submenu'];
762 579 $tempsub = [];
763 580 foreach ( $subitems as $current_menu_item ) {
764 - $sub_level = apply_filters( 'pxlbsadminify/menu_editor', [
581 + $sub_level = apply_filters( 'adminify/menu_editor', [
765 582 'sub_level' => false,
766 583 ] );
767 584 if ( !empty( $sub_level['sub_level'] ) ) {
768 585 if ( empty( $current_menu_item[0] ) || $current_menu_item[2] === 'wp-adminify-settings-pricing' ) {
@@ -788,15 +605,12 @@
788 605 $current_menu_item[2] = $link;
789 606 $current_menu_item['link'] = $link;
790 607 }
791 608 }
792 - if ( isset( $optiongroup['external_link'] ) ) {
793 - $external_link = $optiongroup['external_link'];
794 - }
795 609 if ( isset( $optiongroup['hidden_for'] ) ) {
796 610 $disabled_for = $optiongroup['hidden_for'];
797 611 if ( $this->is_hidden( $disabled_for ) ) {
798 - $current_menu_item['hidden_for'] = true;
612 + $current_menu_item['hidden'] = true;
799 613 continue;
800 614 }
801 615 }
802 616 }
@@ -804,13 +618,10 @@
804 618 if ( strpos( $custom_menu, 'adminify-custom-submenu-' ) !== false ) {
805 619 if ( isset( $submenu_settings[$current_menu_item['key']]['hidden_for'] ) ) {
806 620 $disabled_for = $submenu_settings[$current_menu_item['key']]['hidden_for'];
807 621 }
808 - if ( isset( $submenu_settings[$current_menu_item['key']]['external_link'] ) ) {
809 - $external_link = $submenu_settings[$current_menu_item['key']]['external_link'];
810 - }
811 622 if ( $this->is_hidden( $disabled_for ) ) {
812 - $current_menu_item['hidden_for'] = true;
623 + $current_menu_item['hidden'] = true;
813 624 continue;
814 625 }
815 626 }
816 627 array_push( $tempsub, $current_menu_item );
@@ -834,18 +645,10 @@
834 645 $disabled_for = [];
835 646 $optiongroup = [];
836 647 $order = $key;
837 648 if ( is_array( $this->menu_settings ) ) {
838 - // Direct slug match first, then fallback for dynamic-slug plugins (e.g. Yoast SEO)
839 649 if ( isset( $this->menu_settings[$current_menu_item[2]] ) ) {
840 650 $optiongroup = $this->menu_settings[$current_menu_item[2]];
841 - } else {
842 - $fallback = $this->find_menu_settings_by_slug( $current_menu_item[2] );
843 - if ( $fallback !== null ) {
844 - $optiongroup = $fallback;
845 - }
846 - }
847 - if ( !empty( $optiongroup ) ) {
848 651 if ( isset( $optiongroup['name'] ) ) {
849 652 $name = $optiongroup['name'];
850 653 if ( $name != '' ) {
851 654 $current_menu_item[0] = $name;
@@ -857,11 +660,8 @@
857 660 $current_menu_item[2] = $link;
858 661 $current_menu_item['link'] = $link;
859 662 }
860 663 }
861 - if ( isset( $optiongroup['external_link'] ) ) {
862 - $external_link = ( $optiongroup['external_link'] ? $optiongroup['external_link'] : '' );
863 - }
864 664 if ( isset( $optiongroup['icon'] ) ) {
865 665 $icon = $optiongroup['icon'];
866 666 if ( $icon != '' ) {
867 667 $current_menu_item['icon'] = $icon;
@@ -872,39 +672,31 @@
872 672 }
873 673 if ( isset( $optiongroup['hidden_for'] ) ) {
874 674 $disabled_for = $optiongroup['hidden_for'];
875 675 if ( $this->is_hidden( $disabled_for ) ) {
876 - $current_menu_item['hidden_for'] = true;
676 + $current_menu_item['hidden'] = true;
877 677 } else {
878 - $current_menu_item['hidden_for'] = false;
678 + $current_menu_item['hidden'] = false;
879 679 }
880 680 }
881 681 }
882 682 $custom_menu = ( isset( $current_menu_item[5] ) ? $current_menu_item[5] : '' );
883 683 if ( strpos( $custom_menu, 'adminify-custom-menu-' ) !== false ) {
884 - if ( isset( $this->menu_settings[$current_menu_item[5]]['hidden_for'] ) && !empty( $this->menu_settings[$current_menu_item[5]]['hidden_for'] ) ) {
684 + if ( isset( $this->menu_settings[$current_menu_item[5]]['hidden_for'] ) ) {
885 685 $disabled_for = $this->menu_settings[$current_menu_item[5]]['hidden_for'];
886 - if ( $this->is_hidden( $disabled_for ) ) {
887 - $current_menu_item['hidden_for'] = true;
888 - }
889 686 }
890 - if ( isset( $this->menu_settings[$current_menu_item[5]]['external_link'] ) ) {
891 - $external_link = $this->menu_settings[$current_menu_item[5]]['external_link'];
687 + if ( $this->is_hidden( $disabled_for ) ) {
688 + $current_menu_item['hidden'] = true;
892 689 }
893 690 }
894 691 }
895 692 $current_menu_item['order'] = $order;
896 - // Check hidden_for: boolean true means hide, array means check via is_hidden
897 - if ( isset( $current_menu_item['hidden_for'] ) ) {
898 - if ( $current_menu_item['hidden_for'] === true ) {
693 + if ( isset( $current_menu_item['hidden'] ) ) {
694 + if ( $current_menu_item['hidden'] == true ) {
899 695 return false;
900 - } elseif ( is_array( $current_menu_item['hidden_for'] ) && !empty( $current_menu_item['hidden_for'] ) ) {
901 - // Fallback: hidden_for is still an array (settings lookup may have missed it)
902 - if ( $this->is_hidden( $current_menu_item['hidden_for'] ) ) {
903 - return false;
904 - }
696 + } else {
697 + return $current_menu_item;
905 698 }
906 - return $current_menu_item;
907 699 } else {
908 700 return $current_menu_item;
909 701 }
910 702 }
@@ -920,62 +712,39 @@
920 712 if ( !is_array( $disabled_for ) ) {
921 713 return false;
922 714 }
923 715 $current_user = wp_get_current_user();
716 + $current_name = $current_user->display_name;
717 + $user_login = $current_user->user_login;
924 718 $current_roles = $current_user->roles;
925 719 $all_roles = wp_roles()->get_names();
926 - foreach ( $current_roles as $current_role ) {
927 - if ( isset( $all_roles[$current_role] ) && in_array( $all_roles[$current_role], $disabled_for ) ) {
928 - return true;
929 - }
930 - }
931 - // Normalize disabled_for array
932 720 $disabled_for_arr = [];
933 721 foreach ( $disabled_for as $v ) {
934 - $disabled_for_arr[] = Utils::sluggify_with_underscores( $v );
722 + $disabled_for_arr[] = jlt_adminify_sluggify_with_underscores( $v );
935 723 }
936 - $slugify_user_login = Utils::sluggify_with_underscores( $current_user->user_login );
937 724 // Check Username
938 - if ( in_array( $current_user->user_login, $disabled_for_arr ) || in_array( $slugify_user_login, $disabled_for_arr ) ) {
725 + if ( in_array( $current_user->data->user_login, $disabled_for_arr ) ) {
939 726 return true;
940 727 }
941 - // Check User Roles and Capabilities
942 - foreach ( $current_roles as $role ) {
943 - $role_obj = get_role( $role );
944 - if ( !$role_obj ) {
945 - continue;
946 - }
947 - // Check if role slug is in disabled array
948 - if ( in_array( $role, $disabled_for_arr ) ) {
949 - return true;
950 - }
951 - // Check if role display name is in disabled array
952 - if ( isset( $disabled_for_arr[$role] ) && (in_array( $all_roles[$role], $disabled_for ) || in_array( strtolower( $all_roles[$role] ), array_map( 'strtolower', $disabled_for ) )) ) {
953 - return true;
954 - }
955 - // Check for custom roles
956 - foreach ( $disabled_for as $disabled_item ) {
957 - // Convert role names to match WordPress format
958 - $disabled_role = str_replace( ' ', '_', strtolower( $disabled_item ) );
959 - if ( $role === $disabled_role ) {
960 - return true;
961 - }
962 - }
728 + // Check User Role if the role is selected as diable to access the item
729 + if ( !empty( array_intersect( $current_roles, $disabled_for_arr ) ) ) {
730 + return true;
963 731 }
964 - // Handle Super Admin specially
965 - if ( is_super_admin( $current_user->ID ) ) {
966 - if ( in_array( 'Super Admin', $disabled_for_arr ) || in_array( 'super_admin', $disabled_for_arr ) || in_array( 'administrator', $disabled_for_arr ) ) {
732 + // MULTISITE SUPER ADMIN
733 + if ( is_super_admin() && is_multisite() ) {
734 + if ( in_array( 'Super Admin', $disabled_for_arr ) ) {
967 735 return true;
736 + } else {
737 + return false;
968 738 }
969 - // Super admin sees everything by default unless explicitly disabled
970 - return false;
971 739 }
972 - // Special check for user ID 1 (default admin)
740 + // NORMAL SUPER ADMIN
973 741 if ( $current_user->ID === 1 ) {
974 - if ( in_array( 'Super Admin', $disabled_for_arr ) || in_array( 'super_admin', $disabled_for_arr ) || in_array( 'administrator', $disabled_for_arr ) ) {
742 + if ( in_array( 'Super Admin', $disabled_for_arr ) ) {
975 743 return true;
744 + } else {
745 + return false;
976 746 }
977 - return false;
978 747 }
979 748 return false;
980 749 }
981 750
@@ -1003,16 +772,16 @@
1003 772 }
1004 773 if ( isset( $optiongroup['hidden_for'] ) ) {
1005 774 $disabled_for = $optiongroup['hidden_for'];
1006 775 if ( $this->is_hidden( $disabled_for ) ) {
1007 - $current_menu_item['hidden_for'] = true;
776 + $current_menu_item['hidden'] = true;
1008 777 }
1009 778 }
1010 779 }
1011 780 }
1012 781 $current_menu_item['order'] = $order;
1013 - if ( isset( $current_menu_item['hidden_for'] ) ) {
1014 - if ( $current_menu_item['hidden_for'] == true ) {
782 + if ( isset( $current_menu_item['hidden'] ) ) {
783 + if ( $current_menu_item['hidden'] == true ) {
1015 784 return false;
1016 785 } else {
1017 786 return $current_menu_item;
1018 787 }
@@ -1062,8 +831,10 @@
1062 831 * Render Menu Editor
1063 832 */
1064 833 public function render_menu_editor() {
1065 834 global $wp_roles;
835 + $users = get_users();
836 + $this->users = $users;
1066 837 $this->roles = $wp_roles->roles;
1067 838 if ( $this->menu && is_array( $this->menu ) ) {
1068 839 foreach ( $this->menu as $menu_item ) {
1069 840 $next_menu_item = next( $this->menu );
@@ -1080,8 +851,25 @@
1080 851 );
1081 852 }
1082 853 }
1083 854 $this->render_add_new_menu_item();
855 + ?>
856 + <script>
857 + jQuery(function($) {
858 +
859 + $('.adminify-menu-settings').tokenize2({
860 + placeholder: '<?php
861 + esc_html_e( 'Select roles or users', 'adminify' );
862 + ?>'
863 + });
864 +
865 + $('.adminify-menu-settings').on('tokenize:select', function() {
866 + $(this).tokenize2().trigger('tokenize:search', [$(this).tokenize2().input.val()]);
867 + });
868 +
869 + });
870 + </script>
871 + <?php
1084 872 }
1085 873 }
1086 874
1087 875 public function get_icon( $value, $default ) {
@@ -1096,22 +884,32 @@
1096 884 */
1097 885 public function generate_user_rules_select_field( $menu_id, $disabled_for, $menu_type = 'menu' ) {
1098 886 ob_start();
1099 887 ?>
1100 - <select class="adminify-menu-settings adminify-user-role-select <?php
1101 - echo esc_attr( $menu_type );
888 + <select class="adminify-menu-settings <?php
889 + echo $menu_type;
1102 890 ?>_setting" name="hidden_for" id="<?php
1103 891 echo esc_attr( $menu_id );
1104 892 ?>-user-role-types" multiple>
1105 - <optgroup label="<?php
1106 - esc_attr_e( 'Roles', 'adminify' );
1107 - ?>">
1108 893 <?php
894 + $sel = '';
895 + // if (in_array('Super Admin', $disabled_for)) {
896 + // $sel = 'selected';
897 + // }
898 + ?>
899 +
900 + <!-- <option value="Super Admin" <?php
901 + // echo esc_attr($sel);
902 + ?>><?php
903 + // esc_html_e('Super Admin', 'adminify');
904 + ?></option> -->
905 +
906 + <?php
1109 907 foreach ( $this->roles as $role ) {
1110 908 $rolename = $role['name'];
1111 - if ( 'administrator' == strtolower( $rolename ) ) {
1112 - continue;
1113 - }
909 + // if ('administrator' == strtolower($rolename)) {
910 + // continue;
911 + // }
1114 912 $sel = '';
1115 913 if ( in_array( $rolename, $disabled_for ) ) {
1116 914 $sel = 'selected';
1117 915 }
@@ -1124,40 +922,26 @@
1124 922 echo esc_html( $rolename );
1125 923 ?></option>
1126 924 <?php
1127 925 }
1128 - ?>
1129 - </optgroup>
1130 -
1131 - <optgroup label="<?php
1132 - esc_attr_e( 'Users', 'adminify' );
1133 - ?>" class="adminify-users-optgroup">
926 + foreach ( $this->users as $user ) {
927 + $username = $user->display_name;
928 + $user_login = $user->user_login;
929 + $sel = '';
930 + if ( in_array( $username, $disabled_for ) ) {
931 + $sel = 'selected';
932 + }
933 + ?>
934 + <option value="<?php
935 + echo wp_kses_post( $user_login );
936 + ?>" <?php
937 + echo esc_attr( $sel );
938 + ?>><?php
939 + echo wp_kses_post( $user_login );
940 + ?></option>
1134 941 <?php
1135 - // Only include pre-selected users in HTML (AJAX will populate dropdown)
1136 - foreach ( $disabled_for as $item ) {
1137 - // Check if this is a user (not a role)
1138 - $is_role = false;
1139 - foreach ( $this->roles as $role ) {
1140 - if ( $role['name'] === $item ) {
1141 - $is_role = true;
1142 - break;
1143 - }
1144 - }
1145 - if ( !$is_role ) {
1146 - $user = get_user_by( 'login', $item );
1147 - if ( $user ) {
1148 - ?>
1149 - <option value="<?php
1150 - echo esc_attr( $user->user_login );
1151 - ?>" selected><?php
1152 - echo esc_html( $user->user_login . ' (' . $user->display_name . ')' );
1153 - ?></option>
1154 - <?php
1155 - }
1156 - }
1157 942 }
1158 943 ?>
1159 - </optgroup>
1160 944 </select>
1161 945 <?php
1162 946 return ob_get_clean();
1163 947 }
@@ -1175,13 +959,12 @@
1175 959 ) {
1176 960 if ( empty( $current_menu_item[2] ) ) {
1177 961 return;
1178 962 }
1179 - // $disabled_for = '';
963 + $disabled_for = '';
1180 964 $menu_id = preg_replace( '/[^A-Za-z0-9 ]/', '', $current_menu_item[5] );
1181 965 $name = '';
1182 966 $link = '';
1183 - $external_link = '';
1184 967 $icon = '';
1185 968 $separator = '';
1186 969 $disabled_for = [];
1187 970 $optiongroup = [];
@@ -1206,11 +989,8 @@
1206 989 }
1207 990 if ( isset( $optiongroup['separator'] ) ) {
1208 991 $separator = $optiongroup['separator'];
1209 992 }
1210 - if ( isset( $optiongroup['external_link'] ) ) {
1211 - $external_link = $optiongroup['external_link'];
1212 - }
1213 993 }
1214 994 }
1215 995 $name_attr = $current_menu_item[2];
1216 996 if ( strpos( $current_menu_item[5], 'adminify-custom-menu-' ) !== false ) {
@@ -1228,11 +1008,8 @@
1228 1008 }
1229 1009 if ( isset( $current_menu_item['separator'] ) ) {
1230 1010 $separator = $current_menu_item['separator'];
1231 1011 }
1232 - if ( isset( $current_menu_item['external_link'] ) ) {
1233 - $external_link = $current_menu_item['external_link'];
1234 - }
1235 1012 }
1236 1013 if ( !is_array( $disabled_for ) ) {
1237 1014 $disabled_for = [];
1238 1015 }
@@ -1327,9 +1104,9 @@
1327 1104 <label for="<?php
1328 1105 echo esc_attr( $current_menu_item[2] );
1329 1106 ?>">
1330 1107 <?php
1331 - esc_html_e( 'Hidden For Roles or Users', 'adminify' );
1108 + esc_html_e( 'Hidden For Rules', 'adminify' );
1332 1109 ?>
1333 1110 </label>
1334 1111
1335 1112 <div class="select is-small">
@@ -1334,9 +1111,8 @@
1334 1111
1335 1112 <div class="select is-small">
1336 1113
1337 1114 <?php
1338 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- generate_user_rules_select_field() returns a trusted <select> template with form inputs that wp_kses_post() would strip; values inside are escaped.
1339 1115 echo $this->generate_user_rules_select_field( $menu_id, $disabled_for );
1340 1116 ?>
1341 1117
1342 1118 </div>
@@ -1341,11 +1117,10 @@
1341 1117
1342 1118 </div>
1343 1119 </div>
1344 1120 </div>
1345 -
1346 1121 <div class="columns">
1347 - <!-- <div class="column">
1122 + <div class="column">
1348 1123 <label for="">
1349 1124 <?php
1350 1125 esc_html_e( 'Change Link', 'adminify' );
1351 1126 ?>
@@ -1353,103 +1128,12 @@
1353 1128 <input class="menu_setting" name="link" type="url" placeholder="<?php
1354 1129 esc_html_e( 'New link', 'adminify' );
1355 1130 ?>" value="<?php
1356 1131 echo esc_attr( ( $name_attr != ltrim( $link, '#' ) ? $link : '' ) );
1357 - ?>" onchange="checkForLinkTarget(this)" >
1358 -
1359 - <label for="external_link-<?php
1360 - echo esc_attr( $name_attr );
1361 1132 ?>">
1362 - <?php
1363 - esc_html_e( 'New Window?', 'adminify' );
1364 - ?>
1365 - <input class="menu_setting" id="external_link-<?php
1366 - echo esc_attr( $name_attr );
1367 - ?>" name="external_link" type="checkbox" value="0" <?php
1368 - checked( (int) $external_link, 1 );
1369 - ?> disabled>
1370 -
1371 - </label>
1372 - <script>
1373 - function checkForLinkTarget(inputField) {
1374 - var checkbox = inputField.closest('.column').querySelector('input[type="checkbox"]');
1375 -
1376 - if (inputField.value.trim() !== "") {
1377 - checkbox.disabled = false; // Enable checkbox if input is not empty
1378 - } else {
1379 - checkbox.disabled = true; // Disable checkbox if input is empty
1380 - }
1381 - }
1382 - </script>
1383 - </div> -->
1384 -
1133 + </div>
1385 1134 <div class="column">
1386 1135 <label for="">
1387 - <?php
1388 - esc_html_e( 'Change Link', 'adminify' );
1389 - ?>
1390 - </label>
1391 - <input class="menu_setting" name="link" type="url"
1392 - placeholder="<?php
1393 - esc_html_e( 'New link', 'adminify' );
1394 - ?>"
1395 - value="<?php
1396 - echo esc_attr( ( $name_attr != ltrim( $link, '#' ) ? $link : '' ) );
1397 - ?>"
1398 - oninput="checkForLinkTarget(this)">
1399 - <div class="new-tab-settings" style="padding-top: 10px;">
1400 - <label for="external_link-<?php
1401 - echo esc_attr( $name_attr );
1402 - ?>" style="display: flex; align-items: center; gap: 8px;">
1403 -
1404 - <input class="menu_setting" id="external_link-<?php
1405 - echo esc_attr( $name_attr );
1406 - ?>"
1407 - name="external_link" type="checkbox" value="1"
1408 - <?php
1409 - checked( (int) $external_link, 1 );
1410 - ?> disabled style="margin-top: 0;" >
1411 - <span><?php
1412 - esc_html_e( 'New Window?', 'adminify' );
1413 - ?></span>
1414 - </label>
1415 - </div>
1416 -
1417 - <script>
1418 - // Function to validate URL
1419 - function isValidURL(url) {
1420 - // Allow absolute URLs (with http:// or https://)
1421 - var absolutePattern = /^(https?:\/\/)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}.*$/;
1422 -
1423 - // Allow relative URLs (starting with "/")
1424 - var relativePattern = /^\/[a-zA-Z0-9-_\/]+$/;
1425 -
1426 - return absolutePattern.test(url) || relativePattern.test(url);
1427 - }
1428 -
1429 -
1430 - function checkForLinkTarget(inputField) {
1431 - var checkbox = inputField.closest('.column').querySelector('input[type="checkbox"]');
1432 -
1433 - if (isValidURL(inputField.value.trim())) {
1434 - checkbox.disabled = false; // Enable if URL is valid
1435 - } else {
1436 - checkbox.disabled = true; // Disable if invalid
1437 - checkbox.checked = false; // Also uncheck if disabled
1438 - }
1439 - }
1440 -
1441 - // Run on page load
1442 - document.addEventListener("DOMContentLoaded", function() {
1443 - document.querySelectorAll('.column input[name="link"]').forEach(function(inputField) {
1444 - checkForLinkTarget(inputField);
1445 - });
1446 - });
1447 - </script>
1448 - </div>
1449 -
1450 - <div class="column">
1451 - <label for="">
1452 1136 <?php
1453 1137 esc_html_e( 'Set Custom Icon', 'adminify' );
1454 1138 ?>
1455 1139 </label>
@@ -1462,9 +1146,9 @@
1462 1146 <?php
1463 1147 if ( !empty( $icon ) ) {
1464 1148 if ( preg_match( '/http(s?)\\:\\/\\//i', $icon ) ) {
1465 1149 $image = explode( ',', $icon );
1466 - echo '<i class=""><img width="24" height="24" src=' . esc_url( $image[1] ) . ' ></i>';
1150 + echo '<i class=""><img src=' . esc_url( $image[1] ) . ' ></i>';
1467 1151 } else {
1468 1152 ?>
1469 1153 <i class="<?php
1470 1154 echo esc_attr( $this->get_icon( esc_attr( $icon ), '' ) );
@@ -1471,11 +1155,11 @@
1471 1155 ?>"></i>
1472 1156 <?php
1473 1157 }
1474 1158 } else {
1475 - $adminify_icon = PXLBSADMINIFY_ASSETS_IMAGE . 'logos/menu-icon.svg';
1159 + $adminify_icon = WP_ADMINIFY_ASSETS_IMAGE . 'logos/menu-icon.svg';
1476 1160 if ( empty( $icons[$default_icons] ) ) {
1477 - echo '<i class=""><img width="24" height="24" src=' . esc_url( $adminify_icon ) . ' ></i>';
1161 + echo '<i class=""><img src=' . esc_url( $adminify_icon ) . ' ></i>';
1478 1162 } else {
1479 1163 ?>
1480 1164 <i class="<?php
1481 1165 echo wp_kses_post( $this->get_icon( esc_attr( $icon ), $icons[$default_icons] ) );
@@ -1497,9 +1181,9 @@
1497 1181 <?php
1498 1182 $upgrade_pro = '';
1499 1183 $separator_name_attr = '';
1500 1184 $upgrade_pro = 'upgrade-pro';
1501 - $separator_name_attr = Utils::upgrade_pro_notice( 'Add Separator' );
1185 + $separator_name_attr = Utils::adminify_upgrade_pro( 'Add Separator' );
1502 1186 ?>
1503 1187
1504 1188 <div class='column <?php
1505 1189 echo esc_attr( $upgrade_pro );
@@ -1507,11 +1191,11 @@
1507 1191 <label for="seperator-<?php
1508 1192 echo esc_attr( $name_attr );
1509 1193 ?>">
1510 1194 <?php
1511 - $separator_content = apply_filters( 'pxlbsadminify/menu_editor/add_separator', $separator_name_attr, $separator );
1195 + $separator_content = apply_filters( 'adminify/menu_editor/add_separator', $separator_name_attr, $separator );
1512 1196 // Apply the filter
1513 - echo wp_kses_post( $separator_content || "" );
1197 + echo $separator_content;
1514 1198 ?>
1515 1199 </label>
1516 1200 </div>
1517 1201 </div>
@@ -1614,16 +1298,36 @@
1614 1298 ?>">
1615 1299 </div>
1616 1300 <div class="column">
1617 1301 <label for=""><?php
1618 - esc_html_e( 'Hidden For Roles or Users', 'adminify' );
1302 + esc_html_e( 'Hidden For Rules', 'adminify' );
1619 1303 ?></label>
1620 1304
1621 1305 <div class="select is-small">
1622 1306 <?php
1623 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- generate_user_rules_select_field() returns a trusted <select> template with form inputs that wp_kses_post() would strip; values inside are escaped.
1624 1307 echo $this->generate_user_rules_select_field( $menu_id, $disabled_for );
1625 1308 ?>
1309 +
1310 + <script>
1311 + jQuery('#<?php
1312 + echo esc_attr( $menu_id );
1313 + ?> #<?php
1314 + echo esc_attr( $menu_id );
1315 + ?>-user-role-types').tokenize2({
1316 + placeholder: '<?php
1317 + esc_html_e( 'Select roles or users', 'adminify' );
1318 + ?>'
1319 + });
1320 + jQuery(document).ready(function($) {
1321 + $('#<?php
1322 + echo esc_attr( $menu_id );
1323 + ?> #<?php
1324 + echo esc_attr( $menu_id );
1325 + ?>-user-role-types').on('tokenize:select', function(container) {
1326 + $(this).tokenize2().trigger('tokenize:search', [$(this).tokenize2().input.val()]);
1327 + });
1328 + })
1329 + </script>
1626 1330 </div>
1627 1331 </div>
1628 1332 </div>
1629 1333 </div>
@@ -1638,9 +1342,8 @@
1638 1342 public function build_sub_menu_item( $current_menu_item, $optiongroup, $name_attr ) {
1639 1343 $name = '';
1640 1344 $link = '';
1641 1345 $icon = '';
1642 - $external_link = '';
1643 1346 $disabled_for = [];
1644 1347 $suboptiongroup = [];
1645 1348 $menu_options = $this->menu_settings;
1646 1349 if ( isset( $optiongroup['submenu'] ) ) {
@@ -1651,11 +1354,8 @@
1651 1354 }
1652 1355 if ( isset( $suboptiongroup['link'] ) ) {
1653 1356 $link = $suboptiongroup['link'];
1654 1357 }
1655 - if ( isset( $suboptiongroup['external_link'] ) ) {
1656 - $external_link = $suboptiongroup['external_link'];
1657 - }
1658 1358 if ( isset( $suboptiongroup['icon'] ) ) {
1659 1359 $icon = $suboptiongroup['icon'];
1660 1360 }
1661 1361 if ( isset( $suboptiongroup['hidden_for'] ) ) {
@@ -1675,11 +1375,8 @@
1675 1375 }
1676 1376 if ( isset( $optiongroup['submenu'][$sub_menu_name_attr]['icon'] ) ) {
1677 1377 $icon = $optiongroup['submenu'][$sub_menu_name_attr]['icon'];
1678 1378 }
1679 - if ( isset( $optiongroup['submenu'][$sub_menu_name_attr]['external_link'] ) ) {
1680 - $external_link = $optiongroup['submenu'][$sub_menu_name_attr]['external_link'];
1681 - }
1682 1379 }
1683 1380 if ( !is_array( $disabled_for ) ) {
1684 1381 $disabled_for = [];
1685 1382 }
@@ -1728,16 +1425,38 @@
1728 1425 ?>">
1729 1426 </div>
1730 1427 <div class="column">
1731 1428 <label for=""><?php
1732 - esc_html_e( 'Hidden For Roles or Users', 'adminify' );
1429 + esc_html_e( 'Hidden For Rules', 'adminify' );
1733 1430 ?></label>
1734 1431
1735 1432 <div class="select is-small">
1433 +
1736 1434 <?php
1737 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- generate_user_rules_select_field() returns a trusted <select> template with form inputs that wp_kses_post() would strip; values inside are escaped.
1738 1435 echo $this->generate_user_rules_select_field( $menu_id, $disabled_for, 'sub_menu' );
1739 1436 ?>
1437 +
1438 + <script>
1439 + jQuery('#wp-adminify-sub-menu-<?php
1440 + echo esc_attr( $menu_id );
1441 + ?> #<?php
1442 + echo esc_attr( $menu_id );
1443 + ?>-user-role-types').tokenize2({
1444 + placeholder: '<?php
1445 + esc_html_e( 'Select roles or users', 'adminify' );
1446 + ?>'
1447 + });
1448 + jQuery(document).ready(function($) {
1449 + $('#wp-adminify-sub-menu-<?php
1450 + echo esc_attr( $menu_id );
1451 + ?> #<?php
1452 + echo esc_attr( $menu_id );
1453 + ?>-user-role-types').on('tokenize:select', function(container) {
1454 + $(this).tokenize2().trigger('tokenize:search', [$(this).tokenize2().input.val()]);
1455 + });
1456 + })
1457 + </script>
1458 +
1740 1459 </div>
1741 1460 </div>
1742 1461 </div>
1743 1462 <div class="columns">
@@ -1746,23 +1465,9 @@
1746 1465 esc_html_e( 'Change Link', 'adminify' );
1747 1466 ?></label>
1748 1467 <input class="sub_menu_setting" name="link" type="url" placeholder="New link" value="<?php
1749 1468 echo esc_attr( ( $sub_menu_name_attr != ltrim( $link, '#' ) ? $link : '' ) );
1750 - ?>" onchange="checkForLinkTarget(this)" >
1751 -
1752 - <label for="external_link-<?php
1753 - echo esc_attr( $sub_menu_name_attr );
1754 1469 ?>">
1755 - <?php
1756 - esc_html_e( 'New Window?', 'adminify' );
1757 - ?>
1758 - <input class="sub_menu_setting" id="external_link-<?php
1759 - echo esc_attr( $sub_menu_name_attr );
1760 - ?>" name="external_link" type="checkbox" value="0" <?php
1761 - checked( (int) $external_link, 1 );
1762 - ?>disabled />
1763 -
1764 - </label>
1765 1470 </div>
1766 1471 <div class="column">
1767 1472 <label for="" style="margin-top:25px">
1768 1473 <?php
@@ -1792,10 +1497,10 @@
1792 1497 /**
1793 1498 * Add New Menu Item.
1794 1499 */
1795 1500 public function render_add_new_menu_item( $submenu = false ) {
1796 - $add_item = apply_filters( 'pxlbsadminify/menu_editor', [
1797 - 'upgrade_pro' => Utils::upgrade_pro_notice( ' ' ),
1501 + $add_item = apply_filters( 'adminify/menu_editor', [
1502 + 'upgrade_pro' => Utils::adminify_upgrade_pro( ' ' ),
1798 1503 'upgrade_class' => 'upgrade-pro',
1799 1504 ] );
1800 1505 ?>
1801 1506 <div class="adminify-accordion adminify-add-new-menu-editor-item upgrade-pro adminify-field adminify-field-switcher adminify-depend-visible adminify-depend-on adminify-pro-notice <?php
@@ -1800,9 +1505,9 @@
1800 1505 ?>
1801 1506 <div class="adminify-accordion adminify-add-new-menu-editor-item upgrade-pro adminify-field adminify-field-switcher adminify-depend-visible adminify-depend-on adminify-pro-notice <?php
1802 1507 echo esc_attr( ( $submenu ? 'submenu' : '' ) );
1803 1508 ?> <?php
1804 - echo esc_attr( $add_item['upgrade_class'] );
1509 + echo Utils::wp_kses_custom( $add_item['upgrade_class'] );
1805 1510 ?>">
1806 1511 <div class="inner-text">
1807 1512 <i class="dashicons dashicons-plus-alt"></i>
1808 1513 <span class="title"><?php
@@ -1809,9 +1514,9 @@
1809 1514 esc_html_e( 'Add Item', 'adminify' );
1810 1515 ?></span>
1811 1516 </div>
1812 1517 <?php
1813 - echo wp_kses( $add_item['upgrade_pro'], Utils::kses_allowed_html() );
1518 + echo Utils::wp_kses_custom( $add_item['upgrade_pro'] );
1814 1519 ?>
1815 1520 </div>
1816 1521 <?php
1817 1522 }
@@ -1826,15 +1531,14 @@
1826 1531
1827 1532 <div class="adminify-flex adminify-flex-center adminify-justify-between">
1828 1533 <div class="adminify-menu-editor-help-urls adminify-flex adminify-flex-center adminify-gap-2">
1829 1534 <?php
1830 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- help_urls() returns a trusted template containing inline SVG icons that wp_kses_post() would strip; URLs inside are passed through esc_url().
1831 - echo Utils::help_urls(
1535 + echo Utils::adminfiy_help_urls(
1832 1536 __( 'Menu Editor', 'adminify' ),
1833 1537 'https://wpadminify.com/kb/wordpress-dashboard-menu-editor/',
1834 1538 'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8',
1835 1539 'https://www.facebook.com/groups/jeweltheme',
1836 - esc_url( \PXLBSAdminify\Inc\Admin\AdminSettings::support_url() )
1540 + \WPAdminify\Inc\Admin\AdminSettings::support_url()
1837 1541 );
1838 1542 ?>
1839 1543 </div>
1840 1544
@@ -1890,9 +1594,9 @@
1890 1594 <path fill-rule="evenodd" clip-rule="evenodd" d="M8.00065 1.33334C4.31865 1.33334 1.33398 4.31801 1.33398 8.00001C1.33398 11.682 4.31865 14.6667 8.00065 14.6667C11.6827 14.6667 14.6673 11.682 14.6673 8.00001C14.6673 4.31801 11.6827 1.33334 8.00065 1.33334ZM2.66732 8.00001C2.66732 9.4145 3.22922 10.7711 4.22942 11.7712C5.22961 12.7714 6.58616 13.3333 8.00065 13.3333C9.41514 13.3333 10.7717 12.7714 11.7719 11.7712C12.7721 10.7711 13.334 9.4145 13.334 8.00001C13.334 6.58552 12.7721 5.22897 11.7719 4.22877C10.7717 3.22858 9.41514 2.66668 8.00065 2.66668C6.58616 2.66668 5.22961 3.22858 4.22942 4.22877C3.22922 5.22897 2.66732 6.58552 2.66732 8.00001V8.00001Z" fill="#4E4B66" />
1891 1595 </svg>
1892 1596
1893 1597 <?php
1894 - esc_html_e( 'If you have Adminify Menu Module disabled, icons and label dividers won\'t change.', 'adminify' );
1598 + esc_html_e( 'If you have WP Adminify Menu Module disabled, icons and label dividers won\'t change.', 'adminify' );
1895 1599 ?>
1896 1600
1897 1601 </p>
1898 1602 </div>
@@ -1900,9 +1604,9 @@
1900 1604
1901 1605 <?php
1902 1606 }
1903 1607
1904 - public function menu_editor_contents() {
1608 + public function jltwp_adminify_menu_editor_contents() {
1905 1609 ?>
1906 1610
1907 1611 <div class="wrap">
1908 1612 <div class="wp-adminify--menu--editor--container">