Linux 软件免费装

Conditional Themes

开发者 alex-ye
更新时间 2019年7月20日 00:18
PHP版本: 3.4 及以上
WordPress版本: 5.2.2
版权: GPLv2 or later
版权网址: 版权信息

标签

theme themes api switch theme-switcher

下载

0.1 0.2 0.3 0.4 0.5 0.6

详情介绍:

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.

安装:

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

更新日志:

0.6 0.4 0.4 0.3 0.2 0.1