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