My client wanted the links to open in a new window. This patch uses a variable to set the target attribute (or really any other attribute).

CommentFileSizeAuthor
twitter_pull_target.diff998 bytesdalin
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

robert.wilson3’s picture

In the twitter_pull.module for links in Tweets just add the following target_blank's

/**
 * Automatically add links to URLs and Twitter usernames in a tweet.
 */
function twitter_pull_add_links($text) {
  $pattern = '#(https?)://([^\s\(\)\,]+)#ims';
  $repl = '<a href="$1://$2" rel="nofollow" target="_blank" title="$1://$2">$2</a>';
  $text = preg_replace($pattern, $repl, $text);

  $pattern = '#@(\w+)#ims';
  $repl = '@<a href="http://twitter.com/$1" rel="nofollow" target="_blank" title="@$1">$1</a>';
  $text = preg_replace($pattern, $repl, $text);

  $pattern = '/[#]+([A-Za-z0-9-_]+)/';
  $repl = '#<a href="http://twitter.com/#!/search?q=%23$1" title="#$1" target="_blank" rel="nofollow">$1</a>';
  $text = preg_replace($pattern, $repl, $text);  

  return $text;
}