PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.3.2
Adminify – White Label, Admin Menu Editor, Login Customizer v4.3.2
4.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 All 165 releases
← All changes | Inc/Classes/AdminBar.php +95 -222 4.2.154.3.2 View file →
@@ -56,18 +56,47 @@
56 56 // add_action('pxlbsadminify/before/secondary_menu', [$this, 'before_secondary_menu']);
57 57 // }
58 58
59 59 if (is_admin()) {
60 - // Switcher for Default UI
61 - if (empty($this->adminify_ui)) {
62 - if (!empty($this->options['admin_bar_dark_light_btn'])) {
63 - add_action('admin_bar_menu', [$this, 'dark_mode_switcher_icon']);
64 - }
60 + // Light/Dark Mode switcher add
61 + if (!empty($this->options['admin_bar_dark_light_btn'])) {
62 + add_action('admin_bar_menu', [$this, 'dark_mode_switcher_icon']);
63 + // customize.php never fires `admin_enqueue_scripts` - it does not
64 + // load admin-header.php - so the switcher's assets have to come in
65 + // on the Customizer's own hook. See enqueue_standalone_switcher().
66 + add_action('customize_controls_enqueue_scripts', [$this, 'enqueue_standalone_switcher']);
65 67 }
68 + // Add Frontend Site Preview Icon for UI.
69 + // Priority 10000: nodes render in the order they are added, and core fills
70 + // top-secondary late - my-account at 9991, recovery mode at 9992, search at
71 + // 9999 - so anything lower than this lands before them instead of last.
72 + if (!empty($this->adminify_ui)) {
73 + add_action('admin_bar_menu', [$this, 'preview_icon'], 10000);
74 + }
66 75 }
67 76 }
68 77
78 + public function preview_icon($wp_admin_bar) {
79 + $args = [
80 + 'parent' => 'top-secondary',
81 + 'id' => 'adminify-frontend-site-preview',
82 + // Icon only. ab-icon is what WordPress uses to size and align admin bar
83 + // glyphs; the label stays for screen readers.
84 + 'title' => '<span class="ab-icon dashicons dashicons-visibility" aria-hidden="true"></span><span class="screen-reader-text">' . esc_html__('Preview', 'adminify') . '</span>',
85 + 'href' => home_url('/'),
86 + 'meta' => [
87 + // Opens the site in a new tab so the admin screen stays put.
88 + // noopener keeps the new tab from reaching back via window.opener.
89 + 'target' => '_blank',
90 + 'rel' => 'noopener',
91 + 'title' => esc_attr__('Preview site in a new tab', 'adminify'),
92 + ],
93 + ];
69 94
95 + $wp_admin_bar->add_node($args);
96 + }
97 +
98 +
70 99 // Add Switcher Icon on Admin Bar Secondary
71 100 public function dark_mode_switcher_icon($wp_admin_bar)
72 101 {
73 102 $args = [
@@ -84,9 +113,16 @@
84 113 {
85 114 $global_color_mode = !empty($this->options['light_dark_mode']['admin_ui_mode']) ? $this->options['light_dark_mode']['admin_ui_mode'] : 'light';
86 115 $color_mode = empty(get_user_meta(get_current_user_id(), 'color_mode', true))? $global_color_mode : get_user_meta(get_current_user_id(), 'color_mode', true);
87 116
88 - $color_var = !empty($this->adminify_ui) ? 'var(--adminify-menu-text-color)' : '#fff';
117 + // currentColor, so the glyphs take the colour of whatever bar they land in:
118 + // #f0f0f1 from core's `#wpadminbar .ab-empty-item` in the stock admin bar,
119 + // and the surrounding text colour inside the dropdown or anywhere Adminify
120 + // styles the bar itself. --adminify-menu-text-color was the SIDEBAR's
121 + // colour - near-black in light mode, so the icon all but vanished against
122 + // the dark admin bar - and it is not even defined on screens where
123 + // OutputCSS does not run, customize.php among them.
124 + $color_var = 'currentColor';
89 125
90 126 $adminbar_switcher_icon = '<div id="wp-adminify-color-mode-wrapper">
91 127 <div class="mode-icon adminify-color-mode-' . esc_attr($color_mode) . '-active">
92 128 <svg viewBox="0 0 24 24" width="24" height="24" class="darkIcon" ><path fill="' . $color_var . '" d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"></path></svg>
@@ -271,8 +307,12 @@
271 307 public function admin_scripts()
272 308 {
273 309 global $pagenow;
274 310 if ($pagenow == 'wp-login.php' || $pagenow == 'wp-register.php' || $pagenow == 'customize.php') {
311 + // Adminify's main bundle is skipped on these screens by design, but
312 + // WordPress 7.1 prints the admin bar on customize.php - switcher node
313 + // and all. Hand it the standalone assets so it is not left inert.
314 + $this->enqueue_standalone_switcher();
275 315 return;
276 316 }
277 317
278 318 // Commented on: 9-6-24
@@ -282,14 +322,52 @@
282 322 }
283 323 wp_localize_script('adminify-admin', 'PXLBSADMINIFY_ADMINBAR', $this->create_admin_bar_js_object());
284 324 }
285 325
326 + /**
327 + * Self-contained Light/Dark/System switcher for screens the main bundle skips.
328 + *
329 + * `wp-adminify.css` scopes the switcher rules under `.adminify-ui` and
330 + * `wp-adminify.js` carries the behaviour, and neither loads on customize.php
331 + * (Assets::should_skip_adminify_scripts). WordPress 7.1 renders the admin bar
332 + * there, so without this the node paints as bare unstyled SVGs and clicking it
333 + * does nothing. Same approach DarkModeConflicts already takes for dark mode.
334 + *
335 + * Safe to call more than once: wp_enqueue_*() is a no-op on a handle that is
336 + * already queued.
337 + *
338 + * @return void
339 + */
340 + public function enqueue_standalone_switcher()
341 + {
342 + if (empty($this->options['admin_bar_dark_light_btn'])) {
343 + return;
344 + }
286 345
346 + wp_enqueue_style(
347 + 'adminify-admin-bar-switcher',
348 + PXLBSADMINIFY_ASSETS . 'css/wp-adminify-admin-bar-switcher' . Utils::assets_ext('.css'),
349 + array(),
350 + PXLBSADMINIFY_VER
351 + );
352 +
353 + wp_enqueue_script(
354 + 'adminify-admin-bar-switcher',
355 + PXLBSADMINIFY_ASSETS . 'admin/js/wp-adminify-admin-bar-switcher' . Utils::assets_ext('.js'),
356 + array(),
357 + PXLBSADMINIFY_VER,
358 + true
359 + );
360 +
361 + wp_localize_script('adminify-admin-bar-switcher', 'PXLBSADMINIFY_ADMINBAR', $this->create_admin_bar_js_object());
362 + }
363 +
364 +
287 365 public function create_admin_bar_js_object()
288 366 {
289 367 return [
290 368 'ajax_url' => admin_url('admin-ajax.php'),
291 - 'security_nonce' => wp_create_nonce('pxlbsadminify-admin-bar-security-nonce'),
369 + 'security_nonce' => wp_create_nonce('pxlbsadminify_frame_nonce'),
292 370 'notice_nonce' => wp_create_nonce('pxlbsadminify-notice-nonce'),
293 371 ];
294 372 }
295 373
@@ -329,18 +407,12 @@
329 407 */
330 408 public function color_mode()
331 409 {
332 410 if (defined('DOING_AJAX') && DOING_AJAX) {
333 - // Two callers post to this handler with different nonce objects:
334 - // - dev/admin/wp-adminify.js uses PXLBSADMINIFY_ADMINBAR.security_nonce
335 - // (action: pxlbsadminify-admin-bar-security-nonce)
336 - // - dev/admin/frame/utils/uitls.js (React frame topbar dropdown)
337 - // uses PXLBSADMINIFY_FRAME.security_nonce (action: adminify_nonce)
338 - // Accept either — both are user-bound; failing only one strands the
339 - // React frame toggle (the dark-mode dropdown silently 403s).
340 - $nonce_ok = ( check_ajax_referer('pxlbsadminify-admin-bar-security-nonce', 'security', false) > 0 )
341 - || ( check_ajax_referer('adminify_nonce', 'security', false) > 0 );
342 - if ( ! $nonce_ok ) {
411 + // Both callers (classic admin bar wp-adminify.js and the React frame
412 + // dropdown dev/admin/frame/utils/uitls.js) post the
413 + // pxlbsadminify_frame_nonce nonce.
414 + if ( check_ajax_referer('pxlbsadminify_frame_nonce', 'security', false) <= 0 ) {
343 415 wp_send_json_error( array( 'mess' => __( 'Invalid request.', 'adminify' ) ), 403 );
344 416 }
345 417 // Color mode is per-user preference; require the caller to be
346 418 // a logged-in user with admin-bar access.
@@ -405,9 +477,14 @@
405 477 * @return void
406 478 */
407 479 public function all_search()
408 480 {
409 - if (defined('DOING_AJAX') && DOING_AJAX && check_ajax_referer('pxlbsadminify-admin-bar-security-nonce', 'security') > 0) {
481 + if (defined('DOING_AJAX') && DOING_AJAX) {
482 + // Both the classic admin bar and the React frame search (SearchForm.jsx)
483 + // post the pxlbsadminify_frame_nonce nonce.
484 + if ( check_ajax_referer('pxlbsadminify_frame_nonce', 'security', false) <= 0 ) {
485 + wp_send_json_error( array( 'message' => __( 'Invalid request.', 'adminify' ) ), 403 );
486 + }
410 487 // Security check - only users who can edit posts should access admin search
411 488 if (!current_user_can('edit_posts')) {
412 489 wp_send_json_error(array('message' => __('You do not have permission to perform this action.', 'adminify')));
413 490 }
@@ -500,212 +577,8 @@
500 577
501 578 wp_send_json_success(
502 579 [
503 580 'data' => wp_json_encode($output_data),
504 - ]
505 - );
506 -
507 - return;
508 -
509 - ob_start();
510 - ?>
511 -
512 - <p><span class="count"></span><?php echo count($foundposts) . wp_kses_post(' item<span>s</span> found'); ?></p>
513 -
514 - <table class="top-header-result-table" style="height:500px;">
515 - <thead>
516 - <tr class="has-text-left">
517 - <th><?php esc_html_e('Title', 'adminify'); ?></th>
518 - <th><?php esc_html_e('Type', 'adminify'); ?></th>
519 - <th><?php esc_html_e('User', 'adminify'); ?></th>
520 - <th><?php esc_html_e('Date', 'adminify'); ?></th>
521 - </tr>
522 - </thead>
523 - <tbody>
524 -
525 - <?php
526 - foreach ($foundposts as $item) {
527 - $author_id = $item->post_author;
528 - $editurl = get_edit_post_link($item);
529 - $public = get_permalink($item);
530 - ?>
531 - <tr>
532 - <td><span class="table-title"><a href="<?php echo esc_url($editurl); ?>"><?php echo wp_kses_post(get_the_title($item)); ?></a></span></td>
533 - <td><span class="type"><?php echo wp_kses_post(get_post_type($item)); ?></span></td>
534 - <td><span class="user"><?php echo wp_kses_post(the_author_meta('user_login', $author_id)); ?></span></td>
535 - <td><span class="date"><?php echo wp_kses_post(get_the_date(get_option('date_format'), $item)); ?></span></td>
536 - </tr>
537 - <?php } ?>
538 -
539 - <?php
540 - foreach ($all_taxonomies as $tax_name) {
541 - $terms = get_terms(
542 - [
543 - 'taxonomy' => $tax_name,
544 - 'hide_empty' => 1,
545 - ]
546 - );
547 - foreach ($terms as $cat) {
548 - if (strpos(strtolower($cat->name), strtolower($term)) === false) {
549 - continue;
550 - }
551 - // $user = get_userdata($cat->term_id);
552 - ?>
553 - <tr>
554 - <td>
555 - <span class="table-title">
556 - <a href="<?php echo esc_url(get_term_link($cat->slug, $cat->taxonomy)); ?>">
557 - <?php echo esc_html($cat->name); ?>
558 - </a>
559 - </span>
560 - </td>
561 - <td>
562 - <span class="type"><?php echo esc_html($cat->taxonomy); ?></span>
563 - </td>
564 - <td>
565 - <span class="user">
566 - <?php esc_html_e('N/A', 'adminify'); ?>
567 - </span>
568 - </td>
569 - <td>
570 - <span class="date">
571 - <?php esc_html_e('N/A', 'adminify'); ?>
572 - </span>
573 - </td>
574 - <td>
575 - </td>
576 - </tr>
577 - <?php
578 - }
579 - }
580 - ?>
581 -
582 -
583 - <!-- Get Comments -->
584 - <?php
585 - foreach ($all_comments as $comment) {
586 - if (strpos(strtolower($comment->comment_content), strtolower($term)) === false) {
587 - continue;
588 - }
589 - ?>
590 - <tr>
591 - <td>
592 - <span class="table-title">
593 - <a href="<?php echo esc_url(admin_url('comment.php?action=editcomment&c=' . esc_attr($comment->comment_ID))); ?>">
594 - <?php echo wp_kses_post($comment->comment_content); ?>
595 - </a>
596 - </span>
597 - </td>
598 - <td>
599 - <span class="type">
600 - <?php echo wp_kses_post(ucwords($comment->comment_type)); ?>
601 - </span>
602 - </td>
603 - <td>
604 - <span class="user">
605 - <?php echo wp_kses_post(the_author_meta('display_name', $comment->user_id)); ?>
606 - </span>
607 - </td>
608 - <td>
609 - <span class="date">
610 - <?php echo esc_html(get_the_date(get_option('date_format'), $comment->comment_date)); ?>
611 - </span>
612 - </td>
613 - </tr>
614 - <?php } ?>
615 -
616 -
617 -
618 - <!-- Get Users -->
619 - <?php
620 -
621 - foreach ($all_users as $user) {
622 - if (strpos(strtolower($user->user_login), strtolower($term)) === false) {
623 - continue;
624 - }
625 - ?>
626 - <tr>
627 - <td>
628 - <span class="table-title">
629 - <a href="<?php echo esc_url(admin_url('user-edit.php?user_id=' . $user->ID)); ?>">
630 - <?php echo esc_html($user->display_name); ?>
631 - </a>
632 - </span>
633 - </td>
634 - <td>
635 - <span class="type">
636 - <?php echo wp_kses_post(ucwords($comment->comment_type)); ?>
637 - </span>
638 - </td>
639 - <td>
640 - <span class="user">
641 - <?php echo wp_kses_post(the_author_meta('display_name', $comment->user_id)); ?>
642 - </span>
643 - </td>
644 - <td>
645 - <span class="date">
646 - <?php echo wp_kses_post(get_the_date(get_option('date_format'), $user->user_registered)); ?>
647 - </span>
648 - </td>
649 - </tr>
650 - <?php } ?>
651 -
652 -
653 -
654 - <!-- Get Plugins -->
655 - <?php
656 - foreach ($all_plugins as $plugin) {
657 - if (strpos(strtolower($plugin['Name']), strtolower($term)) === false) {
658 - continue;
659 - }
660 - ?>
661 - <tr>
662 - <td>
663 - <span class="table-title">
664 - <a href="<?php echo esc_url(admin_url('plugins.php')); ?>">
665 - <?php echo esc_html($plugin['Name']); ?>
666 - </a>
667 - </span>
668 - </td>
669 - <td>
670 - <span class="type">
671 - <?php esc_html_e('Plugin', 'adminify'); ?>
672 - </span>
673 - </td>
674 - <td>
675 - <span class="user">
676 - <?php echo esc_html($plugin['AuthorName']); ?>
677 - </span>
678 - </td>
679 - <td>
680 - <span class="date">
681 - <?php esc_html_e('N/A', 'adminify'); ?>
682 - </span>
683 - </td>
684 - </tr>
685 - <?php } ?>
686 -
687 -
688 - </tbody>
689 - </table>
690 -
691 -
692 - <?php
693 -
694 - // $output_data = ob_get_clean();
695 -
696 - // $output_data = [
697 - // 'foundposts' => $foundposts,
698 - // 'all_taxonomies' => $all_taxonomies,
699 - // 'all_comments' => $all_comments,
700 - // 'all_users' => $all_users,
701 - // 'all_plugins' => $all_plugins,
702 - // ];
703 - // echo json_encode($output_data);
704 - echo wp_json_encode($foundposts);
705 - wp_send_json_success(
706 - [
707 - 'data' => $foundposts,
708 581 ]
709 582 );
710 583 }
711 584