Nofollow Comment Author Links
Ensures all comment author anchor tags carry rel="nofollow ugc" to prevent link-spam SEO benefit.
PHPby SnipCraft
php
<?php
add_filter( 'get_comment_author_link', 'scseed_nofollow_comment_author_links' );
if ( ! function_exists( 'scseed_nofollow_comment_author_links' ) ) {
function scseed_nofollow_comment_author_links( $link ) {
if ( strpos( $link, '<a ' ) === false ) {
return $link;
}
// Replace or add the rel attribute with nofollow + ugc.
if ( preg_match( '/\srel=["'][^"']*["']/', $link ) ) {
$link = preg_replace( '/\srel=["'][^"']*["']/', ' rel="nofollow ugc"', $link );
} else {
$link = str_replace( '<a ', '<a rel="nofollow ugc" ', $link );
}
return $link;
}
}#comments#links#security#seo