Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Turns all urls into clickable links.
- */
- function _auto_link_urls($text, $href_options = array(), $truncate = false, $truncate_len = 40, $pad = '...')
- {
- $href_options = _tag_options($href_options);
- $callback_function = '
- if (preg_match("/<a\s/i", $matches[1]))
- {
- return $matches[0];
- }
- ';
- if ($truncate)
- {
- $callback_function .= '
- else if (strlen($matches[2].$matches[3]) > '.$truncate_len.')
- {
- return $matches[1].\'<a href="\'.($matches[2] == "www." ? "http://www." : $matches[2]).$matches[3].\'"'.$href_options.'>\'.substr($matches[2].$matches[3], 0, '.$truncate_len.').\''.$pad.'</a>\'.$matches[4];
- }
- ';
- }
- $callback_function .= '
- else
- {
- return $matches[1].\'<a href="\'.($matches[2] == "www." ? "http://www." : $matches[2]).$matches[3].\'"'.$href_options.'>\'.$matches[2].$matches[3].\'</a>\'.$matches[4];
- }
- ';
- return preg_replace_callback(
- SF_AUTO_LINK_RE,
- create_function('$matches', $callback_function),
- $text
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement