Excluding iPad from is_mobile
-
Hi Team
Sorry for the poor writing I’m in trouble
The problem is that the filter doesn’t work..
I want to Excluding iPad from is_mobileThe filter doesn’t work even if I add it to function.php. Where is the problem
The filters you have prepared are below
/** * Check is browser mobile */ public static function is_mobile() { if ( empty($_SERVER['HTTP_USER_AGENT']) ) { $is_mobile = false; } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') !== false // many mobile devices (all iPhone, iPad, etc.) || strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Silk/') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Kindle') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mobi') !== false ) { $is_mobile = true; } else { $is_mobile = false; } return apply_filters('swift_performance_is_mobile', $is_mobile); }
The filter I set is below
function my_swift_performance_is_mobile( $is_mobile ) { if ( empty($_SERVER['HTTP_USER_AGENT']) ) { $is_mobile = false; } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'iPad') !== false) { $is_mobile = false; } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') !== false // many mobile devices (all iPhone, iPad, etc.) || strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Silk/') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Kindle') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mobi') !== false ) { $is_mobile = true; } else { $is_mobile = false; } return $is_mobile; } add_filter('swift_performance_is_mobile','my_swift_performance_is_mobile');
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Excluding iPad from is_mobile’ is closed to new replies.