[WordPress] 外掛分享: Geolocation IP Detection

首頁外掛目錄 › Geolocation IP Detection
WordPress 外掛 Geolocation IP Detection 的封面圖片
20,000+
安裝啟用
★★★★
4.7/5 分(59 則評價)
140 天前
最後更新
問題解決
WordPress 5.0+ PHP 7.2.5+ v5.6.1 上架:2013-07-03

內容簡介

P地址提供了地理信息,可以在主題或其他外掛中使用,作為 shortcode 或通過 CSS body classes。城市和國家名稱被翻譯成不同的語言(支持的語言)。
特徵:

您可以使用以下其中一個數據源(請參閱比較):

免費(默認源):HostIP.info(僅限IPv4)
需要註冊免費:Maxmind GeoIP2 Lite City,每周自動更新
商業版:Maxmind GeoIP2 City或Maxmind GeoIP2 Country
商業版Web-API:Maxmind GeoIP2 Precision(City、Country或Insights)
基于主機提供商:Cloudflare或Amazon AWS CloudFront(Country)
免費或商業版Web-API:Ipstack
Amazon AWS Marketplace的商業版Web-API:Fastah

提供這5個功能:

geoip_detect2_get_info_from_ip($ip, $locales = array('en'), $options = array()):查找指定IP的地理信息
geoip_detect2_get_info_from_current_ip($locales = array('en'), $options = array()):查找當前網站用戶的地理信息
geoip_detect2_get_current_source_description(...):返回當前選擇的源的可讀標籤。
geoip_detect2_get_external_ip_adress():獲取網絡服務器的互聯網地址
geoip_detect2_get_client_ip():獲取客戶端IP(即使它在反向代理後面)

有關屬性名稱,請在WordPress後端中查看特定IP的結果(在工具>地理位置IP檢測下)。
您可以通過使用短碼[geoip_detect2 property="country.name" default="(country could not be detected)" lang="en"](其中‘country.name’也可以是其他屬性名稱,‘default’和‘lang’是可選的)將這些屬性包含在您的帖子和頁面中。
您可以使用短碼[geoip_detect2_show_if country="FR, DE" not_city="Berlin"]TEXT[/geoip_detect2_show_if] 顯示或隱藏內容。請參閱短碼文檔。
在選項頁面上啟用時,它會將CSS類添加到body標​​籤中,例如geoip-province-HE,geoip-country-DE和geoip-continent-EU。
如果您使用頁面高速緩存,建議使用AJAX模式
在選項頁面上啟用時,客戶端IP地址被添加到每個WordPress注釋的郵件地址中。

外掛標籤

開發者團隊

⬇ 下載最新版 (v5.6.1) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Geolocation IP Detection」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Provides geographic information detected by an IP adress. This can be used in themes or other plugins, as a shortcode, or via CSS body classes. The city & country names are translated in different languages (supported languages).
Features:

You can use one of these data sources (see comparison):

Free (default source): HostIP.info (IPv4 only)
Free with registration: Maxmind GeoIP2 Lite City, automatically updated weekly
Commercial: Maxmind GeoIP2 City or Maxmind GeoIP2 Country
Commercial Web-API: Maxmind GeoIP2 Precision (City, Country or Insights)
Hosting-Provider dependent: Cloudflare or Amazon AWS CloudFront (Country)
Free or Commercial Web-API: Ipstack
Commercial Web-API via AWS Marketplace: Fastah

Provides these 5 functions (see API Documentation):

geoip_detect2_get_info_from_ip($ip, $locales = array('en'), $options = array()): Lookup Geo-Information of the specified IP
geoip_detect2_get_info_from_current_ip($locales = array('en'), $options = array()): Lookup Geo-Information of the current website user
geoip_detect2_get_current_source_description(...): Return a human-readable label of the currently chosen source.
geoip_detect2_get_external_ip_adress(): Fetch the internet adress of the webserver
geoip_detect2_get_client_ip(): Get client IP (even if it is behind a reverse proxy)

For the property names, see the results of a specific IP in the wordpress backend (under Tools > Geolocation IP Detection).
You can include these properties into your posts and pages by using the shortcode [geoip_detect2 property="country.name" default="(country could not be detected)" lang="en"] (where ‘country.name’ can be one of the other property names as well, and ‘default’ and ‘lang’ are optional).
You can show or hide content by using a shortcode [geoip_detect2_show_if country="FR, DE" not_city="Berlin"]TEXT[/geoip_detect2_show_if]. See Shortcode Documentation.
When enabled on the options page, it adds CSS classes to the body tag such as geoip-province-HE, geoip-country-DE and geoip-continent-EU.
If you are using a page cache, it is recommended to use the AJAX mode (see AJAX)
When enabled on the options page, the client IP respects a reverse proxy of the server.
If you are using Contact Form 7, you can use these shortcodes:

A select input with all countries, the detected country being selected by default: [geoip_detect2_countries mycountry]
A text input that is pre-filled with the detected city (or other property): [geoip_detect2_text_input city property:city lang:fr id:id class:class default:Paris]
Geolocation information for the email text: [geoip_detect2_user_info]

If you are using WP Forms, you can use this shortcode:

Geolocation information for the email text: [geoip_detect2_user_info]

Together with SVG Flags you can show the flag of the detected country: [geoip_detect2_current_flag] (see documentation)

See Documentation for more info.
How can I use these functions?

You could choose the currency of the store based on the country name
You could pre-fill the shipping country
You could show the store nearest to your customer
You show or hide content specific to a geographic target group
Etc. … You tell me! I’m rather curious what you’ll do with this plugin!
Be careful to comply to the applicable laws. For example Regulation (EU) 2018/302 …
If you need to get the user’s timezone, it is more accurate to use JS solutions.

System Requirements: You will need at least PHP 7.2.5 . Also, if you use the plugin WooCommerce, you’ll need at least WooCommerce 3.9.0 .
GDPR: See Is this plugin GDPR-compliant?
This extension is “charity-ware”. If you are happy with it, please leave a tip for the benefit of this charity. (See FAQ for more infos.)
Here are other ways to contribute to the development of this plugin.
This product can provide GeoLite2 data created by MaxMind, available from http://www.maxmind.com.
Troubleshooting

Does geoip_detect2_get_info_from_current_ip() return the same country, regardless of where you are visiting the site from?
Maybe your server has a reverse proxy configured. You can check this: Go to the options page and look for “reverse proxy”. Are there 2 IPs listed there? If so, which one corresponds to your public IP?
Or maybe you are using a site cache plugin. Then enable the option Disable caching a page that contains a shortcode or API call to geo-dependent functions.

More Troubleshooting Hints

延伸相關外掛

文章
Filter
Mastodon