Skip to main content

benecaster_admin_shell_panels

Filter Free

Adds a side panel of your add-on’s own beside every screen of the Benecaster admin, for a tool the podcaster reaches for mid-task without leaving the screen they are on. Benecaster draws the panel and its heading; its body is the SlotFill slot BenecasterShellPanel_{id}, which your add-on fills with registerFill. The panel stays open while the podcaster moves between screens.

The fill receives { showId, activeShowIds, close }: the selected show, the published shows your add-on is active on, and a function that closes the panel.

Benecaster owns whether the panel is open, so you never keep that state yourself. One panel is open at a time. Your declared shortcut toggles it, Escape closes it, and window.BenecasterExtensions.openShellPanel( id ) and closeShellPanel() open and close it from your own button. Focus moves into the panel when it opens and back when it closes.

Parameters

Name Type Default Description
$panels array — Panel declarations, each with `id` (required; lowercase letters, numbers, `-` and `_`), `label` (required; translate it), and optionally `add_on` (your entitlement slug), `scope` (`show`, the default, or `any_show`) and `shortcut` (for example `alt+shift+k`)

Returns: array

Example

add_filter( 'benecaster_admin_shell_panels', function ( array $panels ): array {
    $panels[] = [
        'id'       => 'my-lookup',
        'label'    => __( 'Lookup', 'my-addon' ),
        'add_on'   => 'benecaster-addon-my-addon',
        'scope'    => 'any_show',     // A tool for the podcaster's own use. Leave it out for anything about the selected show.
        'shortcut' => 'alt+shift+l',  // mod = Cmd on a Mac, Ctrl elsewhere.
    ];
    return $panels;
} );

Notes

add_on gates per show. The panel is offered while the add-on is switched on for at least one published show. With the default scope of show, your fill runs only when the selected show is one of them; on any other show Benecaster says the add-on isn't switched on for it. Leave add_on out only for a free add-on — without it the panel is on every show.

any_show is for the podcaster's own tools, such as a search of their back catalogue. The fill then runs on every show and is handed activeShowIds, so keep to those shows. Never use it for a panel that shows or changes the selected show's data: on a site that runs two licenses, it would run one customer's add-on against the other's show, and your fill is the only thing in the way. Any value other than any_show means show.

Shortcuts combine any of mod (Cmd on a Mac, Ctrl elsewhere), alt and shift with one key: a letter, a digit, or one of ` / . , ; [ ] - = `. The order of the modifiers does not matter. The browser's own shortcuts (copy, paste, undo, find, reload, tabs, zoom, developer tools) and the episode editor's text-formatting shortcuts (bold, italic, link, headings, lists) are refused, and so is anything else that does not fit, such as mod+enter; a refused shortcut leaves the panel with no shortcut and a warning in the browser console. A shortcut with neither mod nor alt does nothing while someone is typing in a field, so a bare /` still types. When two panels declare the same shortcut, the first declared keeps it and the console names the one that lost.

Give people a button as well. Benecaster draws no launcher of its own, and a shortcut is invisible, so call openShellPanel() from somewhere the podcaster will see, such as your add-on's screen or a Dashboard card. Call it from an event handler, once the admin has loaded.

Worked out at page load, so switching an add-on on or off reaches the panel list on the next load. A second declaration of an id already taken is dropped.

Problems are contained. A panel with no fill registered says the add-on did not load, and a fill that throws is caught without taking the rest of the admin down. The panel element carries data-tour="{id}-panel" for tours. Full walkthrough: Open your own panel beside every Benecaster screen with a shortcut.

Affects

  • Benecaster admin, beside every screen

Need this built rather than just documented? See our services →