Changeset 6450
- Timestamp:
- 12/21/2007 03:14:38 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.3/wp-includes/formatting.php
r6183 r6450 623 623 } 624 624 625 function _make_url_clickable_cb($matches) { 626 $url = $matches[2]; 627 $url = clean_url($url); 628 if ( empty($url) ) 629 return $matches[0]; 630 error_log($matches[0], 0); 631 return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>"; 632 } 633 634 function _make_web_ftp_clickable_cb($matches) { 635 $dest = $matches[2]; 636 $dest = 'http://' . $dest; 637 $dest = clean_url($dest); 638 if ( empty($dest) ) 639 return $matches[0]; 640 641 return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>"; 642 } 643 644 function _make_email_clickable_cb($matches) { 645 $email = $matches[2] . '@' . $matches[3]; 646 return $matches[1] . "<a href=\"mailto:$email\">$email</a>"; 647 } 648 625 649 function make_clickable($ret) { 626 650 $ret = ' ' . $ret; 627 651 // in testing, using arrays here was found to be faster 628 $ret = preg_replace( 629 array( 630 '#([\s>])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is', 631 '#([\s>])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is', 632 '#([\s>])([a-z0-9\-_.]+)@([^,< \n\r]+)#i'), 633 array( 634 '$1<a href="$2" rel="nofollow">$2</a>', 635 '$1<a href="http://$2" rel="nofollow">$2</a>', 636 '$1<a href="mailto:$2@$3">$2@$3</a>'),$ret); 652 $ret = preg_replace_callback('#([\s>])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_url_clickable_cb', $ret); 653 $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_web_ftp_clickable_cb', $ret); 654 $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret); 637 655 // this one is not in an array because we need it to run last, for cleanup of accidental links within links 638 656 $ret = preg_replace("#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i", "$1$3</a>", $ret);
Note: See TracChangeset
for help on using the changeset viewer.