[WordPress] 外掛分享: Geocode Switch

前言介紹

  • 這款 WordPress 外掛「Geocode Switch」是 2014-12-08 上架。
  • 目前有 40 個安裝啟用數。
  • 上一次更新是 2018-07-21,距離現在已有 2777 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 3.0 以上版本才可以安裝。
  • 有 3 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

elialgranti |

外掛標籤

geotag | geocode | geomarketing | geocode filter | geocode switch |

內容簡介

GeoSwitch 是一款外掛,它可以根據客戶端 IP 的位置更改您網站的內容。
要基於 IP 來定位用戶,GeoSwitch 可以使用新的 GeoIP2 MaxMind 資料庫或 GeoIP2 精確服務。
MaxMind 提供免費和付費的地理位置資料庫以及付費的 GeoIP2 精確網路服務,
本外掛的作者並不與 MaxMind 有任何關係。

本外掛的主要開發在 github 上。
如果您在此外掛中發現錯誤,請開啟新的問題。

此外掛使用的是 MaxMind PHP library ,該函式庫已釋出
Apache License version 2.0

用法

= GeoSwitch 條件區塊 =

GeoSwitch 使用兩個短代碼 [geoswitch] 和 [geoswitch_case] 創建條件區塊。
[geoswitch] 短代碼用於將一個或多個 [geoswitch_case] 短代碼與不同的條件包含在內。[geoswitch_case] 短代碼包含將顯示的內容,如果條件為真,則會顯示該內容。
下面的示例說明了一個 GeoSwitch 條件區塊,將基於用戶的 IP 位置,顯示不同的聯繫人信息:

[geoswitch]
[geoswitch_case country_code="AU" state_code="NSW"]新南威爾士辦事處[/geoswitch_case]
[geoswitch_case country_code="AU"]澳大利亞辦事處[/geoswitch_case]
[geoswitch_case]國際辦事處[/geoswitch_case]
[/geoswitch]

以上 GeoSwitch 區塊將向位於澳大利亞新南威爾士的用戶顯示“新南威爾士辦事處”,向其他澳大利亞用戶顯示“澳大利亞辦事處”,向任何其他用戶顯示“國際辦事處”。

[geoswitch_case] 短代碼接受以下屬性:

country – 國家名稱的逗號分隔列表
country_code – 國家 ISO 代碼的逗號分隔列表
state – 州名稱的逗號分隔列表
state_codigoode – 州 ISO 代碼的逗號分隔列表
city – 城市名稱的逗號分隔列表
within,from – 此組屬性用於測試距離。 Within 是公里或英里數的距離,
from 是用度表示的中心點(例如 [geoswitch within=”10” from=”-33.7167,151.6”])。

只有指定的屬性才能與 [geoswitch_case] 短代碼匹配,因此:

[geoswitch]
[geoswitch_case city="paris"]您在巴黎![/geoswitch_case]
[/geoswitch]

將向在名為巴黎的城市中定位的任何用戶顯示“您在巴黎!”(例如法國的巴黎或美國得克薩斯州的巴黎)。
一個沒有任何屬性的 [geoswitch_case] 短代碼始終匹配,可以用作條件塊中的最後一個條件,以顯示預設內容。
在 [geoswitch_case] 塊之間的內容可以包含任何標記,包括任何其他短碼,但是 WordPress 不支持嵌套的條件塊。
[geoswitch] 和 [geoswitch_case] 短碼之間的內容應該是空格,但通常會被忽略:

