WordPress.org

Make WordPress Core

Ticket #8300: wp-includes--formatting.php.2.diff

File wp-includes--formatting.php.2.diff, 1.7 KB (added by josephscott, 10 years ago)
  • wp-includes/formatting.php

     
    964964 * @return string HTML A element with URI address.
    965965 */
    966966function _make_url_clickable_cb($matches) {
     967        // If the URL string started with a ( and ended with a ) then
     968        // don't include the trailing ) as part of the URL.
     969        $last_char = '';
     970        if( $matches[1] == '(' ) {
     971                if( substr( $matches[2], -1 ) == ')' ) {
     972                        $matches[2] = substr( $matches[2], 0, -1 );
     973                        $last_char = ')';
     974                }
     975        }
     976
    967977        $ret = '';
    968978        $url = $matches[2];
    969979        $url = clean_url($url);
     
    974984                $ret = substr($url, -1);
    975985                $url = substr($url, 0, strlen($url)-1);
    976986        }
    977         return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $ret;
     987        return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $ret . $last_char;
    978988}
    979989
    980990/**
     
    10351045function make_clickable($ret) {
    10361046        $ret = ' ' . $ret;
    10371047        // in testing, using arrays here was found to be faster
    1038         $ret = preg_replace_callback('#([\s>])([\w]+?://[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_url_clickable_cb', $ret);
     1048        $ret = preg_replace_callback('#([\s>(])([\w]+?://[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]()+]*)#is', '_make_url_clickable_cb', $ret);
    10391049        $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_web_ftp_clickable_cb', $ret);
    10401050        $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret);
    10411051        // this one is not in an array because we need it to run last, for cleanup of accidental links within links