Finding URLs in text and transforming them into links is handy tool to have around. WordPress does this via the make_clickable function. I extracted this into a stand alone PHP class called MakeItLink.
MakeItLink – Detecting URLs In Text And Making Them Links is the original version of the code and initial blog post.
require dirname( __FILE__ ) . '/makeitlink.php'; $example = 'My home page is at http://josephscott.org/'; $with_links = MakeItLink::transform( $example ); echo $with_links;
0.2.0 – 26 Oct 2009
- Sync with WordPress 2.9 make_clickable()