Posted By

chrisaiv on 09/13/14


Tagged

wordpress


Versions (?)

Wordpress: Detect Safari On iOS


 / Published in: PHP
 

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

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.

  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');

Report this snippet  

You need to login to post a comment.