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
Im Bann des Mitternachtslichts: Ein Abenteuer in Finnisch-Lappland
wallpaper-1019588
[Comic] The Boys – Pocket Edition [6]
wallpaper-1019588
Android Neustart: Dein ultimativer Guide für Neustarts, Fehlerbehebung und aktuelle News
wallpaper-1019588
Was ist eine Weltreise eigentlich?