function tweet_feed_format_output in Tweet Feed 7
Same name and namespace in other branches
- 8.3 tweet_feed.module \tweet_feed_format_output()
- 6 tweet_feed.module \tweet_feed_format_output()
- 7.3 tweet_feed.module \tweet_feed_format_output()
- 7.2 tweet_feed.module \tweet_feed_format_output()
- 4.x tweet_feed.module \tweet_feed_format_output()
Make links, hash tags, and usernames clickable.
Parameters
string $tweet: A string representing the tweet text.
Return value
string $tweet The same tweet with hashtags, tags and user mentions linked.
1 call to tweet_feed_format_output()
- tweet_feed_process_tweets in ./
tweet_feed.module - Process tweet data from what we have retrieved from the Twitter API
File
- ./
tweet_feed.module, line 401
Code
function tweet_feed_format_output($tweet) {
// Based on our preference, assign all links to new windows or to the same window.
$target = variable_get('tweet_feed_new_window', 0) == 1 ? '_blank' : '_self';
// Look for links and make them clickable.
$tweet = preg_replace('/(((f|ht){1}tp:\\/\\/)[-a-zA-Z0-9@:%_\\+.~#?&\\/\\/=]+)/i', '<a target="' . $target . '" href="\\1">\\1</a>', $tweet);
$tweet = preg_replace('/(((f|ht){1}tps:\\/\\/)[-a-zA-Z0-9@:%_\\+.~#?&\\/\\/=]+)/i', '<a target="' . $target . '" href="\\1">\\1</a>', $tweet);
$tweet = preg_replace('/([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\\+.~#?&\\/\\/=]+)/i', '\\1<a target="' . $target . '" href="http:\\/\\/\\2">\\2</a>', $tweet);
$tweet = preg_replace('/([_\\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\\.)+[a-z]{2,3})/i', '<a href="mailto:\\1">\\1</a>', $tweet);
return $tweet;
}