Changeset 10562
- Timestamp:
- 02/12/2009 07:52:43 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/formatting.php
r10527 r10562 1122 1122 */ 1123 1123 function _make_url_clickable_cb($matches) { 1124 $ret = '';1125 1124 $url = $matches[2]; 1126 1125 $url = clean_url($url); 1127 1126 if ( empty($url) ) 1128 1127 return $matches[0]; 1129 // removed trailing [.,;:] from URL 1130 if ( in_array(substr($url, -1), array('.', ',', ';', ':')) === true ) { 1131 $ret = substr($url, -1); 1132 $url = substr($url, 0, strlen($url)-1); 1133 } 1134 return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $ret; 1128 return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>"; 1135 1129 } 1136 1130 … … 1193 1187 $ret = ' ' . $ret; 1194 1188 // in testing, using arrays here was found to be faster 1195 $ret = preg_replace_callback('#( [\s>])([\w]+?://[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_url_clickable_cb', $ret);1189 $ret = preg_replace_callback('#(?<=[\s>])(\()?([\w]+?://(?:[\w\\x80-\\xff\#$%&~/\-=?@\[\](+]|[.,;:](?![\s<])|(?(1)\)(?![\s<])|\)))*)#is', '_make_url_clickable_cb', $ret); 1196 1190 $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_web_ftp_clickable_cb', $ret); 1197 1191 $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret);
Note: See TracChangeset
for help on using the changeset viewer.