[wp-hackers] add_action arrays?

Thomas Belknap dragonfly at dragonflyeye.net
Wed Sep 23 12:00:45 UTC 2009


I've seen a few plugins and bits of code internal to WordPress use the
following convention:

add_action('pre_get_posts', array(&$this, 'postFilter'));

But this usage is not documented anywhere? I attempted to use the same
convention and got the following error:

call_user_func_array() [function.call-user-func-array]: First argument
is expected to be a valid callback, 'Array' was given in blah, blah,
blah...

I was looking at the code for add_action and add_filter, and they
definitely seem to not take arrays into account as far as I can tell.
Is this a deprecated way of doing things? Is there some other way to
hook an object method into an action or filter?

Thanks!


More information about the wp-hackers mailing list