[resolved] Different default themes for different browsers? (4 posts)

  1. Blogesque
    Posted 10 years ago #

    Is there a way to stick some code into either the root INDEX.PHP file or Ryan Boren's Theme Switcher 0.3 plugin file to specify that IE users default to ThemeX, Firefox users get ThemeY and Opera users get ThemeZ?

    The idea works like this:

    user theme cookie
    load that theme

    load ThemeX

    load ThemeY

    load ThemeZ

    Is this possible, and how would it be coded?

    PS: 0.3 was harder to find than 0.1, so if anyone else is having as much trouble as I did locating it, it's here:

  2. Kafkaesqui

    Posted 10 years ago #

    Um, hmm. I think something like this might do it:


    (EDIT: fixed code in pastebin)

    It should go at the top of the header.php template (i.e. above the <head>).

    Notes on the code (I'd read them):

    1. Try to keep MSIE the last option (before a default), only because some browsers mark themselves as MSIE compatible (and get tagged as IE by the *simplistic* code).

    2. I added a default (the final "else"), but you could drop it.

    3. "Gecko" can be changed to "Firefox", but usually one wants to catch all Mozilla-based clients (those using the Gecko rendering engine).

    4. If you can set up a browscap.ini, you're better off on this with the get_browser() function:

    http://php.net/get_browser (info on browscap.ini there)

    5. People who have cookies disabled (for your site, or generally) are not going to like this. If someone can come up with a cookie test to add to this? I'm not sure I'd go public with the code linked above until you have some way to test for cookies (and not just the wptheme cookie).

  3. Blogesque
    Posted 10 years ago #

    Do you mean "wp-blog-header.php" in the ./wordpress directory? I don't have anything titled just plain "header.php." And does "fixed the code" mean that the correct code is in the text box rather than the colored display at the top?

    I'm on a fairly standard install of, the short & sweet "index.php" is in my webroot and everything else is in ./wordpress. The only real customizing I've done is adding a few plugins and a pile of themes. I don't know php so I don't tinker with it much, because I don't like fatal errors.

    This isn't crucial or anything, it was just an idea I had to short-circuit the "it doesn't work right in (browser)" problem if I decided to take advantage of certain features that one has and another doesn't (OK, mainly IE).

    I know you can do user_agent tricks with HTML, but with the Theme Switcher plugin and user cookies involved, I wasn't quite sure how to go about it. I'm not a programmer by any stretch of the imagination.

    Click my username to look at my site if you want, but there's not really a problem to see...this was more an idea to avoid the problem before I caused it. :-P

  4. Kafkaesqui

    Posted 10 years ago #

    "Do you mean "wp-blog-header.php" in the ./wordpress directory?"

    No, I mean the header.php template of your current theme. If it doesn't have one, then look for the template(s) that hold the <head>.

    "Fixed the code" means I messed something up, and I corrected it (with the new pastebin link). The EDIT was just a warning that things changed from the timestamp on my reply.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.