Filter
rpress_fooditem_allergens
On this page
Filters the allergens a menu item contains.
Returned by rpress_get_fooditem_allergens() after the terms are fetched from the rpress_allergen taxonomy and sorted by name. Not run when the item has no allergens assigned or the taxonomy does not exist.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$terms | WP_Term[] | Allergen terms assigned to the item, sorted by name. |
$fooditem_id | int | Menu item (fooditem) ID. |
Return value#
WP_Term[]. Allergen terms.
Example#
add_filter( 'rpress_fooditem_allergens', 'my_fooditem_allergens', 10, 2 );
function my_fooditem_allergens( $terms, $fooditem_id ) {
return array_values( array_filter( $terms, function ( $term ) {
return 'sesame' !== $term->slug;
} ) );
}
Source#
Applied in:
includes/features/allergens/functions.php(line 33), inrpress_get_fooditem_allergens()
See also#
Was this page helpful?
