You are here

function _shurly_filter_process in ShURLy 7

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

Process callback for shurly filter.

1 string reference to '_shurly_filter_process'
shurly_filter_info in ./shurly.module
Implements hook_filter_info().

File

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

Code

function _shurly_filter_process($text, $filter) {

  // 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);
      if ($short_url['success'] === TRUE) {
        $text = str_replace('"' . $link . '"', '"' . $short_url['shortUrl'] . '"', $text);
      }
    }
  }
  return $text;
}