Skip to content

Instantly share code, notes, and snippets.

@psynaptic
Created May 10, 2013 23:25
Show Gist options
  • Save psynaptic/5558195 to your computer and use it in GitHub Desktop.
Save psynaptic/5558195 to your computer and use it in GitHub Desktop.
<?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