You are here

function advagg_critical_css_advagg_mod_critical_css_file_pre_alter in Advanced CSS/JS Aggregation 7.2

Implements hook_advagg_mod_critical_css_file_pre_alter().

Related topics

File

advagg_critical_css/advagg_critical_css.module, line 59
Advanced aggregation critical css module.

Code

function advagg_critical_css_advagg_mod_critical_css_file_pre_alter(&$filename, &$params, &$inline_strings) {
  list($dirs, $front_page, $object) = $params;

  // Build query parameters.
  $lookup = array(
    $dirs[6],
  );
  if ($front_page) {
    $lookup = array(
      '<front>',
    );
  }
  $lookup[] = $dirs[9];
  $lookup[] = $dirs[10];
  if (!empty($object->type)) {
    $lookup[] = $object->type;
  }
  $type = array(
    2,
    8,
  );
  $users = array(
    rtrim($dirs[2], '/\\'),
    rtrim($dirs[3], '/\\'),
  );

  // Get Results.
  $result = advagg_critical_css_table_get($GLOBALS['theme'], $type, $lookup, $users);

  // Put into the inline strings array.
  if (!empty($result)) {

    // Set string values.
    $inline_strings[0] = $result['css'];
    $inline_strings[1] = $result['dns'];
    $inline_strings[2] = $result['pre'];

    // Disable file lookup.
    $dirs[0] = '';
    $dirs[1] = '';
  }

  // Repack the $params array.
  $params = array(
    $dirs,
    $front_page,
    $object,
  );
}