[wp-hackers] How do you store multiple plugin options

Peter van der Does peter at avirtualhome.com
Wed Mar 24 00:00:24 UTC 2010


On Wed, 24 Mar 2010 01:36:45 +0200
scribu <scribu at gmail.com> wrote:


> There's no point in storing default widget options (that never
> change) in the wp_options table.
> 
> Just leave them in the code:
> 
> function widget($instance) {
>     $defaults = array('
>         key => value
>         ...
>     );
> 
>     $instance = array_merge($defaults, $instance);
> }
> 
> 

But people can change the default value :-)
For example: The title of the widget. If you have multiple widgets the
user should be able to change the title for every widget without having
to change the title in every widget separately.

A better example would be my AVH Amazon plugin. It makes calls to
Amazon but it allows you to make calls to Amazon locales(.ca, .fr etc).
So instead of having the user enter the desired locale per widget, they
can enter it in the admin section.

-- 
Peter van der Does

GPG key: E77E8E98

IRC: Ganseki on irc.freenode.net
Twitter: @petervanderdoes

WordPress Plugin Developer
Blog: http://blog.avirtualhome.com
Forums: http://forums.avirtualhome.com
Twitter: @avhsoftware


More information about the wp-hackers mailing list