Created
May 14, 2010 21:30
-
-
Save SCRWD/401700 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // jon.posterous.com | |
| // adds google maps search links to postcodes | |
| add_filter( "the_content", "googlemaps_link"); | |
| function googlemaps_link( $x ) | |
| { | |
| // Regexp based on http://regexlib.com/REDetails.aspx?regexp_id=2268 | |
| return preg_replace('@(>[^<]*?)(GIR ?0AA|(?:[A-PR-UWYZ](?:\d|\d{2}|[A-HK-Y]\d|[A-HK-Y]\d\d|\d[A-HJKSTUW]|[A-HK-Y]\d[ABEHMNPRV-Y]))) ?(\d[ABD-HJLNP-UW-Z]{2})([^<]*?<)@i', '\\1<a href="http://maps.google.co.uk/maps?q=\\2+\\3" target="_blank">\\2 \\3</a>\\4', $x); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment