Auto-link twitter usernames

Writing ‘@twitter_username’ will automatically linked to the twitter user profile. Somehow the code adds an extra ” to it sorry – you need to remove that.

/**
 * Snippet Name: Auto-link twitter usernames
 * Snippet URL: https://www.wpcustoms.net/snippets/auto-link-twitter-usernames/
 */
  function twtreplace($content) {
	$twtreplace = preg_replace('/([^a-zA-Z0-9-_&])@([0-9a-zA-Z_]+)/',"$1@$2",$content);
	return $twtreplace;
}

add_filter('the_content', 'twtreplace');   
add_filter('comment_text', 'twtreplace'); 

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x