function twitter_link_filter in Twitter 6.4
Same name and namespace in other branches
- 6.2 twitter.module \twitter_link_filter()
- 6.3 twitter.module \twitter_link_filter()
This helper function converts Twitter-style @usernames and #hashtags into actual links.
2 calls to twitter_link_filter()
- twitter_filter in ./
twitter.module - Implementation of hook_filter().
- twitter_views_handler_field_xss::render in ./
twitter_views_field_handlers.inc
File
- ./
twitter.module, line 211 - Establishes an interface to communicate with Twitter
Code
function twitter_link_filter($text, $prefix = '@', $destination = '') {
if ($destination == '') {
$destination = variable_get('twitter_host', TWITTER_HOST) . '/';
}
$matches = array(
'/\\>' . $prefix . '([a-z0-9_]+)/i',
'/^' . $prefix . '([a-z0-9_]+)/i',
'/(\\s+)' . $prefix . '([a-z0-9_]+)/i',
);
$replacements = array(
'><a href="' . $destination . '${1}" target="_blank">' . $prefix . '${1}</a>',
'<a href="' . $destination . '${1}" target="_blank">' . $prefix . '${1}</a>',
'${1}<a href="' . $destination . '${2}" target="_blank">' . $prefix . '${2}</a>',
);
return preg_replace($matches, $replacements, $text);
}