function _icon_filter in Icon API 8
Same name and namespace in other branches
- 7 modules/icon_filter/icon_filter.module \_icon_filter()
Process callback for icon filter.
1 string reference to '_icon_filter'
- icon_filter_filter_info in modules/
icon_filter/ icon_filter.module - Implements hook_filter_info().
File
- modules/
icon_filter/ icon_filter.module, line 38 - icon_filter.module Provides a filter for text fields to replace an icon token with icon markup.
Code
function _icon_filter($text, $filter, $format, $langcode, $cache, $cache_id) {
$icons = array();
if (preg_match_all(ICON_FILTER_REGEX, $text, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
if (!isset($icons[$match[0]])) {
// @FIXME
// theme() has been renamed to _theme() and should NEVER be called directly.
// Calling _theme() directly can alter the expected output and potentially
// introduce security issues (see https://www.drupal.org/node/2195739). You
// should use renderable arrays instead.
//
//
// @see https://www.drupal.org/node/2195739
// $icons[$match[0]] = theme('icon', array('bundle' => $match[1], 'icon' => $match[2]));
}
}
}
foreach ($icons as $search => $replace) {
if (!empty($replace)) {
$text = str_replace($search, $replace, $text);
}
}
return $text;
}