HL Twitter Long URL Link Wrap Fix

With some helpful info I found at Perishable Press, I was able to fix two issues I had with the HL Twitter plugin for WordPress 3.0.x.

For me these were:

  1. Long URLs were breaking themes in the sidebar widget (if you are guilty of tweeting long URLs like me)
  2. links from URLs were opening in the same window. Now they open in a new one.

To do this just two files have to be changed, hl_twitter/functions.php and hl_twitter/hl_twitter_widget.php.

Easy one first: hl_twitter/hl_twitter_widget.php

  • copy the hl_twitter_widget.php file into the root of your themes folder.
  • open the newly created copy in an editor (vi is preferred)
  • find the CSS section labeled “.hl_recent_tweets p”
  • add in the following to that section of CSS
white-space: pre;           /* CSS 2.0 */
white-space: pre-wrap;      /* CSS 2.1 */
white-space: pre-line;      /* CSS 3.0 */
white-space: -pre-wrap;     /* Opera 4-6 */
white-space: -o-pre-wrap;   /* Opera 7 */
white-space: -moz-pre-wrap; /* Mozilla */
white-space: -hp-pre-wrap;  /* HP Printers */
word-wrap: break-word;      /* IE 5+ */
  • save the file
  • done! the url overflow is fixed

Now onto the other easy one: hl_twitter/functions.php

  • enter the plugins/hl_twitter folder
  • open functions.php in my favorite editor, VI
  • change line 178, which should read $tweet = preg_replace(“#(^|[\n ])([\w]+?://[\w]+[^ \”\n\r\t< ]*)#”, “\\1<a href=\”\\2\”>\\2</a>”, $tweet) to the following

$tweet = preg_replace(“#(^|[\n ])([\w]+?://[\w]+[^ \”\n\r\t< ]*)#”, “\\1<a href=\”\\2\” target=\”_blank\”>\\2</a>”, $tweet);

  • Save the file and you have completed this part (opens links in new windows)!

Leave a Reply