Ticket #14993: make-clickable-ultimate.14993.diff
File make-clickable-ultimate.14993.diff, 1.6 KB (added by , 13 years ago) |
---|
-
wp-includes/formatting.php
1312 1312 */ 1313 1313 function _make_url_clickable_cb($matches) { 1314 1314 $url = $matches[2]; 1315 $suffix = ''; 1316 1317 /** Include parentheses in the URL only if paired **/ 1318 while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) { 1319 $suffix = strrchr( $url, ')' ) . $suffix; 1320 $url = substr( $url, 0, strrpos( $url, ')' ) ); 1321 } 1315 1322 1316 1323 $url = esc_url($url); 1317 1324 if ( empty($url) ) 1318 1325 return $matches[0]; 1319 1326 1320 return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" ;1327 return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $suffix; 1321 1328 } 1322 1329 1323 1330 /** … … 1379 1386 function make_clickable($ret) { 1380 1387 $ret = ' ' . $ret; 1381 1388 // in testing, using arrays here was found to be faster 1382 $ret = preg_replace_callback('#(?< =[\s>])(\()?([\w]+?://(?:[\w\\x80-\\xff\#$%&~/=?@\[\](!+-]|[.,;:](?![\s<]|(\))?([\s]|$))|(?(1)\)(?![\s<.,;:]|$)|\)))+)#is', '_make_url_clickable_cb', $ret);1389 $ret = preg_replace_callback('#(?<!=[\'"])(?<=[*\')+.,;:!&$\s>])(\()?([\w]+?://(?:[\w\\x80-\\xff\#%~/?@\[\]-]|[\'*(+.,;:!=&$](?![\b\)]|(\))?([\s]|$))|(?(1)\)(?![\s<.,;:]|$)|\)))+)#is', '_make_url_clickable_cb', $ret); 1383 1390 $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret); 1384 1391 $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret); 1385 1392 // this one is not in an array because we need it to run last, for cleanup of accidental links within links