Sidebars are stored in a global variable named $wp_registered_sidebars
.
if ( ! function_exists( 'before_sidebar' ) ) {
function before_sidebar( $columns="five" ) {
global $wp_registered_sidebars;
$class_name = $wp_registered_sidebars[$columns]['class'];
// Apply the markup
echo "<div id='sidebar' class="$class_name" role="complementary">\n";
}
}
I assumed that $columns contains the sidebar ID. The value passed into before_sidebar()
is the name value given to ‘id'
('id' => 'primary-widget-area'
) in the arguments. I say that because naming that variable $columns
seems strange.