Title: Conditional Themes
Author: Nashwan D
Published: <strong>2013 年 10 月 19 日</strong>
Last modified: 2019 年 7 月 19 日

---

搜尋外掛

這個外掛**並未在最新的 3 個 WordPress 主要版本上進行測試**。開發者可能不再對這個
外掛進行維護或提供技術支援，並可能會與更新版本的 WordPress 產生使用上的相容性問題。

![](https://s.w.org/plugins/geopattern-icon/wp-conditional-themes.svg)

# Conditional Themes

 由 [Nashwan D](https://profiles.wordpress.org/alex-ye/) 開發

[下載](https://downloads.wordpress.org/plugin/wp-conditional-themes.0.6.zip)

 * [詳細資料](https://tw.wordpress.org/plugins/wp-conditional-themes/#description)
 * [使用者評論](https://tw.wordpress.org/plugins/wp-conditional-themes/#reviews)
 *  [安裝方式](https://tw.wordpress.org/plugins/wp-conditional-themes/#installation)
 * [開發資訊](https://tw.wordpress.org/plugins/wp-conditional-themes/#developers)

 [技術支援](https://wordpress.org/support/plugin/wp-conditional-themes/)

## 外掛說明

Conditional Themes is an API to switch the themes on certain conditions.

#### Usage

Write an another plugin file and use the Conditional Themes API as the example below:

    ```
    add_action('plugins_loaded', 'my_conditional_themes_setup', 100);

    function my_conditional_themes_setup()
    {
        // Switch to Twenty Eleven theme if the visitor use Internet Explorer.
        Conditional_Themes_Manager::register('twentyeleven', function() {
            global $is_IE;
            return (bool) $is_IE;
        });

        // Switch to Twenty Thirteen theme if the user has administrator role.
        Conditional_Themes_Manager::register('twentythirteen', function() {
            return current_user_can('administrator');
        });

        // Switch to a custom theme if the visitor use a mobile device.
        Conditional_Themes_Manager::register('mobile', 'wp_is_mobile');
    }
    ```

Another example, With enabling persistent mode.

    ```
    add_action('plugins_loaded', 'my_conditional_themes_setup', 100);

    function my_conditional_themes_setup()
    {
        // Enable the switcher persistent mode.
        Conditional_Themes_Manager::set_option('persistent', true);

        // Switch to Twenty Sixteen theme when we being on 2016.
        Conditional_Themes_Manager::register('twentysixteen', function() {
            return (date('Y') == 2016);
        });

        // Switch to Twenty Fifteen theme when the site reaches 500 post.
        Conditional_Themes_Manager::register('twentyfifteen', function() {
            return ((int) wp_count_posts() > 500);
        });
    }
    ```

Note: You can use [Code Snippets](https://wordpress.org/plugins/code-snippets) plugin
to add the code snippets to your site.

#### Contributing

Developers can contribute to the source code on the [Github Repository](https://github.com/nash-ye/WP-Conditional-Themes).

## 安裝方式

 1. Upload and install the plugin
 2. Use the plugin API to powerful your project.

## 使用者評論

![](https://secure.gravatar.com/avatar/4cdf246f77ebb61cf6f65600b7e858ea3c408c48a9801e6c2a623a3ee83b0f1a?
s=60&d=retro&r=g)

### 󠀁[Fonctionne très bien](https://wordpress.org/support/topic/fonctionne-tres-bien-5/)󠁿

 [sbadenis](https://profiles.wordpress.org/sbadenis/) 2018 年 12 月 6 日

Petit plugin très sympa pour programmer des changements de thème à l'avance. Pour
moi changement de thème pour Noël

![](https://secure.gravatar.com/avatar/f6959029950e50b0c287111da6ff7167928d1d607bb99f240b05425bb0ef5c5a?
s=60&d=retro&r=g)

### 󠀁[Awesome Plugin. Neat and Accurate](https://wordpress.org/support/topic/awesome-plugin-neat-and-accurate/)󠁿

 [Dipak Kumar Pusti](https://profiles.wordpress.org/dipakbbsr/) 2017 年 11 月 16
日

Keep up the good work. Plugin exactly doing what it should do. Perfect 🙂

![](https://secure.gravatar.com/avatar/991e6fbcd995c4ea7af220143d495a67c5be6762dca9101eae54a1c5eb1b3d74?
s=60&d=retro&r=g)

### 󠀁[Awesome](https://wordpress.org/support/topic/awesome-782/)󠁿

 [KodeBurner](https://profiles.wordpress.org/kodeburner/) 2016 年 10 月 7 日

Keep up the good work 🙂

![](https://secure.gravatar.com/avatar/11fa2163ea0c1c9825a3ce00b84f4806467c7c08909d8c40fe5ca1060d8a0e02?
s=60&d=retro&r=g)

### 󠀁[Works Great](https://wordpress.org/support/topic/works-great-3040/)󠁿

 [Lafif Astahdziq](https://profiles.wordpress.org/qutek/) 2016 年 9 月 3 日

Very cool code, thanks for dev

![](https://secure.gravatar.com/avatar/b9ccfa81ba51c8cec6e4e654eee3d1a477c083ab42e06d2425fcb6ce64d7f817?
s=60&d=retro&r=g)

### 󠀁[Thank you](https://wordpress.org/support/topic/thank-you-1207/)󠁿

 [televizor](https://profiles.wordpress.org/televizor/) 2017 年 2 月 8 日

Good work!

![](https://secure.gravatar.com/avatar/b74db95eb70a5f8bd66fd6f1a2cbe64a978b5ad29d5f41b16cf751b7b1d98580?
s=60&d=retro&r=g)

### 󠀁[اضافة رائعة](https://wordpress.org/support/topic/%d8%a7%d8%b6%d8%a7%d9%81%d8%a9-%d8%b1%d8%a7%d8%a6%d8%b9%d8%a9-3/)󠁿

 [abudy_iraq](https://profiles.wordpress.org/abudy_iraq/) 2017 年 2 月 7 日

السلام عليكم اضافة راااائعة جداً

 [ 閱讀全部 10 則使用者評論 ](https://wordpress.org/support/plugin/wp-conditional-themes/reviews/)

## 參與者及開發者

以下人員參與了開源軟體〈Conditional Themes〉的開發相關工作。

參與者

 *   [ Nashwan D ](https://profiles.wordpress.org/alex-ye/)

[將〈Conditional Themes〉外掛本地化為台灣繁體中文版](https://translate.wordpress.org/projects/wp-plugins/wp-conditional-themes)

### 對開發相關資訊感興趣？

任何人均可[瀏覽程式碼](https://plugins.trac.wordpress.org/browser/wp-conditional-themes/)、
查看 [SVN 存放庫](https://plugins.svn.wordpress.org/wp-conditional-themes/)，或透過
[RSS](https://plugins.trac.wordpress.org/log/wp-conditional-themes/?limit=100&mode=stop_on_copy&format=rss)
訂閱[開發記錄](https://plugins.trac.wordpress.org/log/wp-conditional-themes/)。

## 變更記錄

#### 0.6

 * Better code style formatting.

#### 0.4

 * Fix updating switched theme sidebars widgets bug, props @Offereins.
 * Better classes and code organization.

#### 0.4

 * Fix the switched theme sidebars widgets bug, props @joyously.
 * Better functions names and code organization.

#### 0.3

 * Add a new feature allow to switch the themes persistently.
 * Improve the performance by excluding the original theme from being switched.

#### 0.2

 * Cleaner code and minor fixes.

#### 0.1

 * The Initial version.

## 中繼資料

 *  版本 **0.6**
 *  最後更新 **7 年前**
 *  啟用安裝數 **70+**
 *  WordPress 版本需求 ** 3.4 或更新版本 **
 *  已測試相容的 WordPress 版本 **5.2.28**
 *  語言
 * [English (US)](https://wordpress.org/plugins/wp-conditional-themes/)
 * 標籤:
 * [api](https://tw.wordpress.org/plugins/tags/api/)[switch](https://tw.wordpress.org/plugins/tags/switch/)
   [theme](https://tw.wordpress.org/plugins/tags/theme/)[Theme Switcher](https://tw.wordpress.org/plugins/tags/theme-switcher/)
   [themes](https://tw.wordpress.org/plugins/tags/themes/)
 *  [進階檢視](https://tw.wordpress.org/plugins/wp-conditional-themes/advanced/)

## 評分

 4.9 星，滿分為 5 星

 *  [  8 個 5 星使用者評論     ](https://wordpress.org/support/plugin/wp-conditional-themes/reviews/?filter=5)
 *  [  1 個 4 星使用者評論     ](https://wordpress.org/support/plugin/wp-conditional-themes/reviews/?filter=4)
 *  [  0 個 3 星使用者評論     ](https://wordpress.org/support/plugin/wp-conditional-themes/reviews/?filter=3)
 *  [  0 個 2 星使用者評論     ](https://wordpress.org/support/plugin/wp-conditional-themes/reviews/?filter=2)
 *  [  0 個 1 星使用者評論     ](https://wordpress.org/support/plugin/wp-conditional-themes/reviews/?filter=1)

[撰寫評分](https://wordpress.org/support/plugin/wp-conditional-themes/reviews/#new-post)

[查看全部使用者評論](https://wordpress.org/support/plugin/wp-conditional-themes/reviews/)

## 參與者

 *   [ Nashwan D ](https://profiles.wordpress.org/alex-ye/)

## 技術支援

使用者可在技術支援論壇提出意見反應或使用問題。

 [檢視技術支援論壇](https://wordpress.org/support/plugin/wp-conditional-themes/)