• Resolved arcanetech

    (@arcanetech)


    BrikPanel replaces the native WordPress admin bar with its own topbar (Brikpanel_Dashboard_Topbar). The topbar already has a solid per-item visibility and audience system (brikpanel-topbar-items.php) covering its 9 built-in controls, but that system only manages existing items. There’s no way for a plugin to register a new item into the topbar programmatically.

    Problem

    Because the native admin bar is hidden (not removed, just CSS-hidden via the brikpanel-has-topbar body class), any plugin using add_action('admin_bar_menu', ...) to add nodes still fires, but renders into a bar nobody sees. The only workaround BrikPanel currently offers is custom_link: a single, owner-typed label+URL pair, entered manually in settings. That’s fine for one static shortcut. It doesn’t scale to a plugin wanting to add a live counter, a dropdown menu, or a status indicator the way create or notifications do internally.

    Requested solution

    Add a filter, e.g.:

    php

    apply_filters( 'brikpanel_topbar_items', array $items )

    fired inside Brikpanel_Dashboard_Topbar::render() before or after the built-in items, so a plugin can register a new item using the same shape BrikPanel’s own items already use: an id, a render callback (or icon + label + href for the simple case), and optionally a position (left/right, before/after a given built-in key).

    Why this specific approach

    The existing visibility/audience code in brikpanel_topbar_item_is_visible() and brikpanel_topbar_item_audience_allows() is keyed by item id and already backward-compatible with unknown keys (defaults to visible). If registered items are pushed through brikpanel_topbar_items_label_map() (or a merged version of it) before the settings UI renders, the existing toggle-switch and per-role audience UI in brikpanel_render_topbar_items_field() extends to cover developer-registered items automatically, with no new UI work. This is the same pattern BrikPanel already uses for brikpanel_product_editor_boxes in the hooks API: register via filter, let the existing render/priority/visibility machinery handle it.

    Suggested minimal shape

    php

    add_filter( 'brikpanel_topbar_items', function ( $items ) {
        $items['my_plugin_status'] = [
            'label'    => __( 'Sync status', 'my-plugin' ),
            'position' => 'right',   // or 'left'
            'priority' => 15,
            'callback' => function () {
                echo '<span class="my-plugin-topbar-badge">Synced</span>';
            },
        ];
        return $items;
    } );

    Open question for the BrikPanel team

    Should registered items pass through brikpanel_topbar_item_is_visible() by default (inheriting the toggle/audience system for free), or should that require an explicit opt-in flag per item? Defaulting to “inherited” matches how brikpanel_product_editor_boxes behaves and avoids every third-party plugin needing to duplicate visibility logic.

Viewing 1 replies (of 1 total)
  • Plugin Support latti

    (@niyht)

    Thank you very much, I’ve made all the changes you requested and released the new version 3.2.60 . If you notice anything missing, please let me know here. In the meantime, you need to download and install the new version from the plugin’s wp.org page because the update notification will appear after 6 hours.

    By the way, if you like the plugin, leaving a review would also be a huge help to me 🙏

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.