dofollow in WordPress ohne Plugin

wordpress logo dofollow in Wordpress ohne PluginDie Diskussion, ob Links in Kommentaren nun dofollow oder nofollow gekennzeichnet sein sollten, ist fast so alt wie die Geschichte mit der Henne und dem Ei. Wir für unseren Teil halten es mit dofollow.

Inzwischen gibt es einige WordPress Plugins, die das Setzten von dofollow unterstützen. Ich für meinen Teil wollte das ganze lieber ohne Plugin umsetzen und bin nach längerer Suche bei CrazyToast fündig geworden. Wer das ganze für Seinen Blog übernehmen möchte, kann folgende code Zeilen in die functions.php einfügen.

/**
 * Enable dofollow from 3 Comment + manual dontfollow 
 * Found it on http://www.crazytoast.de
**/
function strip_nofollow($ret) {
	global $wpdb, $comment;
	$queryString="SELECT COUNT(*) as comments FROM ".$wpdb->comments." WHERE comment_author_url='".$wpdb->escape($comment->comment_author_url)."'";
	$comments_count = $wpdb->get_var($queryString);
	if ($comment->comment_type == "pingback" || $comment->comment_type == "trackback") {
		$ret = str_replace("rel='external nofollow'","rel='external'", $ret);
		return $ret;
	}
	$cmntURL = $comment->comment_author_url;
	$dontfollow_link = stristr($cmntURL, 'dontfollow');
	if ($comments_count >= 3 & $dontfollow_link === FALSE) {
		$ret = str_replace("rel='external nofollow'","rel='external'", $ret);
		return $ret;
	} else {
		$ret = str_ireplace("/dontfollow", "/", $ret);
		return $ret;
	}
}
add_filter('get_comment_author_link', 'strip_nofollow');

wallpaper-1019588
Die richtige Matratze für erholsamen Schlaf
wallpaper-1019588
Indoor-Cycling-Bikes im Vergleich: Widerstand, Einstellung und Training
wallpaper-1019588
Bauchmuskeltrainer im Vergleich: Bauarten, Stabilität und Training
wallpaper-1019588
SunExpress Erfahrungen: Unser Flug XQ716 von Ankara nach München im Test
wallpaper-1019588
Aqua-Jogging-Gürtel: Auftrieb, Passform und Training