diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2008-10-24 07:02:54 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2008-10-24 07:02:54 +0000 |
commit | 88ed5dced2f4a5dd252b0b1667efa18710a9523f (patch) | |
tree | 2a9ade29b1a487ff672957cbcebf3bab514a1a19 /includes/theme.inc | |
parent | 72cd8d63b6833b1190d82e52b7bbcf36f3832c16 (diff) | |
download | brdo-88ed5dced2f4a5dd252b0b1667efa18710a9523f.tar.gz brdo-88ed5dced2f4a5dd252b0b1667efa18710a9523f.tar.bz2 |
#258089 by merlinofchaos and dvessel: Allow themes to have preprocess functions without a corresponding .tpl.php file.
Diffstat (limited to 'includes/theme.inc')
-rw-r--r-- | includes/theme.inc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/includes/theme.inc b/includes/theme.inc index b76a1b4bc..ee6eea387 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -279,6 +279,7 @@ function drupal_theme_rebuild() { * over how and when the preprocess functions are run. */ function _theme_process_registry(&$cache, $name, $type, $theme, $path) { + $result = array(); $function = $name . '_theme'; if (function_exists($function)) { $result = $function($cache, $type, $theme, $path); @@ -368,6 +369,26 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) { // Merge the newly created theme hooks into the existing cache. $cache = array_merge($cache, $result); } + + // Let themes have preprocess functions even if they didn't register a template. + if ($type == 'theme' || $type == 'base_theme') { + foreach ($cache as $hook => $info) { + // Check only if it's a template and not registered by the theme or engine + if (!empty($info['template']) && empty($result[$hook])) { + if (!isset($info['preprocess functions'])) { + $cache[$hook]['preprocess functions'] = array(); + } + if (function_exists($name . '_preprocess')) { + $cache[$hook]['preprocess functions'][] = $name . '_preprocess'; + } + if (function_exists($name . '_preprocess_' . $hook)) { + $cache[$hook]['preprocess functions'][] = $name . '_preprocess_' . $hook; + } + // Ensure uniqueness. + $cache[$hook]['preprocess functions'] = array_unique($cache[$hook]['preprocess functions']); + } + } + } } /** |