[geoswitch] *DO NOT WRITE HERE*
[geoswitch_case]...[/geoswitch_case] *或在這裡*
[geoswitch_case]...[/geoswitch

原文外掛簡介

GeoSwitch is a plugin that allows you to change the content of your site based on the location of your client’s IP.
To geolocate users based on IP GeoSwitch supports can user either the new the new GeoIP2 MaxMind
databases or GeoIP2 Precision Service.
MaxMind offers free and paid geolocation databases and the paid GeoIP2 Precision web service,
the author of this plugin is not affiliated with MaxMind in any way.
The main development of this plugin is in github.
Please open a new issue if you find a bug in this plugin.
This plugin uses the MaxMind PHP library which is released under the
Apache License version 2.0
Usage
= GeoSwitch Conditional Blocks =
GeoSwitch uses two shortcodes [geoswitch] and [geoswitch_case] to create conditional blocks.
The [geoswitch] shortcode is used to enclose one or more [geoswitch_case] shortcodes with different conditions. The
[geoswitch_case] shortcodes enclose content that will be shown if the condition is true.
The following example illustrates a GeoSwitch conditional block that will show different contact information depending
on the user’s IP location:
[geoswitch]
[geoswitch_case country_code="AU" state_code="NSW"]New South Wales Office[/geoswitch_case]
[geoswitch_case country_code="AU"]Australian Office[/geoswitch_case]
[geoswitch_case]International Office[/geoswitch_case]
[/geoswitch]

The above GeoSwitch block will display “New South Wales Office” to users in New South Wales within Australia,
“Australian Office” to other Australian users and “International Office” to any other user.
The [geoswitch_case] shortcode accepts the following attributes:

country – comma delimited list of country names
country_code – comma delimited list of country ISO codes
state – comma delimited list of of state names
state_code – comma delimited list of state ISO codes
city – comma delimited list of city names
within, from – This set of attributes is used to test for distances. Within is the distance in kilometers or miles and
from is the centre point represented as “latitude,longitude” in degrees (example [geoswitch within=”10” from=”-33.7167,151.6”]).

The [geoswitch_case] shortcode matches only the attributes specified so:
[geoswitch]
[geoswitch_case city="paris"]You are in Paris![/geoswitch_case]
[/geoswitch]

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.
A [geoswitch_case] shortcode without any attributes always matches and can be used as the last condition in a conditional block
to show default content.
Content between [geoswitch_case] blocks can contain any markup including any other shortcodes, but conditional blocks should
not be nested as this is not supported by WordPress.
Content between the [geoswitch] and [geoswitch_case] shortcodes should be whitespace but is usually ignored:
[geoswitch] *DON’T WRITE HERE*
[geoswitch_case]...[/geoswitch_case] *OR HERE*
[geoswitch_case]...[/geoswitch_case]
[/geoswitch]

Informational Shortcodes
In addition to the conditional block GeoSwitch offers the following shortcodes to display user information:

[geoswitch_ip] – The user’s IP.
[geoswitch_city] – The user’s city name.
[geoswitch_state] – The user’s state name.
[geoswitch_state_code] – The user’s state ISO code.
[geoswitch_country] – The user’s country name.
[geoswitch_country_code] – The user’s country code.

If the IP of the user cannot be geo located these shortcodes return ‘?’
Debug Shortcodes

geoswitch_setip – Override the user IP. Affects shortcodes after this one.
Usage:
[geoswitch_case ip=’10.0.0.10′]

For debugging whole websites the user IP can be set globally in the admin settings for the plugin.
Filter Hooks
Geoswitch supports the following filter hooks:
geoswitch_skip_ip_check
Allows 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
default content (if configured) will be displayed.
Usage:
function skip_ip_callback( $skipCheck, $userIp ) {
if ( some_custom_test($userIp) ) {
$skipCheck = true;
}
return $skipChek;
}

add_filter( 'geoswitch_skip_ip_check', 'skip_ip_callback', 10, 2 );

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Geocode Switch」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


1.0.0 | 1.1.0 | 1.1.1 | 1.1.2 | 1.1.3 | 1.1.4 | trunk |

延伸相關外掛(你可能也想知道)

  • Bloom for Publishers 》此外掛提供地理標記功能,使您的內容具有超級本地化特點,讓您的網站和通訊能使讀者搜尋和保存位置以獲得個性化體驗。, 大多數功能需要您的網站是在。
  • Images with GPS on GoogleMaps 》使用Google Maps上的GPS信息,可以在地圖上顯示您的照片,因為GPS / Geotags上沒有GPS。將自己的地理標籤添加到您的照片中。, 了解更多有關“Images with GPS ...。
  • OSM Categories 》OSM Categories 外掛可以透過使用 OpenLayer API,將一張 OpenStreetMap 地圖嵌入到您的頁面中。當您的博客中有文章被地理標籤標註時,該博客中的每個類別都...。
  • yapb-geotag 》此外掛可從「Yet another photoblog plugin」的圖片中萃取 GPS 資料,並為 Geotag 外掛建立元資料。, Geotag 外掛是一個非常好的地理標籤解決方案,但它無法...。
  • WP Geoloc 》這款外掛可以在 WordPress 中添加地理定位功能,讓使用者可以找到鄰近自己或特定距離內的文章。, 您可以使用小工具來選擇特定的位置,或是使用 URL(提供緯度...。
  • Twitchers 》Twitcher 是一個 WordPress 外掛,允許訪客張貼野生動物觀察紀錄,並在 Google 地圖上顯示它們。這個外掛只提供前端的 Google 地圖地理標籤選項。它受到 Sigh...。
  • Map Store Locator 》這個外掛包含兩個小工具:, - 一個簡單的小工具,適合顯示在小處。當你點擊此小工具時,它會加載另一個頁面(可以在管理區選擇), - 第二個小工具是一個基於 ...。
  • Big Blog Map – Geotag your posts 》Big Blog Map是一款WordPress外掛,它可以讓你對文章進行Geotagging,讓它們出現在Google地圖上。Big Blog Map十分適合以下用戶:, , 旅遊博主 - 與朋友和家...。
  • WP-Brightkite 》這個外掛提供與使用 Brightkite 規劃師相關的文章的地理資料,Brightkite 是一個基於地理位置的微內容社交網絡。, Brightkite 通過 KML 提供有關用戶活動的數...。
  • LH Places 》LH Places 創建一個名為「場所」的 CPT,每個「場所」都與地理資訊(例如緯度和經度)相關聯。可以將文章、頁面和其他 CPT(例如事件)連接到該「場所」,並...。
  • geoURI 》當你在網誌中提到特定地點時,你可能希望建立連結。在 Android 設備上,你可以使用類似 geo:37.786971,-122.399677 的連結以開啟原生地圖應用程式,例如 Goog...。
  • BlogMap Geolocation 》這款 WordPress 外掛可以在文章中加入地圖標記,讓使用者藉由搜尋地址來查看相關的地理資訊。地圖會在文章內容之前或之後顯示,而你可以自由選擇地圖的大小以...。
  • AmbiProducts 》這個外掛可讓您使用地理標記添加帶有類別的產品,然後使用簡碼按類別列印表格並在地圖上顯示。, 如果您在不同地理位置列出產品,則此外掛可幫助您在單個表格...。

文章
Filter
Mastodon