前言介紹
- 這款 WordPress 外掛「Nginx Mobile Theme」是 2013-11-07 上架。
- 目前有 200 個安裝啟用數。
- 上一次更新是 2018-10-17,距離現在已有 2392 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 3.7.1 以上版本才可以安裝。
- 有 2 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
miyauchi |
外掛標籤
nginx | theme | mobile | tablet | smartphone |
內容簡介
這個外掛允許您根據 Nginx 反向代理中的 User Agent 切換主題。
Nginx Mobile Theme 插件的要求如下:
PHP 5.3 或更新版本
WordPress 3.7 或更新版本
Nginx Cache Controller 2.0.0 或更新版本
一些功能
您可以透過 Nginx Cache Controller自動清除手機和電腦的每個緩存資料。
根據使用者代理切換主題。
允許您通過過濾器書鉤自定義多個移動設備支持。
Nginx 配置
將移動設備檢測添加到 nginx.conf 中。
set $mobile '';
if ($http_user_agent ~* '(iPhone|iPod|incognito|webmate|Android|dream|CUPCAKE|froyo|BlackBerry|webOS|s8000|bada|IEMobile|Googlebot\-Mobile|AdsBot\-Google)') {
set $mobile "@smartphone";
}
設置 proxy_cache_key。
proxy_cache_key "$mobile$scheme://$host$request_uri";
向後端發送自定義請求標頭。
proxy_set_header X-UA-Detect $mobile;
當在 $_SERVER['HTTP_X_UA_DETECT'] 收到 ‘@smartphone’ 時,Nginx Mobile Theme 將切換主題。
使用方法
請訪問 WordPress 管理區域中的主題自定義。
在下拉式菜單中選擇 Mobile Theme。
點擊「保存並發佈」按鈕進行保存。
多個移動設備支持
將自定義移動設備檢測添加到 nginx.conf 文件中。
通過 nginxmobile_mobile_detects 過濾器挂鉤將自定義移動設備檢測添加到 WordPress 中。
nginx.conf:
set $mobile ”;
if ($http_user_agent ~* ‘(iPhone|iPod)’) {
set $mobile “@smartphone”;
}
if ($http_user_agent ~* ‘iPad’) {
set $mobile “@tablet”;
}
在您的自定義插件中:
add_filter(‘nginxmobile_mobile_detects’, function(){
return array(‘@smartphone’, ‘@tablet’);
});
由此,您可以在主題自定義中單獨為 @smartphone 和 @tablet 選擇主題。
Amimoto 支援
Amimoto 是在 AWS EC2 上完美調整的 WordPress AMI。
在第 17 行取消 /etc/nginx/conf.d/default.conf 的註釋。
之前:
#include /etc/nginx/mobile-detect;
之後:
include /etc/nginx/mobile-detect;
在 /etc/nginx/nginx.conf 中添加以下行。
之前:
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding “”;
之後:
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding “”;
proxy_set_header X-UA-Detect $mobile; # 新增一行
定義 wp-config.php 中的常量
define(‘IS_AMIMOTO’, true);
原文外掛簡介
This plugin allows you to switch theme according to the User Agent on the Nginx reverse proxy.
Nginx Mobile Theme’s requirements are as follows.
PHP 5.3 or later
WordPress 3.7 or later
Nginx Cache Controller 2.0.0 or later
Some Features
You can flush mobile’s and pc’s each caches automatically via Nginx Cache Controller.
Allow you to switch theme according to the user-agent.
Allow you to customize multiple mobile device support via filter-hook.
Nginx Configuration
Add mobile device detection to the nginx.conf.
set $mobile '';
if ($http_user_agent ~* '(iPhone|iPod|incognito|webmate|Android|dream|CUPCAKE|froyo|BlackBerry|webOS|s8000|bada|IEMobile|Googlebot\-Mobile|AdsBot\-Google)') {
set $mobile "@smartphone";
}
Set proxy_cache_key.
proxy_cache_key "$mobile$scheme://$host$request_uri";
Send custom request header to the backend.
proxy_set_header X-UA-Detect $mobile;
Nginx Mobile Theme will switch theme when ‘@smartphone’ is received in the $_SERVER['HTTP_X_UA_DETECT'].
How to use
Please access to the theme-customizer in the WordPress admin area.
Please select Mobile Theme in the drop-down.
Click “Save & Publish” button to save.
Multiple mobile device support
Add custom mobile detection to the nginx.conf.
Add custom mobile detection to the WordPress via nginxmobile_mobile_detects filter-hook.
nginx.conf:
set $mobile ”;
if ($http_user_agent ~* ‘(iPhone|iPod)’) {
set $mobile “@smartphone”;
}
if ($http_user_agent ~* ‘iPad’) {
set $mobile “@tablet”;
}
In your custom plugin:
add_filter(‘nginxmobile_mobile_detects’, function(){
return array(‘@smartphone’, ‘@tablet’);
});
As a result, allow you to select theme for @smartphone and @tablet individually in the theme-customizer.
Amimoto Support
The Amimoto is a full-tuned WordPress AMI on the AWS EC2.
Uncomment /etc/nginx/conf.d/default.conf in line 17
before:
#include /etc/nginx/mobile-detect;
after:
include /etc/nginx/mobile-detect;
Add line to /etc/nginx/nginx.conf like following.
before:
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding “”;
after:
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding “”;
proxy_set_header X-UA-Detect $mobile; # add new line
Define constant in the wp-config.php
define(‘IS_AMIMOTO’, true);
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Nginx Mobile Theme」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
1.0.0 | 1.1.0 | 1.2.0 | 1.3.0 | 1.4.0 | 1.5.0 | 1.6.0 | 1.7.0 | 1.8.0 | 1.8.1 | 1.8.2 | trunk |
延伸相關外掛(你可能也想知道)
Speed Optimizer – The All-In-One Performance-Boosting Plugin 》SiteGround Optimizer 插件是由 SiteGround 開發的,可以大幅提高任何托管環境下的 WordPress 網站性能。, 最初設計用於 SiteGround 的服務器,現在已經有近 ...。
Nginx Helper 》, 使用 nginx 時,從永久連結中刪除 index.php。, 在使用nginx-srcache-module創建的完整頁面快取時,添加可清除 redis-cache 的支援。, 從模組中添加對 ngin...。
Proxy Cache Purge 》此外掛不會安裝或配置快取代理,而只是與這些服務進行介面交互。, 網站常見的內容快取方式是通過反向代理快取。常見的例子是 Varnish 和 Nginx。這些系統允許...。
Nginx Cache 》當內容更改時自動清除 Nginx 緩存 (FastCGI、Proxy、uWSGI),或在 WordPress 內手動清除。, 要求:, , Filesystem API 需要在不要求憑證的情況下運作。, Ngin...。
LWSCache 》這個外掛是由 LWS 開發的,可以幫助您在編輯頁面、文章、信息時自動管理您的 LWSCache 清除。, 它提供了一種清除所有 LWSCache 的方法。, 這個外掛僅適用於使...。
TNC Toolbox: Web Performance 》- 外掛名稱:NGINX-on-cPanel Enhancements, - 功能介紹:增強使用 NGINX-on-cPanel 時的 WordPress 體驗, - 使用對象:在 cPanel 上安裝了 NGINX 並運行 Wor...。
WP-FFPC 》警告: WP-FFPC 的開發已被暫停。, 如果您需要新功能,請將代碼和拉取請求發送到WP FFPC @ Github。, 簡短原因:我在2010年開發了這個插件來支持自己的網站。...。
Varnish/Nginx Proxy Caching 》這個外掛可以完整整合 WordPress Varnish Cache 3.x/4.x/5.x 和 Nginx Proxy Cache。, 這個外掛可以處理所有與 Varnish Cache 和 Nginx Proxy Cache 的整合,...。
Nginx Cache Controller 》此外掛提供控制 Nginx 代理伺服器快取的功能。, 安全性, , 將留言作者的資訊設定為 ajax,以防止資訊快取。, 對於需要密碼保護的文章,加入 no-cache 標頭來...。
Hestia Nginx Cache 》重要提示:Hestia 1.6.12 版修正了清除快取後網站可能會無法使用且導致 502 錯誤的問題。如果您尚未使用這個版本,請盡快升級!, WordPress 外掛 Hestia 自動...。
AJAX Hits Counter + Popular Posts Widget 》本外掛使用外部 AJAX 計數器腳本來記錄文章的瀏覽次數,是最適合快取整個頁面或使用其他快取外掛的解決方案。, 此外,外掛還包含了「熱門文章」小工具,可根...。
Cache Purge Helper 》這個外掛會在流行的 WordPress 外掛或佈景主題觸發特定的鉤子時,使用 LSCache 或 Nginx Helper 外掛清除快取。, , 如果使用 LSCache 外掛,需要 Litespeed E...。
PageSpeed Module 》此外掛稱為「PageSpeed Module」,可供Apache或Nginx模組使用。使用此外掛,您可以清除由Apache或Nginx模組建立的Cache,並啟用WordPress網站的開發模式,以...。
Cleavr Clear Cache 》管理您的 Cleavr 站點的 NGINX FastCGI 快取,只需添加清除快取觸發器鉤子,然後您就可以點擊按鈕來清除您的站點快取,並選擇性地在每次內容更改時清除快取。...。
Blizhost CloudCache Purge – Speed, Security, and Optimization 》Blizhost CloudCache Purge 在您網站內容被修改時向 Blizhost 伺服器發送請求來清除快取。這在發布、編輯、評論或刪除頁面或文章以及更改佈景主題時會發生。,...。