WordPress.org

Ready to get started?Download WordPress

Forums

Mobile Smart
[resolved] Redirect doesn't load desktop css (7 posts)

  1. davezatch
    Member
    Posted 2 years ago #

    The plugin is working well but when I load the desktop version from the mobile version, it doesn't load the desktop css file, so everything is haywire until I refresh. Started fooling around with getting the referrer link with PHP but perhaps this is an issue you know a workaround for?

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

  2. dolby_uk
    Member
    Plugin Author

    Posted 2 years ago #

    Hi Dave,

    Sorry to hear you're having problems. I've not seen this issue before - though this could be a cookie problem. You can test if this is true, by clicking on a further page once you're on the (non-styled) desktop version - does it return to the mobile site or stay on the desktop version (non-styled / styled)?

    It might also be something to do with if you're using a child theme - there have been reports of occasional problems with such themes, but nothing that I've been able to repeat yet.

    Best regards,

    Dan

  3. davezatch
    Member
    Posted 2 years ago #

    Dolby_uk,
    You were right about the cookies. I'm also using jquery mobile which hijacks all my links. Had to add a rel="external" on the switch to desktop link, now it works fine. Thanks for the great plugin!

    Dave

  4. dolby_uk
    Member
    Plugin Author

    Posted 2 years ago #

    Dave,

    OK that's good. So is it working now, or do you need support on the cookie issue?

    Dan

  5. davezatch
    Member
    Posted 2 years ago #

    Dan,
    It's working now, marking as solved.

    Thanks,
    Dave

  6. jason_lane
    Member
    Posted 2 years ago #

    Dan,

    I encountered what appears to be the same problem; on my sites (a dev site on my local machine, and a live site) the plugin wasn't switching to the desktop version when the switcher link was clicked. I think I narrowed it down to 2 things:

    1. When the plugin sets a cookie to indicate the preference to view the desktop site, the cookie data wasn't being set properly. I had a look in the plugin code, and I can see that the last parameter of the setcookie() function is trying to set the correct domain name for the cookie (on line 964 of mobile-smart.php). However, on my two sites, the domain that was being set was invalid, for 2 different reasons:

    a) The plugin tries to strip 'http://www' from the front of the blog's home url, to leave a bare domain (eg. example.com). However, I usually use naked domains on my sites, so there's no 'www' in the blog url, and therefor the plugin code doesn't strip the 'http' part from the url (eg. http://example.com). I don't believe that's a valid domain for a cookie.

    b) My dev site uses a multisite WP install, with subfolders. So the blog url would be something like 'http://example.com/blogname/' AFAIK, the domain paramater for setcookie() must be just the domain part, without subfolders.

    For me, the easy fix was to just remove the whole domain parameter from the setcookie() function call. I'm not an expert with cookies, but from what I can tell, the domain parameter is optional, and if it's left out, the current domain is assumed. So, by simply removing the domain parameter, the theme switching link seems to be working on my sites. Or at least, except for issue number 2....

    2. I'm not completely sure about this one, as I haven't had time to have a proper dig into the code, but the issue is that the plugin doesn't switch themes after the first click of the switcher link. The theme only switches after I do a refresh or navigate elsewhere. The mobile theme in this case is a child theme of the desktop theme. You mentioned some people have reported problems with child themes, and I think this might be the same issue. I've had a look at the code, but I've found some strange things that appear to be going on, and I'd need more time to figure this one out.

  7. jherndon
    Member
    Posted 2 years ago #

    Had the same "naked' url issue, the above fix worked for me as well.

    For clarity changed lines 963 & 964 from:

    COOKIEPATH,
    str_replace('http://www','',get_bloginfo('url')));

    to just one line:

    COOKIEPATH);

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic