WordPress.org

Make WordPress Core

Changeset 10562


Ignore:
Timestamp:
02/12/09 19:52:43 (5 years ago)
Author:
ryan
Message:

Handle links with parens in make_clickable(). Props filosofo. fixes #8300

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/formatting.php

    r10527 r10562  
    11221122 */ 
    11231123function _make_url_clickable_cb($matches) { 
    1124     $ret = ''; 
    11251124    $url = $matches[2]; 
    11261125    $url = clean_url($url); 
    11271126    if ( empty($url) ) 
    11281127        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>"; 
    11351129} 
    11361130 
     
    11931187    $ret = ' ' . $ret; 
    11941188    // 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); 
    11961190    $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_web_ftp_clickable_cb', $ret); 
    11971191    $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.