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
Wenn das Neue lockt: Shiny New Object Syndrome im Online-Business
wallpaper-1019588
KiVVON: Der Game-Changer für Content-Creators
wallpaper-1019588
Mexikanische Burrito Bowl mit Pico de Gallo (Vegan)
wallpaper-1019588
The Great Cleric: Serie wird auf Disc erscheinen