Title: Nginx Mobile Theme
Author: Takayuki Miyauchi
Published: <strong>2013 年 11 月 8 日</strong>
Last modified: 2018 年 10 月 17 日

---

搜索插件

![](https://ps.w.org/nginx-mobile-theme/assets/banner-772x250.png?rev=802244)

**该插件尚未通过WordPress的最新3个主要版本进行测试**。 当与较新版本的WordPress一起
使用时，可能不再受到维护或支持，并且可能会存在兼容性问题。

![](https://s.w.org/plugins/geopattern-icon/nginx-mobile-theme_f2e0c8.svg)

# Nginx Mobile Theme

 作者：[Takayuki Miyauchi](https://profiles.wordpress.org/miyauchi/)

[下载](https://downloads.wordpress.org/plugin/nginx-mobile-theme.1.8.2.zip)

 * [详情](https://cn.wordpress.org/plugins/nginx-mobile-theme/#description)
 * [评价](https://cn.wordpress.org/plugins/nginx-mobile-theme/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/nginx-mobile-theme/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/nginx-mobile-theme/#developers)

 [支持](https://wordpress.org/support/plugin/nginx-mobile-theme/)

## 描述

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](https://wordpress.org/plugins/nginx-champuru/) 2.0.0
   or later

#### Some Features

 * You can flush mobile’s and pc’s each caches automatically via [Nginx Cache Controller](https://wordpress.org/plugins/nginx-champuru/).
 * 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

 1. Please access to the theme-customizer in the WordPress admin area.
 2. Please select Mobile Theme in the drop-down.
 3. Click “Save & Publish” button to save.

#### Multiple mobile device support

 1. Add custom mobile detection to the nginx.conf.
 2. 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](http://megumi-cloud.com/) 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);

## 屏幕截图

 * [[
 * theme-customizer

## 安装

 1. Upload `nginx-mobile-theme` to the `/wp-content/plugins/` directory.
 2. Activate the plugin through the ‘Plugins’ menu in WordPress.

## 评价

此插件暂无评价。

## 贡献者及开发者

「Nginx Mobile Theme」是开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ Takayuki Miyauchi ](https://profiles.wordpress.org/miyauchi/)

[帮助将「Nginx Mobile Theme」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/nginx-mobile-theme)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/nginx-mobile-theme/)，
查看[SVN仓库](https://plugins.svn.wordpress.org/nginx-mobile-theme/)，或通过[RSS](https://plugins.trac.wordpress.org/log/nginx-mobile-theme/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/nginx-mobile-theme/)。

## 更新日志

#### 1.8.1

 * Add query strings mobile=on and mobile=off

#### 1.5.0

 * [Bug fix.](https://github.com/megumiteam/nginx-mobile-theme/compare/1.4.0...1.5.0)

#### 1.4.0

 * [Bug fix.](https://github.com/megumiteam/nginx-mobile-theme/compare/1.3.0...1.4.0)

#### 1.3.0

 * [Bug fix.](https://github.com/megumiteam/nginx-mobile-theme/compare/1.2.0...1.3.0)

#### 1.2.0

 * [Add mobile theme preview.](https://github.com/megumiteam/nginx-mobile-theme/compare/1.1.0...1.2.0)

#### 1.1.0

 * Add support child theme.
 * Add notice when Nginx Cache Controller is not activated.

https://github.com/megumiteam/nginx-mobile-theme/compare/1.0.0…1.1.0

#### 1.0.0

 * first release.

## 额外信息

 *  版本 **1.8.2**
 *  最后更新：**8 年前**
 *  活跃安装数量 **200+**
 *  WordPress 版本 ** 3.7.1 或更高版本 **
 *  已测试的最高版本为 **4.9.29**
 *  语言
 * [English (US)](https://wordpress.org/plugins/nginx-mobile-theme/)
 * 标签
 * [mobile](https://cn.wordpress.org/plugins/tags/mobile/)[nginx](https://cn.wordpress.org/plugins/tags/nginx/)
   [smartphone](https://cn.wordpress.org/plugins/tags/smartphone/)[tablet](https://cn.wordpress.org/plugins/tags/tablet/)
   [theme](https://cn.wordpress.org/plugins/tags/theme/)
 *  [高级视图](https://cn.wordpress.org/plugins/nginx-mobile-theme/advanced/)

## 评级

 5 星（最高 5 星）。

 *  [  2 条 5 星评价     ](https://wordpress.org/support/plugin/nginx-mobile-theme/reviews/?filter=5)
 *  [  0 条 4 星评价     ](https://wordpress.org/support/plugin/nginx-mobile-theme/reviews/?filter=4)
 *  [  0 条 3 星评价     ](https://wordpress.org/support/plugin/nginx-mobile-theme/reviews/?filter=3)
 *  [  0 条 2 星评价     ](https://wordpress.org/support/plugin/nginx-mobile-theme/reviews/?filter=2)
 *  [  0 条 1 星评价     ](https://wordpress.org/support/plugin/nginx-mobile-theme/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/nginx-mobile-theme/reviews/#new-post)

[查看全部评论](https://wordpress.org/support/plugin/nginx-mobile-theme/reviews/)

## 贡献者

 *   [ Takayuki Miyauchi ](https://profiles.wordpress.org/miyauchi/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/nginx-mobile-theme/)