前言介紹
- 這款 WordPress 外掛「Conditional Themes」是 2013-10-18 上架。
- 目前有 60 個安裝啟用數。
- 上一次更新是 2019-07-19,距離現在已有 2115 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 3.4 以上版本才可以安裝。
- 有 9 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
alex-ye |
外掛標籤
api | theme | switch | themes | Theme Switcher |
內容簡介
Conditional Themes 是一個用來依照特定條件切換 WordPress 主題的 API。
使用方法
寫一個額外的外掛檔案並像下面的範例一樣使用 Conditional Themes API:
add_action('plugins_loaded', 'my_conditional_themes_setup', 100);
function my_conditional_themes_setup()
{
// 如果使用者使用 Internet Explorer,則切換成 Twenty Eleven 主題。
Conditional_Themes_Manager::register('twentyeleven', function() {
global $is_IE;
return (bool) $is_IE;
});
// 如果使用者的身份是管理員,則切換成 Twenty Thirteen 主題。
Conditional_Themes_Manager::register('twentythirteen', function() {
return current_user_can('administrator');
});
// 如果使用者使用行動裝置,則切換成自訂主題。
Conditional_Themes_Manager::register('mobile', 'wp_is_mobile');
}
另一個例子,啟用永續模式。
add_action('plugins_loaded', 'my_conditional_themes_setup', 100);
function my_conditional_themes_setup()
{
// 啟用切換器的永續模式。
Conditional_Themes_Manager::set_option('persistent', true);
// 當我們處於 2016 年時,切換成 Twenty Sixteen 主題。
Conditional_Themes_Manager::register('twentysixteen', function() {
return (date('Y') == 2016);
});
// 當網站文章數超過 500 篇時,切換成 Twenty Fifteen 主題。
Conditional_Themes_Manager::register('twentyfifteen', function() {
return ((int) wp_count_posts() > 500);
});
}
注意:您可以使用 Code Snippets 外掛將程式碼片段新增到您的網站中。
貢獻
開發人員可以在 Github 儲存庫 上貢獻原始碼。
原文外掛簡介
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 plugin to add the code snippets to your site.
Contributing
Developers can contribute to the source code on the Github Repository.
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Conditional Themes」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
0.1 | 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | trunk |
延伸相關外掛(你可能也想知道)
Manage Notification E-mails 》這個外掛可以讓您開啟或關閉不同的 WordPress 通知電子郵件,例如 WordPress 傳送到管理員和使用者的新使用者和密碼更改通知選項。與許多其他外掛完美結合!,...。
View Admin As 》最終的使用者切換器和角色管理員, 此外掛程式將在管理列中新增一個選單項目,您可以透過它在 WordPress 後台中切換視角。, 無需登入其他使用者帳號,您便可以...。
Sticky Posts – Switch 》這個外掛為文章管理列增加了一欄,讓你可以輕易地將文章標記為置頂狀態。, 文章置頂 (Sticky Posts) 是 WordPress 僅適用於文章的功能,透過這個外掛,你可以...。
Theme Switcha – Easily Switch Themes for Development and Testing 》主題切換正確無誤。, , 在前端私下預覽任何主題, , 在後台私下開發主題, , 使訪客可以切換主題, , 有很多主題切換插件,但沒有一個提供我自己網站所需的簡單...。
Flag Icons 》此外掛可讓您在網站上加入國旗圖示以及可指定的鏈結,可藉由選擇所需的位置或使用簡碼實現。, 第二版支援 Google 翻譯圖示!, 您只需選擇位置、旗幟以及新增...。
Menu Swapper 》菜單交換器(Menu Swapper)提供兩個實用工具:, , , 設置頁面,允許您註冊無限菜單主題位置。, , , 一個元框(meta box),它會出現在頁面和文章上,允許您...。
Taxonomy Switcher 》這個外掛允許您選擇您的「From」和「To」分類法,以轉換所有項目。選擇一個父項可以選擇轉換項目的範圍。在輸入名稱時,將會即時搜尋包含特定名稱和子項目的...。
Fast User Switching 》這個外掛讓您可以快速切換使用者和角色,而不需要離開管理列或是使用者列表,您可以從列表中切換,或是透過使用 ID、使用者名稱、電子郵件等方式搜尋使用者/...。
Plugin Name: Device Theme Switcher 》Device Theme Switcher(裝置主題切換器)是一個 WordPress 外掛,可提供您的 WordPress 主題給行動裝置和平板裝置,電腦訪客會收到在「外觀 > 主題」下啟...。
Fast Page Switch 》此外掛程式將在任何文章類型的編輯畫面中增加一個新的 metabox,您可以使用 Select2 jQuery 外掛快速在所有可用的文章之間切換,而不需要先訪問「所有文章」...。
LIQUID RWD Plus 》這是 Responsive Web Design Plus (RWD+) 外掛。, 使用者能夠在智慧型手機上切換行動裝置和 PC 顯示。, 範例 – Twenty Seventeen 佈景主題與 RWD+。, ...。
Localize WordPress 》這個外掛能夠讓你將 WordPress 安裝語言切換為在 GlotPress 上提供的任何語言。, 一些功能包括:, , 無需 gettext 編譯器!, 完成所有繁瑣的編輯 wp-config.p...。
Switch Core 》Switch Core 是一個免費的 WordPress 外掛,可以用於開發不同的區域,例如:輪播、關於我們、特色、團隊、推薦、作品集、聯絡等等。它是一個非常輕量級的外掛...。
Cryout Theme Switch 》快速輕鬆地切換不同的佈景主題。此外掛會在 WordPress 後台管理列中添加一個主題切換器,內含所有父子佈景主題的篩選列表及常用佈景主題列表。與 WordPress 4...。
Switch Pages 》使用這個外掛,你可以得到一個下拉式選單,並從中選擇你想要編輯的頁面/文章。當你要編輯另一個頁面/文章時,不需要一遍又一遍地轉到「頁面」頁面。只需選擇...。