Filter
rpress_allergen_badges_html
On this page
Filters the allergen badge markup for a menu item.
Runs at the end of rpress_get_allergen_badges_html(), only when the item has allergens or traces. In the card context the badges are compact spans; in the popup context they are a labelled list with a note. Return an empty string to hide the block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$html | string | Badge markup. |
$fooditem_id | int | Menu item (fooditem) ID. |
$context | string | 'card' or 'popup'. |
$contains | WP_Term[] | Allergens the item contains. |
$traces | WP_Term[] | Allergens the item may contain traces of. |
Return value#
string. Badge markup.
Example#
add_filter( 'rpress_allergen_badges_html', 'my_allergen_badges_html', 10, 5 );
function my_allergen_badges_html( $html, $fooditem_id, $context, $contains, $traces ) {
if ( 'card' === $context && count( $contains ) > 4 ) {
return '';
}
return $html;
}
Source#
Applied in:
includes/features/allergens/functions.php(line 205), inrpress_get_allergen_badges_html()
See also#
Was this page helpful?
