Make WordPress Core


Ignore:
Timestamp:
01/21/2005 06:24:14 PM (21 years ago)
Author:
saxmatt
Message:

Adding nofollow support

File:
1 edited

Legend:

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

    r2057 r2117  
    480480function make_clickable($ret) {
    481481    $ret = ' ' . $ret . ' ';
    482     $ret = preg_replace("#([\s>])(https?)://([^\s<>{}()]+[^\s.,<>{}()])#i", "$1<a href='$2://$3'>$2://$3</a>", $ret);
    483     $ret = preg_replace("#(\s)www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[^ <>{}()\n\r]*[^., <>{}()\n\r]?)?)#i", "$1<a href='http://www.$2.$3$4'>www.$2.$3$4</a>", $ret);
     482    $ret = preg_replace("#([\s>])(https?)://([^\s<>{}()]+[^\s.,<>{}()])#i", "$1<a href='$2://$3' rel='nofollow'>$2://$3</a>", $ret);
     483    $ret = preg_replace("#(\s)www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[^ <>{}()\n\r]*[^., <>{}()\n\r]?)?)#i", "$1<a href='http://www.$2.$3$4' rel='nofollow'>www.$2.$3$4</a>", $ret);
    484484    $ret = preg_replace("#(\s)([a-z0-9\-_.]+)@([^,< \n\r]+)#i", "$1<a href=\"mailto:$2@$3\">$2@$3</a>", $ret);
    485485    $ret = trim($ret);
    486486    return $ret;
     487}
     488
     489function wp_rel_nofollow( $text ) {
     490    $text = preg_replace('|<a(.+?)>|i', '<a$1 rel="nofollow">', $text);
     491    return $text;
    487492}
    488493
Note: See TracChangeset for help on using the changeset viewer.