WordPress.org

Support

Support » Plugins and Hacks » Converting hyperlinks and twitter users in twitter text

Converting hyperlinks and twitter users in twitter text

Viewing 3 replies - 1 through 3 (of 3 total)
  • I think the plugin should use the official WordPress method of adding links to tweet text.
    https://github.com/mzsanford/twitter-text-php

    But a quick, though less comprehensive solution, would be to use this code:

    foreach($tweets as $tweet) {
      $tweet_text = $tweet["text"];
      $tweet_text = preg_replace('/http:\/\/([a-z0-9_\.\-\+\&\!\#\~\/\,]+)/i', '<a href="http://$1" target="_blank">http://$1</a>', $tweet_text); //replace links
      $tweet_text = preg_replace('/@([a-z0-9_]+)/i', '<a href="http://twitter.com/$1" target="_blank">@$1</a>', $tweet_text); //replace users
      echo $tweet_text;
    }

    Cool!

    Plugin Author Liam Gladdy

    @lgladdy

    We’re going to add this in the next release too 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Converting hyperlinks and twitter users in twitter text’ is closed to new replies.