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

scribu scribu at gmail.com
Tue Mar 23 23:36:45 UTC 2010


On Wed, Mar 24, 2010 at 1:06 AM, Peter van der Does
<peter at avirtualhome.com>wrote:

> Everybody knows, or at least should know, that storing every variable
> as an option is a bad idea. You usually use an array and store the
> array.
>
> How do you store multiple options.
> What I mean is, you can have general options, options that are to be
> used throughout the plugin. You can have default widget options, so
> when you don't enter a value in the widget this option will be used.
>

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);
}


-- 
http://scribu.net


More information about the wp-hackers mailing list