The Modified Version of phoogle WordPress plugin - Eliminating the needs of Exec-PHP

Posted by Daniel - 407 Views

phoogle imageThis is the modified version of phoogle plugin for WordPress. phoogle is a WordPress plugin to display Google Map within your post. The Original version requires the installation of Exec-PHP, another wordpress plugin to allow the execution of php script on your post.

I don’t have Exec-PHP installed and I have no intention to install it, so here it is the result of my modification on the original phoogle. Now it doesn’t require Exec-PHP and I am glad I had it done. Usage Example can be found here.

If you are wondering what kind of modifications I did so phoogle can display the Google Map without the Exec-PHP, here is the explanation:

Lets talk about the spec first. I want to insert a tag inside the post that will look like this:

[ gm point = "latitude:longitude:infostring" ]

or

[ gm address = "addressstring:infostring" ]

and then I want the phoogle parses that tag to get the latitude and the longitude then it will render the Map inside the post right on the position of the tag.

To do that I had modified the addGeoPoint() function and addAddress() function then created another function that will parse the tag and then returns the post content with the map rendering code inserted.

This is the modified addGeoPoint() function:

function addGeoPoint($lat,$long,$infoHTML){
global $validPoints;
$pointer = count($validPoints);
$validPoints[$pointer][‘lat’] = $lat;
$validPoints[$pointer][‘long’] = $long;
$validPoints[$pointer][‘htmlMessage’] = $infoHTML;
return showMap();
}

The addAddress() function is too long to be placed here (I don’t like long post). If you’re interested you can just check the sourcecode, it’s all there.

This is the function to parse the tag and the one that will trigger the appropriate function:

function GetLocationThenParseIt($content) {
$content = preg_replace(‘#\[gm point="(.*?):(.*?):(.*?)"\]#sie’, ‘addGeoPoint(\’\\1\’, \’\\2\’, \’\\3\’);’, $content);
$content = preg_replace(‘#\[gm address="(.*?):(.*?)"\]#sie’, ‘addAddress(\’\\1\’, \’\\2\’);’, $content);
return $content;
}

Last step, I put the GetPointThenParseIt($content) function as a filter on the_content section. Don’t forget to check my other post explaining the usage example of phoogle plugin.

Get modifed phoogle plugin (8 KB)

__________________________

Related posts brought to you by Yet Another Related Posts Plugin.

share this article

Digg del.icio.us Netscape StumbleUpon Yahoo! MyWeb reddit Furl Magnolia Newsvine Technorati SlashDot Blinklist Simpy Google
This post as PDFPosted in: Programming - February 2008


Leave a Reply


Options for your comment:





Get my Full Feed Here or you can subscribe to one of my category based feeds below:
Coffee Break

Latest Blog Entries

Categories

Neighbours and Friends

Login Here

Comments - Thanks Guys :)

  • Coarveadvexon: As the call, so the echo :D Coarveadvexon’s last blog post: Ford Kuga 2.5 Turbo
  • Chat: nice thank you very much for this article.
  • a_suliman: thanx for every thing
  • Miss Lunatic: Jaja, it’s a yolk. Thanks for the compliment ;) Miss Lunatic’s last blog post: Pitas y guacamole
  • Miss Lunatic: Thank you! Your style css is awesome. I’m going to start customizing with it. Thank you :D Miss Lunatic’s last blog...