Create Your Own Anti-IE6 Plugin For WordPress
SHARE THIS

As the web slowly progress and moves away from IE6 there are still those people or companies that just cannot get the hint and move forward. This handy and quick tutorial will show you how to serve IE6 users the default WordPress theme.

This first part of the code will detect the browser that your visitor is using.
[php]
if (strpos($_SERVER['HTTP_USER_AGENT'], ‘MSIE 6′) !== false) {
// do something
}
[/php]

This next part will now tell WordPress the theme you would like to display to the IE6 users. Or should we say, losers?
[php]
add_filter(‘template’, ‘serve_default_to_iesix’);
add_filter(‘option_template’, ‘serve_default_to_iesix’);
add_filter(‘option_stylesheet’, ‘serve_default_to_iesix’);
function serve_default_to_iesix($theme) {
if(strpos($_SERVER['HTTP_USER_AGENT'], ‘MSIE 6′) !== false)
$theme = ‘default’;

return $theme;
}
[/php]

Now with these two powers combined, we have a complete plugin that makes you feel proud to use a modern web browser.

Just paste the following complete code snippet in a new file and save it as ie6loser.php or something similar that makes you chuckle at the thought of using ie6. Upload it to your wp-content/plugins directory and activate it on your WordPress dashboard.

[php]
<?php
/*
Plugin Name: Serve Default to IE6
Plugin URI: http://www.nathanrice.net/blog/serve-ie6-visitors-the-default-wordpress-theme
Description: This plugin will serve the default theme to any visitors using IE6.
Author: Nathan Rice
Author URI: http://www.nathanrice.net/
Version: 1.0
*/

add_filter(‘template’, ‘serve_default_to_iesix’);
add_filter(‘option_template’, ‘serve_default_to_iesix’);
add_filter(‘option_stylesheet’, ‘serve_default_to_iesix’);
function serve_default_to_iesix($theme) {
if(strpos($_SERVER['HTTP_USER_AGENT'], ‘MSIE 6′) !== false)
$theme = ‘default’;

return $theme;
}
?>
[/php]

.via { Nathan Rice }

1000s Template Choices for Your Site - From $5