Skip to content

Instantly share code, notes, and snippets.

@ryanwelcher
Last active November 14, 2017 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanwelcher/64042dc1946f36840b61 to your computer and use it in GitHub Desktop.
Save ryanwelcher/64042dc1946f36840b61 to your computer and use it in GitHub Desktop.
is_active_sidebar incorrectly returning true after plugin deactivation
add_filter( 'is_active_sidebar', function( $is_active_sidebar, $index ) {
global $wp_registered_widgets;
$widgets = wp_get_sidebars_widgets();
$widget_area_contents = $widgets[ $index ];
$active_widget_count = count( $widget_area_contents );
foreach ( $widgets[ $index ] as $widget_instance ) {
if ( ! array_key_exists( $widget_instance, $wp_registered_widgets ) ) {
$active_widget_count--;
}
}
return ( 0 < $active_widget_count );
}, 10 , 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment