Skip to content

Instantly share code, notes, and snippets.

@PeteMall
Created October 28, 2010 22:52
Show Gist options
  • Save PeteMall/652508 to your computer and use it in GitHub Desktop.
Save PeteMall/652508 to your computer and use it in GitHub Desktop.
WordPress Plugin to converts URLs in the post content to links.
<?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