Support » Plugins » Preventing repeated ‘rel=”nofollow”‘

  • Adding the if-statement below before line 594 of functions-formatting.php 2.0.4, will prevent the filter from adding multiple ‘rel=”nofollow”‘ to links in comments when a comment is edited, which is the current behaviour.

    if (preg_match('/rel=\"nofollow\"/i', $text) == 0)

    The function wp_rel_nofollow( $text ), will be as follows:

    function wp_rel_nofollow( $text ) {
    if (preg_match('/rel=\"nofollow\"/i', $text) == 0)
    $text = preg_replace('|<a (.+?)>|i', '<a $1 rel="nofollow">', $text);
    return $text;
    }

    Repeated rel=”nofollow” will not break your blog in any way. All it does is cause an XHTML validator to throw a warning.

    Regards,

Viewing 2 replies - 1 through 2 (of 2 total)
  • Yes, this is a known bug that is fixed in the current trunk version of WordPress.

    One problem with my approach is that if there’s one nofollow in the comment, no more will be added. This is what I just discovered.

    The apprach suggested on Trac is better.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Preventing repeated ‘rel=”nofollow”‘’ is closed to new replies.