Preventing repeated 'rel="nofollow"' (3 posts)

  1. agharbeia
    Posted 8 years ago #

    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.


  2. Austin Matzko
    Posted 8 years ago #

    Yes, this is a known bug that is fixed in the current trunk version of WordPress.

  3. agharbeia
    Posted 8 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic