[WordPress] 外掛分享: Mobile Detector

前言介紹

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

外掛協作開發者

tubal |

外掛標籤

theme | device | mobile | detector | switcher |

內容簡介

簡要介紹:
此外掛是一個輕量級的移動裝置、操作系統和瀏覽器檢測器,可以選擇性地在偵測到移動裝置時或當使用者想要切換時,讓你的網站切換到移動主題。此外掛會為 WordPress 添加類別 MobileDTS。

移動裝置偵測:
每個請求時,此外掛會嘗試偵測使用者是否使用移動裝置瀏覽您的網站,如果是,偵測器還會提供一些關於使用的裝置、瀏覽器和操作系統的資訊。

使用此偵測器的人:
如果您需要一種快速、可靠的方法來偵測使用者是否使用移動裝置訪問您的網站,那麼您將會很滿意。但是,如果您需要精確的裝置資訊(除了操作系統和瀏覽器之外)例如螢幕解析度,您就需要使用DeviceAtlas或WURFL等偵測器。

如何查詢偵測器:
使用方法MobileDTS::is($key)。is()返回布林值true或false。

可用的$key:
- mobile(是否為移動裝置?)
- other(任何其他移動裝置)
- iphone(蘋果 iPhone)
- ipad(蘋果 iPad)
- kindle(Amazon Kindle)
- android(Android作業系統)
- bada(Bada OS)
- bbos(黑莓OS)
- ios(蘋果iOS)
- palmos(Palm OS)
- symbian(Symbian OS)
- webos(HP WebOS)
- windows(Windows Phone OS和舊版Windows)
- ff_mobile(Mozilla Fennec和Firefox Mobile)
- ie_mobile(IE Mobile)
- netfront(NetFront)
- opera_mobile(Opera Mobile或Mini)
- uc_browser(UC Browser)
- webkit_mobile(Webkit移動版)

主題切換:
您可以設置您的網站,以便在檢測到移動裝置或在使用者按要求時自動切換到移動主題。

安裝完外掛後,將會在「設定」選單下添加子選單「Mobile Detector」。默認情況下,主題切換是禁用的。要啟用主題切換,只需選擇一個主題作為移動主題,插件將處理其餘部分。

本插件假定您的當前主題僅針對桌面屏幕進行了優化。因此,如果您正在使用適應任何螢幕大小的響應式主題,則不應使用主題切換功能(不要選擇主題)。

基本工作模式:
- 在每個頁面加載時,此外掛會檢查一個cookie是否存在,該cookie存儲使用者首選瀏覽哪個主題(移動裝置優化或桌面優化)。
- 如果存在cookie,將顯示使用者期望的主題。
- 如果不存在cookie(首次訪客),此外掛將檢查使用者是否訪問您的網站並使用移動裝置或桌面設備方式瀏覽。

原文外掛簡介

A lightweight detector of mobile devices, OSs & browsers that, optionally, allows your site to switch to a mobile theme when a mobile device is detected or when your users feel like it.
This plugin adds the class MobileDTS to WordPress.
Mobile Detection
On every request, this plugin will try to detect if the user is viewing your site with a mobile device or not. If he is, the detector will also give you some info about the device, browser and OS used.
Who will be happy with this detector?
If you need a fast and reliable way to detect if a user is visiting your site with a mobile device, then you’ll be happy. However, if you need precise information about the device used (other than OS and browser) such as screen resolution you need a detector such as DeviceAtlas or WURFL.
How to query the detector?
Use the method MobileDTS::is($key). is() returns boolean true or false.
Example:

Available keys:

mobile (Is it a mobile?)
other (Any other mobile device)

Popular mobile devices

iphone (Apple iPhone)
ipad (Apple iPad)
kindle (Amazon Kindle)

Mobile OS

android (Android OS)
bada (Bada OS)
bbos (Blackberry OS)
ios (Apple iOS)
palmos (Palm OS)
symbian (Symbian OS)
webos (Hp WebOS)
windows (Windows Phone OS and older)

Mobile browsers

ff_mobile (Mozilla Fennec & Firefox mobile)
ie_mobile (IE mobile)
netfront (NetFront)
opera_mobile (Opera Mobile or Mini)
uc_browser (UC Browser)
webkit_mobile (Webkit mobile)

Theme Switching
You can configure your site to automatically switch to a mobile theme when a mobile device is detected or when the user requests it (on demand).
Once the plugin is installed, a new submenu titled Mobile Detector is added under the Settings menu.
Theme switching is disabled by default. To enable theme switching simply select a theme to use as your mobile theme and the plugin will take care of the rest.
This plugin assumes your active theme is optimized for desktop screens only. So, if you’re using a responsive theme that adapts to any screen size you shouldn’t use the theme switching feature (don’t select a theme).
How it works:

On each page load, this plugin checks for the existence of a cookie that stores which theme (mobile-optimized or desktop-optimized) the user prefers to browse.
If the cookie exists, the theme the user expects will be displayed.
If the cookie does not exist (first-time visitor), this plugin checks whether the user is visiting your site with a mobile device or not and, if he is, your mobile-optimized theme will be used. Afterwards, a cookie will be set to store the user’s “initial preference”.
Anytime the user switches (you must create a link/button in your theme using the Template functions below) between themes, the cookie is updated with his preference so the site version (theme) the user expects will be displayed on future visits.

Template functions

MobileDTS::get_switch_theme_link() Returns the current URL with an additional switch_theme parameter (set automatically to ‘mobile’ or ‘desktop’). You’ll need this function to create a link/button that allows users to switch between the desktop and mobile themes. See example below.

MobileDTS::switch_theme_link(): same as above but this one outputs the URL instead of returning it. URL is escaped.

MobileDTS::get_switch_theme_name() returns the type of the theme to switch to (either ‘mobile’ or ‘desktop’). Use this method together with get_switch_theme_link(). The type can be translated to your language (plugin uses wp’s __() function for ‘mobile’ & ‘desktop’ strings).

MobileDTS::switch_theme_name() same as above but this one outputs the type instead of returning it.

MobileDTS::is_mobile_theme() tells you wether your site is displaying to the user the mobile theme or not. Returns boolean true or false.

MobileDTS::is_switcher_enabled() tells you wether theme switching is disabled or not. Returns boolean true or false.

Creating a ‘Switch to …’ link
Let’s create a switch link to allow the user to switch between the 2 versions of a site (themes):

Switch to the version of this site

Paste that code in your templates (usually in header.php and/or footer.php), enable theme switching and play a little.
Let’s suppose a user is viewing the site (http://example.com/home) for the first time with a mobile device and theme switching is enabled. The above code would output this link:
Switch to the desktop version of this site

各版本下載點

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

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


1.0 | 1.1 | 2.0 | 2.0.1 | 2.0.2 | trunk |

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

  • Widget Detector for Elementor 》這個外掛會分析你的頁面和文章,找出哪些 Elementor Widgets 被使用,未被使用或丟失於某些頁面和文章中。, 作為服務的一部份,有時候使用https://elementdet...。
  • Device Detector 》Device Detector 是一個全功能的分析報告和管理工具,可檢測訪問您的 WordPress 網站的所有設備。, , 🎁 在免費的虛擬站點上測試此外掛: 一鍵測試!, , 對於...。
  • Ad Blocking Detector 》安裝進階分析和收入回收解決方案:Admiral Adblock Analytics, 功能:內建工具, 出版商可以提供替代內容,當用戶啟用廣告過濾器時顯示。廣告阻擋偵測器會智能...。
  • Translation Detector 》此外掛可以讓你在單篇文章中顯示一個簡單的連結,以便於切換至翻譯版本。, 如何運作?, 翻譯偵測器會檢查每篇文章是否有翻譯版本,如果是,該文章內會顯示按...。
  • ZDN Adblock Detector 》總結:ZDN Adblock Detector是一個輕量的外掛程式,可以偵測訪客是否使用廣告封鎖程式並顯示友好訊息要求他們停用廣告封鎖程式。該外掛程式具有可靠的廣告封...。
  • Tiny Simple AdBlock Detector 》這個外掛非常簡單,沒有任何可變選項。, 它唯一的功能是可以偵測 AdBlock(在 Chrome 的 AdBlock 擴充功能上已測試),並定義 HTML 類別以控制根據偵測結果在...。
  • Referrer Detector 》此外掛會向來自不同網址(稱為推薦者)的訪客顯示問候訊息。例如,您可以用提醒 Diggers 推薦您的文章的訊息來歡迎他們,或者要求 Del.icio.us 使用者將您的...。
  • Detector 》Detector 是一個簡單的基於 PHP 和 JavaScript 的瀏覽器和特徵檢測庫。它可以自動適應新的設備和瀏覽器,而無需從中央數據庫中獲取瀏覽器信息。, 也可在 GitH...。
  • Blocks Detector Finder 》這個外掛會分析你的頁面和文章,找出所有已使用、未使用或在特定頁面和文章中缺失的 Gutenberg Blocks。, , 這可以幫助你刪除未使用的 Gutenberg Blocks,並...。

文章
Filter
Apply Filters
Mastodon