You are here

link_css.module in Link CSS 7

Same filename and directory in other branches
  1. 8 link_css.module

Link CSS Module.

Include CSS files using <link> element instead of @import. This is useful for live refresh workflows such as CodeKit which do not support files loaded with @import.

File

link_css.module
View source
<?php

/**
 * @file
 * Link CSS Module.
 *
 * Include CSS files using <link> element instead of @import. This is useful for
 * live refresh workflows such as CodeKit which do not support files loaded with
 * @import.
 */

/**
 * Implements hook_menu().
 */
function link_css_menu() {
  $items = array();
  $items['admin/config/development/link-css'] = array(
    'title' => 'Link CSS',
    'description' => 'Include CSS files using <link> element instead of @import',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'link_css_admin',
    ),
    'access arguments' => array(
      'administer site configuration',
    ),
    'type' => MENU_NORMAL_ITEM,
    'file' => 'link_css.admin.inc',
  );
  return $items;
}

/**
 * Implements hook_css_alter().
 */
function link_css_css_alter(&$css) {
  $count = 0;
  if (!variable_get('preprocess_css')) {
    foreach ($css as $key => $value) {

      // Skip core files.
      $is_core = strpos($value['data'], 'misc/') === 0 || strpos($value['data'], 'modules/') === 0;
      if ((!variable_get('link_css_skip_system', TRUE) || !$is_core) && file_exists($value['data'])) {

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

    // Show IE warning.
    if (variable_get('link_css_warn_ie_limit', TRUE) && $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');
    }
  }
}

Functions

Namesort descending Description
link_css_css_alter Implements hook_css_alter().
link_css_menu Implements hook_menu().