--- general-template.php.ori	2009-06-11 00:04:20.000000000 +0200
+++ general-template.php	2009-08-09 20:04:26.687500000 +0200
@@ -977,7 +977,7 @@
 		}
 	}
 
-	ob_start();
+	$output = '';
 	if ( isset($_GET['w']) )
 		$w = ''.intval($_GET['w']);
 
@@ -1023,7 +1023,7 @@
 
 	/* translators: Calendar caption: 1: month name, 2: 4-digit year */
 	$calendar_caption = _x('%1$s %2$s', 'calendar caption');
-	echo '<table id="wp-calendar" summary="' . __('Calendar') . '">
+	$output .= '<table id="wp-calendar" summary="' . __('Calendar') . '">
 	<caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
 	<thead>
 	<tr>';
@@ -1036,10 +1036,10 @@
 
 	foreach ( $myweek as $wd ) {
 		$day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
-		echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>";
+		$output .= "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>";
 	}
 
-	echo '
+	$output .= '
 	</tr>
 	</thead>
 
@@ -1047,24 +1047,24 @@
 	<tr>';
 
 	if ( $previous ) {
-		echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' .
+		$output .=  "\n\t\t".'<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' .
 		get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month),
 			date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">&laquo; ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
 	} else {
-		echo "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
+		$output .= "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
 	}
 
-	echo "\n\t\t".'<td class="pad">&nbsp;</td>';
+	$output .= "\n\t\t".'<td class="pad">&nbsp;</td>';
 
 	if ( $next ) {
-		echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' .
+		$output .= "\n\t\t".'<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' .
 		get_month_link($next->year, $next->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month),
 			date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' &raquo;</a></td>';
 	} else {
-		echo "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
+		$output .= "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
 	}
 
-	echo '
+	$output .= '
 	</tr>
 	</tfoot>
 
@@ -1116,24 +1116,24 @@
 	// See how much we should pad in the beginning
 	$pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
 	if ( 0 != $pad )
-		echo "\n\t\t".'<td colspan="'.$pad.'" class="pad">&nbsp;</td>';
+		$output .= "\n\t\t".'<td colspan="'.$pad.'" class="pad">&nbsp;</td>';
 
 	$daysinmonth = intval(date('t', $unixmonth));
 	for ( $day = 1; $day <= $daysinmonth; ++$day ) {
 		if ( isset($newrow) && $newrow )
-			echo "\n\t</tr>\n\t<tr>\n\t\t";
+			$output .= "\n\t</tr>\n\t<tr>\n\t\t";
 		$newrow = false;
 
 		if ( $day == gmdate('j', (time() + (get_option('gmt_offset') * 3600))) && $thismonth == gmdate('m', time()+(get_option('gmt_offset') * 3600)) && $thisyear == gmdate('Y', time()+(get_option('gmt_offset') * 3600)) )
-			echo '<td id="today">';
+			$output .= '<td id="today">';
 		else
-			echo '<td>';
+			$output .= '<td>';
 
 		if ( in_array($day, $daywithpost) ) // any posts today?
-				echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$day</a>";
+				$output .= '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$day</a>";
 		else
-			echo $day;
-		echo '</td>';
+			$output .= $day;
+		$output .= '</td>';
 
 		if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
 			$newrow = true;
@@ -1141,12 +1141,11 @@
 
 	$pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
 	if ( $pad != 0 && $pad != 7 )
-		echo "\n\t\t".'<td class="pad" colspan="'.$pad.'">&nbsp;</td>';
+		$output .= "\n\t\t".'<td class="pad" colspan="'.$pad.'">&nbsp;</td>';
 
-	echo "\n\t</tr>\n\t</tbody>\n\t</table>";
+	$output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
 
-	$output = ob_get_contents();
-	ob_end_clean();
+	$output = apply_filters( 'get_calendar',  $output );
 	echo $output;
 	$cache[ $key ] = $output;
 	wp_cache_set( 'get_calendar', $cache, 'calendar' );
