$display_lat $display_lon [GPX | LOC]"; } /** * Coordinate a text string. * * @param text Original text to be coordinated. * @return Coordinated text. */ function coordinate($text) { $title = 'Coordinates'; $link = "http://drbacchus.com/cgi-bin/coords.pl?"; $callback = create_function('$match', "return Coordinates::addLinkCallback(".'$match'.", '$link', '$title');"); $text = preg_split("/(|||<.+?>)/ms", $text, -1, PREG_SPLIT_DELIM_CAPTURE); $newtext = array(); foreach ($text as $chunk) { if (!preg_match('/<.*>/', $chunk)) { $chunk = Coordinates::addLink($chunk, $callback); } $newtext[] = $chunk; } return implode('', $newtext); } } // If 'add_filter' function exists, then we assume that we are initialised as // a WordPress plugin. We will try to create a new global scope function, and // add it to filter main/comment content. if (function_exists('add_filter')) { function __coordinate($content) { return Coordinates::coordinate($content); } add_filter('the_content', '__coordinate'); add_filter('comment_text', '__coordinate'); } ?>