=== Plugin Name === Plugin Name: Device Theme Switcher Contributors: jamesmehorter Requires at least: 3.0 Tested up to: 4.3.1 Stable tag: 3.0.0 Tags: Theme, Switch, Change, Mobile, Mobile Theme, Handheld, Tablet, iPad, iPhone, Android, Blackberry, Tablet Theme, Different Themes, Device Theme Author URI: http://www.jamesmehorter.com/ Plugin URI: https://github.com/jamesmehorter/device-theme-switcher License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html Assign separate themes for handheld and tablet devices under Appearance > Device Themes == Description == Device Theme Switcher is a WordPress plugin which delivers one of your WordPress themes to handheld visitors and another theme to tablet visitors. Computer visitors are given the active theme in 'Appearance > Themes'. == Screenshots == 1. View of the Device Theme Switcher settings. 2. View of the two Device Theme Switcher Widgets and their settings. == Installation == = How to Install = Install and activate in your WordPress Dashboard 'Plugins > Add New' section by searching for 'Device Theme Switcher'. After activation you'll have a new menu: 'Appearance > Device Themes'--where you set which theme is given to which visitor device. == Features == = URL Switching = Your device themes can be easily accessed to 'test' and see what other devices see. `www.mywebsite.com/?theme=handheld www.mywebsite.com/?theme=tablet www.mywebsite.com/?theme=low_support www.mywebsite.com/?theme=active` You can also use these ?theme= query strings in themes for your users—however, our built in template tags also retain the page the user is currently on and any other query string variables in the URL. = Template Tags, Shortcodes, and Widgets = Template Tags, Shortcodes, and Widgets all output a simple HTML anchor tag which links to the mobile/active theme for the website by using URL Switching (See Above). Template tags can be used in any theme or plugin file: `// Display a link to 'View Full Website' // Display a link to 'Return to Mobile Website' ` Shortcodes can be used in the content of any post, page, or custom-post-type: `// Display a link to 'View Full Website' [link_to_full_website link_text="View Full Website" css_classes="blue-text, alignleft"] // Display a link to 'Return to Mobile Website' [link_back_to_device link_text="Return to Mobile Website" css_classes="red-text, alignright"]` The anchor tags output with a CSS class of 'dts-link'. The 'View Full Website' anchor tag also has a class of 'to-full-website' and the 'Return to the Mobile Website' link has an additional class of 'back-to-mobile'. Link Styling Example (For Template Tags, Widgets, or Shortcodes): `` = DTS Internal Switcher Class = The DTS_Switcher class creates an object which contains all the run-time device theme switcher settings and the current visitor device. You can access this class object anywhere in your theme or plugin: `device == 'tablet' ) do_something() ; //See what's in there.. print_r( $dts ) ; DTS_Switcher Object ( [handheld_theme] => Array ( [name] => Responsive [template] => responsive [stylesheet] => responsive ) [tablet_theme] => Array ( [name] => Twenty Twelve [template] => twentytwelve [stylesheet] => twentytwelve ) [low_support_theme] => Array ( [name] => WordPress Default [template] => default [stylesheet] => default ) [active_theme] => Array ( [name] => Responsive [template] => responsive [stylesheet] => responsive ) [device] => active (Possible values: active, handheld, tablet, and low_support) [theme_override] => tablet (Possible Values: See Above)(Explanation: I'm on a computer, so my device is 'active' [I get the active theme] and I used a URL parameter [site.com?theme=tablet] to view the tablet theme) ) ?>` == Frequently Asked Questions == = Which devices are considered 'handheld' and which are 'tablet'? = 'Handheld' devices include Android, BlackBerry, iPod, iPhone, Windows Mobile, and other various 'hand held' smart phones. 'Tablet' devices include iPad, Android tablets, Kindle Fire and other large-screen handhelds. 'Low Support' devices include those which have poor CSS & JavaScript rendering capabilities-often these are older devices. = Are WordPress child themes supported? = Yes! = How do I display 'View Full Website' and 'Back to Mobile Site' links? = See our [Features page](https://wordpress.org/plugins/device-theme-switcher/features/) for details on using Widgets, Template Tags, or Shortcodes to display 'View Full Website' and 'Back to Mobile Site' links. = Help!? My theme isn't working! = If your theme does not work as expected on any of the devices-**the issue is with the theme, NOT with the plugin!** Follow [typical WordPress debugging practices](http://codex.wordpress.org/Debugging_in_WordPress) to find and correct the issue in your theme (Or possibly another plugin). The only theme-requirement this plugin relies on is that you have [properly-written WordPress themes](http://codex.wordpress.org/Theme_Development#Theme_Development_Standards). If your theme activates in Appearance > Themes and you can preview the theme in your computer's browser-then it is 'properly-written' as far as Device Theme Switcher is concerned. = How do Menus and Widgets work?! = All Device Theme Switcher really does is change which theme is delivered to the visitor based on the device they're using-*but WordPress still thinks the active theme is 'active' the whole time*. This means you need to have your `register_nav_menu()` or `register_widget()` functions in all your themes! See below for details and examples. = How do I show the same menu in each theme? = Simply place you register_nav_menu('my-menu-location', 'My Menu Location Name'); function in both of your primary/active and handheld/tablet theme functions.php files. Then, while your primary theme is 'active' go into Appearance > Menus-create your menu and assign it to the menu location-and populate it with some menu items. That's it! = How do I show one menu in my active theme and a different menu in my handheld/tablet theme? = Register a menu location for each theme, and place your register_nav_menus() code in each theme. E.g.: In each theme's functions.php file: `register_nav_menus(array( 'active-menu-location' => 'Active Theme Menu Location', 'handheld-menu-location' => 'Handheld Theme Menu Location', 'tablet-menu-location' => 'Tablet Theme Menu Location', ));` Then, while your primary theme is 'active' go into Appearance > Menus-create your 3 menus-assign each one to their designated menu location-and populate each with some menu items. Lastly we just need to display each menu in each theme: Active theme header.php: `wp_nav_menu(array('theme_location' => 'active-menu-location'));` Handheld theme header.php `wp_nav_menu(array('theme_location' => 'handheld-menu-location'));` Tablet theme header.php `wp_nav_menu(array('theme_location' => 'tablet-menu-location'));` That's it-the important part is that you register each location in each theme! = How can I display the same sidebar in each theme? = Place the same register_sidebar() function in each theme's functions.php file, and add your widgets to your sidebar while the primary theme is 'active'. = How can I display a different sidebar in each theme? = Place the same 3 register_sidebar() functions in each theme's functions.php file, and add your widgets to each sidebar while the primary theme is 'active'. E.g: In each theme's functions.php file: `register_sidebar(array('name' => 'Active Theme Sidebar')); register_sidebar(array('name' => 'Handheld Theme Sidebar')); register_sidebar(array('name' => 'Tablet Theme Sidebar'));` Then, while your primary theme is 'active' go into Appearance > Widgets-and assign some widgets to each sidebar. Lastly we just need to display each sidebar in each theme: Active theme page.php: `dynamic_sidebar('Active Theme Sidebar');` Handheld theme page.php `dynamic_sidebar('Handheld Theme Sidebar');` Tablet theme page.php `dynamic_sidebar('Tablet Theme Sidebar');` == Changelog == = Version 3.0.0 - Released 10/23/2015 = * New banner and icon! :) * FIX - Corrected an issue with the plugin update code which caused some user's to not receive the complete update routine. * FIX - Added rel="nofollow" to the device switcher links which the plugin creates. Thanks ljmac for this! https://wordpress.org/support/topic/please-make-theme-switcher-link-no-follow?replies=2 * FIX - Corrected a PHP recursion found by Jonathan McLean (https://github.com/jmclean) * FIX - Updated widget classes per WP_Widget deprecated use PHP notice * IMPROVEMENT - Rewrote several aspects of the plugin to improve testability, which ultimately improves the codebase architecture and readability. * IMPROVEMENT - Updated to the latest [MobileESP version](https://github.com/ahand/mobileesp) * IMPROVEMENT - Introduced initial phpunit tests for the plugin. * IMPROVEMENT - Moved the massive Github readme into sections in a new Github wiki. * IMPROVEMENT - Implemented Travis on-the-fly testing integration for Github. * IMPROVEMENT - Implemented Grunt for SASS & JS complilation, and automated *.pot file creation for translators. = Version 2.9.2 - Released 12/19/2014 = * FIX - Completely removed the use of a singleton base class. It just doesn't work for PHP <= 5.2 which we must support. = Version 2.9.1 - Released 12/18/2014 = * FIX - Removed use of Late Static Binding which is a PHP 5.3 feature, though WordPress supports back to PHP 5.2.4. Thank you Craig S. for pointing this out! = Version 2.9.0 - Released 12/18/2014 = * IMPROVRMENT - Rewrites/Modifications throughout the plugin code to improve overall stability, maintainability, and adherence to WordPress Coding Standards. * IMPROVEMENT - Rewrote the updating routine to be far more stable, logical, and to allow 3 digit version numbers (ex: 2.9.0). * IMPROVEMENT - Added initial .pot for i18n. Users can now provide translations via .po files by using the .pot. * FIX - Corrected an issue reported by QStudio (https://wordpress.org/support/topic/small-bug-in-28?replies=2#post-6238900) whereby the plugin update routine would fail and run on each page load. Ouch. Thanks QStudio! = Version 2.8 - Released 5/18/2014 = * FIX - Removed an empty space (whitespace) preceding Device Themes Allows users to override the session timeout. Also moved the low-support theme setting to this section. This new section also a * NEW - Help & Support section in the WordPress admin in Appearance > Device Themes * Included the latest version of MobileESP ~ Thanks Anthony! = Version 1.9 = * Note: DTS Version 1.9 was not released to the public * NEW - Made the Admin UI more presentable and WordPressy * FIX - Included a pull request from Tim Broder (https://github.com/broderboy) which adds support for Varnish Device Detect (https://github.com/varnish/varnish-devicedetect). Thanks Tim!! = Version 1.8 = * Updated the Kindle detection for a wider range of support = Version 1.7 = * Updated the plugin to provide backwards compatible support for WordPress < v3.4 (Pre the new Themes API) * Added a 3rd theme selection option for older/non-compliant devices, so theme authors can also supply a text-only version to those devices if they like. * Revised some language in the plugin readme file = Version 1.6 = * Updated the plugin to use the new Theme API within WordPress 3.4 * Updated MobileESP Library to the latest verion (April 23, 2012) which adds support for BlackBerry Curve Touch, e-Ink Kindle, and Kindle Fire in Silk mode. And fixed many other bugs. * Updated the Device Theme Switcher widgets so they only display to the devices they should, e.g. The 'View Full Website' widget will only display in the handheld theme. * Revised readme language and added a WordPress Plugin Repository banner graphic. = Version 1.5 = * Modified the way themes are deliveried so the process is more stable for users with odd WordPress setups, by detecting where their theme folders are located instead of assuming wp-content/themes = Version 1.4 = * Updated to the latest version of the MobileESP library which now detects some newer phones like the BlackBerry Bold Touch (9900 and 9930) = Version 1.3 = * Changed the admin page to submit to admin_url() for those who have changed /wp-admin/ * Added a warning suppresor to session_start() in case another plugin has already called it * Updated language in the WordPress readme file = Version 1.2 = * Added the handheld and tablet theme choices to the WordPress Dashboard Right Now panel * Update both GitHub and WordPress readme files to be better styled and versed * Added two wigets for users to put in their themes * Coding and efficiency improvments = Version 1.1 = * Bug fixes * Efficency improvements = Version 1.0 = * First Public Stable Release == Upgrade Notice == = 2.0 = Major Improvements, New Features, and even prettier! == Credits == This plugin is powered by the MobileESP PHP library created by Anthony Hand (http://blog.mobileesp.com/). This plugin is based on the concepts provided by Jonas Vorwerk's (http://www.jonasvorwerk.com/) Mobile theme switcher plugin, and Jeremy Arntz's (http://www.jeremyarntz.com/) Mobile Theme Switcher plugin. Copyright (C) 2015 James Mehorter