info['external scripts'])) ? $theme->info['external scripts'] : array(); foreach ($scripts as $url) { $assets .= ''."\n"; } // Add external stylesheets $media = (is_array($theme->info['external stylesheets'])) ? $theme->info['external stylesheets'] : array(); foreach ($media as $medium => $styles) { foreach ($styles as $url) { $assets .= ''."\n"; } } } return $assets; } /** * Remove most stylesheets. */ function _hi5_styles($theme_key) { static $styles = ''; if (empty($styles)) { $themes = list_themes(); $theme = $themes[$theme_key]; $css = drupal_add_css(); // Add path to current theme (plus base theme[s]) to whitelist. $whitelist = _hi5_theme_paths($theme_key); // Add paths for specified modules to whitelist. $exceptions = (is_array($theme->info['module whitelist'])) ? $theme->info['module whitelist'] : array(); foreach ($exceptions as $exception) { if (module_exists($exception)) { $whitelist[] = drupal_get_path('module', $exception) .'/*'; } } // Implode whitelist array to use with drupal_match_path() $whitelist = implode("\n", $whitelist); // Actually remove css files not found in whitelist. foreach ($css as $media => $types) { foreach ($types as $type => $paths) { foreach (array_keys($paths) as $path) { if (!drupal_match_path($path, $whitelist)) { unset($css[$media][$type][$path]); } } } } // Trigger CSS aggregation, get HTML $styles = drupal_get_css($css); } return $styles; } /** * (Recursively) get current theme and base theme paths. */ function _hi5_theme_paths($theme_key) { $themes = list_themes(); $theme = $themes[$theme_key]; $paths = array(drupal_get_path('theme', $theme_key) .'/*'); if (isset($theme->info['base theme'])) { $paths = array_merge($paths, _hi5_theme_paths($theme->info['base theme'])); } return $paths; }