I had a project where I needed Modernizr, so I added a no-js class to the html file, but the way I was prevously doing it is I would pull in the header.php into my child theme and comment out 2 lines, it felt dirty, so I fixed it so it now works from the functions.php file only.
HTML5 Boilerplate Style
// creates the doctype section ( html5 boilerplate style )
function childtheme_create_doctype() {
$content = "<!doctype html>" . "\n";
$content .= '<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7 ie6" dir="' . get_bloginfo ('text_direction') . '" lang="'. get_bloginfo ('language') . '"> <![endif]-->' . "\n";
$content .= '<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8 ie7" dir="' . get_bloginfo ('text_direction') . '" lang="'. get_bloginfo ('language') . '"> <![endif]-->'. "\n";
$content .= '<!--[if IE 8]> <html class="no-js lt-ie9 ie8" dir="' . get_bloginfo ('text_direction') . '" lang="'. get_bloginfo ('language') . '"> <![endif]-->' . "\n";
$content .= "<!--[if gt IE 8]><!-->" . "\n";
$content .= "<html class=\"no-js\"";
return $content;
}
add_filter('thematic_create_doctype', 'childtheme_create_doctype');
// creates the head and meta charset tags
function childtheme_head_profile() {
$content = "<!--<![endif]-->";
$content .= "\n" . "<head>" . "\n";
$content .= "\n\t" . "<meta charset=\"utf-8\">" . "\n\n";
return $content;
}
add_filter('thematic_head_profile', 'childtheme_head_profile');
// remove meta charset tag, now in the above function
function childtheme_create_contenttype() {
// silence
}
add_filter('thematic_create_contenttype', 'childtheme_create_contenttype');
Ouputs in the Header
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7 ie6" dir="ltr" lang="en-US"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8 ie7" dir="ltr" lang="en-US"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9 ie8" dir="ltr" lang="en-US"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" dir="ltr" lang="en-US">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<title>Dev Site | Just another WordPress site</title>
I also made another "cleaner" HTML5 header which also has the no-js class and just has 1 class of ".ie" for IE6, IE7 and IE8 and is more intended for sites that don't care about supporting IE6. If you are good at CSS and tend to never need IE specific CSS you might want to try the other version http://scottnix.com/2012/html5-header-with-thematic/
Eventually I will get around to cleaning up some stuff and post the information on how to get Modernizr on a Thematic theme here too (which is cake) but I just have to write it up.
Any suggestions/changes/thoughts are welcome, thanks.