Skip to main content

display_mode_in

Filters the list of display_mode values that NoticeManager::get_active() accepts when building the GET /benecaster/v1/notices response.

Access: Free
Since: feature/announcement-system


Parameters

Name Type Description
$allowed_modes string[] Display-mode values to include. Default: ['bell', 'bar', 'both']

Return: string[] — the list of allowed mode values.


Default Values

Value Meaning
bell Notice appears in the bell panel only
bar Notice appears in the persistent bar only
both Notice appears in both surfaces

When to Use

Most add-ons do not need this filter. Use [benecaster_before_notice_display](/docs/benecaster_before_notice_display/) for per-notice decisions — suppressing a notice, overriding a CTA, or varying message copy per context.

Use display_mode_in only when you are introducing a new display surface in an add-on and need NoticeManager::get_active() to recognize a new mode string. This is an advanced extension point for add-ons that add their own admin UI surfaces alongside the bell and bar.

add_filter( 'display_mode_in', function ( array $modes ): array {
    $modes[] = 'sidebar'; // Add-on introduces a new "sidebar" notice surface.
    return $modes;
} );

Notices carrying an unrecognized display_mode value are excluded from the GET /notices response by default — adding the value to this filter makes them visible.


See Also