[wp-hackers] register_activation_hook and PHP closure

Dion Hulse (dd32) wordpress at dd32.id.au
Wed Apr 25 12:15:31 UTC 2012


The warning won't be generated from register_activation_hook(), or at
least, I don't expect it will be, as it's internally simply
add_action()

register_uninstall_hook() however does serialize things, and would
probably throw an error like that. as the "hook" needs to be stored in
the database for later usage..
Have a look at the docs of that one here:
http://core.trac.wordpress.org/browser/trunk/wp-includes/plugin.php#L647

On 25 April 2012 22:08, Ryan Chan <ryanchan404 at gmail.com> wrote:
> Seems register_activation_hook not support closure but not throwing out error?
>
> e.g.
>
>        register_activation_hook(__FILE__, function() {
>            update_option('myplugin_activated', 1);
>        });
>
>
> However, register_uninstall_hook do throw out that closure cannot be
> serialized error if I use closure.
> _______________________________________________
> 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