[wp-hackers] Nofollow fixes

Kimmo Suominen kim at tac.nyc.ny.us
Mon Feb 14 21:23:34 GMT 2005


Hi!

I'd file this in mosquito, if I would be able to activate my account...
:-)

While creating a simple plugin to allow disabling of rel="nofollow"
attributes, I noticed a couple of cases of hard-coded nofollows.  I
changed them to use the wp_rel_nofollow filter instead (diffs below).

In case anyone is interetested, the DoFollow plugin is at

http://kimmo.suominen.com/sw/dofollow/

Regards,
+ Kim
-- 
<A HREF="http://kimmo.suominen.com/">Kimmo Suominen</A>


Index: wp-includes/comment-functions.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/comment-functions.php,v
retrieving revision 1.29
diff -u -r1.29 comment-functions.php
--- wp-includes/comment-functions.php	14 Feb 2005 09:17:23 -0000	1.29
+++ wp-includes/comment-functions.php	14 Feb 2005 17:20:30 -0000
@@ -170,7 +170,7 @@
 	if ( empty( $url ) )
 		$return = $author;
 	else
-		$return = "<a href='$url' rel='external nofollow'>$author</a>";
+		$return = "<a href='$url' rel='external'>$author</a>";
 	return apply_filters('get_comment_author_link', $return);
 }
 
Index: wp-includes/default-filters.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/default-filters.php,v
retrieving revision 1.1
diff -u -r1.1 default-filters.php
--- wp-includes/default-filters.php	7 Feb 2005 07:46:40 -0000	1.1
+++ wp-includes/default-filters.php	14 Feb 2005 17:20:30 -0000
@@ -34,6 +35,8 @@
 add_filter('pre_comment_author_email', 'wp_filter_kses');
 add_filter('pre_comment_author_url', 'wp_filter_kses');
 
+add_filter('get_comment_author_link', 'wp_rel_nofollow', 15);
+
 // Default filters for these functions
 add_filter('comment_author', 'wptexturize');
 add_filter('comment_author', 'convert_chars');
@@ -45,6 +48,7 @@
 
 add_filter('comment_text', 'convert_chars');
 add_filter('comment_text', 'make_clickable');
+add_filter('comment_text', 'wp_rel_nofollow', 15);
 add_filter('comment_text', 'wpautop', 30);
 add_filter('comment_text', 'convert_smilies', 20);
 
Index: wp-includes/functions-formatting.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/functions-formatting.php,v
retrieving revision 1.67
diff -u -r1.67 functions-formatting.php
--- wp-includes/functions-formatting.php	11 Feb 2005 00:55:01 -0000	1.67
+++ wp-includes/functions-formatting.php	14 Feb 2005 17:20:30 -0000
@@ -481,8 +481,8 @@
 
 function make_clickable($ret) {
 	$ret = ' ' . $ret . ' ';
-	$ret = preg_replace("#([\s>])(https?)://([^\s<>{}()]+[^\s.,<>{}()])#i", "$1<a href='$2://$3' rel='nofollow'>$2://$3</a>", $ret);
-	$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);
+	$ret = preg_replace("#([\s>])(https?)://([^\s<>{}()]+[^\s.,<>{}()])#i", "$1<a href='$2://$3'>$2://$3</a>", $ret);
+	$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);
 	$ret = preg_replace("#(\s)([a-z0-9\-_.]+)@([^,< \n\r]+)#i", "$1<a href=\"mailto:$2@$3\">$2@$3</a>", $ret);
 	$ret = trim($ret);
 	return $ret;


More information about the hackers mailing list