Skip to content

Instantly share code, notes, and snippets.

@raphaelchaib
Created March 24, 2014 14:59
Show Gist options
  • Save raphaelchaib/9741782 to your computer and use it in GitHub Desktop.
Save raphaelchaib/9741782 to your computer and use it in GitHub Desktop.
WordPress: Adjust site to viewport. iPad calculate the site width by landscape view, and it makes the site to get cut in the portrait view. This is the default schema for WordPress, but can be modified to work in another plataforms.
<?php
/* Viewport meta tag */
add_action( 'wp_head', 'cg_viewport_meta' );
function cg_viewport_meta() {
if( is_ipad() ) :
echo '<meta name="viewport" content="width=device-width; initial-scale=0.8" />';
else :
echo '<meta name="viewport" content="width=device-width;" />';
endif;
}
/* Detect if it is an iPad */
function is_ipad() {
$is_ipad = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPad');
if ($is_ipad)
return true;
else return false;
}
@viewport{
zoom: 1.0;
width: extend-to-zoom;
}
@-ms-viewport{
zoom: 1.0;
width: extend-to-zoom;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment