Skip to content

Instantly share code, notes, and snippets.

// 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);
}
// jon.posterous.com
// makes the month a short month e.g. April becomes Apr
add_filter( "get_archives_link", "customarchives_shortmonth");
function customarchives_shortmonth( $x )
{
return preg_replace('@((janu|febru)ary|march|april|may|june|july|august|(septem|octo|novem|decem)ber)@ie', "substr('\\1', 0, 3)", $x);
}
// jon.posterous.com
// adds current class to archives link
add_filter( "get_archives_link", "customarchives_link");
function customarchives_link( $x )
{
$url = preg_match('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.-]*(\?\S+)?)?)?)@i', $x, $matches);
return $matches[4] == $_SERVER['REQUEST_URI'] ? preg_replace('@<li@', '<li class="current_page_item"', $x) : $x;
}
void You(object truth, EventArgs e)
{
throw new NotImplementedException();
} // #moviesincode
@SCRWD
SCRWD / Jchjr.markdown
Created August 9, 2014 22:41
A Pen by Jon B.