function _glossify_replace in Glossify 6.3
Same name and namespace in other branches
- 6 glossify.module \_glossify_replace()
Helper function that fetches and returns the styled term depending on the style and term.
1 call to _glossify_replace()
File
- ./
glossify.module, line 667
Code
function _glossify_replace($configuration, &$html, $term_title, $replacement, &$replaced) {
$text_nodes = $html
->find('text');
// Add some specific tags to exclusion list.
$exclude_tags = array_merge(is_array($configuration['excl_tags']) ? $configuration['excl_tags'] : array(), array(
'iframe' => 'iframe',
'object' => 'object',
));
foreach ($text_nodes as $text_node) {
if (!isset($text_node->parent->tag) || $configuration['excl_mode'] == 0 && !isset($exclude_tags[$text_node->parent->tag]) || $configuration['excl_mode'] == 1 && isset($exclude_tags[$text_node->parent->tag])) {
// Include
$text_node->innertext = preg_replace(_glossify_regex($configuration, $term_title), $replacement, $text_node->innertext, $configuration['only_first'] ? 1 : -1, $result);
if ($result) {
$replaced += $result;
if ($configuration['only_first']) {
break;
}
}
}
}
}