function _hashtags_filter_process in Hashtags 7
1 string reference to '_hashtags_filter_process'
- hashtags_filter_info in ./
hashtags.module - Implements hook_filter_info().
File
- ./
hashtags.module, line 683
Code
function _hashtags_filter_process($text, $filter, $format, $langcode, $cache, $cache_id) {
$hashtags_array = hashtags_parse_tags($text, FALSE);
// No hashtag found in text
if (!sizeof($hashtags_array)) {
return $text;
}
$hashtags_tids = hashtags_get_terms_by_names($hashtags_array);
// No hashtag tids found
if (!sizeof($hashtags_tids)) {
return $text;
}
// create a class to pass parameters and have replace logic
$replace_parameter = new HashtagsLinksConverter();
$replace_parameter->hashtags_tids = $hashtags_tids;
// 1) 2+ character after #
// 2) Don't start with or use only numbers (0-9) (#123abc, #123 etc)
// 3) Letters - digits work correct (#abc123, #conference2013)
// 4) No Special Characters “!, $, %, ^, &, *, +, .”
// 5) No Spaces
// 6) May use an underscore. Hyphens and dashes will not work.
// 7) <p>#hashtag</p> - is valid
// 8) <a href="#hashtag">Link</p> - is not valid
// Bug when hashtag resides at the begining of the string
$pattern = "/([\\s>]*?)(#)([[:alpha:]][[:alnum:]_]*[^<\\s[:punct:]])/iu";
$text = preg_replace_callback($pattern, array(
&$replace_parameter,
'replace',
), $text);
return $text;
}