Skip to main content

benecaster_episode_editor_tabs

Filter Free

Declares a tab in the episode editor. Benecaster draws each declared tab’s button in the editor’s tab bar and, as its panel, the SlotFill slot BenecasterEpisodeEditorTab_{id}, which your add-on fills with its own React component. The fill receives { episodeId, showId } and saves through your own REST route or post meta. The Benecaster admin app fetches the declarations from GET /benecaster/v1/admin/extensions for the episode’s own show.

This filter declares the tab; it does not draw or save anything. A tab declared here with no fill shows an empty panel. A sections key is accepted and passed through to GET /admin/extensions as data, but nothing renders it and no field in it is saved.

add_on is the per-show visibility gate. Benecaster drops any tab whose add_on is not active on the episode’s show, so a paid add-on’s tab appears only where it is licensed and switched on. A tab with no add_on shows on every show — right for a free add-on, wrong for a paid one.

?tab={id} opens your tab: #/episodes/{episodeId}?tab=my-addon lands on it, as it does for Benecaster’s own tabs. On a show where your add-on is off, the URL falls back to Details. For a guided-tour step, use the episode-tab:{id} screen — see the recipe Point a tour step at your tab in the episode editor. Benecaster’s tabs come first; add-on tabs follow in the order they were appended to $tabs.

Parameters

Name Type Default Description
$tabs array — Array of tab declaration arrays. Keys per tab: `id` (string — unique tab identifier, letters, digits, `-` or `_`; the slot name suffix and the `?tab=` value), `label` (string — the tab's label), `add_on` (string — the add-on's entitlement slug; hides the tab on shows where the add-on is not active), `icon` (string, optional — icon name from the Benecaster icon set).
$show_id int — The show whose episode is being edited, or `0` when the list is fetched without a show (then nothing is hidden). Keep returning your tab unconditionally; `add_on` does the per-show filtering.

Returns: array

Examples

Declare a tab, then fill its panel in React

// PHP: declare the tab. Shown only on shows where the add-on is active.
add_filter( 'benecaster_episode_editor_tabs', function ( array $tabs, int $show_id ): array {
    $tabs[] = [
        'id'     => 'sponsorships',
        'label'  => __( 'Sponsorships', 'my-addon' ),
        'icon'   => 'megaphone',
        'add_on' => 'benecaster-addon-my-sponsorships',
    ];
    return $tabs;
}, 10, 2 );

// JS (enqueued on admin_enqueue_scripts): draw the panel and save it yourself.
// window.BenecasterExtensions.registerFill( 'BenecasterEpisodeEditorTab_sponsorships', SponsorshipsPanel );

Notes

Register with 10, 2 to receive $show_id. A callback registered with one argument keeps working, and add_on still hides its tab per show.

Related filters:

- benecaster_settings_pages — declare an add-on page on the Benecaster Settings screen. - benecaster_show_settings_pages — declare an add-on tab in one show's settings. - benecaster_dashboard_cards — declare a card on the main Benecaster dashboard.

For a complete working example, see the Add a tab to the episode editor recipe.

Affects

  • Episode Editor Sidebar

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