Auto-hyperlink URLs

by Scott Reilly (coffee2code)

Automatically hyperlink text URLs and email addresses originally written only as plaintext.

coffee2code.com/wp-plugins/auto-hyperlink-urls/

This plugin seeks to replace and extend WordPress’s default auto-hyperlinking function. This plugin uses different pattern matching expressions than the WordPress default in order to prevent inappropriate adjacent characters from becoming part of the link (as WordPress has improved over the years, nowadays this is just a few edge cases like text links that are braced or bracketed) and it prevents invalid URIs (i.e. blah) from becoming links.

More significantly, this plugin adds configurability to the auto-hyperlinker such that you can configure:

  • If you want text URLs to only show the hostname
  • If you want text URLs truncated after N characters
  • If you want auto-hyperlinked URLs to open in new browser window or not
  • If you want the protocol (i.e. “http://”) to be stripped for displayed links
  • The text to come before and after the link text for truncated links
  • If you want rel=”nofollow” to be supported
  • If you wish to support additional domain extensions not already configured into the plugin

This plugin will recognize any protocol-specified URI (http|https|ftp|news)://, etc, as well as email addresses. It also adds the new ability to recognize Class B domain references (i.e. “somesite.net”, not just domains prepended with “www.”) as valid links (i.e. “wordpress.org” would get auto-hyperlinked)

The following domain extensions (aka TLDs, Top-Level Domains) are recognized by the plugin: com, org, net, gov, edu, mil, us, info, biz, ws, name, mobi, cc, tv. These only comes into play when you have a plaintext URL that does not have an explicit protocol specified. If you need support for additional TLDs, you can add more via the plugin’s admin options page.

This plugin also activates auto-hyperlinking of text links within post/page content.