Filter
rpress_allergens_any_assigned
On this page
Filters whether any allergen is assigned to a menu item, when the answer is computed.
Used so stores that never use allergens do not load the allergen stylesheet. The answer is cached for a day in the rpress_allergens_assigned transient. The filter only runs on the call that computes the answer, not when the cached value is read.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$assigned | bool | True when an allergen or trace is assigned to a published menu item. |
Return value#
bool. Whether allergens are in use.
Example#
add_filter( 'rpress_allergens_any_assigned', 'my_allergens_any_assigned', 10, 1 );
function my_allergens_any_assigned( $assigned ) {
return true;
}
Notes#
Because the filtered value is not what gets cached, the cached answer is returned unchanged on later requests until the transient is cleared or expires.
Source#
Applied in:
includes/features/allergens/frontend.php(line 187), inrpress_allergens_any_assigned()
Was this page helpful?
