is_active_sidebar() problem
I'm trying to develop a wordpress theme with a hero slider, I use some 3rd party slider widget inserted to the hero widget area I've defined as sidebar-hero in my functions.php
file.
I'm using this code to display the hero slider:
?php if(is_active_sidebar("sidebar-hero")) : ?
?php dynamic_sidebar("sidebar-hero");?
script type="text/javascript"document.body.classList.add("hero-widget-enabled");/script
?php else: ?
div class="carousel-page-container container"
div class="header-filter" style='background-image: url(/wp-content/themes/sometheme/assets/images/demo/back.png)'
div class="header-filter-gradient"/div
/div
/div
/div
?php endif;?
Now the problem is, I add the custom slider to the sidebar-hero widget area, it shows the slider. I remove the slider from the widgets, it shows the default image. But when I disable the slider from the extensions page without removing it from the widget area, it still tries to show the dynamic sidebar.
The is_active_sidebar()
method returns true
even if there are any widgets displayed in the widget settings page on the sidebar-hero widget area.
Do you have any solutions for this issue? Is it a wordpress bug, or am I doing something wrong?
Update
wp_get_sidebars_widgets()
shows this output (which smartslider3-2 should not
be included because it's plugin is disabled):
array(6) {
["wp_inactive_widgets"]=
array(11) {
[0]=
string(10) "archives-2"
[1]=
string(10) "archives-4"
[2]=
string(6) "meta-2"
[3]=
string(8) "search-2"
[4]=
string(8) "search-4"
[5]=
string(6) "text-2"
[6]=
string(12) "categories-2"
[7]=
string(14) "recent-posts-2"
[8]=
string(17) "recent-comments-2"
[9]=
string(6) "text-3"
[10]=
string(11) "tag_cloud-2"
}
["sidebar-primary"]=
array(3) {
[0]=
string(12) "categories-3"
[1]=
string(11) "tag_cloud-1"
[2]=
string(10) "calendar-1"
}
["sidebar-footer-1"]=
array(1) {
[0]=
string(14) "recent-posts-3"
}
["sidebar-footer-2"]=
array(1) {
[0]=
string(7) "pages-2"
}
["sidebar-footer-3"]=
array(1) {
[0]=
string(11) "tag_cloud-3"
}
["sidebar-hero"]=
array(1) {
[0]=
string(14) "smartslider3-2"
}
}
Topic deactivation widgets theme-development Wordpress
Category Web