[WordPress] 外掛分享: WP User Timezone

WordPress 外掛 WP User Timezone 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「WP User Timezone」是 2016-04-22 上架。
  • 目前有 10 個安裝啟用數。
  • 上一次更新是 2016-05-07,距離現在已有 3284 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 3.0.1 以上版本才可以安裝。
  • 有 4 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

ravikatha |

外掛標籤

date | time | timezone |

內容簡介

WordPress 後台有全站時區設定,前台顯示的所有日期和時間通常會顯示在這個時區。

這個外掛可使用瀏覽器時區顯示前端的日期和時間。透過覆寫 WordPress 的 'timezone_string' 和 'gmt_offset' 選項,來符合使用者的時區在特定請求的持續時間的前端介面。

瀏覽器時區偵測

瀏覽器時區是使用以下兩種方法之一偵測的

jsTimezoneDetect(預設)
HTML5 Geolocation API 和 Google Timezone API

jsTimezoneDetect(預設)
這是預設的時區偵測機制。請參閱腳本的主頁
以取得相容性和其他注意事項

HTML5 Geolocation API
使用navigator.geolocation.getCurrentPosition來偵測目前的地理位置。之後將偵測到的地理位置傳送至Google Timezone API
此 API 會返回類似於「Asia/Kolkata」的時區 ID。

此方法需要您

在外掛選項頁面上啟用 "Google 時區 API" 選項
指定有效的Google API Key

此金鑰應該是瀏覽器專屬金鑰
"接受的 HTTP 引薦者" 應該包括使用主機 WordPress 網站的域名,或留白以允許所有引薦者

如果未達成使用 Google 時區 API 所需的必要選項,則偵測機制將回復到預設值。

文章時區偵測

如果瀏覽器的時區 ID 未被成功偵測,則其他所有操作都會像未安裝此外掛一樣。
如果偵測到瀏覽器的時區 ID,則會執行以下操作

會根據在外掛選項頁面上指定的 cookie 選項,在瀏覽器中設置 cookie
如果具有相同 ID 的 cookie 已存在,則不會採取任何行動
如果以前不存在 cookie 或存在具有不同時區 ID 的 cookie,則會觸發 window.reload 以刷新頁面,以便更新頁面上的日期和時間

EventON 拋鉤

此外掛提供一個功能,可掛鉤到 EventON 外掛。啟用後,所有 EventON 的日期和時間都會更新以反映瀏覽器的時區。

簡碼

此外掛定義以下簡碼

[wp_user_timezone_id] => 返回瀏覽器的時區 ID,如果不可用則返回 null。
[wp_user_timezone_offset] => 返回瀏覽器的時區的 GMT 偏移量(小時),如果不可用則返回 null。

選項

此外掛定義以下選項以檢索在站點層級定義的原始 timezone_string 和 gmt_offset

get_option ('site_timezone_string') => 返回站點的原始 timezone_string 選項
get_opt

原文外掛簡介

WordPress has a site-level timezone setting configured from the admin back-end. All dates and times displayed on the front-end are typically displayed in this timezone.
This plugin enables the display of dates/times in the front-end using the browser’s timezone. This is done by overriding the WordPress’s ‘timezone_string’ and ‘gmt_offset’ options to match the user’s timezone for the duration of a particular request
ONLY on the front-end interface.
Browser Timezone Detection
The browser’s timezone is detected using one of the following two methods

jsTimezoneDetect (default)
HTML5 Geolocation API and Google Timezone API

jsTimezoneDetect (default)
This is the default timezone detection mechanism. Please refer to the script home page
for the compatibility and other notes
HTML5 Geolocation API
Detects the current geo-location using navigator.geolocation.getCurrentPosition. The location thus detected will be sent to the Google Timezone API
which returns the timezone id – similar to “Asia/Kolkata”.
This method requires you to

Enable the “Google Timezone API” option on the plugin options page
Specify a valid Google API Key

The key should be a browser key
The “Accepted HTTP Referrers” should include the domain name used by the hosting wordpress site or left blank to allow all referrers

If the required options for the usage of Google Timezone API are not met, the detection mechanism falls back to the default one.
Post Timezone Detection

If the browser’s timezone id is not detected successfully, everything else behaves as if this plugin is not installed.
If the browser’s timezone id is detected, the following actions take place

A cookie will be set in the browser, based on the cookie options specified on the plugin options page
If a cookie already exists previously with the same id, no action is taken
If a cookie doesn’t already exist previously or exists with a different timezone id, then a window.reload is triggered to refresh the page so that the dates/times on the page are updated

EventON Hook
This plugin provides a feature to hook into the EventON plugin. When enabled, all EventON dates/times are updated to reflect the browser’s timezone.
Shortcodes
This plugin defines the below shortcodes

