Created
July 26, 2013 07:39
-
-
Save klan/6086990 to your computer and use it in GitHub Desktop.
Custom D7 module for running jQuery 1.5 backend, and newest version frontend.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_module_implements_alter(). | |
*/ | |
function custom_jquery_update_module_implements_alter(&$implementations, $hook) { | |
if ($hook == 'library_alter') { | |
if(isset($implementations['jquery_update'])) { | |
// Move jquery update to the end. This will make sure our hook_library_alter | |
// is always called before the jquery_update. | |
$jquery_update = $implementations['jquery_update']; | |
unset($implementations['jquery_update']); | |
$implementations['jquery_update'] = $jquery_update; | |
} | |
} | |
} | |
/** | |
* Implements hook_library_alter(). | |
*/ | |
function custom_jquery_update_library_alter(&$libraries, $module) { | |
// If it is the admin theme all we want to do is change the global $conf | |
// variable so when jquery_update runs right after us it will use 1.5. | |
// We are not using path_is_admin(current_path()) because some admin path can use | |
// the frontend theme like node edit page | |
global $theme_key; | |
if (variable_get('admin_theme') == $theme_key) { | |
// Modifying global $conf variable, can be dangerous. Be carefull. | |
global $conf; | |
$conf['jquery_update_jquery_version'] = '1.5'; | |
} | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = "Custom jQuery Update" | |
description = "Custom module for running jQuery 1.5 backend, and newest version frontend." | |
core = "7.x" | |
package = "Custom" | |
dependencies[] = jquery_update |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment