You are here

function link_css_css_alter in Link CSS 8

Same name and namespace in other branches
  1. 7 link_css.module \link_css_css_alter()

Implements hook_css_alter().

File

./link_css.module, line 16
Link CSS Module.

Code

function link_css_css_alter(&$css) {
  $system_css_preprocess = \Drupal::config('system.performance')
    ->get('css.preprocess');
  $config = \Drupal::config('link_css.settings');
  $count = 0;
  if (!$system_css_preprocess) {
    foreach ($css as $key => $value) {

      // Skip core files.
      $is_core = strpos($value['data'], 'misc/') === 0 || strpos($value['data'], 'modules/') === 0;
      if (!$config
        ->get('link_css_skip_system') || !$is_core) {

        // This option forces embeding with a link element.
        $css[$key]['preprocess'] = FALSE;
        $count++;
      }
    }

    // Show IE warning.
    if ($config
      ->get('link_css_warn_ie_limit') && $count > 31) {
      drupal_set_message(t('Internet Explorer <=7 which will not load more than 31
        linked stylesheets. The current page links to @count. Disable Link CSS
        module or turn on CSS aggregation to ensure compatibility.', array(
        '@count' => $count,
      )), 'warning');
    }
  }
}