Wordpress: Detect Safari On iOS


/ Published in: PHP
Save to your folder(s)

It's probably not a good idea to always use this trick but if you need to, you'll be glad you bookmarked this script.


Copy this code and paste it in your HTML
  1. /**
  2. * Title: Detect Safari On iOS
  3. *
  4. *
  5. * @param string $role Role name.
  6. * @param int $user_id (Optional) The ID of a user. Defaults to the current user.
  7. * @return bool
  8. */
  9. function add_ios_styles(){
  10. global $is_iphone;
  11. if( $is_iphone ){
  12. wp_enqueue_style('iphone-css', get_stylesheet_directory_uri() . '/iphone.css' );
  13. }
  14. else{
  15. wp_enqueue_style('common-css', get_stylesheet_directory_uri() . '/common.css' );
  16. }
  17. }
  18. add_action('wp_print_styles', 'add_ios_styles');

URL: http://www.smashingmagazine.com/2011/12/07/10-tips-optimize-wordpress-theme/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.