[wp-hackers] register_uninstall_hook VS uninstall.php
wp at andrewnacin.com
Fri May 7 17:01:55 UTC 2010
Arbitrary code is referring to code that is not wrapped inside a function,
with the exception of course of add_action and add_filter calls (and
_ref_array) tying those functions to hooks. (And hook registrations for
activation, deactivation, uninstall, etc.)
Generally speaking, a plugin should never do anything before the init hook.
That includes the enqueue of scripts and styles, the registration of custom
post types and taxonomies, and so much else.
Since the plugin file needs to be included to execute the uninstall
function, that code would run here. You don't want that.
As Dion said, you cannot use a class method for a callback for an uninstall
hook. You also cannot use multiple uninstall callbacks. If you need a more
complex uninstall process, use uninstall.php. Make sure you check for
defined( 'WP_UNINSTALL_PLUGIN' ) before continuing (die if it is not
defined) when using the uninstall.php file.
More information about the wp-hackers