Index: wp-admin/includes/widgets.php
===================================================================
--- wp-admin/includes/widgets.php	(revision 8180)
+++ wp-admin/includes/widgets.php	(working copy)
@@ -21,7 +21,7 @@
 		$no_widgets_shown = true;
 		$already_shown = array();
 		foreach ( $wp_registered_widgets as $name => $widget ) :
-			if ( 'all' == $show && in_array( $widget['callback'], $already_shown ) ) // We already showed this multi-widget
+			if ( in_array( $widget['callback'], $already_shown ) ) // We already showed this multi-widget
 				continue;
 
 			if ( $search_terms ) {
@@ -47,7 +47,7 @@
 				continue;
 
 			ob_start();
-				$args = wp_list_widget_controls_dynamic_sidebar( array( 0 => array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template', '_show' => $show ), 1 => $widget['params'][0] ) );
+				$args = wp_list_widget_controls_dynamic_sidebar( array( 0 => array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template' ) ) );
 				$sidebar_args = call_user_func_array( 'wp_widget_control', $args );
 			$widget_control_template = ob_get_contents();
 			ob_end_clean();
@@ -61,10 +61,10 @@
 					'key' => false,
 					'edit' => false
 				);
-				if ( 'all' == $show && $is_multi ) {
+				if ( $is_multi ) {
 					// it's a multi-widget.  We only need to show it in the list once.
 					$already_shown[] = $widget['callback'];
-					$num = (int) array_pop( explode( '-', $widget['id'] ) );
+					$num = array_pop( explode( '-', $widget['id'] ) );
 					$id_base = $wp_registered_widget_controls[$widget['id']]['id_base'];
 					// so that we always add a new one when clicking "add"
 					while ( isset($wp_registered_widgets["$id_base-$num"]) )
@@ -76,7 +76,7 @@
 				}
 				$add_query['add'] = $widget['id'];
 				$action = 'add';
-				$add_url = clean_url( wp_nonce_url( add_query_arg( $add_query ), "add-widget_$widget[id]" ) );
+				$add_url = wp_nonce_url( add_query_arg( $add_query ), "add-widget_$widget[id]" );
 			} else {
 				$action = 'edit';
 				$edit_url = clean_url( add_query_arg( array(
@@ -92,17 +92,12 @@
 
 			$no_widgets_shown = false;
 
-
-			if ( 'all' != $show && $sidebar_args['_widget_title'] )
-				$widget_title = $sidebar_args['_widget_title'];
-			else
-				$widget_title = $widget['name'];
 		?>
 
 		<li id="widget-list-item-<?php echo attribute_escape( $widget['id'] ); ?>" class="widget-list-item">
 			<h4 class="widget-title widget-draggable">
 
-				<span><?php echo $widget_title; ?></span>
+				<?php echo wp_specialchars( $widget['name'] ); ?>
 
 				<?php if ( 'add' == $action ) : ?>
 
@@ -116,8 +111,6 @@
 
 				<?php endif; ?>
 
-				<br class="clear" />
-
 			</h4>
 
 
@@ -199,7 +192,7 @@
 
 	$id_format = $widget['id'];
 	// We aren't showing a widget control, we're outputing a template for a mult-widget control
-	if ( 'all' == $sidebar_args['_show'] && 'template' == $sidebar_args['_display'] && isset($control['params'][0]['number']) ) {
+	if ( 'template' == $sidebar_args['_display'] && isset($control['params'][0]['number']) ) {
 		// number == -1 implies a template where id numbers are replaced by a generic '%i%'
 		$control['params'][0]['number'] = -1;
 		// if given, id_base means widget id's should be constructed like {$id_base}-{$id_number}
@@ -209,7 +202,7 @@
 
 	$widget_title = '';
 	// We grab the normal widget output to find the widget's title
-	if ( ( 'all' != $sidebar_args['_show'] || 'template' != $sidebar_args['_display'] ) && is_callable( $widget['_callback'] ) ) {
+	if ( is_callable( $widget['_callback'] ) ) {
 		ob_start();
 		$args = func_get_args();
 		call_user_func_array( $widget['_callback'], $args );
@@ -219,22 +212,19 @@
 	$wp_registered_widgets[$widget_id]['callback'] = $wp_registered_widgets[$widget_id]['_callback'];
 	unset($wp_registered_widgets[$widget_id]['_callback']);
 
-	if ( $widget_title && $widget_title != $sidebar_args['widget_name'] )
+	if ( $widget_title )
 		$widget_title = sprintf( _c('%1$s: %2$s|1: widget name, 2: widget title' ), $sidebar_args['widget_name'], $widget_title );
 	else
 		$widget_title = wp_specialchars( strip_tags( $sidebar_args['widget_name'] ) );
 
-	$sidebar_args['_widget_title'] = $widget_title;
-
 	if ( empty($sidebar_args['_display']) || 'template' != $sidebar_args['_display'] )
 		echo $sidebar_args['before_widget'];
 ?>
-		<div class="widget-top">
-		<h4 class="widget-title"><span><?php echo $widget_title ?></span>
+		<h4 class="widget-title"><?php echo $widget_title ?>
 
 			<?php if ( $edit ) : ?>
 
-			<a class="widget-action widget-control-edit" href="<?php echo clean_url( remove_query_arg( array( 'edit', 'key' ) ) ); ?>"><?php _e('Cancel'); ?></a>
+			<a class="widget-action widget-control-edit" href="<?php echo remove_query_arg( array( 'edit', 'key' ) ); ?>"><?php _e('Cancel'); ?></a>
 
 			<?php else : ?>
 
@@ -242,13 +232,12 @@
 
 			<?php endif; ?>
 
-			<br class="clear" />
+		</h4>
 
-		</h4></div>
-
 		<div class="widget-control"<?php if ( $edit ) echo ' style="display: block;"'; ?>>
-
+				<!--allen's change begins-->
 			<?php
+					global $wpdb,$post,$wp_registered_widget_controls;
 			if ( $control )
 				call_user_func_array( $control['callback'], $control['params'] );
 			else
@@ -257,7 +246,88 @@
 
 			<input type="hidden" name="widget-id[]" value="<?php echo $id_format; ?>" />
 			<input type="hidden" class="widget-width" value="<?php echo $control['width']; ?>" />
+			<?php
+				$widget_display_options=get_option('widget_display_option');
+				$widget_dipslay_array=array_keys((array)$widget_display_options);
+				foreach($widget_dipslay_array as $widget_display) {
+					$display_checked[$widget_display]="checked='checked'";
+				}
+				foreach ((array)$widget_display_options as $widget_display_key=>$widget_display_on) {
+					if (!is_array($widget_display_options[$id_format.'-display'])) {
+						$all_checked='1';
+					}else{
+						$all_checked='0';
+					}
+					if (($widget_display_key==$id_format.'-display') && (!$all_checked)) {
+						if (is_array($widget_display_options[$widget_display_key]['page_id']))
+							$widget_dipslay_pages=array_keys($widget_display_options[$widget_display_key]['page_id']);
+						if (is_array($widget_display_options[$widget_display_key]['post_id']))
+							$widget_dipslay_posts=array_keys($widget_display_options[$widget_display_key]['post_id']);
+					}
+				}
+			?>
+			<p><label for="<?php echo $id_format; ?>-title"><?php _e('Display on:'); ?> </label><br>
+			<input <?php echo $display_checked[$id_format."-display-frontpage"];?> id="<?php echo $id_format; ?>-display-frontpage" name="<?php echo $id_format; ?>-display-frontpage" type="checkbox" /><label for="<?php echo $id_format; ?>-display-frontpage"><?php _e('Front Page'); ?></label><br>
+			<input <?php echo $display_checked[$id_format."-display-category"];?> id="<?php echo $id_format; ?>-display-category" name="<?php echo $id_format; ?>-display-category" type="checkbox" /><label for="<?php echo $id_format; ?>-display-category"><?php _e('Category'); ?></label><br>
+			<input <?php echo $display_checked[$id_format."-display-archive"];?> id="<?php echo $id_format; ?>-display-archive" name="<?php echo $id_format; ?>-display-archive" type="checkbox" /><label for="<?php echo $id_format; ?>-display-archive"><?php _e('Archives'); ?></label><br>
+			<input <?php echo $display_checked[$id_format."-display-search"];?> id="<?php echo $id_format; ?>-display-search" name="<?php echo $id_format; ?>-display-search" type="checkbox" /><label for="<?php echo $id_format; ?>-display-search"><?php _e('Search Results'); ?></label><br>
+			<?php _e('Static pages'); ?><br>
 
+			<?php
+// 					echo ("<pre>".print_r(get_option("widget_display_option"),1)."</pre>");
+			$type='page';
+			$posts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'page' ORDER BY menu_order");
+			?>
+			<div id="<?php echo($type); ?>-ids" class="checkbox-list" style="height:100px;overflow:auto;border:1px solid #999999;background-color:white;padding:0 0 0 3px;margin:-3px 0 3px 0px;">
+			<a style="cursor:pointer;" onclick="jQuery('input[@id^=\'display-<?php echo($type); ?>-<?php echo $id_format; ?>-id-ids\'][@type=\'checkbox\']').each(function() {this.checked = true; });">Check All</a>
+			|
+			<a style="cursor:pointer;" onclick="jQuery('input[@id^=\'display-<?php echo($type); ?>-<?php echo $id_format; ?>-id-ids\'][@type=\'checkbox\']').each(function() {this.checked = false; });">Uncheck All</a>
+			<?php foreach($posts as $post):
+					if (is_array($widget_dipslay_pages)) {
+						if ($all_checked=='1') {
+							$checked="checked='checked'";
+						} else {
+							if (in_array($post->ID,$widget_dipslay_pages))
+								$checked="checked='checked'";
+							else
+								$checked="";
+						}
+					}
+			?>
+					
+			<p><input <?php echo $checked ?> id="display-<?php echo($type); ?>-<?php echo $id_format; ?>-id-ids-<?php echo($post->ID); ?>" name="<?php echo $id_format; ?>-display[<?php echo($type); ?>_id][<?php echo($post->ID); ?>]" type="checkbox"<?php checked($module->display[$type . '_id']['ids'][$post->ID], true); ?> /> <label for="display-<?php echo($type); ?>-id-ids-<?php echo($post->ID); ?>"><?php the_title(); ?></label></p>
+			<?php endforeach; ?>
+			</div>
+			<?php _e('Single posts'); ?><br>
+			<?php
+					$type='post';
+			$posts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_type != 'page' ORDER BY post_date_gmt DESC");
+
+			?>
+					<div id="<?php echo($type); ?>-ids" class="checkbox-list" style="height:100px;overflow:auto;border:1px solid #999999;background-color:white;padding:0 0 0 3px;margin:3px 0 3px 0px;">
+			<a style="cursor:pointer;" onclick="jQuery('input[@id^=\'display-<?php echo($type); ?>-<?php echo $id_format; ?>-id-ids\'][@type=\'checkbox\']').each(function() {this.checked = true; });">Check All</a>
+			|
+			<a style="cursor:pointer;" onclick="jQuery('input[@id^=\'display-<?php echo($type); ?>-<?php echo $id_format; ?>-id-ids\'][@type=\'checkbox\']').each(function() {this.checked = false; });">Uncheck All</a>
+			<?php foreach($posts as $post): 
+					if (is_array($widget_dipslay_posts)) {
+						if ($all_checked=='1') {
+							$checked="";
+						} else {
+							if (in_array($post->ID,$widget_dipslay_posts))
+								$checked="checked='checked'";
+							else
+								$checked="";
+						}
+					}
+					
+// 					
+					
+			?>
+		<p><input <?php echo $checked;?> id="display-<?php echo($type); ?>-<?php echo $id_format; ?>-id-ids-<?php echo($post->ID); ?>" name="<?php echo $id_format; ?>-display[<?php echo($type); ?>_id][<?php echo($post->ID); ?>]" type="checkbox"<?php checked($module->display[$type . '_id']['ids'][$post->ID], true); ?> /> <label for="display-<?php echo($type); ?>-id-ids-<?php echo($post->ID); ?>"><?php the_title(); ?></label></p>
+			<?php endforeach; ?>
+			</div>
+			</p>
+			<!--allen's change ends-->
 			<div class="widget-control-actions">
 
 				<?php if ( $control ) : ?>
@@ -282,8 +352,7 @@
 	if ( false === $end = strpos( $string, '%END_OF_TITLE%' ) )
 		return '';
 	$string = substr( $string, $beg + 14 , $end - $beg - 14);
-	$string = str_replace( '&nbsp;', ' ', $string );
-	return trim( wp_specialchars( strip_tags( $string ) ) );
+	return wp_specialchars( strip_tags( $string ) );
 }
 
-?>
+?>
\ No newline at end of file
Index: wp-admin/widgets.php
===================================================================
--- wp-admin/widgets.php	(revision 8180)
+++ wp-admin/widgets.php	(working copy)
@@ -7,19 +7,23 @@
 	wp_die( __( 'Cheatin&#8217; uh?' ));
 
 wp_enqueue_script( array( 'wp-lists', 'admin-widgets' ) );
-wp_admin_css( 'widgets' );
 
 do_action( 'sidebar_admin_setup' );
 
 $title = __( 'Widgets' );
 $parent_file = 'themes.php';
 
+add_action( 'admin_head', 'widget_css' );
+function widget_css() {
+	wp_admin_css( 'css/widgets' );
+}
+
 // $sidebar = What sidebar are we editing?
 if ( isset($_GET['sidebar']) && isset($wp_registered_sidebars[$_GET['sidebar']]) ) {
 	$sidebar = attribute_escape( $_GET['sidebar'] );
 } elseif ( is_array($wp_registered_sidebars) && !empty($wp_registered_sidebars) ) {
 	// By default we look at the first defined sidebar
-	$sidebar = array_shift( $keys = array_keys($wp_registered_sidebars) );
+	$sidebar = array_shift( array_keys($wp_registered_sidebars) );
 } else {
 	// If no sidebars, die.
 	require_once( 'admin-header.php' );
@@ -52,7 +56,13 @@
 // We're updating a sidebar
 if ( $http_post && isset($sidebars_widgets[$_POST['sidebar']]) ) {
 	check_admin_referer( 'edit-sidebar_' . $_POST['sidebar'] );
-
+	$temp_display_keys=array_keys($_POST);
+	foreach($temp_display_keys as $name => $key) {
+		if (preg_match(':display:',$key)) {
+			$display_info[$key]=$_POST[$key];
+		}
+	}
+	update_option('widget_display_option',$display_info);
 	/* Hack #1
 	 * The widget_control is overloaded.  It updates the widget's options AND echoes out the widget's HTML form.
 	 * Since we want to update before sending out any headers, we have to catch it with an output buffer,
@@ -92,9 +102,6 @@
 	exit;
 }
 
-
-
-
 // What widget (if any) are we editing
 $edit_widget = -1;
 
@@ -135,9 +142,7 @@
 		
 			<ul class="widget-control-list">
 				<li class="widget-list-control-item">
-					<div class="widget-top">
 					<h4 class="widget-title"><?php echo $control['name']; ?></h4>
-					</div>
 					<div class="widget-control" style="display: block;">
 	<?php
 						call_user_func_array( $control_callback, $control['params'] );
@@ -235,16 +240,15 @@
 
 	<h2><?php _e( 'Widgets' ); ?></h2>
 	<p id="widget-search">
-		<label class="hidden" for="widget-search-input"><?php _e( 'Search Widgets' ); ?>:</label>
 		<input type="text" id="widget-search-input" name="s" value="<?php echo attribute_escape( $widget_search ); ?>" />
 		<input type="submit" class="button" value="<?php _e( 'Search Widgets' ); ?>" />
 	</p>
 
 	<div class="widget-liquid-left-holder">
 	<div id="available-widgets-filter" class="widget-liquid-left">
-		<h3><label for="show"><?php _e('Available Widgets'); ?></label></h3>
+		<h3><?php _e('Available Widgets'); ?></h3>
 		<div class="nav">
-			<select name="show" id="show">
+			<select name="show">
 <?php foreach ( $show_values as $show_value => $show_text ) : $show_value = attribute_escape( $show_value ); ?>
 				<option value='<?php echo $show_value; ?>'<?php selected( $show_value, $show ); ?>><?php echo wp_specialchars( $show_text ); ?></option>
 <?php endforeach; ?>
@@ -258,7 +262,7 @@
 	</div>
 
 	<div id="available-sidebars" class="widget-liquid-right">
-		<h3><label for="sidebar-selector"><?php _e('Current Widgets'); ?></label></h3>
+		<h3><?php _e('Current Widgets'); ?></h3>
 
 		<div class="nav">
 			<select id="sidebar-selector" name="sidebar">
@@ -318,10 +322,5 @@
 	</form>
 
 </div>
-
 <?php do_action( 'sidebar_admin_page' ); ?>
-
-<br class="clear" />
-
-<?php require_once( 'admin-footer.php' ); ?>
-
+<?php require_once( 'admin-footer.php' ); ?>
\ No newline at end of file
Index: wp-includes/widgets.php
===================================================================
--- wp-includes/widgets.php	(revision 8180)
+++ wp-includes/widgets.php	(working copy)
@@ -95,8 +95,6 @@
 function wp_register_sidebar_widget($id, $name, $output_callback, $options = array()) {
 	global $wp_registered_widgets;
 
-	$id = strtolower($id);
-
 	if ( empty($output_callback) ) {
 		unset($wp_registered_widgets[$id]);
 		return;
@@ -166,8 +164,6 @@
  */
 function wp_register_widget_control($id, $name, $control_callback, $options = array()) {
 	global $wp_registered_widget_controls;
-	
-	$id = strtolower($id);
 
 	if ( empty($control_callback) ) {
 		unset($wp_registered_widget_controls[$id]);
@@ -202,8 +198,8 @@
 }
 
 function dynamic_sidebar($index = 1) {
-	global $wp_registered_sidebars, $wp_registered_widgets;
-
+	global $wp_registered_sidebars, $wp_registered_widgets,$wp_query;
+	
 	if ( is_int($index) ) {
 		$index = "sidebar-$index";
 	} else {
@@ -215,9 +211,7 @@
 			}
 		}
 	}
-
 	$sidebars_widgets = wp_get_sidebars_widgets();
-
 	if ( empty($wp_registered_sidebars[$index]) || !array_key_exists($index, $sidebars_widgets) || !is_array($sidebars_widgets[$index]) || empty($sidebars_widgets[$index]) )
 		return false;
 
@@ -229,7 +223,62 @@
 			array( array_merge( $sidebar, array('widget_id' => $id, 'widget_name' => $wp_registered_widgets[$id]['name']) ) ),
 			(array) $wp_registered_widgets[$id]['params']
 		);
-
+		
+		
+// 		allen's change begins
+		$widget_display_options=get_option('widget_display_option');
+		$display_registered_widgets = $sidebars_widgets[$index];
+		
+		if (is_front_page()) 
+			$current_page='frontpage';
+		else if ((is_home()) && (!is_front_page))
+			$current_page='blog';
+		else if(is_category())
+			$current_page='category';
+		else if(is_archive())
+			$current_page='archive';
+		else if(is_search())
+			$current_page='search';
+		else if(is_page()) {
+			$current_page='pages';
+			$display_id=$wp_query->get_queried_object_id();
+		} else if(is_tag()) {
+			$current_page='tag';
+		} else if(is_single()) {
+			$current_page='post';
+			$display_id=$wp_query->get_queried_object_id();
+		}
+		if (array_key_exists($id."-display-".$current_page, (array)$widget_display_options)){
+			$display='1';
+		} else {
+			$display='0';
+		}
+		if (($current_page=='pages') && ($display_id!='')) {
+			$dispaly_pages=$widget_display_options[$id."-display"]['page_id'];
+			if (is_array($dispaly_pages)){
+				if (array_key_exists($display_id,$dispaly_pages)) {
+					$display='1';
+				} else {
+					$display='0';
+				}
+			}
+		}
+		
+		if (($current_page=='post') && ($display_id!='')) {
+// 			exit("<pre>".print_r($widget_display_options[$id."-display"]['post_id'],1)."</pre>");
+			$dispaly_pages=$widget_display_options[$id."-display"]['post_id'];
+			if (is_array($dispaly_pages)){
+				if (array_key_exists($display_id, (array)$dispaly_pages)) {
+					$display='1';
+				} else {
+					$display='0';
+				}
+			} else {
+				$display='0';
+			}
+		}
+		
+		// allen's change ends
 		// Substitute HTML id and class attributes into before_widget
 		$classname_ = '';
 		foreach ( (array) $wp_registered_widgets[$id]['classname'] as $cn ) {
@@ -242,13 +291,17 @@
 		$params[0]['before_widget'] = sprintf($params[0]['before_widget'], $id, $classname_);
 
 		$params = apply_filters( 'dynamic_sidebar_params', $params );
+		
+		if ((!is_admin()) && !$display){
+		
+		} else {
+			$callback = $wp_registered_widgets[$id]['callback'];
+			if ( is_callable($callback) ) {
+				call_user_func_array($callback, $params);
+				$did_one = true;
+			}
+		}
 
-		$callback = $wp_registered_widgets[$id]['callback'];
-
-		if ( is_callable($callback) ) {
-			call_user_func_array($callback, $params);
-			$did_one = true;
-		}
 	}
 
 	return $did_one;
@@ -310,24 +363,6 @@
 					$_sidebars_widgets[$index][$i] = $id;
 					continue;
 				}
-
-				$found = false;
-
-				foreach ( $wp_registered_widgets as $widget_id => $widget ) {
-					if ( strtolower($widget['name']) == strtolower($name) ) {
-						$_sidebars_widgets[$index][$i] = $widget['id'];
-						$found = true;
-						break;
-					} elseif ( sanitize_title($widget['name']) == sanitize_title($name) ) {
-						$_sidebars_widgets[$index][$i] = $widget['id'];
-						$found = true;
-						break;
-					}
-				}
-
-				if ( $found )
-					continue;
-
 				unset($_sidebars_widgets[$index][$i]);
 			}
 			$_sidebars_widgets['array_version'] = 2;
@@ -385,7 +420,7 @@
 	extract( $args );
 	$options = get_option( 'widget_pages' );
 
-	$title = empty( $options['title'] ) ? __( 'Pages' ) : apply_filters('widget_title', $options['title']);
+	$title = empty( $options['title'] ) ? __( 'Pages' ) : $options['title'];
 	$sortby = empty( $options['sortby'] ) ? 'menu_order' : $options['sortby'];
 	$exclude = empty( $options['exclude'] ) ? '' : $options['exclude'];
 
@@ -450,13 +485,11 @@
 
 function wp_widget_links($args) {
 	extract($args, EXTR_SKIP);
-
-	$before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);
-	wp_list_bookmarks(apply_filters('widget_links_args', array(
+	wp_list_bookmarks(array(
 		'title_before' => $before_title, 'title_after' => $after_title,
 		'category_before' => $before_widget, 'category_after' => $after_widget,
 		'show_images' => true, 'class' => 'linkcat widget'
-	)));
+	));
 }
 
 function wp_widget_search($args) {
@@ -465,7 +498,6 @@
 		<?php echo $before_widget; ?>
 			<form id="searchform" method="get" action="<?php bloginfo('home'); ?>">
 			<div>
-			<label class="hidden" for="s"><?php _e('Search for:'); ?></label>
 			<input type="text" name="s" id="s" size="15" /><br />
 			<input type="submit" value="<?php echo attribute_escape(__('Search')); ?>" />
 			</div>
@@ -479,7 +511,7 @@
 	$options = get_option('widget_archives');
 	$c = $options['count'] ? '1' : '0';
 	$d = $options['dropdown'] ? '1' : '0';
-	$title = empty($options['title']) ? __('Archives') : apply_filters('widget_title', $options['title']);
+	$title = empty($options['title']) ? __('Archives') : $options['title'];
 
 	echo $before_widget;
 	echo $before_title . $title . $after_title;
@@ -527,7 +559,7 @@
 function wp_widget_meta($args) {
 	extract($args);
 	$options = get_option('widget_meta');
-	$title = empty($options['title']) ? __('Meta') : apply_filters('widget_title', $options['title']);
+	$title = empty($options['title']) ? __('Meta') : $options['title'];
 ?>
 		<?php echo $before_widget; ?>
 			<?php echo $before_title . $title . $after_title; ?>
@@ -561,7 +593,7 @@
 function wp_widget_calendar($args) {
 	extract($args);
 	$options = get_option('widget_calendar');
-	$title = apply_filters('widget_title', $options['title']);
+	$title = $options['title'];
 	if ( empty($title) )
 		$title = '&nbsp;';
 	echo $before_widget . $before_title . $title . $after_title;
@@ -570,10 +602,12 @@
 	echo '</div>';
 	echo $after_widget;
 }
+
 function wp_widget_calendar_control() {
 	$options = $newoptions = get_option('widget_calendar');
 	if ( $_POST["calendar-submit"] ) {
 		$newoptions['title'] = strip_tags(stripslashes($_POST["calendar-title"]));
+		$newoptions['displayon'] = $_POST['calendar-display-frontpage'];
 	}
 	if ( $options != $newoptions ) {
 		$options = $newoptions;
@@ -581,8 +615,8 @@
 	}
 	$title = attribute_escape($options['title']);
 ?>
-			<p><label for="calendar-title"><?php _e('Title:'); ?> <input class="widefat" id="calendar-title" name="calendar-title" type="text" value="<?php echo $title; ?>" /></label></p>
-			<input type="hidden" id="calendar-submit" name="calendar-submit" value="1" />
+		<p><label for="calendar-title"><?php _e('Title:'); ?> <input class="widefat" id="calendar-title" name="calendar-title" type="text" value="<?php echo $title; ?>" /></label></p>
+		<input type="hidden" id="calendar-submit" name="calendar-submit" value="1" />
 <?php
 }
 
@@ -598,7 +632,7 @@
 	if ( !isset($options[$number]) )
 		return;
 
-	$title = apply_filters('widget_title', $options[$number]['title']);
+	$title = $options[$number]['title'];
 	$text = apply_filters( 'widget_text', $options[$number]['text'] );
 ?>
 		<?php echo $before_widget; ?>
@@ -639,8 +673,6 @@
 		}
 
 		foreach ( (array) $_POST['widget-text'] as $widget_number => $widget_text ) {
-			if ( !isset($widget_text['text']) && isset($options[$widget_number]) ) // user clicked cancel
-				continue;
 			$title = strip_tags(stripslashes($widget_text['title']));
 			if ( current_user_can('unfiltered_html') )
 				$text = stripslashes( $widget_text['text'] );
@@ -665,7 +697,7 @@
 		<p>
 			<input class="widefat" id="text-title-<?php echo $number; ?>" name="widget-text[<?php echo $number; ?>][title]" type="text" value="<?php echo $title; ?>" />
 			<textarea class="widefat" rows="16" cols="20" id="text-text-<?php echo $number; ?>" name="widget-text[<?php echo $number; ?>][text]"><?php echo $text; ?></textarea>
-			<input type="hidden" name="widget-text[<?php echo $number; ?>][submit]" value="1" />
+			<input type="hidden" id="text-submit-<?php echo $number; ?>" name="text-submit-<?php echo $number; ?>" value="1" />
 		</p>
 <?php
 }
@@ -710,16 +742,15 @@
 	$h = $options[$number]['hierarchical'] ? '1' : '0';
 	$d = $options[$number]['dropdown'] ? '1' : '0';
 
-	$title = empty($options[$number]['title']) ? __('Categories') : apply_filters('widget_title', $options[$number]['title']);
+	$title = empty($options[$number]['title']) ? __('Categories') : $options[$number]['title'];
 
 	echo $before_widget;
 	echo $before_title . $title . $after_title;
 
-	$cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h);
+	$cat_args = "orderby=name&show_count={$c}&hierarchical={$h}";
 
 	if ( $d ) {
-		$cat_args['show_option_none'] = __('Select Category');
-		wp_dropdown_categories($cat_args);
+		wp_dropdown_categories($cat_args . '&show_option_none= ' . __('Select Category'));
 ?>
 
 <script type='text/javascript'>
@@ -738,10 +769,7 @@
 	} else {
 ?>
 		<ul>
-		<?php 
-			$cat_args['title_li'] = '';
-			wp_list_categories($cat_args); 
-		?>
+		<?php wp_list_categories($cat_args . '&title_li='); ?>
 		</ul>
 <?php
 	}
@@ -781,8 +809,6 @@
 		}
 
 		foreach ( (array) $_POST['widget-categories'] as $widget_number => $widget_cat ) {
-			if ( !isset($widget_cat['title']) && isset($options[$widget_number]) ) // user clicked cancel
-				continue;
 			$title = trim(strip_tags(stripslashes($widget_cat['title'])));
 			$count = isset($widget_cat['count']);
 			$hierarchical = isset($widget_cat['hierarchical']);
@@ -831,7 +857,7 @@
 				</label>
 			</p>
 
-			<input type="hidden" name="widget-categories[<?php echo $number; ?>][submit]" value="1" />
+			<input type="hidden" id="categories-submit-<?php echo $number; ?>" name="categories-submit-<?php echo $number; ?>" value="1" />
 <?php
 }
 
@@ -891,15 +917,13 @@
 }
 
 function wp_widget_recent_entries($args) {
-	if ( '%BEG_OF_TITLE%' != $args['before_title'] ) {
-		if ( $output = wp_cache_get('widget_recent_entries', 'widget') )
-			return print($output);
-		ob_start();
-	}
+	if ( $output = wp_cache_get('widget_recent_entries', 'widget') )
+		return print($output);
 
+	ob_start();
 	extract($args);
 	$options = get_option('widget_recent_entries');
-	$title = empty($options['title']) ? __('Recent Posts') : apply_filters('widget_title', $options['title']);
+	$title = empty($options['title']) ? __('Recent Posts') : $options['title'];
 	if ( !$number = (int) $options['number'] )
 		$number = 10;
 	else if ( $number < 1 )
@@ -907,7 +931,7 @@
 	else if ( $number > 15 )
 		$number = 15;
 
-	$r = new WP_Query(array('showposts' => $number, 'what_to_show' => 'posts', 'nopaging' => 0, 'post_status' => 'publish'));
+	$r = new WP_Query("showposts=$number&what_to_show=posts&nopaging=0&post_status=publish");
 	if ($r->have_posts()) :
 ?>
 		<?php echo $before_widget; ?>
@@ -921,9 +945,7 @@
 <?php
 		wp_reset_query();  // Restore global post data stomped by the_post().
 	endif;
-
-	if ( '%BEG_OF_TITLE%' != $args['before_title'] )
-		wp_cache_add('widget_recent_entries', ob_get_flush(), 'widget');
+	wp_cache_add('widget_recent_entries', ob_get_flush(), 'widget');
 }
 
 function wp_flush_widget_recent_entries() {
@@ -964,7 +986,7 @@
 	global $wpdb, $comments, $comment;
 	extract($args, EXTR_SKIP);
 	$options = get_option('widget_recent_comments');
-	$title = empty($options['title']) ? __('Recent Comments') : apply_filters('widget_title', $options['title']);
+	$title = empty($options['title']) ? __('Recent Comments') : $options['title'];
 	if ( !$number = (int) $options['number'] )
 		$number = 5;
 	else if ( $number < 1 )
@@ -1070,12 +1092,11 @@
 		$title = $desc;
 	if ( empty($title) )
 		$title = __('Unknown Feed');
-	$title = apply_filters('widget_title', $title );
 	$url = clean_url(strip_tags($url));
 	if ( file_exists(dirname(__FILE__) . '/rss.png') )
-		$icon = str_replace(ABSPATH, site_url() . '/', dirname(__FILE__)) . '/rss.png';
+		$icon = str_replace(ABSPATH, get_option('siteurl').'/', dirname(__FILE__)) . '/rss.png';
 	else
-		$icon = includes_url('images/rss.png');
+		$icon = get_option('siteurl').'/wp-includes/images/rss.png';
 	$title = "<a class='rsswidget' href='$url' title='" . attribute_escape(__('Syndicate this content')) ."'><img style='background:orange;color:white;border:none;' width='14' height='14' src='$icon' alt='RSS' /></a> <a class='rsswidget' href='$link' title='$desc'>$title</a>";
 
 	echo $before_widget;
@@ -1150,7 +1171,7 @@
 
 				if ( $date ) {
 					if ( $date_stamp = strtotime( $date ) )
-						$date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date_stamp ) . '</span>';
+						$date = '<span class="rss-date">' . gmdate( get_option( 'date_format' ), $date_stamp ) . '</span>';
 					else
 						$date = '';
 				}
@@ -1208,8 +1229,6 @@
 		}
 
 		foreach( (array) $_POST['widget-rss'] as $widget_number => $widget_rss ) {
-			if ( !isset($widget_rss['url']) && isset($options[$widget_number]) ) // user clicked cancel
-				continue;
 			$widget_rss = stripslashes_deep( $widget_rss );
 			$url = sanitize_url(strip_tags($widget_rss['url']));
 			$options[$widget_number] = wp_widget_rss_process( $widget_rss, !isset($urls[$url]) );
@@ -1294,7 +1313,7 @@
 			<?php _e('Display item date?'); ?>
 		</label>
 	</p>
-	<input type="hidden" name="widget-rss[<?php echo $number; ?>][submit]" value="1" />
+	<input type="hidden" id="rss-submit-<?php echo $number; ?>" name="rss-submit-<?php echo $number; ?>" value="1" />
 <?php
 	endif;
 	foreach ( array_keys($default_inputs) as $input ) :
@@ -1363,7 +1382,7 @@
 function wp_widget_tag_cloud($args) {
 	extract($args);
 	$options = get_option('widget_tag_cloud');
-	$title = empty($options['title']) ? __('Tags') : apply_filters('widget_title', $options['title']);
+	$title = empty($options['title']) ? __('Tags') : $options['title'];
 
 	echo $before_widget;
 	echo $before_title . $title . $after_title;
@@ -1392,6 +1411,7 @@
 <?php
 }
 
+
 function wp_widgets_init() {
 	if ( !is_blog_installed() )
 		return;
@@ -1404,6 +1424,7 @@
 	wp_register_sidebar_widget('calendar', __('Calendar'), 'wp_widget_calendar', $widget_ops);
 	wp_register_widget_control('calendar', __('Calendar'), 'wp_widget_calendar_control' );
 
+
 	$widget_ops = array('classname' => 'widget_archive', 'description' => __( "A monthly archive of your blog's posts") );
 	wp_register_sidebar_widget('archives', __('Archives'), 'wp_widget_archives', $widget_ops);
 	wp_register_widget_control('archives', __('Archives'), 'wp_widget_archives_control' );
@@ -1500,13 +1521,11 @@
 
 		foreach ( (array) $_POST['widget-many'] as $widget_number => $widget_many_instance ) {
 			// compile data from $widget_many_instance
-			if ( !isset($widget_many_instance['something']) && isset($options[$widget_number]) ) // user clicked cancel
-				continue;
 			$something = wp_specialchars( $widget_many_instance['something'] );
 			$options[$widget_number] = array( 'something' => $something );  // Even simple widgets should store stuff in array, rather than in scalar
 		}
 
-		update_option('widget_many', $options);
+		update_option('widget_text', $options);
 
 		$updated = true; // So that we don't go through this more than once
 	}
@@ -1525,7 +1544,7 @@
 ?>
 		<p>
 			<input class="widefat" id="widget-many-something-<?php echo $number; ?>" name="widget-many[<?php echo $number; ?>][something]" type="text" value="<?php echo $data; ?>" />
-			<input type="hidden" id="widget-many-submit-<?php echo $number; ?>" name="widget-many[<?php echo $number; ?>][submit]" value="1" />
+			<input type="hidden" id="widget-many-submit-<?php echo $number; ?>" name="widget-many-<?php echo $number; ?>" value="1" />
 		</p>
 <?php
 }
@@ -1548,8 +1567,8 @@
 		// $id should look like {$id_base}-{$o}
 		$id = "many-$o"; // Never never never translate an id
 		$registered = true;
-		wp_register_sidebar_widget( $id, $name, 'widget_many', $widget_ops, array( 'number' => $o ) );
-		wp_register_widget_control( $id, $name, 'widget_many_control', $control_ops, array( 'number' => $o ) );
+		wp_register_sidebar_widget( $id, $name, 'wp_widget_text', $widget_ops, array( 'number' => $o ) );
+		wp_register_widget_control( $id, $name, 'wp_widget_text_control', $control_ops, array( 'number' => $o ) );
 	}
 
 	// If there are none, we register the widget's existance with a generic template
@@ -1564,4 +1583,4 @@
 
 */
 
-?>
+?>
\ No newline at end of file

