[wp-hackers] Need help with: coding new Plugin options
DD32
wordpress at dd32.id.au
Thu Nov 6 22:45:33 GMT 2008
On Fri, 07 Nov 2008 07:54:20 +1100, Ozh <ozh at planetozh.com> wrote:
> On Thu, Nov 6, 2008 at 9:49 PM, Daiv Mowbray <daiv at daivmowbray.com>
> wrote:
>> Ozh, the functions which you refer are from the plugin builder:
>> http://www.wp-fun.co.uk/wizzards/fun-with-plugins/
>> It reads to see if the options are there, if not they write the default
>> into
>> the ops table.
>> If you know another way to check for options ... all ears.
>
> A lot of plugins do this on every instantiation:
> 1) read options from DB
> 2) do various checks, including default values
> 3) write options in DB
>
> The write part is totally unneeded and is just a query waste, since
> after step 2 everything is ok. Just to steps 1 and 2, and write to the
> DB only when options are updated through the admin form.
Just a note.. update_option() doesnt do a query unless the value has
changed from what its got in its cache:
http://trac.wordpress.org/browser/trunk/wp-includes/functions.php#L513
More information about the wp-hackers
mailing list