[wp-hackers] Programmatic Widget Handling

Jeremy Clarke jer at simianuprising.com
Wed Oct 20 18:08:53 UTC 2010

On Wed, Oct 20, 2010 at 2:02 PM, Moya, Eddie <emoya at tribune.com> wrote:

> We need to have this sort of constraint available. This I think I can do.
> In fact I only have not added it because other priorities have taken up my
> time. I am fairly certain that creating a way of having logic where it only
> loads in a sidebar named "sidebar1" for example. I think the quick (less
> elegant) solution will be to let users add the widget to whatever sidebar
> they want, but simply have that widget not work if the constraint is not
> met.
FWIW I think the use-case you're dealing with is probably outside the scope
of the much more general API that should be in core. Limiting what widgets
can go in what sidebar may also be a use-case the API should handle, but
that would probably do better to be part of the register_sidebar() end of
things rather than the suite of functions that would allow adding of widgets
into sidebars with PHP (other features that would be nice in
register_sidebar() would be limits on the number of widgets that can go in
and the ability to randomize their order).

Obviously you are adding widgets programmatically for some reason, so even
if this theoretical new API didn't account for your constraints, it would
let you focus only on those parts of your problem rather than having it all
mixed together in your workaround class.

Jeremy Clarke | http://jeremyclarke.org

More information about the wp-hackers mailing list