is_active_widget() should skip orphaned widgets.

props Ninos Ego.
fixes #28810.
Built from https://develop.svn.wordpress.org/trunk@29064


git-svn-id: http://core.svn.wordpress.org/trunk@28850 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2014-07-10 15:49:14 +00:00
parent 105d9ce9cc
commit f281e72922

View File

@ -1142,8 +1142,9 @@ function is_active_widget($callback = false, $widget_id = false, $id_base = fals
if ( is_array($sidebars_widgets) ) { if ( is_array($sidebars_widgets) ) {
foreach ( $sidebars_widgets as $sidebar => $widgets ) { foreach ( $sidebars_widgets as $sidebar => $widgets ) {
if ( $skip_inactive && 'wp_inactive_widgets' == $sidebar ) if ( $skip_inactive && ( 'wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr( $sidebar, 0, 16 ) ) ) {
continue; continue;
}
if ( is_array($widgets) ) { if ( is_array($widgets) ) {
foreach ( $widgets as $widget ) { foreach ( $widgets as $widget ) {
@ -1424,8 +1425,9 @@ function retrieve_widgets( $theme_changed = false ) {
} }
foreach ( $_sidebars_widgets as $sidebar => $widgets ) { foreach ( $_sidebars_widgets as $sidebar => $widgets ) {
if ( 'wp_inactive_widgets' == $sidebar || 'orphaned_widgets' == substr( $sidebar, 0, 16 ) ) if ( 'wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr( $sidebar, 0, 16 ) ) {
continue; continue;
}
if ( !in_array( $sidebar, $registered_sidebar_keys ) ) { if ( !in_array( $sidebar, $registered_sidebar_keys ) ) {
$_sidebars_widgets['orphaned_widgets_' . ++$orphaned] = $widgets; $_sidebars_widgets['orphaned_widgets_' . ++$orphaned] = $widgets;