Index: wp-includes/widgets.php
===================================================================
--- wp-includes/widgets.php	(revision 12240)
+++ wp-includes/widgets.php	(working copy)
@@ -381,8 +381,8 @@
 /**
  * Private
  */
- $_wp_deprecated_widgets_callbacks = array(
- 	'wp_widget_pages',
+$_wp_deprecated_widgets_callbacks = array(
+	'wp_widget_pages',
 	'wp_widget_pages_control',
 	'wp_widget_calendar',
 	'wp_widget_calendar_control',
@@ -404,7 +404,7 @@
 	'wp_widget_rss_control',
 	'wp_widget_recent_comments',
 	'wp_widget_recent_comments_control'
- );
+);
 
 /* Template tags & API functions */
 
@@ -448,6 +448,53 @@
 }
 
 /**
+ * Return the registered ID of a sidebar given it's name or registration ID.
+ *
+ * Since register_sidebar() supports it, this function will look for sidebars
+ * named as integers or as a default id (like 2 or 'sidebar-13') first and check
+ * those as IDs if the name fails (and those IDs exist).
+ * ie: $id = wp_get_sidebar_id(1);
+ *     $id = wp_get_sidebar_id('Sidebar Top');
+ *
+ * wp_get_sidebar_id() will also take an array of arguments. The array should have
+ * keys 'name', 'id' or both: $id = wp_get_sidebar_id( array('id' => 'sidebar-1') );
+ *
+ * @since 2.9.0
+ *
+ * @param int|string|array $args The name or id of the sidebar as registered with
+ * register_sidebar(s) functions. If an array, use the register_sidebar() syntax.
+ *
+ * @return mixed returns false if id not found or returns sidebar id.
+ */
+function wp_get_sidebar_id($args) {
+	global $wp_registered_sidebars;
+
+	 if ( is_array($args) ) {
+		// $args is an array holding a name, an id or both.
+		if ( !empty($args['id']) )
+			$args = $args['id'];
+		elseif ( !empty($args['name']) )
+			$args = $args['name'];
+		else
+			return false;
+	}
+
+	if ( is_int($args) ) {
+		return "sidebar-$args";
+	} elseif ( is_string($args) ) {
+		$name = sanitize_title($args);
+
+		foreach ( (array) $wp_registered_sidebars as $id => $value ) {
+			if ( sanitize_title($value['name']) == $name || $id == $name )
+				return $id;
+		}
+	}
+
+	return false;
+}
+
+
+/**
  * Creates multiple sidebars.
  *
  * If you wanted to quickly create multiple sidebars for a theme or internally.
@@ -565,10 +612,13 @@
  *
  * @uses $wp_registered_sidebars Stores the new sidebar in this array by sidebar ID.
  *
- * @param string $name The ID of the sidebar when it was added.
+ * @param int|string|array $name The name or id of the sidebar as registered with
+ * register_sidebar(s) functions. If an array, use the register_sidebar() syntax
+ * including keys 'name', 'id' or both.
  */
-function unregister_sidebar( $name ) {
+function unregister_sidebar($name) {
 	global $wp_registered_sidebars;
+	$name = wp_get_sidebar_id($name);
 
 	if ( isset( $wp_registered_sidebars[$name] ) )
 		unset( $wp_registered_sidebars[$name] );
@@ -825,33 +875,25 @@
  *
  * @since 2.2.0
  *
- * @param int|string $index Optional, default is 1. Name or ID of dynamic sidebar.
+ * @param int|string|array $args Optional, default is 1. The name or id of the wigdet
+ * specified by register_sidebar(s) functions. As an array use the register_sidebar()
+ * syntax identifying sidebar by name or id or both.
  * @return bool True, if widget sidebar was found and called. False if not found or not called.
  */
-function dynamic_sidebar($index = 1) {
+function dynamic_sidebar($name = 1) {
 	global $wp_registered_sidebars, $wp_registered_widgets;
 
-	if ( is_int($index) ) {
-		$index = "sidebar-$index";
-	} else {
-		$index = sanitize_title($index);
-		foreach ( (array) $wp_registered_sidebars as $key => $value ) {
-			if ( sanitize_title($value['name']) == $index ) {
-				$index = $key;
-				break;
-			}
-		}
-	}
+	$name = wp_get_sidebar_id($name);
 
 	$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]) )
+	if ( empty($wp_registered_sidebars[$name]) || !array_key_exists($name, $sidebars_widgets) || !is_array($sidebars_widgets[$name]) || empty($sidebars_widgets[$name]) )
 		return false;
 
-	$sidebar = $wp_registered_sidebars[$index];
+	$sidebar = $wp_registered_sidebars[$name];
 
 	$did_one = false;
-	foreach ( (array) $sidebars_widgets[$index] as $id ) {
+	foreach ( (array) $sidebars_widgets[$name] as $id ) {
 
 		if ( !isset($wp_registered_widgets[$id]) ) continue;
 
@@ -953,16 +995,17 @@
  *
  * @since 2.8
  *
- * @param mixed $index, sidebar name, id or number to check.
+ * @param int|string|array $name The name or id of the sidebar as registered with
+ * register_sidebar(s) functions. If an array, use the register_sidebar() syntax
+ * including keys 'name' or 'id' or both.
+ *
  * @return bool true if the sidebar is in use, false otherwise.
  */
-function is_active_sidebar( $index ) {
-	$index = ( is_int($index) ) ? "sidebar-$index" : sanitize_title($index);
+function is_active_sidebar($name) {
+	$name = wp_get_sidebar_id($name);
 	$sidebars_widgets = wp_get_sidebars_widgets();
-	if ( isset($sidebars_widgets[$index]) && !empty($sidebars_widgets[$index]) )
-		return true;
-
-	return false;
+	
+	return !empty($sidebars_widgets[$name]);
 }
 
 /* Internal Functions */
