Fix widgets using old-style multi instance support. Props mdawaffe. fixes #6023

git-svn-id: http://svn.automattic.com/wordpress/trunk@7080 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-02-28 00:31:46 +00:00
parent 3a9016a05b
commit b2838e11c7
2 changed files with 9 additions and 5 deletions

View File

@ -41,7 +41,8 @@ function wp_list_widgets( $show = 'all', $_search = false ) {
continue; continue;
} }
$sidebar = is_active_widget( $widget['callback'] ); $sidebar = is_active_widget( $widget['callback'], $widget['id'] );
if ( ( 'unused' == $show && $sidebar ) || ( 'used' == $show && !$sidebar ) ) if ( ( 'unused' == $show && $sidebar ) || ( 'used' == $show && !$sidebar ) )
continue; continue;
@ -50,8 +51,9 @@ function wp_list_widgets( $show = 'all', $_search = false ) {
$widget_control_template = ob_get_contents(); $widget_control_template = ob_get_contents();
ob_end_clean(); ob_end_clean();
if ( !$sidebar || false !== strpos( $widget_control_template, '%i%' ) ) { if ( !$sidebar || $is_multi = false !== strpos( $widget_control_template, '%i%' ) ) {
$already_shown[] = $widget['callback']; // it's a multi-widget. We only need to show it in the list once. if ( $is_multi )
$already_shown[] = $widget['callback']; // it's a multi-widget. We only need to show it in the list once.
$action = 'add'; $action = 'add';
$add_url = wp_nonce_url( add_query_arg( array( $add_url = wp_nonce_url( add_query_arg( array(
'sidebar' => $sidebar, 'sidebar' => $sidebar,

View File

@ -252,7 +252,7 @@ function dynamic_sidebar($index = 1) {
/* @return mixed false if widget is not active or id of sidebar in which the widget is active /* @return mixed false if widget is not active or id of sidebar in which the widget is active
*/ */
function is_active_widget($callback) { function is_active_widget($callback, $widget_id = false) {
global $wp_registered_widgets; global $wp_registered_widgets;
$sidebars_widgets = wp_get_sidebars_widgets(false); $sidebars_widgets = wp_get_sidebars_widgets(false);
@ -260,7 +260,9 @@ function is_active_widget($callback) {
if ( is_array($sidebars_widgets) ) foreach ( $sidebars_widgets as $sidebar => $widgets ) if ( is_array($sidebars_widgets) ) foreach ( $sidebars_widgets as $sidebar => $widgets )
if ( is_array($widgets) ) foreach ( $widgets as $widget ) if ( is_array($widgets) ) foreach ( $widgets as $widget )
if ( isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] == $callback ) if ( isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] == $callback )
return $sidebar; if ( !$widget_id || $widget_id == $wp_registered_widgets[$widget]['id'] )
return $sidebar;
return false; return false;
} }