{"id":25747,"date":"2013-10-19T00:18:38","date_gmt":"2013-10-19T00:18:38","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/wp-conditional-themes\/"},"modified":"2019-07-19T16:18:50","modified_gmt":"2019-07-19T16:18:50","slug":"wp-conditional-themes","status":"publish","type":"plugin","link":"https:\/\/twd.wordpress.org\/plugins\/wp-conditional-themes\/","author":5941287,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"0.6","stable_tag":"0.6","tested":"5.2.24","requires":"3.4","requires_php":"","requires_plugins":"","header_name":"Conditional Themes","header_author":"Nashwan Doaqan","header_description":"","assets_banners_color":"","last_updated":"2019-07-19 16:18:50","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"https:\/\/github.com\/nash-ye\/WP-Conditional-Themes","header_author_uri":"https:\/\/profiles.wordpress.org\/alex-ye\/","rating":4.9,"author_block_rating":0,"active_installs":50,"downloads":4766,"num_ratings":9,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":"1","5":"9"},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["0.1","0.2","0.3","0.4","0.5","0.6"],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[1556,2414,1141,11085,1249],"plugin_category":[43],"plugin_contributors":[80699],"plugin_business_model":[],"class_list":["post-25747","plugin","type-plugin","status-publish","hentry","plugin_tags-api","plugin_tags-switch","plugin_tags-theme","plugin_tags-theme-switcher","plugin_tags-themes","plugin_category-customization","plugin_contributors-alex-ye","plugin_committers-alex-ye"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/wp-conditional-themes.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=description-->\n<p>Conditional Themes is an API to switch the themes on certain conditions.<\/p>\n\n<h4>Usage<\/h4>\n\n<p>Write an another plugin file and use the Conditional Themes API as the example below:<\/p>\n\n<pre><code>add_action('plugins_loaded', 'my_conditional_themes_setup', 100);\n\nfunction my_conditional_themes_setup()\n{\n    \/\/ Switch to Twenty Eleven theme if the visitor use Internet Explorer.\n    Conditional_Themes_Manager::register('twentyeleven', function() {\n        global $is_IE;\n        return (bool) $is_IE;\n    });\n\n    \/\/ Switch to Twenty Thirteen theme if the user has administrator role.\n    Conditional_Themes_Manager::register('twentythirteen', function() {\n        return current_user_can('administrator');\n    });\n\n    \/\/ Switch to a custom theme if the visitor use a mobile device.\n    Conditional_Themes_Manager::register('mobile', 'wp_is_mobile');\n}\n<\/code><\/pre>\n\n<p>Another example, With enabling persistent mode.<\/p>\n\n<pre><code>add_action('plugins_loaded', 'my_conditional_themes_setup', 100);\n\nfunction my_conditional_themes_setup()\n{\n    \/\/ Enable the switcher persistent mode.\n    Conditional_Themes_Manager::set_option('persistent', true);\n\n    \/\/ Switch to Twenty Sixteen theme when we being on 2016.\n    Conditional_Themes_Manager::register('twentysixteen', function() {\n        return (date('Y') == 2016);\n    });\n\n    \/\/ Switch to Twenty Fifteen theme when the site reaches 500 post.\n    Conditional_Themes_Manager::register('twentyfifteen', function() {\n        return ((int) wp_count_posts() &gt; 500);\n    });\n}\n<\/code><\/pre>\n\n<p>Note: You can use <a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\">Code Snippets<\/a> plugin to add the code snippets to your site.<\/p>\n\n<h4>Contributing<\/h4>\n\n<p>Developers can contribute to the source code on the <a href=\"https:\/\/github.com\/nash-ye\/WP-Conditional-Themes\">Github Repository<\/a>.<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Upload and install the plugin<\/li>\n<li>Use the plugin API to powerful your project.<\/li>\n<\/ol>\n\n<!--section=changelog-->\n<h4>0.6<\/h4>\n\n<ul>\n<li>Better code style formatting.<\/li>\n<\/ul>\n\n<h4>0.4<\/h4>\n\n<ul>\n<li>Fix updating switched theme sidebars widgets bug, props @Offereins.<\/li>\n<li>Better classes and code organization.<\/li>\n<\/ul>\n\n<h4>0.4<\/h4>\n\n<ul>\n<li>Fix the switched theme sidebars widgets bug, props @joyously.<\/li>\n<li>Better functions names and code organization.<\/li>\n<\/ul>\n\n<h4>0.3<\/h4>\n\n<ul>\n<li>Add a new feature allow to switch the themes persistently.<\/li>\n<li>Improve the performance by excluding the original theme from being switched.<\/li>\n<\/ul>\n\n<h4>0.2<\/h4>\n\n<ul>\n<li>Cleaner code and minor fixes.<\/li>\n<\/ul>\n\n<h4>0.1<\/h4>\n\n<ul>\n<li>The Initial version.<\/li>\n<\/ul>","raw_excerpt":"A simple API to switch the themes on certain conditions.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/25747","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=25747"}],"author":[{"embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/alex-ye"}],"wp:attachment":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=25747"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=25747"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=25747"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=25747"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=25747"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=25747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}