iPhone Viewport Meta Plugin for WordPress

Get the plugin from wordpress.org.

Update 4: Plugin now hosted at wordpress.org.

Update 3: New version with support for viewport constants, and iPod Touch.

Update 2: James Craig points out that the ID attribute is not allowed in the META element, so I’ve updated the plugin.

Update: I should add what my aim is. Rather than creating a separate template for mobile, I want to have a theme that ‘does the right thing’ for iPhone and desktop browsers.

Some documentation:

  1. Plugin tests user agent string.
    • If it contains ‘iPhone’ then it adds <meta content="width=480; maximum-scale=0.6667" name="viewport"/> to the document’s head.
    • It also adds iPhone specific CSS rules. For that reason, you should call wp_head() in your theme file after you declare your default CSS files.
    • These rules were written with Sandbox in mind. You will want to edit the CSS rules to suit your theme.
    • You can force the viewport and CSS rules by adding forceiphone=y to the query string portion of a URL.
  2. Adds a boolean function: weh_is_iPhone().
    • Returns true if user agent string contains ‘iPhone’.
    • You can call this function from your theme to add or turn off generation of markup.
    • Most likely you’ll use it to turn off generation of sidebars.

More like this: , , , , , .

6 Comments

  1. Posted July 13, 2007 at 11:03 pm | Permalink

    Thanks for doing this…works great!

  2. Posted September 5, 2007 at 4:24 pm | Permalink

    ID is invalid on a META element.

  3. Posted September 5, 2007 at 9:41 pm | Permalink

    James, thanks for pointing that out. I’ve updated the plugin.

  4. Posted October 8, 2007 at 2:31 pm | Permalink

    I also just heard (from a good source) that semi-colons are invalid and all those internal delimiters should be commas. That was news to me.

    Ex: “width=480; maximum-scale=0.6667″
    Becomes: “width=480, maximum-scale=0.6667″

  5. Posted November 26, 2007 at 7:20 pm | Permalink

    At the moment I do not have a iPhone but i would like to develop content for it so i downloaded iphoney and viewed my site with your plugin (it looks no different ) am I doing something wrong ? what emulator do you use ?

  6. Posted April 13, 2008 at 12:13 am | Permalink

    dear bill, how do i adjust the plug so that the background image of the site will not be loaded? i really like the plugin, but the background image destroys everything….

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*