Created
May 18, 2016 12:42
-
-
Save MeonValleyWeb/b8c58de9e095893790b17da75b3ffccb to your computer and use it in GitHub Desktop.
Remove nofollow attribute in wordpress links and text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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