Hooks Alter not called in Template.php for I run into strange thing today. I have some custom hook declared in a custom module as following:

drupal_alter('strange_thing', $shared_var, $vars);


then in template file(template.php) I got the function:

function THEME_strange_thing_alter(&amp;$shared_var, $vars){
    //do something with $shared_var
}


The THEME_strange_thing_alter() is called if i have unchecked " Use the administration theme when editing or creating content" in the admin/appearance in the "Administration Theme" section, but it is not otherwise. 

To satisfy curiosity, I moved all the logic from tempalate.php into custom module/.module file and it works like expected...the hooks are called not matter if the box is checked or unchecked for " Use the administration theme when editing or creating content"

It would be great that the hooks work in template.php no matter if there is some box checked or unchecked in the UI. Is there way to make it so? Thank You
Hooks are only invoked for enabled modules, and the current theme. So code in template.php for theme1 won't be used when theme2 is active (unless theme2 is a subtheme of theme1, thanks @greggles).

The reason is obvious when you think about it: if you've explicitly said you want one theme on a certain page, code from another theme shouldn't be allowed to interfere. It could cause all sorts of problems.

If you have code that should run independently of the theme that's being used to display the page, the proper (and only) place to put it is in a module.