Last active
November 14, 2017 13:22
-
-
Save ryanwelcher/64042dc1946f36840b61 to your computer and use it in GitHub Desktop.
is_active_sidebar incorrectly returning true after plugin deactivation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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