You are here

function _twitter_filter_text in Twitter 7.4

Same name and namespace in other branches
  1. 6.5 twitter.module \_twitter_filter_text()
  2. 7.6 twitter.module \_twitter_filter_text()
  3. 7.3 twitter.module \_twitter_filter_text()
  4. 7.5 twitter.module \_twitter_filter_text()

This helper function converts Twitter-style @usernames and #hashtags into actual links.

3 calls to _twitter_filter_text()
twitter_views_handler_field_xss::render in ./twitter_views_field_handlers.inc
Processes the message through the selected options.
_twitter_filter_hashtag in ./twitter.module
Callback for twitter #hashtag converter.
_twitter_filter_username in ./twitter.module
Callback for twitter @username converter.

File

./twitter.module, line 252
Provides API integration with the Twitter microblogging service.

Code

function _twitter_filter_text($text, $prefix, $destination) {
  $matches = array(
    '/\\>' . $prefix . '(\\w+)/ui',
    '/^' . $prefix . '(\\w+)/ui',
    '/(\\s+)' . $prefix . '(\\w+)/ui',
  );
  $replacements = array(
    '><a href="' . $destination . '${1}">' . $prefix . '${1}</a>',
    '<a href="' . $destination . '${1}">' . $prefix . '${1}</a>',
    '${1}<a href="' . $destination . '${2}">' . $prefix . '${2}</a>',
  );
  return preg_replace($matches, $replacements, $text);
}