[wp-hackers] How do you store multiple plugin options
Peter van der Does
peter at avirtualhome.com
Tue Mar 23 23:06:29 UTC 2010
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.
Currently I store this as follows:
$general=array('key1'=>'value1', 'key2'=>'value2');
$widget=array('key3'=>'value1', 'key2'=>'value4');
$option=array('general'=>$general,'widget'=>$widget);
update_option( 'myplugin', $options );
I also can see it as follows:
$general=array('key1'=>'value1', 'key2'=>'value2');
$widget=array('key3'=>'value1', 'key2'=>'value4');
update_option( 'myplugin-general', $general );
update_option( 'myplugin-widget', $widget );
So how do you store your options?
--
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