WP user agent returns random variables
I am using a PHP function in order to return the user browser, using the WP global variables.
It used to work perfectly, but recently it started doing random things on Safari. I use chrome and everything is fine at home. My colleague uses Safari and depending on the test, he has different results.
On sidebar.php :
div class="sidebar s2 ?php echo 's2_'.detecter_user_agent(); ?"
In functions.php :
function detecter_user_agent() {
$cl = '';
global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_macIE, $is_winIE;
if($is_lynx) $cl = 'lynx';
elseif($is_gecko) $cl = 'gecko';
elseif($is_opera) $cl = 'opera';
elseif($is_NS4) $cl = 'ns4';
elseif($is_safari) $cl = 'safari';
elseif($is_chrome) $cl = 'chrome';
elseif($is_IE) $cl = 'ie';
elseif($is_macIE) $cl = 'macie';
elseif($is_winIE) $cl = 'winie';
else $cl = 'unknown';
return $cl;
}
This is the code to generate a CSS class for the right sidebar on https://blog.defi-ecologique.com
When my colleague tries it, it sometimes returns s2_chrome, s2_gecko or even s2_unknown.
I have no way of knowing how many of my readers have this issue.
Could you please help me make sure that the right global variable is returned at any time ?
Thank you !
Topic browser-compatibility globals Wordpress
Category Web