Created
October 28, 2010 22:52
-
-
Save PeteMall/652508 to your computer and use it in GitHub Desktop.
WordPress Plugin to converts URLs in the post content to links.
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
<?php | |
/* | |
Plugin Name: Linkify URLs | |
*/ | |
add_filter( 'the_content', 'linkify_urls' ); | |
function linkify_urls( $content ){ | |
return preg_replace( '/\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i', '<a href="$0">$0</a>', $content ); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment