diff options
author | Andrew Dolgov <[email protected]> | 2010-11-26 13:13:09 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2010-11-26 13:13:09 +0300 |
commit | 533c0ea6ec2a833585f50535e6d16594f5371711 (patch) | |
tree | cdfe9e4da0424aae608458b299e20004523decb8 /functions.php | |
parent | 0f41fce845757e0d986be0c00f290ef1da7dc1e1 (diff) |
make plaintext urls in article content clickable
Diffstat (limited to 'functions.php')
-rw-r--r-- | functions.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/functions.php b/functions.php index 1d37727fe..a7e106a9d 100644 --- a/functions.php +++ b/functions.php @@ -3671,6 +3671,8 @@ $res = preg_replace('/<img[^>]+>/is', '', $res); } + $res = rewrite_urls($res); + $charset_hack = '<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> </head>'; @@ -7040,4 +7042,15 @@ } + function rewrite_urls($line) { + global $url_regex; + + $urls = null; + + $result = preg_replace("/((?<!=.)((http|https|ftp)+):\/\/[^ ,!]+)/i", + "<a target=\"_blank\" href=\"\\1\">\\1</a>", $line); + + return $result; + } + ?> |