[wp-hackers] Sidebar ID Naming Problems
Charles K. Clarkson
cclarkson at htcomp.net
Wed Nov 18 16:43:28 UTC 2009
Chris Jean wrote:
> I'd love a solution that allowed me
> to specify very specific sidebar IDs using alphanumeric, -, and _
> characters.
>
> I'm going to start working on a Core patch that does just that. Does
> anyone know of any potential pitfalls as I begin working with this? For
> example, is there code in the widget handling that expects/requires an
> integer sidebar id?
Hey Chris,
I already have a ticket open: http://core.trac.wordpress.org/ticket/11160
It does what you want by allowing you to pass an array as the parameter:
array(
'id' => 'foo'
'name' => 'My Weird Sidebar name',
}
I didn't test for this solution yet, but you should be able to pass the same
array to is_active_sidebar(), dynamic_sidebar() and unregister_sidebar() as
you do to register_sidebar().
So, you could set your arrays up for register sidebar and then use those same
arrays for all other sidebar functions.
Assuming $my_sidebars is a long list of sidebars:
foreach ( $my_sidebars as $name => $side_bar ) {
register_sidebar($side_bar);
}
if ( is_active_sidebar( $my_sidebars['categories'] ) ) {
dynamic_sidebar( $my_sidebars['categories'] );
}
Unlike now, dynamic_sidebar() will find the id in the array and do the right
thing.
HTH,
Charles Clarkson
--
Mobile Home Investor
Free Market Advocate
Programmer
I'm not really a smart person. I just play one on the Internet.
Stephenville, TX
http://www.clarksonenergyhomes.com/wordpress/about/
http://twitter.com/CharlesClarkson
+1 (254) 968-8328
More information about the wp-hackers
mailing list