The below function identifies the operating system, browser and prints it into the body tag.

It helps to write CSS based OS and browser specific.

function customBodyClass($classes) {
$user_agent = getenv("HTTP_USER_AGENT");
if (strpos($user_agent, "Win") !== FALSE) { 
$os = "windows"; 
} elseif(strpos($user_agent, "Mac") !== FALSE) { 
$os = "mac"; 
} if (strpos($user_agent, "Chrome") !== FALSE) { 
$browser = "chrome"; 
} elseif(strpos($user_agent, "Safari") !== FALSE) {
 $browser = "safari"; 
} elseif(strpos($user_agent, "MSIE") !== FALSE) { 
$browser = "MSIE"; 
} 
$classes[] = $os; 
$classes[] = $browser; 
return $classes;
}
add_filter('body_class', 'customBodyClass');

Previous post Find which WordPress template file is currently used?
Earn Money from Dark Web Next post How to Get Money from Dark Web?

Leave a Reply

Your email address will not be published. Required fields are marked *