-
Notifications
You must be signed in to change notification settings - Fork 9
2 Features
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 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'
<?php link_to_full_website( $link_text = "View Full Website", $css_classes = array(), $echo = true ); ?>
// Display a link to 'Return to Mobile Website'
<?php link_back_to_device( $link_text = "Return to Mobile Website", $css_classes = array(), $echo = true ); ?>
Shortcodes can be used in the content of any post, page, or custom-post-type.
[link_to_full_website link_text="View Full Website" css_classes="blue-text, alignleft"]
[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):
<style type="text/css">
.dts-link {
font-size: 1.5em ;
}
.dts-link.to-full-website {
color: red ;
}
.dts-link.back-to-mobile {
color: blue ;
}
</style>
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:
<?php
//Access the device theme switcher object anywhere in your theme or plugin
$dts = get_dts_switcher();
//use it..
if ( $dts->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)
)
?>