Feature Request: custom topbar items filter
-
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-topbarbody class), any plugin usingadd_action('admin_bar_menu', ...)to add nodes still fires, but renders into a bar nobody sees. The only workaround BrikPanel currently offers iscustom_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 waycreateornotificationsdo 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()andbrikpanel_topbar_item_audience_allows()is keyed by item id and already backward-compatible with unknown keys (defaults to visible). If registered items are pushed throughbrikpanel_topbar_items_label_map()(or a merged version of it) before the settings UI renders, the existing toggle-switch and per-role audience UI inbrikpanel_render_topbar_items_field()extends to cover developer-registered items automatically, with no new UI work. This is the same pattern BrikPanel already uses forbrikpanel_product_editor_boxesin 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 howbrikpanel_product_editor_boxesbehaves and avoids every third-party plugin needing to duplicate visibility logic.
You must be logged in to reply to this topic.