Skip to content

Instantly share code, notes, and snippets.

@LarkRiseMedia
Created May 18, 2016 12:42
Show Gist options
  • Save LarkRiseMedia/b8c58de9e095893790b17da75b3ffccb to your computer and use it in GitHub Desktop.
Save LarkRiseMedia/b8c58de9e095893790b17da75b3ffccb to your computer and use it in GitHub Desktop.
Remove nofollow attribute in wordpress links and text
/**
* Removes the value ›nofollow‹ from the rel attribute.
*/
function xwp_dofollow($str)
{
$str = preg_replace(
'~<a ([^>]*)\s*(["|\']{1}\w*)\s*nofollow([^>]*)>~U',
'<a ${1}${2}${3}>', $str);
return str_replace(array(' rel=""', " rel=''"), '', $str);
}
remove_filter('pre_comment_content', 'wp_rel_nofollow');
add_filter ('get_comment_author_link', 'xwp_dofollow');
add_filter ('post_comments_link', 'xwp_dofollow');
add_filter ('comment_reply_link', 'xwp_dofollow');
add_filter ('comment_text', 'xwp_dofollow');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment