
內容簡介
Geo IP Library 可以啟用一些簡單但強大的功能,以在 WordPress 上提供地理 IP 國家功能。到目前為止,其主要功能包括:
用於插件和主題的靜態 PHP 函數。
顯示不同地區或一組國家的內容的簡碼。
從其來源更新本地庫的管理。
關於庫
此外掛使用一個沒有外部依賴性的第三方 PHP 單一庫文件,因此它在掛件中並在本地運行。它適用於不想使用(或依靠) Web 服務或實現 PHP GeoIP 擴展的任何人。
該庫由 Chirag Mehta 製作。
庫更新
由於使用本地庫可以節省時間,其數據可能在將來過期。此插件允許從其遠程來源更新本地庫。要這樣做,請轉到管理儀表板(具體位於工具菜單下),可以在不經任何風險的情況下更新庫。
更新限制
庫可每72小時更新一次。沒有必要進行較小的間隔。
如何使用
簡碼
使用 [geo-ip] 或 [geo] 標記,在文章和頁面中顯示每個國家(或國家)的不同內容。要實現魔法,請參閱以下語法:
/**
* INCLUDE PROPERTY
* Show content to a specific country or many countries
*/
// [geo-ip] tag
[geo-ip include="{2-digits country code [, other countries]}"]{plain text, HTML and/or shortcodes}[/geo-ip]
// [geo] tag
[geo include="{2-digits country code [, other countries]}"]{plain text, HTML and/or shortcodes}[/geo]
/**
* EXCLUDE PROPERTY
* Show content to all countries but...
*/
// [geo-ip] tag
[geo-ip exclude="{2-digits country code [, other countries]}"]{plain text, HTML and/or shortcodes}[/geo-ip]
// [geo] tag
[geo exclude="{2-digits country code [, other countries]}"]{plain text, HTML and/or shortcodes}[/geo]
如果沒有其他插件正在使用 [geo] 標籤(因為它是一個非常常見的單詞),則只能使用 [geo] 標籤。
包括和排除由於其目的而無法一起使用。
編程
可以在 GeoIPLibrary 類任何位置使用以下靜態函數:
/** 返回當前客戶端的 IP 地址(字符串)。
* 繞過代理和/或轉發。
* 如果失敗,則返回 FALSE。 */
GeoIPLibrary::get_client_address()
/** 返回當前客戶端的 ISO 3166-1 alpha-2 國家代碼
* 或指定為 $ip 參數的字符串
* 如果失敗,則返回 FALSE。 */
GeoIPLibrary::get_client_country_code(string $ip = '')
/** 返回當前客戶端的國家名稱
* 或指定為 $ip 參數的字符串
* 如果失敗,則返回 FALSE。 */
GeoIPLibrary::get_client_country_name(string $ip = '')<h3>Contributions</h3>Geo IP Library 仍在開發中,但目前穩定。您可以貢獻新想法、代碼優化/問題甚至語法/拼寫檢查(英語不是我的母語)。歡迎自由地 [提交請求拉取](https://github.com/ricardo-miguel/geo-ip-library/pulls) 或 [開啟問題](https://github.com/ricardo-miguel/geo-ip-library/issues)。
外掛標籤
開發者團隊
原文外掛簡介
Geo IP Library enables sort of simple but powerful functions in order to provide geo ip country features on WordPress. Main features so far until now:
Static PHP functions to be used in plugins and themes.
Shortcodes to display different contents by country or a bunch of countries.
Update management of local library from its source.
About library
This plugin uses a third-party PHP single library file which does not have external dependencies, so it comes within the plugin and works locally. It is intended for anyone who don’t want to use (or depend of) web services or either implement native PHP GeoIP extensions.
The library was made by Chirag Mehta.
Library update
Since working with a local library can be a time-saver, its data may get deprecated sometime in the future. This plugin allow update your local library from its remote source. To do that, go to admin dashboard (specifically under Tools menu), where the library can be updated without any risk.
Updating restriction
The library can be updated every 72 hours. It is not really necessary a minor interval.
How to use
Shortcode
Display different content for each country (or countries) within posts and pages by using [geo-ip] or [geo] tags. To do magic, see the following syntaxes:
/**
* INCLUDE PROPERTY
* Display content to a specific country or many countries
*/
// [geo-ip] tag
[geo-ip include="{2-digits country code [, other countries]}"]{plain text, HTML and/or shortcodes}[/geo-ip]
// [geo] tag
[geo include="{2-digits country code [, other countries]}"]{plain text, HTML and/or shortcodes}[/geo]
/**
* EXCLUDE PROPERTY
* Display content to all countries but...
*/
// [geo-ip] tag
[geo-ip exclude="{2-digits country code [, other countries]}"]{plain text, HTML and/or shortcodes}[/geo-ip]
// [geo] tag
[geo exclude="{2-digits country code [, other countries]}"]{plain text, HTML and/or shortcodes}[/geo]
[geo] tag is only available if no other plugin is using it (since it’s a pretty common word).
include and exclude cannot be used together due to their purpose.
Coding
The following static functions can be used anywhere along GeoIPLibrary class:
/** Returns the current client's IP address as STRING.
* It bypasses proxies and/or forwarding.
* Returns FALSE if it fails. */
GeoIPLibrary::get_client_address()
/** Returns the current client's ISO 3166-1 alpha-2 country code
* or the specified at $ip parameter as STRING.
* Returns FALSE if it fails. */
GeoIPLibrary::get_client_country_code(string $ip = '')
/** Returns the current client's country name
* or the specified at $ip parameter as STRING.
* Returns FALSE if it fails. */
GeoIPLibrary::get_client_country_name(string $ip = '')
Contributions
Geo IP Library is still in development, but currently stable. You can contribute with new ideas, coding improves/issues and even grammar/spelling check (english is not my mother language). Feel free to [make a pull request](https://github.com/ricardo-miguel/geo-ip-library/pulls) or [open an issue](https://github.com/ricardo-miguel/geo-ip-library/issues).
