function _admin_menu_toggle_modules in Administration menu 5.3
Menu callback; Enable/disable developer modules.
This can save up to 150ms on each uncached page request.
1 call to _admin_menu_toggle_modules()
- admin_menu_toggle_modules in ./
admin_menu.module - Menu callback; Enable/disable developer modules.
File
- ./
admin_menu.inc, line 560 - Menu build functions for Administration menu.
Code
function _admin_menu_toggle_modules() {
$rebuild = FALSE;
$saved_state = variable_get('admin_menu_devel_modules_enabled', NULL);
if (isset($saved_state)) {
// Re-enable modules that were enabled before.
module_enable($saved_state);
variable_del('admin_menu_devel_modules_enabled');
drupal_set_message(t('Enabled these modules: !module-list.', array(
'!module-list' => implode(', ', $saved_state),
)));
$rebuild = TRUE;
}
else {
// Allow site admins to override this variable via settings.php.
$devel_modules = variable_get('admin_menu_devel_modules', _admin_menu_developer_modules());
// Store currently enabled modules in a variable.
$devel_modules = array_intersect(module_list(FALSE, FALSE), $devel_modules);
$devel_modules = array_diff($devel_modules, variable_get('admin_menu_devel_modules_skip', array()));
if (!empty($devel_modules)) {
variable_set('admin_menu_devel_modules_enabled', $devel_modules);
// Disable developer modules.
module_disable($devel_modules);
drupal_set_message(t('Disabled these modules: !module-list.', array(
'!module-list' => implode(', ', $devel_modules),
)));
$rebuild = TRUE;
}
else {
drupal_set_message(t('No developer modules are enabled.'));
}
}
if ($rebuild) {
// Make sure everything is rebuilt, basically a combination of the calls
// from system_modules() and system_modules_submit().
menu_rebuild();
cache_clear_all();
drupal_clear_css_cache();
// Finally, flush admin_menu's cache.
admin_menu_flush_caches();
}
drupal_goto(referer_uri());
}