Questo plugin non è stato testato con le ultime 3 versioni principali (major releases) di WordPress. Potrebbe non essere più mantenuto, o supportato, e potrebbe presentare problemi di compatibilità se utilizzato con versioni più recenti di WordPress.

TTT Devices

Descrizione

This plugin detects the client device in a simple way at php level.

Identify the device with a CSS body class

  • For a desktop in linux

  • For a desktop in Mac

  • For an iphone mobile

  • For an iphone mobile landscape

  • For an android mobile

And also for IE 😉

How to indentify the device

<?php
if ( is_tttdevice('desktop') ) {
    echo "this is a desktop device";
}
elseif ( is_tttdevice('mobile') ) {
    echo "this is a mobile device";
}
elseif ( is_tttdevice('tablet') ) {
    echo "this is a tablet device";
}
else {
    echo "Opps...  we don't know what this device is!!";
}
?>

How to remove the sidebar for mobile only

<?php
if ( ! is_tttdevice('mobile') ) {
    get_sidebar();
}
?>

This means, the sidebar will not show in mobile devices. This is not the same has “hidden” in CSS, with TTT Devices the code is not sent to the client.

Other keywords to detect devices

<?php
if ( is_tttdevice('iphone') ) {
    echo "this is an iPhone";
}
if ( is_tttdevice('android') ) {
    echo "this is an android";
}
if ( is_tttdevice('windowsphone') ) {
    echo "this is an windows phone";
}
if ( is_tttdevice('mobile') ) {
    echo "this is a mobile";
}
?>

Stop loading some js for mobile

It is very useful if you need make your site faster for mobile or tablet, these browsers can’t handle well some javascript effects. You can stop loading them in mobile devices. Example:

In your functions.php file:

function heavyanimation_script() {
    if ( is_tttdevice('desktop') ) { 
        wp_enqueue_script( 'heavyanimation', get_template_directory_uri() . '/js/havyscript.js', array('jquery'));
    }
}   
add_action('wp_enqueue_scripts', 'heavyanimation_script');

This means that js only loads in desktop devices, easy 🙂

Installazione

This section describes how to install the plugin and get it working.

  1. Upload ttt-devices folder to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress

FAQ

How does the plugin detecte devices?

We use the user agent of the browser client.

Does the plugin use some standar library?

Yes, we use the sources from http://www.mobileesp.com

For better performance with server cache systems like varnish the plugin detects the browser using Javascript. The idea came from this threat: http://stackoverflow.com/a/2401861

Recensioni

Non ci sono revisioni per questo plugin.

Contributi e sviluppo

“TTT Devices” è un software open source. Le persone che hanno contribuito allo sviluppo di questo plugin sono indicate di seguito.

Collaboratori

Traduci “TTT Devices” nella tua lingua.

Ti interessa lo sviluppo?

Esplora il Codice segui il Repository SVN iscriviti al Log delle Modifiche. Puoi farlo tramite RSS con un lettore di feed.