Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Anyone know any resources to help me install my widget when my plugin is activated?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

By "install" your widget, I'm assuming you mean "automatically add the new widget to the sidebar for your user after the plugin gets 'activated'". (Because if you activate the plugin, which also contains a widget, your widget should be visible in the widgets area immediately, without any more work needed).

Jordan Bosch has a great write-up on how to create a plugin that automatically assigns a widget to the sidebar without intervention from the user.

If you're already familiar with plugin / widget development, that should get you going pretty quickly. Good luck!

share|improve this answer
    
Once again, though, this is somewhat dangerous. The theme on my main site defines 4 sidebars ... which sidebar will the widget be added to? Above or below my existing widgets? –  EAMann Jul 5 '11 at 21:37
    
EAMann, yep, I completely agree, if this is a plugin for general distribution. However, many times WordPress developers are creating themes and plugins for a single client and the context is predictable. (Similar to a theme design that expects exactly 5 menu items in the header navigation, or perhaps a theme design that requires a special taxonomy to function properly, etc). –  Jared Cobb Jul 5 '11 at 21:44
add comment

If you coded it correctly, your widget will automatically be registered upon activation, but there's no good way to automatically place it in a sidebar. The theme might define multiple sidebars, so you won't know ahead of time which sidebar to place it in to.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.