Skip to content
Docs
Get RestroPress

Filter

rpress_allergen_badges_html

Updated
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#

ParameterTypeDescription
$htmlstringBadge markup.
$fooditem_idintMenu item (fooditem) ID.
$contextstring'card' or 'popup'.
$containsWP_Term[]Allergens the item contains.
$tracesWP_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), in rpress_get_allergen_badges_html()

See also#

Was this page helpful?