You are here

function _shurly_filter_process in ShURLy 6

Same name and namespace in other branches
  1. 7 shurly.module \_shurly_filter_process()

Process callback for shurly filter.

1 call to _shurly_filter_process()
shurly_filter in ./shurly.module
Implementation of hook_filter().

File

./shurly.module, line 992
description http://www.youtube.com/watch?v=Qo7qoonzTCE

Code

function _shurly_filter_process($text) {

  // Find all a tags containing a full URL.
  preg_match_all('/<a[^>]*href="(http[^"]*)"[^>]*>/i', $text, $links);
  if (!empty($links)) {
    $links = $links[1];
    foreach ($links as $key => $link) {
      $short_url = shurly_shorten($link);
      $text = str_replace('"' . $link . '"', '"' . $short_url['shortUrl'] . '"', $text);
    }
  }
  return $text;
}