Ticket #8300: leaner_make_url_clickable_cb.diff
| File leaner_make_url_clickable_cb.diff, 1.5 KB (added by filosofo, 4 years ago) |
|---|
-
wp-includes/formatting.php
964 964 * @return string HTML A element with URI address. 965 965 */ 966 966 function _make_url_clickable_cb($matches) { 967 $ret = '';968 967 $url = $matches[2]; 969 968 $url = clean_url($url); 970 969 if ( empty($url) ) 971 970 return $matches[0]; 972 // removed trailing [.,;:] from URL 973 if ( in_array(substr($url, -1), array('.', ',', ';', ':')) === true ) { 974 $ret = substr($url, -1); 975 $url = substr($url, 0, strlen($url)-1); 976 } 977 return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $ret; 971 return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>"; 978 972 } 979 973 980 974 /** … … 1035 1029 function make_clickable($ret) { 1036 1030 $ret = ' ' . $ret; 1037 1031 // in testing, using arrays here was found to be faster 1038 $ret = preg_replace_callback('#( [\s>])([\w]+?://[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_url_clickable_cb', $ret);1032 $ret = preg_replace_callback('#(?<=[\s>])(\()?([\w]+?://(?:[\w\\x80-\\xff\#$%&~/\-=?@\[\](+]|[.,;:](?![\s<])|(?(1)\)(?![\s<])|\)))*)#is', '_make_url_clickable_cb', $ret); 1039 1033 $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_web_ftp_clickable_cb', $ret); 1040 1034 $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret); 1041 1035 // this one is not in an array because we need it to run last, for cleanup of accidental links within links
