PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.0.2.5
Adminify – White Label, Admin Menu Editor, Login Customizer v4.0.2.5
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 +186 -491 4.2.84.0.2.5 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,29 @@
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;
877 - } else {
878 - $current_menu_item['hidden_for'] = false;
676 + $current_menu_item['hidden'] = true;
879 677 }
880 678 }
881 679 }
882 680 $custom_menu = ( isset( $current_menu_item[5] ) ? $current_menu_item[5] : '' );
883 681 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'] ) ) {
682 + if ( isset( $this->menu_settings[$current_menu_item[5]]['hidden_for'] ) ) {
885 683 $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 684 }
890 - if ( isset( $this->menu_settings[$current_menu_item[5]]['external_link'] ) ) {
891 - $external_link = $this->menu_settings[$current_menu_item[5]]['external_link'];
685 + if ( $this->is_hidden( $disabled_for ) ) {
686 + $current_menu_item['hidden'] = true;
892 687 }
893 688 }
894 689 }
895 690 $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 ) {
691 + if ( isset( $current_menu_item['hidden'] ) ) {
692 + if ( $current_menu_item['hidden'] == true ) {
899 693 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 - }
694 + } else {
695 + return $current_menu_item;
905 696 }
906 - return $current_menu_item;
907 697 } else {
908 698 return $current_menu_item;
909 699 }
910 700 }
@@ -920,64 +710,36 @@
920 710 if ( !is_array( $disabled_for ) ) {
921 711 return false;
922 712 }
923 713 $current_user = wp_get_current_user();
714 + $current_name = $current_user->display_name;
924 715 $current_roles = $current_user->roles;
925 716 $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 - $disabled_for_arr = [];
933 - foreach ( $disabled_for as $v ) {
934 - $disabled_for_arr[] = Utils::sluggify_with_underscores( $v );
935 - }
936 - $slugify_user_login = Utils::sluggify_with_underscores( $current_user->user_login );
937 - // Check Username
938 - if ( in_array( $current_user->user_login, $disabled_for_arr ) || in_array( $slugify_user_login, $disabled_for_arr ) ) {
717 + if ( in_array( $current_name, $disabled_for ) ) {
939 718 return true;
940 719 }
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 ) ) {
720 + // MULTISITE SUPER ADMIN
721 + if ( is_super_admin() && is_multisite() ) {
722 + if ( in_array( 'Super Admin', $disabled_for ) ) {
949 723 return true;
724 + } else {
725 + return false;
950 726 }
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 - }
963 727 }
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 ) ) {
728 + // NORMAL SUPER ADMIN
729 + if ( $current_user->ID === 1 ) {
730 + if ( in_array( 'Super Admin', $disabled_for ) ) {
967 731 return true;
732 + } else {
733 + return false;
968 734 }
969 - // Super admin sees everything by default unless explicitly disabled
970 - return false;
971 735 }
972 - // Special check for user ID 1 (default admin)
973 - 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 ) ) {
736 + foreach ( $current_roles as $role ) {
737 + $role_name = $all_roles[$role];
738 + if ( in_array( $role_name, $disabled_for ) ) {
975 739 return true;
976 740 }
977 - return false;
978 741 }
979 - return false;
980 742 }
981 743
982 744 /**
983 745 * Applies separator menu item settings
@@ -1003,16 +765,16 @@
1003 765 }
1004 766 if ( isset( $optiongroup['hidden_for'] ) ) {
1005 767 $disabled_for = $optiongroup['hidden_for'];
1006 768 if ( $this->is_hidden( $disabled_for ) ) {
1007 - $current_menu_item['hidden_for'] = true;
769 + $current_menu_item['hidden'] = true;
1008 770 }
1009 771 }
1010 772 }
1011 773 }
1012 774 $current_menu_item['order'] = $order;
1013 - if ( isset( $current_menu_item['hidden_for'] ) ) {
1014 - if ( $current_menu_item['hidden_for'] == true ) {
775 + if ( isset( $current_menu_item['hidden'] ) ) {
776 + if ( $current_menu_item['hidden'] == true ) {
1015 777 return false;
1016 778 } else {
1017 779 return $current_menu_item;
1018 780 }
@@ -1062,8 +824,10 @@
1062 824 * Render Menu Editor
1063 825 */
1064 826 public function render_menu_editor() {
1065 827 global $wp_roles;
828 + $users = get_users();
829 + $this->users = $users;
1066 830 $this->roles = $wp_roles->roles;
1067 831 if ( $this->menu && is_array( $this->menu ) ) {
1068 832 foreach ( $this->menu as $menu_item ) {
1069 833 $next_menu_item = next( $this->menu );
@@ -1080,8 +844,25 @@
1080 844 );
1081 845 }
1082 846 }
1083 847 $this->render_add_new_menu_item();
848 + ?>
849 + <script>
850 + jQuery(function($) {
851 +
852 + $('.adminify-menu-settings').tokenize2({
853 + placeholder: '<?php
854 + esc_html_e( 'Select roles or users', 'adminify' );
855 + ?>'
856 + });
857 +
858 + $('.adminify-menu-settings').on('tokenize:select', function() {
859 + $(this).tokenize2().trigger('tokenize:search', [$(this).tokenize2().input.val()]);
860 + });
861 +
862 + });
863 + </script>
864 + <?php
1084 865 }
1085 866 }
1086 867
1087 868 public function get_icon( $value, $default ) {
@@ -1096,17 +877,27 @@
1096 877 */
1097 878 public function generate_user_rules_select_field( $menu_id, $disabled_for, $menu_type = 'menu' ) {
1098 879 ob_start();
1099 880 ?>
1100 - <select class="adminify-menu-settings adminify-user-role-select <?php
1101 - echo esc_attr( $menu_type );
881 + <select class="adminify-menu-settings <?php
882 + echo $menu_type;
1102 883 ?>_setting" name="hidden_for" id="<?php
1103 884 echo esc_attr( $menu_id );
1104 885 ?>-user-role-types" multiple>
1105 - <optgroup label="<?php
1106 - esc_attr_e( 'Roles', 'adminify' );
1107 - ?>">
1108 886 <?php
887 + $sel = '';
888 + // if (in_array('Super Admin', $disabled_for)) {
889 + // $sel = 'selected';
890 + // }
891 + ?>
892 +
893 + <!-- <option value="Super Admin" <?php
894 + // echo esc_attr($sel);
895 + ?>><?php
896 + // esc_html_e('Super Admin', 'adminify');
897 + ?></option> -->
898 +
899 + <?php
1109 900 foreach ( $this->roles as $role ) {
1110 901 $rolename = $role['name'];
1111 902 if ( 'administrator' == strtolower( $rolename ) ) {
1112 903 continue;
@@ -1124,40 +915,25 @@
1124 915 echo esc_html( $rolename );
1125 916 ?></option>
1126 917 <?php
1127 918 }
1128 - ?>
1129 - </optgroup>
1130 -
1131 - <optgroup label="<?php
1132 - esc_attr_e( 'Users', 'adminify' );
1133 - ?>" class="adminify-users-optgroup">
919 + foreach ( $this->users as $user ) {
920 + $username = $user->display_name;
921 + $sel = '';
922 + if ( in_array( $username, $disabled_for ) ) {
923 + $sel = 'selected';
924 + }
925 + ?>
926 + <option value="<?php
927 + echo esc_attr( $username );
928 + ?>" <?php
929 + echo esc_attr( $sel );
930 + ?>><?php
931 + echo esc_html( $username );
932 + ?></option>
1134 933 <?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 934 }
1158 935 ?>
1159 - </optgroup>
1160 936 </select>
1161 937 <?php
1162 938 return ob_get_clean();
1163 939 }
@@ -1175,13 +951,12 @@
1175 951 ) {
1176 952 if ( empty( $current_menu_item[2] ) ) {
1177 953 return;
1178 954 }
1179 - // $disabled_for = '';
955 + $disabled_for = '';
1180 956 $menu_id = preg_replace( '/[^A-Za-z0-9 ]/', '', $current_menu_item[5] );
1181 957 $name = '';
1182 958 $link = '';
1183 - $external_link = '';
1184 959 $icon = '';
1185 960 $separator = '';
1186 961 $disabled_for = [];
1187 962 $optiongroup = [];
@@ -1206,11 +981,8 @@
1206 981 }
1207 982 if ( isset( $optiongroup['separator'] ) ) {
1208 983 $separator = $optiongroup['separator'];
1209 984 }
1210 - if ( isset( $optiongroup['external_link'] ) ) {
1211 - $external_link = $optiongroup['external_link'];
1212 - }
1213 985 }
1214 986 }
1215 987 $name_attr = $current_menu_item[2];
1216 988 if ( strpos( $current_menu_item[5], 'adminify-custom-menu-' ) !== false ) {
@@ -1228,11 +1000,8 @@
1228 1000 }
1229 1001 if ( isset( $current_menu_item['separator'] ) ) {
1230 1002 $separator = $current_menu_item['separator'];
1231 1003 }
1232 - if ( isset( $current_menu_item['external_link'] ) ) {
1233 - $external_link = $current_menu_item['external_link'];
1234 - }
1235 1004 }
1236 1005 if ( !is_array( $disabled_for ) ) {
1237 1006 $disabled_for = [];
1238 1007 }
@@ -1327,9 +1096,9 @@
1327 1096 <label for="<?php
1328 1097 echo esc_attr( $current_menu_item[2] );
1329 1098 ?>">
1330 1099 <?php
1331 - esc_html_e( 'Hidden For Roles or Users', 'adminify' );
1100 + esc_html_e( 'Hidden For Rules', 'adminify' );
1332 1101 ?>
1333 1102 </label>
1334 1103
1335 1104 <div class="select is-small">
@@ -1334,9 +1103,8 @@
1334 1103
1335 1104 <div class="select is-small">
1336 1105
1337 1106 <?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 1107 echo $this->generate_user_rules_select_field( $menu_id, $disabled_for );
1340 1108 ?>
1341 1109
1342 1110 </div>
@@ -1341,11 +1109,10 @@
1341 1109
1342 1110 </div>
1343 1111 </div>
1344 1112 </div>
1345 -
1346 1113 <div class="columns">
1347 - <!-- <div class="column">
1114 + <div class="column">
1348 1115 <label for="">
1349 1116 <?php
1350 1117 esc_html_e( 'Change Link', 'adminify' );
1351 1118 ?>
@@ -1353,103 +1120,12 @@
1353 1120 <input class="menu_setting" name="link" type="url" placeholder="<?php
1354 1121 esc_html_e( 'New link', 'adminify' );
1355 1122 ?>" value="<?php
1356 1123 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 1124 ?>">
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 -
1125 + </div>
1385 1126 <div class="column">
1386 1127 <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 1128 <?php
1453 1129 esc_html_e( 'Set Custom Icon', 'adminify' );
1454 1130 ?>
1455 1131 </label>
@@ -1462,9 +1138,9 @@
1462 1138 <?php
1463 1139 if ( !empty( $icon ) ) {
1464 1140 if ( preg_match( '/http(s?)\\:\\/\\//i', $icon ) ) {
1465 1141 $image = explode( ',', $icon );
1466 - echo '<i class=""><img width="24" height="24" src=' . esc_url( $image[1] ) . ' ></i>';
1142 + echo '<i class=""><img src=' . esc_url( $image[1] ) . ' ></i>';
1467 1143 } else {
1468 1144 ?>
1469 1145 <i class="<?php
1470 1146 echo esc_attr( $this->get_icon( esc_attr( $icon ), '' ) );
@@ -1471,11 +1147,11 @@
1471 1147 ?>"></i>
1472 1148 <?php
1473 1149 }
1474 1150 } else {
1475 - $adminify_icon = PXLBSADMINIFY_ASSETS_IMAGE . 'logos/menu-icon.svg';
1151 + $adminify_icon = WP_ADMINIFY_ASSETS_IMAGE . 'logos/menu-icon.svg';
1476 1152 if ( empty( $icons[$default_icons] ) ) {
1477 - echo '<i class=""><img width="24" height="24" src=' . esc_url( $adminify_icon ) . ' ></i>';
1153 + echo '<i class=""><img src=' . esc_url( $adminify_icon ) . ' ></i>';
1478 1154 } else {
1479 1155 ?>
1480 1156 <i class="<?php
1481 1157 echo wp_kses_post( $this->get_icon( esc_attr( $icon ), $icons[$default_icons] ) );
@@ -1495,11 +1171,9 @@
1495 1171 </div>
1496 1172 <div class='columns'>
1497 1173 <?php
1498 1174 $upgrade_pro = '';
1499 - $separator_name_attr = '';
1500 1175 $upgrade_pro = 'upgrade-pro';
1501 - $separator_name_attr = Utils::upgrade_pro_notice( 'Add Separator' );
1502 1176 ?>
1503 1177
1504 1178 <div class='column <?php
1505 1179 echo esc_attr( $upgrade_pro );
@@ -1507,11 +1181,12 @@
1507 1181 <label for="seperator-<?php
1508 1182 echo esc_attr( $name_attr );
1509 1183 ?>">
1510 1184 <?php
1511 - $separator_content = apply_filters( 'pxlbsadminify/menu_editor/add_separator', $separator_name_attr, $separator );
1185 + $separator_content = Utils::adminify_upgrade_pro( 'Add Separator' );
1186 + $separator_content = apply_filters( 'adminify/menu_editor/add_separator', $name_attr, $separator );
1512 1187 // Apply the filter
1513 - echo wp_kses_post( $separator_content || "" );
1188 + echo $separator_content;
1514 1189 ?>
1515 1190 </label>
1516 1191 </div>
1517 1192 </div>
@@ -1614,16 +1289,36 @@
1614 1289 ?>">
1615 1290 </div>
1616 1291 <div class="column">
1617 1292 <label for=""><?php
1618 - esc_html_e( 'Hidden For Roles or Users', 'adminify' );
1293 + esc_html_e( 'Hidden For Rules', 'adminify' );
1619 1294 ?></label>
1620 1295
1621 1296 <div class="select is-small">
1622 1297 <?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 1298 echo $this->generate_user_rules_select_field( $menu_id, $disabled_for );
1625 1299 ?>
1300 +
1301 + <script>
1302 + jQuery('#<?php
1303 + echo esc_attr( $menu_id );
1304 + ?> #<?php
1305 + echo esc_attr( $menu_id );
1306 + ?>-user-role-types').tokenize2({
1307 + placeholder: '<?php
1308 + esc_html_e( 'Select roles or users', 'adminify' );
1309 + ?>'
1310 + });
1311 + jQuery(document).ready(function($) {
1312 + $('#<?php
1313 + echo esc_attr( $menu_id );
1314 + ?> #<?php
1315 + echo esc_attr( $menu_id );
1316 + ?>-user-role-types').on('tokenize:select', function(container) {
1317 + $(this).tokenize2().trigger('tokenize:search', [$(this).tokenize2().input.val()]);
1318 + });
1319 + })
1320 + </script>
1626 1321 </div>
1627 1322 </div>
1628 1323 </div>
1629 1324 </div>
@@ -1638,9 +1333,8 @@
1638 1333 public function build_sub_menu_item( $current_menu_item, $optiongroup, $name_attr ) {
1639 1334 $name = '';
1640 1335 $link = '';
1641 1336 $icon = '';
1642 - $external_link = '';
1643 1337 $disabled_for = [];
1644 1338 $suboptiongroup = [];
1645 1339 $menu_options = $this->menu_settings;
1646 1340 if ( isset( $optiongroup['submenu'] ) ) {
@@ -1651,11 +1345,8 @@
1651 1345 }
1652 1346 if ( isset( $suboptiongroup['link'] ) ) {
1653 1347 $link = $suboptiongroup['link'];
1654 1348 }
1655 - if ( isset( $suboptiongroup['external_link'] ) ) {
1656 - $external_link = $suboptiongroup['external_link'];
1657 - }
1658 1349 if ( isset( $suboptiongroup['icon'] ) ) {
1659 1350 $icon = $suboptiongroup['icon'];
1660 1351 }
1661 1352 if ( isset( $suboptiongroup['hidden_for'] ) ) {
@@ -1675,11 +1366,8 @@
1675 1366 }
1676 1367 if ( isset( $optiongroup['submenu'][$sub_menu_name_attr]['icon'] ) ) {
1677 1368 $icon = $optiongroup['submenu'][$sub_menu_name_attr]['icon'];
1678 1369 }
1679 - if ( isset( $optiongroup['submenu'][$sub_menu_name_attr]['external_link'] ) ) {
1680 - $external_link = $optiongroup['submenu'][$sub_menu_name_attr]['external_link'];
1681 - }
1682 1370 }
1683 1371 if ( !is_array( $disabled_for ) ) {
1684 1372 $disabled_for = [];
1685 1373 }
@@ -1728,16 +1416,38 @@
1728 1416 ?>">
1729 1417 </div>
1730 1418 <div class="column">
1731 1419 <label for=""><?php
1732 - esc_html_e( 'Hidden For Roles or Users', 'adminify' );
1420 + esc_html_e( 'Hidden For Rules', 'adminify' );
1733 1421 ?></label>
1734 1422
1735 1423 <div class="select is-small">
1424 +
1736 1425 <?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 1426 echo $this->generate_user_rules_select_field( $menu_id, $disabled_for, 'sub_menu' );
1739 1427 ?>
1428 +
1429 + <script>
1430 + jQuery('#wp-adminify-sub-menu-<?php
1431 + echo esc_attr( $menu_id );
1432 + ?> #<?php
1433 + echo esc_attr( $menu_id );
1434 + ?>-user-role-types').tokenize2({
1435 + placeholder: '<?php
1436 + esc_html_e( 'Select roles or users', 'adminify' );
1437 + ?>'
1438 + });
1439 + jQuery(document).ready(function($) {
1440 + $('#wp-adminify-sub-menu-<?php
1441 + echo esc_attr( $menu_id );
1442 + ?> #<?php
1443 + echo esc_attr( $menu_id );
1444 + ?>-user-role-types').on('tokenize:select', function(container) {
1445 + $(this).tokenize2().trigger('tokenize:search', [$(this).tokenize2().input.val()]);
1446 + });
1447 + })
1448 + </script>
1449 +
1740 1450 </div>
1741 1451 </div>
1742 1452 </div>
1743 1453 <div class="columns">
@@ -1746,23 +1456,9 @@
1746 1456 esc_html_e( 'Change Link', 'adminify' );
1747 1457 ?></label>
1748 1458 <input class="sub_menu_setting" name="link" type="url" placeholder="New link" value="<?php
1749 1459 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 1460 ?>">
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 1461 </div>
1766 1462 <div class="column">
1767 1463 <label for="" style="margin-top:25px">
1768 1464 <?php
@@ -1792,10 +1488,10 @@
1792 1488 /**
1793 1489 * Add New Menu Item.
1794 1490 */
1795 1491 public function render_add_new_menu_item( $submenu = false ) {
1796 - $add_item = apply_filters( 'pxlbsadminify/menu_editor', [
1797 - 'upgrade_pro' => Utils::upgrade_pro_notice( ' ' ),
1492 + $add_item = apply_filters( 'adminify/menu_editor', [
1493 + 'upgrade_pro' => Utils::adminify_upgrade_pro( ' ' ),
1798 1494 'upgrade_class' => 'upgrade-pro',
1799 1495 ] );
1800 1496 ?>
1801 1497 <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 +1496,9 @@
1800 1496 ?>
1801 1497 <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 1498 echo esc_attr( ( $submenu ? 'submenu' : '' ) );
1803 1499 ?> <?php
1804 - echo esc_attr( $add_item['upgrade_class'] );
1500 + echo Utils::wp_kses_custom( $add_item['upgrade_class'] );
1805 1501 ?>">
1806 1502 <div class="inner-text">
1807 1503 <i class="dashicons dashicons-plus-alt"></i>
1808 1504 <span class="title"><?php
@@ -1809,9 +1505,9 @@
1809 1505 esc_html_e( 'Add Item', 'adminify' );
1810 1506 ?></span>
1811 1507 </div>
1812 1508 <?php
1813 - echo wp_kses( $add_item['upgrade_pro'], Utils::kses_allowed_html() );
1509 + echo Utils::wp_kses_custom( $add_item['upgrade_pro'] );
1814 1510 ?>
1815 1511 </div>
1816 1512 <?php
1817 1513 }
@@ -1826,15 +1522,14 @@
1826 1522
1827 1523 <div class="adminify-flex adminify-flex-center adminify-justify-between">
1828 1524 <div class="adminify-menu-editor-help-urls adminify-flex adminify-flex-center adminify-gap-2">
1829 1525 <?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(
1526 + echo Utils::adminfiy_help_urls(
1832 1527 __( 'Menu Editor', 'adminify' ),
1833 1528 'https://wpadminify.com/kb/wordpress-dashboard-menu-editor/',
1834 1529 'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8',
1835 1530 'https://www.facebook.com/groups/jeweltheme',
1836 - esc_url( \PXLBSAdminify\Inc\Admin\AdminSettings::support_url() )
1531 + \WPAdminify\Inc\Admin\AdminSettings::support_url()
1837 1532 );
1838 1533 ?>
1839 1534 </div>
1840 1535
@@ -1890,9 +1585,9 @@
1890 1585 <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 1586 </svg>
1892 1587
1893 1588 <?php
1894 - esc_html_e( 'If you have Adminify Menu Module disabled, icons and label dividers won\'t change.', 'adminify' );
1589 + esc_html_e( 'If you have WP Adminify Menu Module disabled, icons and label dividers won\'t change.', 'adminify' );
1895 1590 ?>
1896 1591
1897 1592 </p>
1898 1593 </div>
@@ -1900,9 +1595,9 @@
1900 1595
1901 1596 <?php
1902 1597 }
1903 1598
1904 - public function menu_editor_contents() {
1599 + public function jltwp_adminify_menu_editor_contents() {
1905 1600 ?>
1906 1601
1907 1602 <div class="wrap">
1908 1603 <div class="wp-adminify--menu--editor--container">