]> git.wh0rd.org - tt-rss.git/blobdiff - functions.php
make plaintext urls in article content clickable
[tt-rss.git] / functions.php
index 1d37727fe0ab4ca54fba94e0f0bd0bf3b77ae4d2..a7e106a9d8400ccd149fd391d1ca2375026cc1f5 100644 (file)
                        $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>';
 
        }
 
+       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;
+       }
+
 ?>