Skip to content

Commit 0f3de5e

Browse files
committed
Prevent errors in assigning widgets to sidebars for themes with dynamic sidebars, props batmoo, fixes #19274
git-svn-id: https://develop.svn.wordpress.org/trunk@19334 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 1cc6c3c commit 0f3de5e

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

wp-admin/widgets.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,21 @@ function wp_widgets_access_body_class($classes) {
6262
if ( 'wp_inactive_widgets' == $sidebar_id )
6363
continue;
6464

65-
if ( empty( $wp_registered_sidebars[ $sidebar_id ] ) && ! empty( $widgets ) ) {
66-
// register the inactive_widgets area as sidebar
67-
register_sidebar(array(
68-
'name' => __( 'Inactive Sidebar (from previous theme)' ),
69-
'id' => $sidebar_id,
70-
'class' => 'inactive-sidebar orphan-sidebar',
71-
'description' => __( 'This is a left over sidebar from an old theme and does not show anywhere on your site' ),
72-
'before_widget' => '',
73-
'after_widget' => '',
74-
'before_title' => '',
75-
'after_title' => '',
76-
));
65+
if ( !isset( $wp_registered_sidebars[ $sidebar_id ] ) ) {
66+
if ( ! empty( $widgets ) ) { // register the inactive_widgets area as sidebar
67+
register_sidebar(array(
68+
'name' => __( 'Inactive Sidebar (from previous theme)' ),
69+
'id' => $sidebar_id,
70+
'class' => 'inactive-sidebar orphan-sidebar',
71+
'description' => __( 'This is a left over sidebar from an old theme and does not show anywhere on your site' ),
72+
'before_widget' => '',
73+
'after_widget' => '',
74+
'before_title' => '',
75+
'after_title' => '',
76+
));
77+
} else {
78+
unset( $sidebars_widgets[ $sidebar_id ] );
79+
}
7780
}
7881
}
7982

0 commit comments

Comments
 (0)