Skip to main content

benecaster_badge_icons

Filter Free

Filters the icon registry used by the per-tier badge editor and the `GET /badge-icons` REST endpoint. Six built-in icons ship with the plugin: crown, star, lightning bolt, heart, microphone, and headphones. Add custom icons by appending entries to the array — each entry must have exactly three keys: `slug` (a unique, URL-safe machine identifier), `label` (the human-readable name shown in the icon picker), and `svg` (complete SVG markup).

Icons must use `fill=”currentColor”` or `stroke=”currentColor”` on the primary shape so the badge chip’s accent color applies automatically. Multi-color SVGs will not respond to the accent color override. Entries missing any of the three required keys are silently dropped from the registry.

Parameters

Name Type Default Description
$icons array Current icon registry — array of entries, each with `slug`, `label`, and `svg` keys.

Examples

Entry schema

[
    'slug'  => 'podcast-mic',      // Machine-readable identifier — unique, URL-safe
    'label' => 'Podcast Mic',      // Human-readable label shown in the icon picker
    'svg'   => '<svg ...>...</svg>', // Complete SVG markup
]

Register custom RSS feed icon

add_filter( 'benecaster_badge_icons', function ( array $icons ): array {
    $icons[] = [
        'slug'  => 'rss-feed',
        'label' => 'RSS Feed',
        'svg'   => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">'
                 . '<path fill="currentColor" d="M6.18 15.64a2.18 2.18 0 0 1 2.18 2.18C8.36 19.01 7.38 20 6.18 20C4.98 20 4 19.01 4 17.82a2.18 2.18 0 0 1 2.18-2.18M4 4.44A15.56 15.56 0 0 1 19.56 20h-2.83A12.73 12.73 0 0 0 4 7.27V4.44Z"/>'
                 . '</svg>',
    ];
    return $icons;
} );

Notes

Entries missing slug, label, or svg are silently dropped from the registry. SVG is not sanitized at filter time — it is sanitized when a badge definition is saved and an admin selects the icon. The slug must be unique across the registry; duplicate slugs cause unpredictable behavior in the badge editor.