You are here

function jquery_update_preprocess_page in jQuery Update 6.2

Same name and namespace in other branches
  1. 6 jquery_update.module \jquery_update_preprocess_page()

Implementation of moduleName_preprocess_hook().

Replace Drupal core's jquery.js with the new one from jQuery Update module.

1 string reference to 'jquery_update_preprocess_page'
jquery_update_theme_registry_alter in ./jquery_update.module
Implementation of hook_theme_registry_alter().

File

./jquery_update.module, line 80
Updates Drupal to use the latest version of jQuery.

Code

function jquery_update_preprocess_page(&$variables) {

  // Only do this for pages that have JavaScript on them.
  if (!empty($variables['scripts'])) {

    // Perform the logic if either jQuery Update's jquery.js is newer than core's.
    if (variable_get('jquery_update_replace', TRUE)) {

      // Get an array of all the JavaScript files loaded by Drupal on this page.
      $javascript = drupal_add_js();

      // Invoke hook_js_alter().
      drupal_alter('jquery_update', $javascript);

      // Replace with all the new JavaScript.
      $variables['scripts'] = drupal_get_js('header', $javascript);
    }
  }
}