Created
May 10, 2013 23:25
-
-
Save psynaptic/5558195 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function orchid_preprocess_page(&$variables) { | |
_orchid_conditional_stylesheets($variables); | |
} | |
function _orchid_conditional_stylesheets(&$variables) { | |
$themes = list_themes(); | |
$theme = $GLOBALS['theme']; | |
$query_string = substr(variable_get('css_js_query_string', '0'), 0, 1); | |
$theme_path = drupal_get_path('theme', 'orchid'); | |
$conditional_stylesheets = $themes[$theme]->info['conditional-stylesheets']; | |
foreach ($conditional_stylesheets as $condition => $css) { | |
foreach ($css as $media => $files) { | |
foreach ($files as $file_path) { | |
$stylesheet_path = url(sprintf('%s/%s', $theme_path, $file_path), array('query' => $query_string)); | |
if (file_exists(".$stylesheet_path")) { | |
$conditional_stylesheet = <<<DOC | |
<!--[$condition]> | |
<link type="text/css" rel="stylesheet" media="$media" href="$stylesheet_path" /> | |
<![endif]--> | |
DOC; | |
$variables['conditional_styles'] .= $conditional_stylesheet; | |
} | |
} | |
} | |
} | |
kpr($variables['conditional_styles']); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment