{"id":33210,"date":"2014-12-09T11:45:16","date_gmt":"2014-12-09T11:45:16","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/geoswitch\/"},"modified":"2018-07-21T12:49:21","modified_gmt":"2018-07-21T12:49:21","slug":"geoswitch","status":"publish","type":"plugin","link":"https:\/\/pap-aw.wordpress.org\/plugins\/geoswitch\/","author":14003019,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.1.4","stable_tag":"1.1.4","tested":"4.9.29","requires":"3.0","requires_php":"","requires_plugins":"","header_name":"GeoSwitch","header_author":"elialgranti","header_description":"","assets_banners_color":"","last_updated":"2018-07-21 12:49:21","external_support_url":"","external_repository_url":"","donate_link":"https:\/\/www.paypal.com\/cgi-bin\/webscr?cmd=_s-xclick&hosted_button_id=C7QAD2M3L5T6E","header_plugin_uri":"https:\/\/wordpress.org\/plugins\/geoswitch\/","header_author_uri":"","rating":4.7,"author_block_rating":0,"active_installs":40,"downloads":4380,"num_ratings":3,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":{"1.1.4":"<ul>\n<li>Bug fix: Private and reserved IPs are not checked and no longer generate <\/li>\n<li>Added filter hook <code>geoswitch_skip_ip_check<\/code> to bypass the ip check based on \n(Thanks to <a href=\"https:\/\/github.com\/ideag\">Ar\u016bnas Liuiza<\/a> from <a href=\"https:\/\/arunas.co\/\">arunas.co<\/a> for the BugFix and filter hook)<\/li>\n<\/ul>"},"ratings":{"1":0,"2":0,"3":0,"4":"1","5":"2"},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0.0","1.1.0","1.1.1","1.1.2","1.1.3","1.1.4"],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[3528,32114,32113,4175,6341],"plugin_category":[49],"plugin_contributors":[89357],"plugin_business_model":[],"class_list":["post-33210","plugin","type-plugin","status-publish","hentry","plugin_tags-geocode","plugin_tags-geocode-filter","plugin_tags-geocode-switch","plugin_tags-geomarketing","plugin_tags-geotag","plugin_category-maps-and-location","plugin_contributors-elialgranti","plugin_committers-elialgranti"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/geoswitch.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=description-->\n<p>GeoSwitch is a plugin that allows you to change the content of your site based on the location of your client\u2019s IP.\nTo geolocate users based on IP GeoSwitch supports can user either the new the new GeoIP2 <a href=\"https:\/\/www.maxmind.com\">MaxMind<\/a> \ndatabases or GeoIP2 Precision Service.\nMaxMind offers free and paid geolocation databases and the paid GeoIP2 Precision web service, \nthe author of this plugin is not affiliated with MaxMind in any way.<\/p>\n\n<p>The main development of this plugin is in <a href=\"https:\/\/github.com\/elialgranti\/geoswitch\">github<\/a>. \nPlease open a new <a href=\"https:\/\/github.com\/elialgranti\/geoswitch\/issues\">issue<\/a> if you find a bug in this plugin.<\/p>\n\n<p><strong>This plugin uses the <a href=\"http:\/\/maxmind.github.io\/GeoIP2-php\/\">MaxMind PHP library<\/a> which is released under the \nApache License version 2.0<\/strong><\/p>\n\n<h3>Usage<\/h3>\n\n<p>= GeoSwitch Conditional Blocks =<\/p>\n\n<p>GeoSwitch uses two shortcodes [geoswitch] and [geoswitch_case] to create conditional blocks.\nThe [geoswitch] shortcode is used to enclose one or more [geoswitch_case] shortcodes with different conditions. The \n[geoswitch_case] shortcodes enclose content that will be shown if the condition is true.\nThe following example illustrates a GeoSwitch conditional block that will show different contact information depending \non the user\u2019s IP location:<\/p>\n\n<pre><code>[geoswitch]\n[geoswitch_case country_code=\"AU\" state_code=\"NSW\"]New South Wales Office[\/geoswitch_case]\n[geoswitch_case country_code=\"AU\"]Australian Office[\/geoswitch_case]\n[geoswitch_case]International Office[\/geoswitch_case]\n[\/geoswitch]\n<\/code><\/pre>\n\n<p>The above GeoSwitch block will display \u201cNew South Wales Office\u201d to users in New South Wales within Australia, \n\u201cAustralian Office\u201d to other Australian users and \u201cInternational Office\u201d to any other user.<\/p>\n\n<p>The [geoswitch_case] shortcode accepts the following attributes:<\/p>\n\n<ul>\n<li><code>country<\/code> - comma delimited list of country names<\/li>\n<li><code>country_code<\/code> - comma delimited list of country ISO codes<\/li>\n<li><code>state<\/code> - comma delimited list of of state names<\/li>\n<li><code>state_code<\/code> - comma delimited list of state ISO codes<\/li>\n<li><code>city<\/code> - comma delimited list of city names<\/li>\n<li><code>within<\/code>, <code>from<\/code> - This set of attributes is used to test for distances. Within is the distance in kilometers or miles and \nfrom is the centre point represented as \u201clatitude,longitude\u201d in degrees (example [geoswitch within=\u201d10\u201d from=\u201d-33.7167,151.6\u201d]).<\/li>\n<\/ul>\n\n<p>The <code>[geoswitch_case]<\/code> shortcode matches only the attributes specified so:<\/p>\n\n<pre><code>[geoswitch]\n[geoswitch_case city=\"paris\"]You are in Paris![\/geoswitch_case]\n[\/geoswitch]\n<\/code><\/pre>\n\n<p>Will display \"You are in Paris!\" to any user with an IP location in a city named Paris, e.g Paris, France or Paris, Texas, USA.\nA <code>[geoswitch_case]<\/code> shortcode without any attributes always matches and can be used as the last condition in a conditional block \nto show default content.\nContent between [geoswitch_case] blocks can contain any markup including any other shortcodes,  but conditional blocks should \nnot be nested as this is not supported by Wordpress.\nContent between the [geoswitch] and [geoswitch_case] shortcodes should be whitespace but is usually ignored:<\/p>\n\n<pre><code>[geoswitch] *DON\u2019T WRITE HERE*\n[geoswitch_case]...[\/geoswitch_case] *OR HERE*\n[geoswitch_case]...[\/geoswitch_case]\n[\/geoswitch]\n<\/code><\/pre>\n\n<h4>Informational Shortcodes<\/h4>\n\n<p>In addition to the conditional block GeoSwitch offers the following shortcodes to display user information:<\/p>\n\n<ul>\n<li><code>[geoswitch_ip]<\/code> - The user\u2019s IP.<\/li>\n<li><code>[geoswitch_city]<\/code> - The user\u2019s city name.<\/li>\n<li><code>[geoswitch_state]<\/code> - The user\u2019s state name.<\/li>\n<li><code>[geoswitch_state_code]<\/code> - The user\u2019s state ISO code.<\/li>\n<li><code>[geoswitch_country]<\/code> - The user\u2019s country name.<\/li>\n<li><code>[geoswitch_country_code]<\/code> - The user\u2019s country code.<\/li>\n<\/ul>\n\n<p>If the IP of the user cannot be geo located these shortcodes return '?'<\/p>\n\n<h4>Debug Shortcodes<\/h4>\n\n<ul>\n<li><p><code>geoswitch_setip<\/code> - Override the user IP. Affects shortcodes after this one.\nUsage:<\/p>\n\n<p>[geoswitch_case ip='10.0.0.10']<\/p><\/li>\n<\/ul>\n\n<p>For debugging whole websites the user IP can be set globally in the admin settings for the plugin.<\/p>\n\n<h4>Filter Hooks<\/h4>\n\n<p>Geoswitch supports the following filter hooks:\n    geoswitch_skip_ip_check\nAllows to programatically skip the ip check. If the hook callback function returns true the MaxMind libraries are not used to check the IP and the \ndefault content (if configured) will be displayed.\nUsage:<\/p>\n\n<pre><code>function skip_ip_callback( $skipCheck, $userIp ) {\n    if ( some_custom_test($userIp) ) {\n        $skipCheck = true;\n    }\n    return $skipChek;\n}\n\nadd_filter( 'geoswitch_skip_ip_check', 'skip_ip_callback', 10, 2 );\n<\/code><\/pre>\n\n<!--section=installation-->\n<h4>Prerequisites<\/h4>\n\n<p>The Geoswitch plugin uses either MaxMind\u2019s city database or webservice.<\/p>\n\n<ul>\n<li>To use a local database for geocoding you\u2019ll need either the free GeoLite2 city database \n(download from <a href=\"http:\/\/geolite.maxmind.com\/download\/geoip\/database\/GeoLite2-City.mmdb.gz\">here<\/a>) or obtain a license from MaxMind \nfor a GeoIP2 citydatabase. After obtaining the database uncompress it before installation.<\/li>\n<li>To use the webservice you'll need to obtain a user ID and license key for <a href=\"https:\/\/www.maxmind.com\/en\/geoip2-precision-services\">GeoIP2 Precision Services<\/a>.<\/li>\n<\/ul>\n\n<h4>Installation<\/h4>\n\n<ol>\n<li>Copy the Plugin directory to your wordpress plugins directory (usually wp-content\/plugins)<\/li>\n<li>Optionally copy your MaxMind binary database to the database subdirectory inside the plugin root direcory (GeoSwitch\/database). \nThe database should be uncompressed.<\/li>\n<li>In the Wordpress administration settings search for the GeoSwitch configuration page:<\/li>\n<li>Select the type of geocoding service to use (local database or webservice). <\/li>\n<li>Enter the name of the database or the user ID and license key depending on the service you've selected.<\/li>\n<li>Set the units to use for distance calculations (kilometer or miles).<\/li>\n<\/ol>\n\n<p><em>Note: if you use the local database you should update it periodically.<\/em><\/p>\n\n<!--section=faq-->\n<dl>\n<dt>Installation Instructions<\/dt>\n<dd><h4>Prerequisites<\/h4>\n\n<p>The Geoswitch plugin uses either MaxMind\u2019s city database or webservice.<\/p>\n\n<ul>\n<li>To use a local database for geocoding you\u2019ll need either the free GeoLite2 city database \n(download from <a href=\"http:\/\/geolite.maxmind.com\/download\/geoip\/database\/GeoLite2-City.mmdb.gz\">here<\/a>) or obtain a license from MaxMind \nfor a GeoIP2 citydatabase. After obtaining the database uncompress it before installation.<\/li>\n<li>To use the webservice you'll need to obtain a user ID and license key for <a href=\"https:\/\/www.maxmind.com\/en\/geoip2-precision-services\">GeoIP2 Precision Services<\/a>.<\/li>\n<\/ul>\n\n<h4>Installation<\/h4>\n\n<ol>\n<li>Copy the Plugin directory to your wordpress plugins directory (usually wp-content\/plugins)<\/li>\n<li>Optionally copy your MaxMind binary database to the database subdirectory inside the plugin root direcory (GeoSwitch\/database). \nThe database should be uncompressed.<\/li>\n<li>In the Wordpress administration settings search for the GeoSwitch configuration page:<\/li>\n<li>Select the type of geocoding service to use (local database or webservice). <\/li>\n<li>Enter the name of the database or the user ID and license key depending on the service you've selected.<\/li>\n<li>Set the units to use for distance calculations (kilometer or miles).<\/li>\n<\/ol>\n\n<p><em>Note: if you use the local database you should update it periodically.<\/em><\/p><\/dd>\n<dt>Why do I see only question marks instead of my location?<\/dt>\n<dd><p>Your IP was not found in the database. The most usual cause if that your browser and server are behind a NAT and you are \ngetting a private IP not a public one. For debugging purposes you can set the IP used by plug-in in the settings page.<\/p><\/dd>\n<dt>My location is wrong\/partial. How come?<\/dt>\n<dd><p>Geolocation using IP addresses is not entirely accurate. The geolocation relies on a static database of addresses and \ntheir approximate location, not exact location like mobile GPS. \nTo ensure maximum accuracy make sure you have the latest database. Purchasing the non-lite version of the database from MaxMind \nor a license for their service may also yield better information.\nI am not affiliated in any way with MaxMind, so it is up to you to contact them and evaluate their offers for suitability to your purposes.<\/p><\/dd>\n<dt>How do I test other locations?<\/dt>\n<dd><p>You can set the IP used in by the plug-in in the settings page and use Google to search for IPs in the location you are interested \nin (i.e. IP in California) or use the <code>geoswitch_setip<\/code> shortcode.\nDebug overrides for other setting are coming.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.1.4<\/h4>\n\n<ul>\n<li>Bug fix: Private and reserved IPs are not checked and no longer generate <\/li>\n<li>Added filter hook <code>geoswitch_skip_ip_check<\/code> to bypass the ip check based on \n(Thanks to <a href=\"https:\/\/github.com\/ideag\">Ar\u016bnas Liuiza<\/a> from <a href=\"https:\/\/arunas.co\/\">arunas.co<\/a> for the BugFix and filter hook)<\/li>\n<\/ul>\n\n<h4>1.1.3<\/h4>\n\n<p>Bug fix: when IP cannot be found plugin correctly evaluates all cases and uses default empty case (if it exists), instead of not displaying anything.\nImplemented support for comma separated values in geoswitch_case shortcode. Previous version mentioned this feature in the Readme file, but it was not actually implemented.<\/p>\n\n<h4>1.1.2<\/h4>\n\n<p>Error deploying to wordpress. Use version 1.1.3 instead.<\/p>\n\n<h4>1.1.1<\/h4>\n\n<p>Added setting to for user IP for debugging purposes and updated MaxMind Libraries.<\/p>\n\n<h4>1.1.0<\/h4>\n\n<ul>\n<li>Added support for MaxMind GeoIP2 Precision Service (thanks to <a href=\"https:\/\/github.com\/ninjapanzer\">Paul Scarrone<\/a> \nand <a href=\"https:\/\/github.com\/carlcapozza\">carlcapozza<\/a>).<\/li>\n<li>Fixed bug with measurement units. Units were always considered kilometers.<\/li>\n<li>Tested under Wordpress 4.1.<\/li>\n<\/ul>\n\n<h4>1.0.0<\/h4>\n\n<ul>\n<li>Initial release<\/li>\n<\/ul>","raw_excerpt":"GeoSwitch is a plugin that allows you to change the content of your site based on the location of your client\u2019s IP.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/pap-aw.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/33210","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pap-aw.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/pap-aw.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/pap-aw.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=33210"}],"author":[{"embeddable":true,"href":"https:\/\/pap-aw.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/elialgranti"}],"wp:attachment":[{"href":"https:\/\/pap-aw.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=33210"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/pap-aw.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=33210"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/pap-aw.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=33210"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/pap-aw.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=33210"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/pap-aw.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=33210"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/pap-aw.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=33210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}