You are here

function advagg_theme_registry_alter in Advanced CSS/JS Aggregation 6

Same name and namespace in other branches
  1. 7.2 advagg.module \advagg_theme_registry_alter()

Implementation of hook_theme_registry_alter().

Make sure our preprocess function runs last for page.

Parameters

$theme_registry: The existing theme registry data structure.

File

./advagg.module, line 386
Advanced CSS/JS aggregation module

Code

function advagg_theme_registry_alter(&$theme_registry) {
  global $_advagg;
  if (isset($theme_registry['page'])) {

    // If jquery_update's preprocess function is there already, remove it.
    if (module_exists('jquery_update') && ($key = array_search('jquery_update_preprocess_page', $theme_registry['page']['preprocess functions']))) {
      unset($theme_registry['page']['preprocess functions'][$key]);
    }

    // If ctools hasn't been patched remove it from getting pre-processed.
    if (!empty($_advagg['ctools_patched']) && module_exists('ctools') && ($key = array_search('ctools_ajax_page_preprocess', $theme_registry['page']['preprocess functions']))) {
      unset($theme_registry['page']['preprocess functions'][$key]);
    }

    // Add our own preprocessing function to the end of the array.
    $theme_registry['page']['preprocess functions'][] = 'advagg_processor';

    // If labjs's is enabled, move it to the bottom.
    if (module_exists('labjs') && ($key = array_search('labjs_preprocess_page', $theme_registry['page']['preprocess functions']))) {
      $theme_registry['page']['preprocess functions'][] = $theme_registry['page']['preprocess functions'][$key];
      unset($theme_registry['page']['preprocess functions'][$key]);
    }

    // If designkit is enabled, move it to the bottom.
    if (module_exists('designkit') && ($key = array_search('designkit_preprocess_page', $theme_registry['page']['preprocess functions']))) {
      $theme_registry['page']['preprocess functions'][] = $theme_registry['page']['preprocess functions'][$key];
      unset($theme_registry['page']['preprocess functions'][$key]);
    }

    // If conditional styles is enabled, move it to the bottom.
    if (module_exists('conditional_styles') && ($key = array_search('conditional_styles_preprocess_page', $theme_registry['page']['preprocess functions']))) {
      $theme_registry['page']['preprocess functions'][] = $theme_registry['page']['preprocess functions'][$key];
      unset($theme_registry['page']['preprocess functions'][$key]);
    }
  }
}