function advagg_cdn_css_alter in Advanced CSS/JS Aggregation 8.3
Same name and namespace in other branches
- 8.4 advagg_cdn/advagg_cdn.module \advagg_cdn_css_alter()
- 8.2 advagg_cdn/advagg_cdn.module \advagg_cdn_css_alter()
Implements hook_css_alter().
File
- advagg_cdn/
advagg_cdn.module, line 216 - Advanced aggregates cdn module.
Code
function advagg_cdn_css_alter(&$css) {
// Setup variables.
$cdn_settings = \Drupal::config('advagg_cdn.settings');
$cdn = $cdn_settings
->get('cdn');
$min = $cdn_settings
->get('minified') ? '.min' : '';
// If AdvAgg in development mode don't serve minified CSS.
if (\Drupal::config('advagg.settings')
->get('cache_level') < 0) {
$min = '';
}
$targets = [];
if ($cdn_settings
->get('jquery_ui_css')) {
$path = $cdn_settings
->get('jquery_ui_version') . '/themes/' . $cdn_settings
->get('jquery_ui_theme') . '/jquery-ui' . $min . '.css';
$targets += [
'core/assets/vendor/jquery.ui/themes/base/core.css' => [
'google' => 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $path,
'microsoft' => 'https://ajax.aspnetcdn.com/ajax/jquery.ui/' . $path,
'type' => 'external',
],
'core/assets/vendor/jquery.ui/themes/base/theme.css' => [
'unset' => TRUE,
],
'core/assets/vendor/jquery.ui/themes/base/accordion.css' => [
'unset' => TRUE,
],
'core/assets/vendor/jquery.ui/themes/base/autocomplete.css' => [
'unset' => TRUE,
],
'core/assets/vendor/jquery.ui/themes/base/button.css' => [
'unset' => TRUE,
],
'core/assets/vendor/jquery.ui/themes/base/datepicker.css' => [
'unset' => TRUE,
],
'core/assets/vendor/jquery.ui/themes/base/dialog.css' => [
'unset' => TRUE,
],
'core/assets/vendor/jquery.ui/themes/base/menu.css' => [
'unset' => TRUE,
],
'core/assets/vendor/jquery.ui/themes/base/progressbar.css' => [
'unset' => TRUE,
],
'core/assets/vendor/jquery.ui/themes/base/resizable.css' => [
'unset' => TRUE,
],
'core/assets/vendor/jquery.ui/themes/base/selectable.css' => [
'unset' => TRUE,
],
'core/assets/vendor/jquery.ui/themes/base/selectmenu.css' => [
'unset' => TRUE,
],
'core/assets/vendor/jquery.ui/themes/base/slider.css' => [
'unset' => TRUE,
],
'core/assets/vendor/jquery.ui/themes/base/spinner.css' => [
'unset' => TRUE,
],
'core/assets/vendor/jquery.ui/themes/base/tabs.css' => [
'unset' => TRUE,
],
'core/assets/vendor/jquery.ui/themes/base/tooltip.css' => [
'unset' => TRUE,
],
];
}
foreach ($targets as $name => $values) {
if (isset($css[$name])) {
if (isset($values['unset'])) {
unset($css[$name]);
}
elseif (isset($values[$cdn])) {
$css[$name]['data'] = $values[$cdn];
$css[$name]['type'] = $values['type'];
}
}
}
}