I have looked here on WA and also on the codex but there is no definitive source that I could find.
Which is the proper/best way to check to see if a dynamic_sidebar is active and contains a widget?
I see these 3 solutions at large but not sure what the proper way is:
1. if(is_active_sidebar('foo')){ //check if the sidebar is active
dynamic_sidebar('foo');
}
2. dynamic_sidebar('foo'); //basically just call it
3. if(dynamic_sidebar('foo')) //also have seen the inverse if(!dynamic_sidebar('foo') check the return of the function
If they are all valid then why not just choose option 2?
is_active_sidebar
can be used in case if you want to wrap the sidebar within some html codes, ex -if( is_active_sidebar('foo') ){ echo '<div id="sidebar-foo">'; dynamic_sidebar('foo'); echo '</div>'; }