前言介紹
- 這款 WordPress 外掛「Geocode Switch」是 2014-12-08 上架。
- 目前有 40 個安裝啟用數。
- 上一次更新是 2018-07-21,距離現在已有 2479 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 3.0 以上版本才可以安裝。
- 有 3 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
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 |
延伸相關外掛(你可能也想知道)
暫無相關外掛推薦。