{"id":33085,"date":"2014-11-27T08:35:55","date_gmt":"2014-11-27T08:35:55","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/wp-geonames\/"},"modified":"2025-05-02T09:27:50","modified_gmt":"2025-05-02T09:27:50","slug":"wp-geonames","status":"publish","type":"plugin","link":"https:\/\/pirate.wordpress.org\/plugins\/wp-geonames\/","author":13532811,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.9.2","stable_tag":"trunk","tested":"6.7.5","requires":"3.0.1","requires_php":"5.3","requires_plugins":null,"header_name":"WP GeoNames","header_author":"Jacques Malgrange","header_description":"","assets_banners_color":"3a3b3d","last_updated":"2025-05-02 09:27:50","external_support_url":"","external_repository_url":"","donate_link":"https:\/\/www.paypal.me\/JacquesMalgrange","header_plugin_uri":"","header_author_uri":"https:\/\/www.boiteasite.fr","rating":5,"author_block_rating":0,"active_installs":200,"downloads":15708,"num_ratings":2,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":"2"},"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":1033712,"resolution":"128x128","location":"assets","locale":""}},"assets_banners":{"banner-772x250.png":{"filename":"banner-772x250.png","revision":1033712,"resolution":"772x250","location":"assets","locale":""}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":[],"block_files":[],"assets_screenshots":{"screenshot-1.jpg":{"filename":"screenshot-1.jpg","revision":3286119,"resolution":"1","location":"plugin"},"screenshot-2.jpg":{"filename":"screenshot-2.jpg","revision":3286119,"resolution":"2","location":"plugin"}},"screenshots":{"1":"WP-GeoNames main tab in the Dashboard.","2":"Check your database in Dashboard."},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[248,3524,2591,1625,2289],"plugin_category":[49,59],"plugin_contributors":[86187],"plugin_business_model":[],"class_list":["post-33085","plugin","type-plugin","status-publish","hentry","plugin_tags-city","plugin_tags-data","plugin_tags-geo","plugin_tags-sql","plugin_tags-table","plugin_category-maps-and-location","plugin_category-utilities-and-tools","plugin_contributors-sojahu","plugin_committers-sojahu"],"banners":{"banner":"https:\/\/ps.w.org\/wp-geonames\/assets\/banner-772x250.png?rev=1033712","banner_2x":false,"banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/wp-geonames\/assets\/icon-128x128.png?rev=1033712","icon_2x":false,"generated":false},"screenshots":[{"src":"https:\/\/ps.w.org\/wp-geonames\/trunk\/screenshot-1.jpg?rev=3286119","caption":"WP-GeoNames main tab in the Dashboard."},{"src":"https:\/\/ps.w.org\/wp-geonames\/trunk\/screenshot-2.jpg?rev=3286119","caption":"Check your database in Dashboard."}],"raw_content":"<!--section=description-->\n<p>This lightweight plugin makes it easy to install the millions of GEONAMES Data on your WordPress site.\nIt allows :<\/p>\n\n<ul>\n<li>Install data from one or more file (place &amp; postal code) ;<\/li>\n<li>Choose column to install to avoid excessive enlargement of the base ;<\/li>\n<li>Choose type of data to install (city, park, road...) ;<\/li>\n<li>Remove all the data.<\/li>\n<li>Check data in the database.<\/li>\n<li>Edit and change datas from Dashboard.<\/li>\n<li>Display the places on OpenStreetMap.<\/li>\n<\/ul>\n\n<p>A shortcode is also available to create a city region and country taxonomy.<\/p>\n\n<p>This plugin will give you plenty of ideas to improve the quality of your website.<\/p>\n\n<p>Official <a href=\"http:\/\/www.geonames.org\/\">GeoNames<\/a> website.<\/p>\n\n<h3>1.9.1<\/h3>\n\n<p>05\/12\/2024<\/p>\n\n<ul>\n<li>Fix XSS vulnerability in shortcode attributes<\/li>\n<li>Fix translation issue with WP 6.7<\/li>\n<\/ul>\n\n<h4>1.9<\/h4>\n\n<p>18\/10\/2024 - Fix XSS vulnerability on geoSearch field<\/p>\n\n<h4>1.8<\/h4>\n\n<p>08\/02\/2022<\/p>\n\n<ul>\n<li>Update Leaflet 1.7.1.<\/li>\n<li>Update SumoSelect 3.4.2.<\/li>\n<li>Split admin sidet in a specific file.<\/li>\n<\/ul>\n\n<h4>1.7<\/h4>\n\n<p>21\/03\/2020<\/p>\n\n<ul>\n<li>Fix issue with very long line in Geoname DB.<\/li>\n<li>Add nonce.<\/li>\n<li>Braces style standardisation in the code.<\/li>\n<\/ul>\n\n<h4>1.6<\/h4>\n\n<p>14\/03\/2019 - Add Postal code database.<\/p>\n\n<h4>1.5.1<\/h4>\n\n<p>27\/01\/2018 - Curl used by default if exists in place of File_Get_Content.<\/p>\n\n<h4>1.5<\/h4>\n\n<p>12\/01\/2018 - Add tab to edit and change datas.<\/p>\n\n<h4>1.4<\/h4>\n\n<p>24\/06\/2017<\/p>\n\n<ul>\n<li>Add Taxonomy.<\/li>\n<li>Add shortcode to create taxonomy in the site.<\/li>\n<li>Add template to customize the taxonomy form.<\/li>\n<li>Ability to download multiple files in one click.<\/li>\n<li>Check the database with a taxonomy form and display the place on OpenStreetMap.<\/li>\n<li>Multisite.<\/li>\n<\/ul>\n\n<h4>1.3<\/h4>\n\n<p>09\/10\/2015 - Fix \"Fatal error: Out of memory (allocated xxx) (tried to allocate xxx bytes)\".<\/p>\n\n<p>07\/06\/2016 - 1.3.1 - Fix error when reactivate (header already sent...).<\/p>\n\n<h4>1.2<\/h4>\n\n<p>06\/08\/2015 - Fix installation bug.<\/p>\n\n<h4>1.1<\/h4>\n\n<p>01\/12\/2014 - Add Ajax hook.<\/p>\n\n<h4>1.0<\/h4>\n\n<p>25\/11\/2014 - First stable version.<\/p>\n\n<!--section=installation-->\n<h4>Install and Activate<\/h4>\n\n<ol>\n<li>Unzip the downloaded wp-geonames zip file<\/li>\n<li>Upload the <code>wp-geonames<\/code> folder and its contents into the <code>wp-content\/plugins\/<\/code> directory of your WordPress installation<\/li>\n<li>Activate WP GeoNames from Plugins page<\/li>\n<\/ol>\n\n<h4>Insert GeoNames data<\/h4>\n\n<ol>\n<li>Go to the new tab in Settings : WP GeoNames<\/li>\n<li>Select the GeoNames file you want<\/li>\n<li>Select Columns you want to insert (latitude, longitude, population, elevation...)<\/li>\n<li>Select type of data you want (city, building, lake, mountain...)<\/li>\n<li>Click ADD<\/li>\n<\/ol>\n\n<p>You can insert as many file as you want.<\/p>\n\n<h4>Use<\/h4>\n\n<p>You must use the WordPress tools to get the database. <strong>WPDB is your friend<\/strong>.\nYou can write the code directly in your template or in functions.php of your theme.<\/p>\n\n<p>Name of the table : ($wpdb-&gt;prefix)geonames<\/p>\n\n<p>Names of the columns :<\/p>\n\n<ul>\n<li><code>idwpgn<\/code> (bigint)<\/li>\n<li><code>geonameid<\/code> (bigint)<\/li>\n<li><code>name<\/code> (varchar)<\/li>\n<li><code>asciiname<\/code> (varchar)<\/li>\n<li><code>alternatenames<\/code> (text)<\/li>\n<li><code>latitude<\/code> (decimal)<\/li>\n<li><code>longitude<\/code> (decimal)<\/li>\n<li><code>feature_class<\/code> (char)<\/li>\n<li><code>feature_code<\/code> (varchar)<\/li>\n<li><code>country_code<\/code> (varchar)<\/li>\n<li><code>cc2<\/code> (varchar)<\/li>\n<li><code>admin1_code<\/code> (varchar)<\/li>\n<li><code>admin2_code<\/code> (varchar)<\/li>\n<li><code>admin3_code<\/code> (varchar)<\/li>\n<li><code>admin4_code<\/code> (varchar)<\/li>\n<li><code>population<\/code> (bigint)<\/li>\n<li><code>elevation<\/code> (int)<\/li>\n<li><code>dem<\/code> (smallint)<\/li>\n<li><code>timezone<\/code> (varchar)<\/li>\n<li><code>modification_date<\/code> (date)<\/li>\n<\/ul>\n\n<p>Feature Class &amp; Code <a href=\"http:\/\/www.geonames.org\/export\/codes.html\">here<\/a>.<\/p>\n\n<p>Example : get GPS position for a specific city in a specific country :<\/p>\n\n<pre><code>global $wpdb;\n$s = $wpdb-&gt;get_row(\"SELECT latitude, longitude \n    FROM \".$wpdb-&gt;prefix.\"geonames \n    WHERE name='Paris' and country_code='FR' \");\necho $s-&gt;latitude . \" - \" . $s-&gt;longitude;\n<\/code><\/pre>\n\n<p>Example : 10 most populous cities in Switzerland :<\/p>\n\n<pre><code>global $wpdb;\n$s = $wpdb-&gt;get_results(\"SELECT name, population \n    FROM \".$wpdb-&gt;prefix.\"geonames \n    WHERE country_code='CH' and feature_class='P' \n    ORDER BY population DESC \n    LIMIT 10\");\nforeach($s as $t) {\n    echo $t-&gt;name. \" : \" . $t-&gt;population . \"&lt;br \/&gt;\";\n}\n<\/code><\/pre>\n\n<p>Example : hotels within 40 km from Marbella (ES) :<\/p>\n\n<pre><code>global $wpdb;\n$p = $wpdb-&gt;get_row(\"SELECT latitude, longitude \n    FROM \".$wpdb-&gt;prefix.\"geonames \n    WHERE name='Marbella' and country_code='ES' \");\n$dlat = 40 \/ 1.852 \/ 60;\n$dlon = 40 \/ 1.852 \/ 60 \/ cos($p-&gt;latitude * 0.0174533);\n$s = $wpdb-&gt;get_results(\"SELECT name, latitude, longitude\n    FROM \".$wpdb-&gt;prefix.\"geonames \n    WHERE country_code='ES' and \n        feature_code='HTL' and \n        latitude&lt;\".($p-&gt;latitude+$dlat).\" and\n        latitude&gt;\".($p-&gt;latitude-$dlat).\" and\n        longitude&lt;\".($p-&gt;longitude+$dlon).\" and\n        longitude&gt;\".($p-&gt;longitude-$dlon).\"\n    LIMIT 100\");\nforeach($s as $t) {\n    $d = (floor(sqrt(pow(($p-&gt;latitude-$t-&gt;latitude)*60*1.852,2)+pow(($p-&gt;longitude-$t-&gt;longitude)*60*1.852*cos($p-&gt;latitude * 0.0174533),2))));\n    if($d&lt;=40) echo $t-&gt;name. \" : \" . $d . \" km&lt;br \/&gt;\";\n}\n<\/code><\/pre>\n\n<p>Example : Suggest cities during the typing by the user (like Google search)<\/p>\n\n<p>You must use Ajax action and PHP function with the name <strong>\"wpgeonamesAjax\"<\/strong><\/p>\n\n<p>In your theme, in function.php ; add :\n    function wpgeonamesAjax() {\n        global $wpdb;\n        $s = $wpdb-&gt;get_results(\"SELECT name \n            FROM \".$wpdb-&gt;prefix.\"geonames \n            WHERE country_code='FR' and feature_class='P' and name LIKE '\".strip_tags($_POST[\"city\"]).\"%' \n            ORDER BY name \n            LIMIT 10\");\n        foreach($s as $t) {\n            echo '<\/p>\n\n'.$t-&gt;name.'\n\n<p>';\n        }\n    }<\/p>\n\n<p>In your theme, in the right page ; add :<\/p>\n\n<pre><code>&lt;input id=\"inpCity\" name=\"inpCity\" type=\"text\" onkeyup=\"sugg(this,'&lt;?php echo admin_url('admin-ajax.php'); ?&gt;');\" \/&gt;\n&lt;div class=\"suggCity\" id=\"suggCity\"&gt;&lt;\/div&gt;\n&lt;script&gt;\nfunction sugg(f,g){\n    jQuery(document).ready(function(){\n        jQuery.post(g,{'action':'wpgeonamesAjax','city':f.value},function(r){\n            jQuery('#suggCity').empty();jQuery('#suggCity').append(r.substring(0,r.length-1));\n        });\n    });\n}\n&lt;\/script&gt;\n<\/code><\/pre>\n\n<!--section=changelog-->\n<h4>1.9.2<\/h4>\n\n<p>02\/05\/2025 - Fix translation warning with WP 6.8<\/p>","raw_excerpt":"Allows you to insert all or part of the global GeoNames database in your WordPress base.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/33085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=33085"}],"author":[{"embeddable":true,"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/sojahu"}],"wp:attachment":[{"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=33085"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=33085"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=33085"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=33085"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=33085"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=33085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}