- $widgets = array();
- foreach ( $wp_registered_widgets as $name => $widget ) {
- $widgets[] = '\'' . $widget['id'] . '\'';
- }
- $widgets = implode( ', ', $widgets );
-?>
-<script type="text/javascript">
-// <![CDATA[
- var cols = [<?php echo $cols; ?>];
- var widgets = [<?php echo $widgets; ?>];
- var controldims = new Array;
- <?php foreach ( $wp_registered_widget_controls as $name => $widget ) : ?>
- controldims['#<?php echo $widget['id']; ?>control'] = new Array;
- controldims['#<?php echo $widget['id']; ?>control']['width'] = <?php echo (int) $widget['width']; ?>;
- controldims['#<?php echo $widget['id']; ?>control']['height'] = <?php echo (int) $widget['height']; ?>;
- <?php endforeach; ?>
- function initWidgets() {
- <?php foreach ( $wp_registered_widget_controls as $name => $widget ) : ?>
- jQuery('#<?php echo $widget['id']; ?>popper').click(function() {popControl('#<?php echo $widget['id']; ?>control');});
- jQuery('#<?php echo $widget['id']; ?>closer').click(function() {unpopControl('#<?php echo $widget['id']; ?>control');});
- jQuery('#<?php echo $widget['id']; ?>control').Draggable({handle: '.controlhandle', zIndex: 1000});
- if ( true && window.opera )
- jQuery('#<?php echo $widget['id']; ?>control').css('border','1px solid #bbb');
- <?php endforeach; ?>
- jQuery('#shadow').css('opacity','0');
- jQuery(widgets).each(function(o) {o='#widgetprefix-'+o; jQuery(o).css('position','relative');} );
- }
- function resetDroppableHeights() {
- var max = 6;
- jQuery.map(cols, function(o) {
- var c = jQuery('#' + o + ' li').length;
- if ( c > max ) max = c;
- });
- var maxheight = 35 * ( max + 1);
- jQuery.map(cols, function(o) {
- height = 0 == jQuery('#' + o + ' li').length ? maxheight - jQuery('#' + o + 'placemat').height() : maxheight;
- jQuery('#' + o).height(height);
- });
- }
- function maxHeight(elm) {
- htmlheight = document.body.parentNode.clientHeight;
- bodyheight = document.body.clientHeight;
- var height = htmlheight > bodyheight ? htmlheight : bodyheight;
- jQuery(elm).height(height);
- }
- function getViewportDims() {
- var x,y;
- if (self.innerHeight) { // all except Explorer
- x = self.innerWidth;
- y = self.innerHeight;
- } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
- x = document.documentElement.clientWidth;
- y = document.documentElement.clientHeight;
- } else if (document.body) { // other Explorers
- x = document.body.clientWidth;
- y = document.body.clientHeight;
+// register the inactive_widgets area as sidebar
+register_sidebar(array(
+ 'name' => __('Inactive Widgets'),
+ 'id' => 'wp_inactive_widgets',
+ 'before_widget' => '',
+ 'after_widget' => '',
+ 'before_title' => '',
+ 'after_title' => '',
+));
+
+// These are the widgets grouped by sidebar
+$sidebars_widgets = wp_get_sidebars_widgets();
+if ( empty( $sidebars_widgets ) )
+ $sidebars_widgets = wp_get_widget_defaults();
+
+// look for "lost" widgets, this has to run at least on each theme change
+function retrieve_widgets() {
+ global $wp_registered_widget_updates, $wp_registered_sidebars, $sidebars_widgets, $wp_registered_widgets;
+
+ $_sidebars_widgets = array();
+ $sidebars = array_keys($wp_registered_sidebars);
+
+ unset( $sidebars_widgets['array_version'] );
+
+ $old = array_keys($sidebars_widgets);
+ sort($old);
+ sort($sidebars);
+
+ if ( $old == $sidebars )
+ return;
+
+ // Move the known-good ones first
+ foreach ( $sidebars as $id ) {
+ if ( array_key_exists( $id, $sidebars_widgets ) ) {
+ $_sidebars_widgets[$id] = $sidebars_widgets[$id];
+ unset($sidebars_widgets[$id], $sidebars[$id]);