[wp-hackers] [help] sink plugin hooks for $this

Robert Deaton false.hopes at gmail.com
Sat Jan 14 13:21:32 GMT 2006


On 1/14/06, Jamie Talbot <wphackers at jamietalbot.com> wrote:
> Yes, but from what I understand, Niels is having problem with references.

The problem is not references, its where he calls add_action.

> Niels Hackius wrote:
> >My problem isn't really that the hook doesn't work its more that I can't
> >pass a classvariable by reference

Mark Jaquith wrote:
> If you use add_action() from within the class, $this is perfectly fine:

The problem is that $this is a special variable reserved for being
called inside the class. You cannot use $this at all outside of the
context of a class, and doing so will cause errors.

The key to fixing this, is to move the add_action call to the
constrictor of the class.

--
--Robert Deaton
http://somethingunpredictable.com


More information about the wp-hackers mailing list