Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.254
diff -u -F^f -r1.254 theme.inc
--- includes/theme.inc	18 Aug 2005 22:07:14 -0000	1.254
+++ includes/theme.inc	24 Aug 2005 07:24:33 -0000
@@ -165,21 +165,30 @@ function theme() {
     $theme = init_theme();
   }
 
-  $args = func_get_args();
+  $all_args = $args = func_get_args();
   $function = array_shift($args);
 
+  $output = '';
+  foreach (module_implements('theme pre') as $module) {
+    $output .= call_user_func_array($module .'theme pre', $all_args);
+  }
+
   if (($theme != '') && function_exists($theme .'_'. $function)) {
     // call theme function
-    return call_user_func_array($theme .'_'. $function, $args);
+    $output .= call_user_func_array($theme .'_'. $function, $args);
   }
   elseif (($theme != '') && isset($theme_engine) && function_exists($theme_engine .'_'. $function)) {
     // call engine function
-    return call_user_func_array($theme_engine .'_'. $function, $args);
+    $output .= call_user_func_array($theme_engine .'_'. $function, $args);
   }
   elseif (function_exists('theme_'. $function)){
     // call Drupal function
     return call_user_func_array('theme_'. $function, $args);
   }
+
+  foreach (module_implements('theme post') as $module) {
+    $output .= call_user_func_array($module .'theme post', $all_args);
+  }
 }
 
 /**
