Make WordPress Core


Ignore:
Timestamp:
03/21/2008 04:29:59 PM (16 years ago)
Author:
markjaquith
Message:

make_clickable() trailing punctuation fixes from neodude. fixes #5081

File:
1 edited

Legend:

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

    r7190 r7452  
    632632
    633633function _make_url_clickable_cb($matches) {
     634    $ret = '';
    634635    $url = $matches[2];
    635636    $url = clean_url($url);
    636637    if ( empty($url) )
    637638        return $matches[0];
    638     return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>";
     639    // removed trailing [.,;:] from URL
     640    if ( in_array(substr($url, -1), array('.', ',', ';', ':')) === true ) {
     641        $ret = substr($url, -1);
     642        $url = substr($url, 0, strlen($url)-1);
     643    }
     644    return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $ret;
    639645}
    640646
    641647function _make_web_ftp_clickable_cb($matches) {
     648    $ret = '';
    642649    $dest = $matches[2];
    643650    $dest = 'http://' . $dest;
     
    645652    if ( empty($dest) )
    646653        return $matches[0];
    647 
    648     return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>";
     654    // removed trailing [,;:] from URL
     655    if ( in_array(substr($dest, -1), array('.', ',', ';', ':')) === true ) {
     656        $ret = substr($dest, -1);
     657        $dest = substr($dest, 0, strlen($dest)-1);
     658    }
     659    return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>" . $ret;
    649660}
    650661
Note: See TracChangeset for help on using the changeset viewer.