Plugin Directory

Changeset 3441068


Ignore:
Timestamp:
01/16/2026 02:43:04 PM (2 months ago)
Author:
apos37
Message:

3.0.1.1

  • Fix: If on the network, the admin bar menu links were reset to network links
  • Update: Admin bar menu links were out of order due to defaults
Location:
dev-debug-tools
Files:
224 added
4 edited

Legend:

Unmodified
Added
Removed
  • dev-debug-tools/trunk/dev-debug-tools.php

    r3439754 r3441068  
    44 * Plugin URI:          https://pluginrx.com/plugin/dev-debug-tools/
    55 * Description:         WordPress debugging and testing tools for developers
    6  * Version:             3.0.1
     6 * Version:             3.0.1.1
    77 * Requires at least:   5.9
    88 * Tested up to:        6.9
  • dev-debug-tools/trunk/inc/admin-area/admin-bar/class-admin-bar.php

    r3423844 r3441068  
    521521        $saved_admin_menu_items = filter_var_array( get_option( 'ddtt_admin_menu_items', [] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS );
    522522
    523 
    524         /**
    525          * Allow filtering of the admin menu items
    526          */
     523        // Allow filtering
    527524        $saved_admin_menu_items = apply_filters( 'ddtt_admin_bar_dropdown_links', $saved_admin_menu_items );
    528        
    529         if ( ! empty( $saved_admin_menu_items ) ) {
    530 
    531             $has_access = Helpers::has_access();
    532 
    533             foreach ( $saved_admin_menu_items as $admin_menu_link ) {
    534                 if ( ! current_user_can( $admin_menu_link[ 'perm' ] ) ) {
    535                     continue;
     525        if ( empty( $saved_admin_menu_items ) ) {
     526            return;
     527        }
     528
     529        // Remove trailing separator from saved menu if it exists
     530        $last_item = end( $saved_admin_menu_items );
     531        if ( isset( $last_item[ 'slug' ] ) && str_starts_with( (string) $last_item[ 'slug' ], 'separator' ) ) {
     532            array_pop( $saved_admin_menu_items );
     533        }
     534
     535        $has_access = Helpers::has_access();
     536
     537        $has_dashboard = false;
     538        foreach ( $saved_admin_menu_items as $item ) {
     539            if ( isset( $item[ 'slug' ] ) && $item[ 'slug' ] === 'index.php' ) {
     540                $has_dashboard = true;
     541                break;
     542            }
     543        }
     544
     545        if ( $has_dashboard ) {
     546            $parent = 'site-name';
     547            $children = $wp_admin_bar->get_nodes();
     548            foreach ( $children as $child ) {
     549                if ( $child->parent === $parent ) {
     550                    $wp_admin_bar->remove_node( $child->id );
    536551                }
    537 
    538                 if ( $admin_menu_link[ 'slug' ] === 'dev-debug-dashboard' && ! $has_access ) {
    539                     continue;
    540                 }
    541 
    542                 $wp_admin_bar->add_node( [
    543                     'parent' => 'site-name',
    544                     'id'     => isset( $admin_menu_link[ 'slug' ] ) ? $admin_menu_link[ 'slug' ] : strtolower( str_replace( ' ', '_', $admin_menu_link[ 'label' ] ) ),
    545                     'title'  => $admin_menu_link[ 'label' ],
    546                     'href'   => $admin_menu_link[ 'url' ]
    547                 ] );
    548             }
     552            }
     553        }
     554
     555        // Add saved items in the saved order
     556        foreach ( $saved_admin_menu_items as $admin_menu_link ) {
     557            if ( ! current_user_can( $admin_menu_link[ 'perm' ] ) ) {
     558                continue;
     559            }
     560
     561            if ( $admin_menu_link[ 'slug' ] === 'dev-debug-dashboard' && ! $has_access ) {
     562                continue;
     563            }
     564
     565            $classes = 'ddtt-admin-bar-menu-link';
     566
     567            // Add separator class if slug starts with "separator"
     568            if ( isset( $admin_menu_link['slug'] ) && str_starts_with( (string) $admin_menu_link['slug'], 'separator' ) ) {
     569                $classes .= ' ddtt-admin-bar-separator';
     570            }
     571
     572            $wp_admin_bar->add_node( [
     573                'parent' => 'site-name',
     574                'id'     => $admin_menu_link[ 'slug' ] ?? strtolower( str_replace( ' ', '_', $admin_menu_link[ 'label' ] ) ),
     575                'title'  => $admin_menu_link[ 'label' ],
     576                'href'   => $admin_menu_link[ 'url' ],
     577                'meta'   => [
     578                    'class' => $classes
     579                ]
     580            ] );
    549581        }
    550582    } // End render_add_admin_menu_links()
     
    555587     */
    556588    public function maybe_store_admin_menu_options() {
     589        // Don't store menu items in the multisite network admin
     590        if ( is_network_admin() ) {
     591            return;
     592        }
     593
    557594        $adding_links = filter_var( get_option( 'ddtt_admin_bar_add_links', true ), FILTER_VALIDATE_BOOLEAN );
    558595        $saved_admin_menu_items = filter_var_array( get_option( 'ddtt_admin_menu_items', [] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS );
     
    619656        ];
    620657
    621         $already_added = [
    622             'index.php',
    623             'plugins.php',
    624             'themes.php',
    625         ];
     658        $already_added = [];
    626659
    627660        $admin_menu_items = [];
     
    630663            $slug = $item[2];
    631664
    632             // Skip separators and non-admin URLs
    633             if ( $slug === null || $slug === '' || in_array( $slug, $already_added, true ) || strpos( $slug, 'separator' ) !== false || strpos( $slug, 'http' ) === 0 || strpos( $slug, 'https' ) === 0 ) {
     665            // Skip non-admin URLs
     666            // strpos( $slug, 'separator' ) !== false ||
     667            if ( $slug === null || $slug === '' || in_array( $slug, $already_added, true ) || strpos( $slug, 'http' ) === 0 || strpos( $slug, 'https' ) === 0 ) {
    634668                continue;
    635669            }
     
    647681            } elseif ( strpos( $slug, '.php' ) !== false || strpos( $slug, '?' ) !== false ) {
    648682                $url = admin_url( $slug );
     683            } elseif ( strpos( $slug, 'separator' ) !== false ) {
     684                $url = '';
    649685            } else {
    650686                $url = menu_page_url( $slug, false );
  • dev-debug-tools/trunk/inc/admin-area/admin-bar/menu-links.css

    r3422220 r3441068  
    77    padding-bottom: 10px;
    88}
     9
     10/* Admin bar separator style */
     11.ddtt-admin-bar-separator {
     12    pointer-events: none;
     13    cursor: default;
     14    height: 1px !important;
     15    margin: 5px 0 !important;
     16    border-top: 1px solid #d1d1d1;
     17    background: transparent !important;
     18    opacity: 0.2;
     19}
  • dev-debug-tools/trunk/readme.txt

    r3439754 r3441068  
    55Tested up to: 6.9
    66Requires PHP: 8.0
    7 Stable tag: 3.0.1
     7Stable tag: 3.0.1.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.txt
     
    107107
    108108== Changelog ==
     109= 3.0.1.1 =
     110* Fix: If on the network, the admin bar menu links were reset to network links
     111* Update: Admin bar menu links were out of order due to defaults
     112
    109113= 3.0.1 =
    110114* Update: Added a Force Update Check button to the Updates page, with option to remove it in Settings > Admin Area
Note: See TracChangeset for help on using the changeset viewer.