IP 2 Nation Location Wordpress Plugin
I modified the wordpress plugin called IP 2 Nation in order to retrieve 2 important values of the ip2nation database used in the generation of maps: the Longitude and Latitude of the country based on the IP. This plugin is based on the version 1.1 by Ozh and Per Gustafsson.
This is my first plugin update for Wordpress, I hope it is useful. I am planning to use it to generate another plugin for create a Google Map based on the IP addresses of the comments of a user.
Any suggestion, is welcomed, thank you.
Set up the MySQL database (as mentioned on Ozh website)
First of all, go to ip2nation and download the .sql file (I’m not mirroring it because it is updated from times to times, so get the latest one) This .sql file will create two tables, ip2nation and ip2nationCountries.
Tips : first, install PHPMyAdmin on your website. This is a great interface for anything you can do with MySQL databases. Once it’s done, look for the “SQL” link in the menu : you will be prompted for a .sql file, for example the one you just downloaded on your computer. It will set up and populate the required tables.
Download the plugin
Click in the file and save it in your preferred drive. You will need a compression utility like WinZip to uncompress the zip file of the plugin; then drop the file “wp_vz_ip2nationlocation.php” in your plugin directory (yourblog/wp-content/plugins). Then activate the plugin (in the admin interface).
Note: If you have the previous version of IP 2 Nation you first need to deactivate it and delete the file “wp_ozh_ip2nation.php” of your wp-content/plugins directory.
Use the plugin
The use of this plugin is exactly the same as mentioned by Ozh in the original plugin page, I only added 2 extra functions to obtain the Latitude and Longitude of a country:
- getCountryLat() : return the numeric Latitude of the country.
- getCountryLon() : return the numeric Longitude of the country.
Both functions have two optional parameters:
- $display : default is 0, means that you don’t want to print the result, just to return it. 1 to print it.
- $ip : default to the remote ip address ($_SERVER[’REMOTE_ADDR’]) .
As mentioned it implements exactly the two other functions defined by the original plugin: wp_ohz_getCountryName() and wp_ohz_getCountryCode(), you can see the definition and examples of these two function here.
Examples of use
Here is a simple example of using the two new functions implemented with the default parameters:
< ?php
echo “Your country Longitude is “.getCountryLon();
echo “Your country Latitude is “.getCountryLat();
?>
Another example with different parameters, where the Longitude and Latitude is printed and the IP is obtained from the comment author IP in Wordpress:
< ?php comment_author_link() ?>
from Longitude < ?php getCountryLon(1,$comment->comment_author_IP) ?>
and Latitude < ?php getCountryLat(1,$comment->comment_author_IP) ?>
Notes
If you need support, please be as simple, consistent and accurate as possible. If you need to post lines of code, please upload it somewhere and give me the information to check the code. I can not give support of anything in relation with ip2nation or the original IP 2 Nation Wordpress plugin.
Posted by Vadim Zendejas
05.Apr.07
You can leave a response, or trackback from your own site.
22 Responses to “IP 2 Nation Location Wordpress Plugin”
4 pingbacks and 1 trackbacks to this post.
- ManyakHost // Tasarım » Post Topic » Wordpress Eklenti Sürümleri »» December 25th, 2007 at 1:24 am from Germany
- IP 2 Nation Location | わーどぷれすっ! »» July 23rd, 2007 at 7:02 pm from United States
- WP Plugins DB » Blog Archive » IP 2 Nation Longitude and Latitude Update »» May 20th, 2007 at 4:59 pm from United States
- WP Plugins April 8, 2007 « Blogtology »» April 9th, 2007 at 3:37 am from United States
- Nicky's blog »» April 6th, 2007 at 7:34 pm from China
Leave a Reply
IP 2 Nation Location Wordpress Plugin
I modified the wordpress plugin called IP 2 Nation in order to retrieve 2 important values of the ip2nation database used in the generation of maps: the Longitude and Latitude of the country based on the IP. This plugin is based on the version 1.1 by Ozh and Per Gustafsson.
This is my first plugin update for Wordpress, I hope it is useful. I am planning to use it to generate another plugin for create a Google Map based on the IP addresses of the comments of a user.
Any suggestion, is welcomed, thank you.
Set up the MySQL database (as mentioned on Ozh website)
First of all, go to ip2nation and download the .sql file (I’m not mirroring it because it is updated from times to times, so get the latest one) This .sql file will create two tables, ip2nation and ip2nationCountries.
Tips : first, install PHPMyAdmin on your website. This is a great interface for anything you can do with MySQL databases. Once it’s done, look for the “SQL” link in the menu : you will be prompted for a .sql file, for example the one you just downloaded on your computer. It will set up and populate the required tables.
Download the plugin
Click in the file and save it in your preferred drive. You will need a compression utility like WinZip to uncompress the zip file of the plugin; then drop the file “wp_vz_ip2nationlocation.php” in your plugin directory (yourblog/wp-content/plugins). Then activate the plugin (in the admin interface).
Note: If you have the previous version of IP 2 Nation you first need to deactivate it and delete the file “wp_ozh_ip2nation.php” of your wp-content/plugins directory.
Use the plugin
The use of this plugin is exactly the same as mentioned by Ozh in the original plugin page, I only added 2 extra functions to obtain the Latitude and Longitude of a country:
- getCountryLat() : return the numeric Latitude of the country.
- getCountryLon() : return the numeric Longitude of the country.
Both functions have two optional parameters:
- $display : default is 0, means that you don’t want to print the result, just to return it. 1 to print it.
- $ip : default to the remote ip address ($_SERVER[’REMOTE_ADDR’]) .
As mentioned it implements exactly the two other functions defined by the original plugin: wp_ohz_getCountryName() and wp_ohz_getCountryCode(), you can see the definition and examples of these two function here.
Examples of use
Here is a simple example of using the two new functions implemented with the default parameters:
< ?php
echo “Your country Longitude is “.getCountryLon();
echo “Your country Latitude is “.getCountryLat();
?>
Another example with different parameters, where the Longitude and Latitude is printed and the IP is obtained from the comment author IP in Wordpress:
< ?php comment_author_link() ?>
from Longitude < ?php getCountryLon(1,$comment->comment_author_IP) ?>
and Latitude < ?php getCountryLat(1,$comment->comment_author_IP) ?>
Notes
If you need support, please be as simple, consistent and accurate as possible. If you need to post lines of code, please upload it somewhere and give me the information to check the code. I can not give support of anything in relation with ip2nation or the original IP 2 Nation Wordpress plugin.
Posted by Vadim Zendejas
05.Apr.07
You can leave a response, or trackback from your own site.
22 Responses to “IP 2 Nation Location Wordpress Plugin”
-
Andrei Gravura Says:
July 29th, 2010 at 6:05 pm from RomaniaThat car looks awesome. I would pay anything to own it. Has anyone made any bids on it yet?:D Sow i want 2 o them if its possible
-
Classifieds Says:
July 28th, 2010 at 8:54 pm from United StatesI really enjoyed reading this article. I didn’t know any of these! So glad to have found this.
-
Kristen Says:
July 14th, 2010 at 1:46 pm from United StatesHi there-
Can this be used to call post author information instead of (or in addition to) comment authors?
Thanks and best wishes,
Kristen -
Antione Apolo Says:
June 18th, 2010 at 4:16 pm from United StatesCool! But I alternative thoughts personally. But I unreservedly support your right to believe what you like.
-
Roma Guerreiro Says:
May 3rd, 2010 at 11:42 pm from RussiaHeartfelt thanks to
-
Shonari Says:
February 10th, 2008 at 11:12 pm from United StatesCan the plugin be mdified to pull a category based on location?
ie the plugin will read the visitors latitude and longtitude and based on results will call for a category.
-
Ambo Says:
February 7th, 2008 at 6:25 pm from Philippinesopen sesame! just testing. Thanks for this wonderful plugin.:-)
-
sven Says:
January 12th, 2008 at 8:44 pm from JapanOn my blog it always shows the flag of the country where my webhost is located (Germany), but never the actual poster’s country (Japan in my case)…
Anyone knows how to solve this?
-
impropio Says:
October 8th, 2007 at 2:54 pm from Venezuelaprueba
-
- Says:
June 20th, 2007 at 4:19 pm from Mexicohello
-
Ugg Boots Says:
June 4th, 2007 at 4:44 pm from Great Britain (UK)Finest Ugg Boots anywhere.
-
Vadim Zendejas Says:
April 26th, 2007 at 4:21 pm from JapanWelcome evitc… always is a pleasure to help, my best regards!
-
evitc Says:
April 26th, 2007 at 4:13 pm from ChinaHi vadimz! I have fixed it and now it works correctly. Thank you again, my sincere friend!
-
evitc Says:
April 26th, 2007 at 1:53 pm from ChinaHello vadimz, I have updated my database to the latest but still the wrong display.:-(
-
Vadim Zendejas Says:
April 26th, 2007 at 1:20 pm from JapanYeah, I see that the plug-in is displaying wrong the information, but is not a problem of the plug-in, is because your ip2nation database is not updated, I recommend to you that you download the latest version of it from http://www.ip2nation.com/
Please install it and check if now the location is correct.
I think the information of the browser and the OS is correct, if u don\’t want that this information appears, then you need to modify your comment template and delete that part.Please let me know about the results after upgrading the ip2nation database… Thanks.
-
evitc Says:
April 26th, 2007 at 12:45 pm from ChinaVadizm, please help me. Wherever the commenter is, the plugin always display my location and my browser and OS info.
-
evitc Says:
April 25th, 2007 at 11:12 pm from ChinaI see it! Great Job! Thank you, I would like to install it for my weblog.
-
evitc Says:
April 25th, 2007 at 11:10 pm from Chinaleave a comment and have a look ^_^
-
Vadim Zendejas Says:
April 7th, 2007 at 4:00 pm from JapanHello marc, as you can see in the comment that you posted the flag of your country is displayed correctly. Anyway, the ip2nation database is not 100% accurate, and is not updated every day, so in some cases the IP address that your internet provider assigns to you can be misclassified. Any way, try to be updated with the most recent version of the ip2nation database.
-
marc Says:
April 7th, 2007 at 3:49 pm from Philippinestesting my flag.
Using Oz’s ver and a change to DSL for whatever reason caused my flag to shift from the correct Philippines to the French Flag.
Here goes.
-
Vadim Zendejas Says:
April 6th, 2007 at 8:50 pm from JapanAgain Nicky… if I understand, (is not that I speak Chinese, but Google Language Tools always help) I update the IP 2 Nation by Ozh just in order to create my new plugin “Comments on a Map” that I posted today here in my web page… so check it, maybe you will like it. Thanks.
-
Vadim Zendejas Says:
April 6th, 2007 at 8:21 pm from JapanThank you Nicky… can you post in English please?
4 pingbacks and 1 trackbacks to this post.
- ManyakHost // Tasarım » Post Topic » Wordpress Eklenti Sürümleri »» December 25th, 2007 at 1:24 am from Germany
- IP 2 Nation Location | わーどぷれすっ! »» July 23rd, 2007 at 7:02 pm from United States
- WP Plugins DB » Blog Archive » IP 2 Nation Longitude and Latitude Update »» May 20th, 2007 at 4:59 pm from United States
- WP Plugins April 8, 2007 « Blogtology »» April 9th, 2007 at 3:37 am from United States
- Nicky's blog »» April 6th, 2007 at 7:34 pm from China









July 29th, 2010 at 6:05 pm from Romania
That car looks awesome. I would pay anything to own it. Has anyone made any bids on it yet?:D Sow i want 2 o them if its possible
July 28th, 2010 at 8:54 pm from United States
I really enjoyed reading this article. I didn’t know any of these! So glad to have found this.
July 14th, 2010 at 1:46 pm from United States
Hi there-
Can this be used to call post author information instead of (or in addition to) comment authors?
Thanks and best wishes,
Kristen
June 18th, 2010 at 4:16 pm from United States
Cool! But I alternative thoughts personally. But I unreservedly support your right to believe what you like.
May 3rd, 2010 at 11:42 pm from Russia
Heartfelt thanks to
February 10th, 2008 at 11:12 pm from United States
Can the plugin be mdified to pull a category based on location?
ie the plugin will read the visitors latitude and longtitude and based on results will call for a category.
February 7th, 2008 at 6:25 pm from Philippines
open sesame! just testing. Thanks for this wonderful plugin.:-)
January 12th, 2008 at 8:44 pm from Japan
On my blog it always shows the flag of the country where my webhost is located (Germany), but never the actual poster’s country (Japan in my case)…
Anyone knows how to solve this?
October 8th, 2007 at 2:54 pm from Venezuela
prueba
June 20th, 2007 at 4:19 pm from Mexico
hello
June 4th, 2007 at 4:44 pm from Great Britain (UK)
Finest Ugg Boots anywhere.
April 26th, 2007 at 4:21 pm from Japan
Welcome evitc… always is a pleasure to help, my best regards!
April 26th, 2007 at 4:13 pm from China
Hi vadimz! I have fixed it and now it works correctly. Thank you again, my sincere friend!
April 26th, 2007 at 1:53 pm from China
Hello vadimz, I have updated my database to the latest but still the wrong display.:-(
April 26th, 2007 at 1:20 pm from Japan
Yeah, I see that the plug-in is displaying wrong the information, but is not a problem of the plug-in, is because your ip2nation database is not updated, I recommend to you that you download the latest version of it from http://www.ip2nation.com/
Please install it and check if now the location is correct.
I think the information of the browser and the OS is correct, if u don\’t want that this information appears, then you need to modify your comment template and delete that part.
Please let me know about the results after upgrading the ip2nation database… Thanks.
April 26th, 2007 at 12:45 pm from China
Vadizm, please help me. Wherever the commenter is, the plugin always display my location and my browser and OS info.
April 25th, 2007 at 11:12 pm from China
I see it! Great Job! Thank you, I would like to install it for my weblog.
April 25th, 2007 at 11:10 pm from China
leave a comment and have a look ^_^
April 7th, 2007 at 4:00 pm from Japan
Hello marc, as you can see in the comment that you posted the flag of your country is displayed correctly. Anyway, the ip2nation database is not 100% accurate, and is not updated every day, so in some cases the IP address that your internet provider assigns to you can be misclassified. Any way, try to be updated with the most recent version of the ip2nation database.
April 7th, 2007 at 3:49 pm from Philippines
testing my flag.
Using Oz’s ver and a change to DSL for whatever reason caused my flag to shift from the correct Philippines to the French Flag.
Here goes.
April 6th, 2007 at 8:50 pm from Japan
Again Nicky… if I understand, (is not that I speak Chinese, but Google Language Tools always help) I update the IP 2 Nation by Ozh just in order to create my new plugin “Comments on a Map” that I posted today here in my web page… so check it, maybe you will like it. Thanks.
April 6th, 2007 at 8:21 pm from Japan
Thank you Nicky… can you post in English please?