[wp-hackers] add_action arrays?

John Blackbourn johnbillion+wp at gmail.com
Wed Sep 23 12:14:11 UTC 2009


It's for when you use a class method as the callback. The first item
in the array is a reference to the class, the second to the method.

2009/9/23 Thomas Belknap <dragonfly at dragonflyeye.net>:
> 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!
> _______________________________________________
> 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