• Hi,

    Thanks for creating this plugin! Is it possible to display the allergen icons with text as well as just the icon? (otherwise many customers may struggle to understand what the different icons mean without using a legend and on a phone browser will not be able to hover over them to get a tooltip).

    Thanks,
    T

Viewing 5 replies - 1 through 5 (of 5 total)
  • Anonymous User 17720058

    (@anonymized-17720058)

    Of course!
    Use the “Allergens_list_html_hook” in functions.php. Thus:

    // Delete default display
    remove_filter('allergens_list_html_hook', 'allergens_list_910_render_html');
    
    function my_filter_function($data) {
    
        // See: plugins/allergens-list/libs/hooks.php
        
        $html = array();
        
        foreach ($data as $key => $item) {
        	if (!empty($item['url'])) {
                $html[] = '<a href="'.$item['url'].'" target="_blank" title="'.$item['title'].'">'.
                          $item['title'].
                          '</a>';
            } else {
                $html[] = $item['title'];
            }
        }    
        return implode('', $html);    
    }
    add_filter('allergens_list_html_hook', 'my_filter_function', 11, 1);

    Some more tips are found here.

    • This reply was modified 3 years, 8 months ago by Anonymous User 17720058.
    • This reply was modified 3 years, 8 months ago by Anonymous User 17720058.
    Anonymous User 17720058

    (@anonymized-17720058)

    Of course!
    Use the “Allergens_list_html_hook” in functions.php. Thus:

    // Delete default display
    remove_filter('allergens_list_html_hook', 'allergens_list_910_render_html');
    
    function my_filter_function($data) {
    
        // See: plugins/allergens-list/libs/hooks.php
        
        $html = array();
        
        foreach ($data as $key => $item) {
        	if (!empty($item['url'])) {
                $html[] = '<a href="'.$item['url'].'" target="_blank" title="'.$item['title'].'">'.
                          $item['title'].
                          '</a>';
            } else {
                $html[] = $item['title'];
            }
        }    
        return implode('', $html);    
    }
    add_filter('allergens_list_html_hook', 'my_filter_function', 11, 1);

    Some more tips are found here.

    Hi,
    I try too to show icons with icons name behind, but this hook doesn’t work.
    Can you help me ?
    Thank you for this useful plugin.
    Best

    Anonymous User 17720058

    (@anonymized-17720058)

    Holidays, so only quickly:

    // Delete default display
    remove_filter('allergens_list_html_hook', 'allergens_list_910_render_html');
    function my_filter_function($data) {
    $html = array();
    
            foreach ($data as $key => $item) {
                if (!empty($item['url'])) {
                    $html[] = '<a href="'.$item['url'].'" target="_blank" title="'.$item['title'].'" rel="noopener">'.
                              '<img src="'.$item['icon'].'" alt="'.$item['title'].'" />' .
                              $item['title'] . '</a>';
                } else {
                    $html[] = '<img src="'.$item['icon'].'" alt="'.$item['title'].'" />' . $item['title'];
                }
            }
            
            return implode('', $html);
    }
    add_filter('allergens_list_html_hook', 'my_filter_function', 11, 1);
    • This reply was modified 3 years, 4 months ago by Anonymous User 17720058.
    • This reply was modified 3 years, 4 months ago by Anonymous User 17720058.

    Thanks a lot and have a nice holiday !

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Show allergen icons with text (not just icons)’ is closed to new replies.