Here's a new implementation that allows for any stylesheet named ieX_stylesheet.css, or an ie_stylesheet.css. Still to go is the section that grabs anything with a ieLT7_stylesheet or an ieLTE7_stylesheet.
PHP Code:
/**
* IE Conditional Comments
* Load all template-specific stylesheets for IE in alphabetical order, but AFTER
* the main stylesheets have been called, thus overriding them in the cascade.
* Naming convention for stylesheet files is as follows:
* "ie_stylesheet.css" targets all versions of IE
* "ie7_stylesheet.css" only targets IE 7
* "ie6_stylesheet.css" will affect IE 6
* "ie5_stylesheet.css" will only affect IE 5 and IE 5.5
*/
$directory_array = $template->get_template_part($template->get_template_dir('.css',DIR_WS_TEMPLATE, $current_page_base,'css'), '/^ie[lt]?[lte]?[5-9]*_/', '.css');
while(list ($key, $value) = each($directory_array)) {
$allVersions = substr ($value, 0, 3); // Get the 'ie_' fro mthe array, if it's there.
$versionNumber = substr ($value, 2, 1); // Get numeric digit from the array.
// Check for an ie_stylesheet.css file in the css folder.
if ($allVersions == "ie_") {
echo '<!--[if IE]>' . "\n";
echo ' <style type="text/css" media="all">@import "' . $template->get_template_dir('.css',DIR_WS_TEMPLATE, $current_page_base,'css') . '/ie_stylesheet.css";></style>' . "\n";
echo '<![endif]-->' . "\n";
}
// Check for all other numbered versions of ieX_stylesheet.css files in the css folder.
if (preg_match("/^[5-9]/i", $versionNumber)) {
echo '<!--[if IE ' . $versionNumber . ']>' . "\n";
echo '<link rel="stylesheet" type="text/css" href="' . $template->get_template_dir('.css',DIR_WS_TEMPLATE, $current_page_base,'css') . '/' . $value . '" />' . "\n";
echo '<![endif]-->' . "\n";
}
}
unset($allVersions, $versionNumber, $key, $value); // A little housecleaning.