[wp_user_timezone_id] => Returns the timezone id of the browser or null if not available.
[wp_user_timezone_offset] => Returns the timezone’s gmt offset in hours of the browser or null if not available.

Options
This plugin defines the below options to retrieve the original timezone_string and gmt_offset defined at the site level

get_option( ‘site_timezone_string’ ) => Returns the original timezone_string option for the site
get_option( ‘site_gmt_offset’ ) => Returns the original gmt_offset option for the site

Actions/Hooks
This plugin defines the below filters/hooks

apply_filters( ‘wp_user_timezone_id’, $tz_id ) => Allows you to override the timezone string determined by the plugin. This filter can be used to apply user’s timezone preference. If any plugin or wordpress core implements a feature to accept and store user’s preferred timezone, the ‘wp_user_timezone_id’ can be used to apply that timezone value to the front-end. Reference: Add user-level timezone setting).

Admin Backend Dates/Times
Important: The admin back-end is not modified by this plugin. All dates/times displayed in the back-end are still in the original timezone specified by the WordPress General Settings.

各版本下載點

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

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


最新版本

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

  • Saan World Clock 》此外掛可以讓您顯示來自所有時區的時間和日期。設定頁面會生成您喜歡的短碼。只需複製並粘貼此代碼在您想要的任何地方即可。時間會根據伺服器時間進行調整。,...。
  • WP TimeZone 》這個輕量級的外掛程式可以用於解決 WordPress 的預約發佈功能無法正常運作(錯誤的預約發佈),且你的網站位於歐洲國家,在夏季使用中歐夏令時間(CEST)和冬...。
  • TimeZoneCalculator 》, 基於 PHP 時區資料庫 (請參閱FAQ以獲取更多訊息), 全功能設定頁面,可使用 GUI 或手動進行設定, 易於整合 (內置多個/側邊欄和儀表板小工具功能), 在 WordPr...。
  • Current Date & Time Widget 》這是一個相當簡單的外掛程式,可用於在任何支援小工具(widget-enabled)的地方顯示日期和時間。, 這個外掛程式有兩個目標:, , 提供一種方法來讓產生的日期...。
  • Timezone Conversion Widget 》這是一個輕量級的外掛,可讓您的客戶將時間從一個時區轉換為另一個時區。, 基本上,這個外掛會在網站前端新增一個時區轉換小工具,它會顯示日期和時間、來源...。
  • jClocksGMT World Clocks 》jClocksGMT 是一個基於 GMT 偏移量的 jQuery 模擬和數字世界時鐘外掛程式。, 現在支援受影響時區的自動日光節約時間轉換。, 需要使用 jQuery Rotate 外掛程式...。
  • WP Server Date Time 》這個外掛很實用,當你身處不同時區時,想知道 WordPress 所在的伺服器日期、時間和時區。, 輸出結果看起來像這樣:, 伺服器日期/時間:Sat 06th Dec,2008 11:...。
  • Localize Time 》這個 WordPress 外掛加入了 [localize_time] 短代碼。這個短代碼允許作者輸入任何時區的日期和時間。短代碼顯示帶時區的原始時間,接著顯示符合使用者地區設...。
  • WP User Level Timezone 》WordPress 在後台管理中設定網站時區,並以此顯示所有日期和時間。不過當您的使用者來自世界各地時,日期和時間可能不再具有實際意義。, 此外掛可以讓使用者...。
  • World Clocks

    WordPress全球時鐘自訂區塊外掛總結:

    , ,
      ,
    • 此外掛可讓網站在不同時區間啟用全球時鐘,為WordPress區塊編輯器(...。
    • Whereabouts 》每個使用者都可以儲存他/她目前的位置和對應的時間(時區)。該資訊將作為使用者的元數據存儲。, 「行蹤」小工具會顯示指定使用者(在小工具選項中選擇使用者...。
    • Whereabouts: Swarm 》使用小工具或簡碼 [whereabouts-swarm] 在網站的任何位置顯示您目前的位置。, 請注意:僅在設置了位置時才會顯示位置。, 樣式, 沒有額外的樣式,但是您可以在...。
    • Softech Wp Clock 》, , Softech WP Clock 可以透過插入 shortcode 在您的頁面 / 文章上顯示一個時區時鐘。只需按下「新增」並選擇您城市的時區,即可建立一個時間區域。您可以為...。
    • Simple default timezone 》這個外掛可讓網絡管理員在多站點安裝中以一次點擊的方式設置相同的時區,同時也限制了本地部落格設置改變時區的權限。, *基於:https://premium.wpmudev.org/...。
    • GNTT Timezone Clock 》此外掛會在您的文章、頁面和小工具文字中顯示具有您所在的時區的現場時鐘。插件網址:http://market.mathgr.com/gntt-timezone-clock/。。

文章
Filter
Mastodon