WordPress.org

Ready to get started?Download WordPress

Forums

Mobile Smart
Excludes some gadgets (8 posts)

  1. genim
    Member
    Posted 3 years ago #

    I really want only iphone to show diferrent theme.. whats the conditional statement for this.. and which part of the codes?

    May if I could do this.. I could do different themes for some of the other gadgets also?

    http://wordpress.org/extend/plugins/mobile-smart/

  2. dolby_uk
    Member
    Plugin Author

    Posted 3 years ago #

    There is currently no functionality built in to directly change theme depending on mobile device - rather it changes to a mobile theme, which you can then perform conditional statements within.

    For example, you can include a different stylesheet if you are using an iPhone:

    global $mobile_smart;
    
    if ($mobile_smart && $mobile_smart->getCurrentDevice() == MOBILE_DEVICE_IPHONE) {
      ?>
      <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/css/iphone.css"/>
      <?php
    }

    Or you can include different loop files, e.g.

    global $mobile_smart;
    
    if ($mobile_smart && $mobile_smart->getCurrentDevice() == MOBILE_DEVICE_IPHONE) {
      get_template_part('loop', 'iphone'); // looks for loop-iphone.php in your theme folder
    }
    else {
      get_template_part('loop'); // looks for loop.php in your theme folder
    }

    Does this help you?

    Best...Dan

  3. danpaulson
    Member
    Posted 3 years ago #

    Hey Dan, thanks for the great plugin. I'm looking for an avenue of disabling the theme swap for Tablet, and specifically iPad platforms. Is there any quick hackish way to get around this? Thanks.

  4. dolby_uk
    Member
    Plugin Author

    Posted 3 years ago #

    Hi Dan,

    I'm currently writing an admin screen for excluding devices, however, in the meantime:

    in the DetectIsMobile() function, on line 663, modify it from:

    return ( $this->DetectMobileQuick() || $this->DetectIpad() );

    to

    return ( $this->DetectMobileQuick() /*|| $this->DetectIpad()*/ );

    Hope this helps,

    Dan

  5. danpaulson
    Member
    Posted 3 years ago #

    Thanks Dan, works brilliantly. Looking forward to the update as well, thank you for all the good work.

  6. genim
    Member
    Posted 3 years ago #

    Thanks Dan....

    somehow i got it using a your conditions with
    a few twists....

  7. dolby_uk
    Member
    Plugin Author

    Posted 3 years ago #

    Glad it works danpaulson and genim.

    Genim - any chance you could post here what those twists were, in case it can help others in the same situation?

    Cheers...Dan

  8. kristarella
    Member
    Posted 2 years ago #

    Thought I'd throw my 2c in, as I was just looking into this same issue for someone. I used this in my child theme's functions file to add the desktop cookie for tablets.

    function desktop_tablet() {
    	global $mobile_smart;
    	if ($mobile_smart->DetectTierTablet() && !isset($_COOKIE[MOBILESMART_SWITCHER_COOKIE]))
    		setcookie(MOBILESMART_SWITCHER_COOKIE,'desktop');
    	$current_page = $_SERVER['PHP_SELF'];
    	header("Location: $current_page");
    }
    add_action('template_redirect','desktop_tablet');

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic