[wp-hackers] A Question On Plugins

Andy Staines andy at yellowswordfish.com
Tue Apr 25 15:13:24 GMT 2006

Thanks Andy

This is EXACTLY what I have re-coded it to do this morning except not  
knowing about 'dbDelta' I constructed mg own update routine. But I am  
now keeping the db version in Options.

The WP version they are using is a good question and I will enquire -  
but I have specified that the plugin needs Wp2 or above.

On the issue of things like 'dbDelta' are there other, more  
comprehensive resources than the Codex for finding this stuff short  
of trawling through the whole of the WP admin code?

And - as an associated question - having watched this list and read  
Ryans and Owens blog on some things to come in the next release, is  
there a definitive document available to plugin authors detailing all  
the changes so we know what needs to be done to our code to make it  
work? Trac is Ok up to a point but hardly gives a decent description  
of what we really need to know...

thanks again

On 03:47  PM |  Tue 25 Apr 06, at 03:47  PM |  25 Apr 06, Andy  
Skelton wrote:

> On 4/25/06, Andy Staines <andy at yellowswordfish.com> wrote:
>> I know you guys are in the middle of a big security conference but
> hehe
>> Is this the 'right' way to ensure tables get created or is there a
>> better hook to use? And, if so, any ideas why it should fail?
> I do it a bit differently. This method had the added benefit of
> letting you upgrade the tables just like WP does.
> Save your plugin db version as an option. Check the option on every
> page load. It's autoloaded so the cost of this operation is trivial.
> If the db version in the option is outdated or missing:
> $my_queries = "CREATE TABLE foo (...); CREATE TABLE bar (...);"
> require_once(ABSPATH/wp-admin/upgrade-functions.php);
> dbDelta($my_queries);
> update your db version option.
> Of course, you'll have to clean up that code and make it your own.
> When you update the plugin with new table schema, just update
> $my_queries and bump the db_version coded in your plugin. It'll see
> the outdated version in the options table and run the upgrade.
> Cheers,
> Andy
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list